Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# model2vec-rs

This crate provides a lightweight Rust implementation for loading and running inference on Model2Vec static embedding models (including quantized formats: float32, float16, int8) from either local folders or the Hugging Face Hub.
This crate provides a lightweight Rust implementation for loading and running inference on [Model2Vec](https://github.com/MinishLab/model2vec) static embedding models from either local folders or the Hugging Face Hub.

## Quick Start

Expand All @@ -18,10 +18,11 @@ Make embeddings:

```rust
use anyhow::Result;
use model2vec_rust::inference::StaticModel;
use model2vec_rs::model::StaticModel;

fn main() -> Result<()> {
// Load a model from the Hugging Face Hub or a local path
// args = (repo_or_path, token, normalize, subfolder)
let model = StaticModel::from_pretrained("minishlab/potion-base-8M", None, None, None)?;

// Prepare a list of sentences
Expand All @@ -48,4 +49,22 @@ cargo run -- encode "Hello world" minishlab/potion-base-8M
# Multiple lines from a file
echo -e "Hello world\nRust is awesome" > input.txt
cargo run -- encode input.txt minishlab/potion-base-8M --output embeds.json
```


Make embeddings with custom encode args:

```rust
let embeddings = model.encode_with_args(
&texts, // input texts
false, // show progress
Some(512), // max length
1204, // batch size
true, // use multiprocessing
10_000, // multiprocessing threshold
);
```

## License

MIT