mirror of
https://github.com/hanzoai/engine.git
synced 2026-11-20 14:17:52 +00:00
25 lines
638 B
Rust
25 lines
638 B
Rust
//! Generate text embeddings using an embedding model.
|
|
//!
|
|
//! Run with: `cargo run --release --example embedding -p hanzo`
|
|
|
|
use anyhow::Result;
|
|
use hanzo::{EmbeddingModelBuilder, EmbeddingRequest};
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<()> {
|
|
let model = EmbeddingModelBuilder::new("google/embeddinggemma-300m")
|
|
.with_logging()
|
|
.build()
|
|
.await?;
|
|
|
|
let embeddings = model
|
|
.generate_embeddings(
|
|
EmbeddingRequest::builder()
|
|
.add_prompt("task: search result | query: What is graphene?"),
|
|
)
|
|
.await?;
|
|
println!("{:?}", embeddings.first());
|
|
|
|
Ok(())
|
|
}
|