Skip to content

Commit c4763fb

Browse files
Privatemode Embedder Update (#173)
* perf: upgrade privatemode embeddings model * perf: increase trim length for privatemode * perf: update auto_tokenizer for privatemode
1 parent b7795c3 commit c4763fb

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/embedders/classification/contextual.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,16 @@ class PrivatemodeAISentenceEmbedder(SentenceEmbedder):
217217
def __init__(
218218
self,
219219
batch_size: int = 128,
220-
model_name: str = "intfloat/multilingual-e5-large-instruct",
220+
model_name: str = "qwen3-embedding-4b",
221+
hf_model_name: str = "boboliu/Qwen3-Embedding-4B-W4A16-G128",
221222
):
222223
"""
223224
Embeds documents using privatemode ai proxy via OpenAI classes.
224225
Note that the model and api key are currently hardcoded since they aren't configurable.
225226
226227
Args:
227228
batch_size (int, optional): Defines the number of conversions after which the embedder yields. Defaults to 128.
228-
model_name (str, optional): Name of the embedding model from Privatemode AI (e.g. intfloat/multilingual-e5-large-instruct). Defaults to "intfloat/multilingual-e5-large-instruct".
229+
model_name (str, optional): Name of the embedding model from Privatemode AI (e.g. intfloat/multilingual-e5-large-instruct). Defaults to "qwen3-embedding-4b".
229230
230231
Raises:
231232
Exception: If you use Azure, you need to provide api_type, api_version and api_base.
@@ -238,8 +239,8 @@ def __init__(
238239
api_key="dummy", # Set in proxy
239240
base_url=PRIVATEMODE_AI_URL,
240241
)
241-
# for trimming the length of the text if > 512 tokens
242-
self._auto_tokenizer = AutoTokenizer.from_pretrained(self.model_name)
242+
# for trimming the length of the text if > 32000 tokens
243+
self._auto_tokenizer = AutoTokenizer.from_pretrained(hf_model_name)
243244

244245
def _encode(
245246
self, documents: List[Union[str, Doc]], fit_model: bool
@@ -278,7 +279,7 @@ def dump(self, project_id: str, embedding_id: str) -> None:
278279
export_file.parent.mkdir(parents=True, exist_ok=True)
279280
util.write_json(self.to_json(), export_file, indent=2)
280281

281-
def _trim_length(self, text: str, max_length: int = 512) -> str:
282+
def _trim_length(self, text: str, max_length: int = 32000) -> str:
282283
tokens = self._auto_tokenizer(
283284
text,
284285
truncation=True,

0 commit comments

Comments
 (0)