Skip to content

deadpool implementation for fastembed

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

aqora-io/deadpool_fastembed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deadpool for FastEmbed-rs

Deadpool is a dead simple async pool for connections and objects of any type.

This crate implements a deadpool manager for [fastembed]((https://crates.io/crates/fastembed).

Features

Feature Description Extra dependencies Default
rt_tokio_1 Enable support for tokio runtime deadpool/rt_tokio_1 yes
rt_async-std_1 Enable support for async-std runtime deadpool/rt_async-std_1 no
hf-hub Enable support for loading models from Hugging Face Hub fastembed/hf-hub no
hf-hub-native-tls Hugging Face Hub with native-tls fastembed/hf-hub-native-tls no
hf-hub-rustls-tls Hugging Face Hub with rustls TLS backend fastembed/hf-hub-rustls-tls no
ort-download-binaries Automatically download ONNX Runtime binaries fastembed/ort-download-binaries no
ort-load-dynamic Dynamically load ONNX Runtime library at runtime fastembed/ort-load-dynamic no
optimum-cli Enable compatibility with Hugging Face Optimum CLI fastembed/optimum-cli no
online Allow fetching models and resources at runtime fastembed/online no

All of the features of fastembed are also re-exported. For example, enabling the feature hf-hub-rustls-tls here will also enable hf-hub-rustls-tls in the fastembed crate.

Example

use deadpool_fastembed::{Config, ModelKind, Pool};
use fastembed::{EmbeddingModel, TextEmbedding};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let config = Config::from_model(ModelKind::text(EmbeddingModel::AllMiniLML6V2));

    let pool: Pool = config.create_pool(None)?;

    let mut embedding = pool.get().await?;

    if let Some(text_embed) = embedding.as_text_mut() {
        let vectors = text_embed.embed(vec!["hello world".to_string()]).await?;
        println!("Embedding length: {}", vectors[0].len());
    }

    Ok(())
}

License

Licensed under either of

at your option.

About

deadpool implementation for fastembed

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages