First_RAG_System / day3 /embeddings.py
Hamid Omarov
HF Space app + minimal pipeline code (no secrets)
e7e9247
raw
history blame
463 Bytes
from typing import List, Dict
from sentence_transformers import SentenceTransformer
_embedder = SentenceTransformer("all-MiniLM-L6-v2")
def embed_texts(texts: List[str]) -> List[List[float]]:
# Return as Python lists of floats (Chroma-compatible)
return _embedder.encode(texts, convert_to_numpy=True).tolist()
def create_embeddings(chunks: List[str]) -> Dict:
vectors = embed_texts(chunks)
return {"embeddings": vectors, "count": len(vectors)}