pub struct Parameters { /* private fields */ }Expand description
Parameters for the GLiClass pipeline.
Implementations§
Source§impl Parameters
impl Parameters
Sourcepub fn with_prompt_first(self, b: bool) -> Self
pub fn with_prompt_first(self, b: bool) -> Self
This parameter must be set according to the expectations of the loaded model.
Examples:
gliclass-xxx-1.0=>falsegliclass-modern-base-v2.0-xxx=>true- for other models see the accompanying
config.jsonfile
Examples found in repository?
examples/sample4.rs (line 8)
4fn 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"], // expecting 'performance'
20 &["gastronomy", "plane"], // expecting 'gastronomy'
21 &["conferencing", "teaching"], // expecting 'conferencing'
22 ]
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}pub fn prompt_first(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Parameters
impl RefUnwindSafe for Parameters
impl Send for Parameters
impl Sync for Parameters
impl Unpin for Parameters
impl UnwindSafe for Parameters
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more