-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7bb0e91
commit ecbdcee
Showing
6 changed files
with
173 additions
and
17 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
candle-holder-examples/examples/text_classification_pipeline/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
candle-holder-examples/examples/text_generation_pipeline/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Text Generation Pipeline | ||
|
||
## Running the example | ||
|
||
```bash | ||
cargo run --example text_generation_pipeline | ||
``` |
32 changes: 32 additions & 0 deletions
32
candle-holder-examples/examples/text_generation_pipeline/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use anyhow::Result; | ||
use candle_holder_examples::get_device_from_args; | ||
use candle_holder_models::{GenerationConfig, GenerationParams}; | ||
use candle_holder_pipelines::TextGenerationPipeline; | ||
use candle_holder_tokenizers::Message; | ||
|
||
fn main() -> Result<()> { | ||
let device = get_device_from_args()?; | ||
println!("Device: {:?}", device); | ||
|
||
let pipeline = | ||
TextGenerationPipeline::new("meta-llama/Meta-Llama-3.1-8B-Instruct", &device, None, None)?; | ||
|
||
let generations = pipeline.run( | ||
vec![Message::user("How much is 2 + 2?")], | ||
Some(GenerationParams { | ||
generation_config: Some(GenerationConfig { | ||
do_sample: true, | ||
max_new_tokens: Some(256), | ||
top_p: Some(0.9), | ||
top_k: None, | ||
temperature: 0.6, | ||
..GenerationConfig::default() | ||
}), | ||
..Default::default() | ||
}), | ||
)?; | ||
|
||
println!("`pipeline.run` results: {:?}", generations); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters