Update README.md
Browse files
README.md
CHANGED
@@ -39,6 +39,37 @@ print(embeddings)
|
|
39 |
|
40 |
```
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
|
44 |
## Usage (HuggingFace Transformers)
|
|
|
39 |
|
40 |
```
|
41 |
|
42 |
+
## Usage (FastEmbed)
|
43 |
+
|
44 |
+
Using this model becomes easy when you have [FastEmbed](https://github.com/qdrant/fastembed) installed:
|
45 |
+
|
46 |
+
```
|
47 |
+
pip install fastembed
|
48 |
+
```
|
49 |
+
|
50 |
+
Then you can use the model like this:
|
51 |
+
|
52 |
+
```python
|
53 |
+
from fastembed import TextEmbedding
|
54 |
+
from fastembed.common.model_description import PoolingType, ModelSource
|
55 |
+
|
56 |
+
sentences = ["Una ragazza si acconcia i capelli.", "Una ragazza si sta spazzolando i capelli."]
|
57 |
+
|
58 |
+
TextEmbedding.add_custom_model(
|
59 |
+
model="nickprock/sentence-bert-base-italian-uncased",
|
60 |
+
pooling=PoolingType.MEAN,
|
61 |
+
normalization=True,
|
62 |
+
sources=ModelSource(hf="nickprock/sentence-bert-base-italian-uncased"), # can be used with an `url` to load files from a private storage
|
63 |
+
dim=768,
|
64 |
+
model_file="onnx/model_qint8_avx512_vnni.onnx", # can be used to load an already supported model with another optimization or quantization, e.g. onnx/model_O4.onnx
|
65 |
+
)
|
66 |
+
|
67 |
+
model = TextEmbedding(model_name="nickprock/sentence-bert-base-italian-uncased")
|
68 |
+
embeddings = list(model.embed(sentences))
|
69 |
+
print(embeddings)
|
70 |
+
|
71 |
+
```
|
72 |
+
|
73 |
|
74 |
|
75 |
## Usage (HuggingFace Transformers)
|