Spaces:
Sleeping
Sleeping
File size: 525 Bytes
94f5c4b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
from sentence_transformers import SentenceTransformer
from sklearn.preprocessing import normalize
from config.rag_config import RAGConfig
class Embedder:
def __init__(self, config: RAGConfig):
self.model = SentenceTransformer(config.embedding_model_name)
self.normalize = config.normalize_embeddings
def embed_texts(self, texts):
embeddings = self.model.encode(texts, convert_to_numpy=True)
if self.normalize:
embeddings = normalize(embeddings)
return embeddings
|