quanfire-dev commited on
Commit
463a0fd
·
verified ·
1 Parent(s): 2d70d4e

Fix usage snippet: correct import path and add HTTP /v1/embeddings + search examples

Browse files
Files changed (1) hide show
  1. README.md +29 -15
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 serves normalized embeddings). Pull the weights from this repo, then point the
81
- framework at the downloaded directory:
82
 
83
  ```bash
84
  pip install 'quanfire-multilingual-embedding[neural]'
85
 
86
- # download this model's two files into a local directory
87
- python -c "from huggingface_hub import snapshot_download; \
88
- print(snapshot_download('quanfire-ai/multilingual-embedding', local_dir='multilingual-embedding'))"
 
 
 
 
89
 
90
- # serve an HTTP embeddings endpoint from it
91
- qfme serve --adapter multilingual-embedding
92
  ```
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  ```python
95
- from huggingface_hub import snapshot_download
96
- from multilingual_embedding.embedding.neural.pretrained import SemanticSearchPipeline
97
-
98
- path = snapshot_download("quanfire-ai/multilingual-embedding", local_dir="multilingual-embedding")
99
- pipe = SemanticSearchPipeline.from_adapter(path)
100
- enc = pipe.encoder
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