Fix usage snippet: correct import path and add HTTP /v1/embeddings + search examples
Browse files
README.md
CHANGED
|
@@ -77,29 +77,43 @@ stay neutral within sampling noise versus the prior internal Indic model.
|
|
| 77 |
## Usage
|
| 78 |
|
| 79 |
The adapter runs through the QuanFire framework (it applies the LoRA over the base
|
| 80 |
-
and
|
| 81 |
-
framework at the downloaded directory:
|
| 82 |
|
| 83 |
```bash
|
| 84 |
pip install 'quanfire-multilingual-embedding[neural]'
|
| 85 |
|
| 86 |
-
# download this model's
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
-
|
| 91 |
-
qfme serve --adapter multilingual-embedding
|
| 92 |
```
|
| 93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
```python
|
| 95 |
-
from
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
# this adapter uses EMPTY prefixes (not "query: "/"passage: ") — recorded in adapter.json
|
| 102 |
-
vecs = enc.encode(["नमस्ते दुनिया", "hello world", "bonjour le monde"])
|
| 103 |
```
|
| 104 |
|
| 105 |
Vectors are L2-normalized `float32` (dimension 384), so cosine similarity is a dot
|
|
|
|
| 77 |
## Usage
|
| 78 |
|
| 79 |
The adapter runs through the QuanFire framework (it applies the LoRA over the base
|
| 80 |
+
and produces normalized embeddings). Install the package and pull the weights:
|
|
|
|
| 81 |
|
| 82 |
```bash
|
| 83 |
pip install 'quanfire-multilingual-embedding[neural]'
|
| 84 |
|
| 85 |
+
# download this model's files into a local directory
|
| 86 |
+
hf download quanfire-ai/multilingual-embedding --local-dir multilingual-embedding
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
**As an HTTP embeddings service (recommended for applications).** This exposes an
|
| 90 |
+
OpenAI-compatible `POST /v1/embeddings` endpoint, so your app stores the vectors in
|
| 91 |
+
its own database or vector index:
|
| 92 |
|
| 93 |
+
```bash
|
| 94 |
+
qfme serve --adapter multilingual-embedding --port 8000
|
| 95 |
```
|
| 96 |
|
| 97 |
+
```bash
|
| 98 |
+
curl -s localhost:8000/v1/embeddings \
|
| 99 |
+
-H 'content-type: application/json' \
|
| 100 |
+
-d '{"input": ["नमस्ते दुनिया", "hello world", "bonjour le monde"]}'
|
| 101 |
+
# -> {"object":"list","data":[{"index":0,"embedding":[...384 floats...]}, ...],
|
| 102 |
+
# "model":"multilingual-embedding","usage":{...},"prefix_applied":null}
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
This model is symmetric (empty prefixes), so `input_type` is not required; pass
|
| 106 |
+
`"input_type": "query"` or `"passage"` only for asymmetric models.
|
| 107 |
+
|
| 108 |
+
**In-process, as a search pipeline:**
|
| 109 |
+
|
| 110 |
```python
|
| 111 |
+
from multilingual_embedding.pipelines.search import SemanticSearchPipeline
|
| 112 |
+
|
| 113 |
+
pipe = SemanticSearchPipeline.from_adapter("multilingual-embedding")
|
| 114 |
+
pipe.index(["नमस्ते दुनिया", "hello world", "bonjour le monde", "Bonjour tout le monde"])
|
| 115 |
+
for hit in pipe.search("a french greeting", top_k=3):
|
| 116 |
+
print(hit.rank, round(hit.score, 3), hit.text)
|
|
|
|
|
|
|
| 117 |
```
|
| 118 |
|
| 119 |
Vectors are L2-normalized `float32` (dimension 384), so cosine similarity is a dot
|