How to Use Hugging Face Models from Rust

Use the huggingface crate in Rust to load and run pre-trained models by adding the dependency and initializing a pipeline.

Use the huggingface crate to load and run models directly in Rust. Add the dependency to your Cargo.toml and initialize the pipeline in your code.

[dependencies]
huggingface = "0.3"
use huggingface::Pipeline;

fn main() {
    let pipeline = Pipeline::new("sentiment-analysis").unwrap();
    let result = pipeline.run("I love Rust!").unwrap();
    println!("{:#?}", result);
}