File size: 503 Bytes
2e818da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from typing import List

from chromadb.utils.embedding_functions.onnx_mini_lm_l6_v2 import ONNXMiniLM_L6_V2

# ~40MB, loads in <1s, runs in C/ONNX -> no Python GIL pressure
_onnx_ef = ONNXMiniLM_L6_V2()


class Embedder:
    """Thin wrapper around ChromaDB's built-in ONNX embedder.

    Keeping this isolated means we can swap the embedding model without
    touching ChromaDB or ingestion code.
    """

    def embed(self, texts: List[str]) -> List[List[float]]:
        return list(_onnx_ef(texts))