You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<a href="#relation-to-python-model2vec"><strong>Relation to Python Model2Vec</strong></a>
32
+
</p>
13
33
</div>
14
34
15
-
This crate provides a lightweight Rust implementation for loading and inference of [Model2Vec](https://github.com/MinishLab/model2vec) static embedding models. For distillation and training, the [Python Model2Vec package](https://github.com/MinishLab/model2vec) can be used.
35
+
`model2vec-rs` is a Rust crate providing an efficient implementation for inference with [Model2Vec](https://github.com/MinishLab/model2vec) static embedding models. Model2Vec is a technique for creating compact and fast static embedding models from sentence transformers, achieving significant reductions in model size and inference speed. This Rust crate is optimized for performance, making it suitable for applications requiring fast embedding generation.
36
+
37
+
## Quickstart
38
+
39
+
You can utilize `model2vec-rs` in two ways:
16
40
41
+
1.**As a library** in your Rust projects
42
+
2.**As a standalone Command-Line Interface (CLI) tool** for quick terminal-based inferencing
17
43
44
+
---
18
45
19
-
##Quick Start
46
+
### 1. Using `model2vec-rs` as a Library
20
47
21
-
Add the crate:
48
+
Integrate `model2vec-rs` into your Rust application to generate embeddings within your code.
49
+
50
+
**a. Add `model2vec-rs` as a dependency:**
22
51
23
52
```bash
24
53
cargo add model2vec-rs
25
54
```
26
55
27
-
Make embeddings:
28
-
56
+
**b. Load a model and generate embeddings:**
29
57
```rust
30
58
useanyhow::Result;
31
59
usemodel2vec_rs::model::StaticModel;
32
60
33
61
fnmain() ->Result<()> {
34
-
// Load a model from the Hugging Face Hub or a local path
We provide a number of models that can be used out of the box. These models are available on the [HuggingFace hub](https://huggingface.co/collections/minishlab/model2vec-base-models-66fd9dd9b7c3b3c0f25ca90e) and can be loaded using the `from_pretrained` method. The models are listed below.
142
+
***Fast Inference:** Optimized Rust implementation for fast embedding generation.
143
+
***Hugging Face Hub Integration:** Load pre-trained Model2Vec models directly from the Hugging Face Hub using model IDs, or use models from local paths.
144
+
***Model Formats:** Supports models with f32, f16, and i8 weight types stored in`safetensors` files.
145
+
***Batch Processing:** Encodes multiple sentences in batches.
146
+
***Configurable Encoding:** Allows customization of maximum sequence length and batch size during encoding.
78
147
148
+
## What is Model2Vec?
79
149
150
+
Model2Vec is a technique to distill large sentence transformer models into highly efficient static embedding models. This process significantly reduces model size and computational requirements for inference. For a detailed understanding of how Model2Vec works, including the distillation process and model training, please refer to the [main Model2Vec Python repository](https://github.com/MinishLab/model2vec) and its [documentation](https://github.com/MinishLab/model2vec/blob/main/docs/what_is_model2vec.md).
80
151
81
-
| Model | Language | Sentence Transformer | Params | Task |
|[potion-base-32M](https://huggingface.co/minishlab/potion-base-32M)| English |[bge-base-en-v1.5](https://huggingface.co/BAAI/bge-base-en-v1.5)| 32.3M | General |
84
-
|[potion-base-8M](https://huggingface.co/minishlab/potion-base-8M)| English |[bge-base-en-v1.5](https://huggingface.co/BAAI/bge-base-en-v1.5)| 7.5M | General |
85
-
|[potion-base-4M](https://huggingface.co/minishlab/potion-base-4M)| English |[bge-base-en-v1.5](https://huggingface.co/BAAI/bge-base-en-v1.5)| 3.7M | General |
86
-
|[potion-base-2M](https://huggingface.co/minishlab/potion-base-2M)| English |[bge-base-en-v1.5](https://huggingface.co/BAAI/bge-base-en-v1.5)| 1.8M | General |
87
-
|[potion-retrieval-32M](https://huggingface.co/minishlab/potion-retrieval-32M)| English |[bge-base-en-v1.5](https://huggingface.co/BAAI/bge-base-en-v1.5)| 32.3M | Retrieval |
88
-
|[M2V_multilingual_output](https://huggingface.co/minishlab/M2V_multilingual_output)| Multilingual |[LaBSE](https://huggingface.co/sentence-transformers/LaBSE)| 471M | General |
152
+
This `model2vec-rs` crate provides a Rust-based engine specifically for**inference** using these Model2Vec models.
89
153
154
+
## Models
155
+
156
+
A variety of pre-trained Model2Vec models are available on the [HuggingFace Hub (MinishLab collection)](https://huggingface.co/collections/minishlab/model2vec-base-models-66fd9dd9b7c3b3c0f25ca90e). These can be loaded by `model2vec-rs` using their Hugging Face model ID or by providing a local path to the model files.
157
+
158
+
| Model | Language | Distilled From (Original Sentence Transformer) | Params | Task |
0 commit comments