Rename embedchain to mem0 and open sourcing code for long term memory (#1474)
Co-authored-by: Deshraj Yadav <deshrajdry@gmail.com>
This commit is contained in:
19
mem0/embeddings/huggingface.py
Normal file
19
mem0/embeddings/huggingface.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from embedding.base import EmbeddingBase
|
||||
from sentence_transformers import SentenceTransformer
|
||||
|
||||
|
||||
class HuggingFaceEmbedding(EmbeddingBase):
|
||||
def __init__(self, model_name="multi-qa-MiniLM-L6-cos-v1"):
|
||||
self.model = SentenceTransformer(model_name)
|
||||
|
||||
def get_embedding(self, text):
|
||||
"""
|
||||
Get the embedding for the given text using Hugging Face.
|
||||
|
||||
Args:
|
||||
text (str): The text to embed.
|
||||
|
||||
Returns:
|
||||
list: The embedding vector.
|
||||
"""
|
||||
return self.model.encode(text)
|
||||
Reference in New Issue
Block a user