embed_mul_sentence/
embed-mul-sentence.rs

1//! Complete example for text embedding using `gte-multilingual` (raw mode)
2
3fn main() -> gte::util::result::Result<()> {    
4    const TOKENIZER_PATH: &str = "models/gte-multilingual-base/tokenizer.json";
5    const MODEL_PATH: &str = "models/gte-multilingual-base/onnx/model.onnx";
6
7    let params = gte::params::Parameters::default()
8        .with_output_id("sentence_embedding")
9        .with_mode(gte::embed::output::ExtractorMode::Raw);
10
11    let pipeline = gte::embed::pipeline::TextEmbeddingPipeline::new(TOKENIZER_PATH, &params)?;
12    let model = orp::model::Model::new(MODEL_PATH, orp::params::RuntimeParameters::default())?;
13            
14    let inputs = gte::embed::input::TextInput::from_str(&[
15        "What is the capital of France?", 
16        "How to implement quick sort in python?", 
17        "Die Hauptstadt von Frankreich ist Paris.",
18        "La capital de Francia es ParĂ­s.",
19        "London is the capital of the UK",
20    ]);
21
22    let outputs = model.inference(inputs, &pipeline, &params)?;
23    let distances = gte::util::test::distances_to_first(&outputs);
24
25    println!("Distances: {:?}", distances);     
26
27    Ok(())
28}