study-buddy / app /rag /embeddings.py
GitHub Actions
deploy d092bea3608b7a29952f16357fda39b7a29e399b
2e818da
Raw
History Blame Contribute Delete
503 Bytes
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))