1fn main() -> gliclass::util::result::Result<()> {
5 const TOKENIZER_PATH: &str = "models/gliclass-modern-base-v2.0-init/tokenizer.json";
6 const MODEL_PATH: &str = "models/gliclass-modern-base-v2.0-init/onnx/model.onnx";
7
8 let params = gliclass::params::Parameters::default().with_prompt_first(true);
9 let pipeline = gliclass::pipeline::ClassificationPipeline::new(TOKENIZER_PATH, ¶ms)?;
10 let model = orp::model::Model::new(MODEL_PATH, orp::params::RuntimeParameters::default())?;
11
12 let inputs = gliclass::input::text::TextInput::from_str_per_text(
13 &[
14 "Rust is a systems programming language focused on safety, speed, and concurrency, with a strong ownership model that prevents memory errors without needing a garbage collector.",
15 "Traveling is the perfect way to explore new cultures through their food, from savoring street tacos in Mexico to indulging in fresh sushi in Japan.",
16 "Traveling for science allows researchers to explore new environments, gather crucial data, and collaborate with experts worldwide to expand our understanding of the universe.",
17 ],
18 &[
19 &["performance", "user interface"], &["gastronomy", "plane"], &["conferencing", "teaching"], ]
23 );
24
25 let classes = model.inference(inputs, &pipeline, ¶ms)?;
26
27 for i in 0..classes.len() {
28 println!("Text {i}:\n\t=> {}\n\t=> {:?}",
29 classes.best_label(i, None).unwrap(),
30 classes.ordered_scores(i, None).unwrap().iter().rev().collect::<Vec<_>>(),
31 );
32 }
33
34 Ok(())
35}
36
37