test-api / utils /convert_embedding.py
LalitMahale
data push
eb66dcb
raw
history blame contribute delete
763 Bytes
from sentence_transformers import SentenceTransformer
class GetEmbedding:
def __init__(self,data:list):
self.data = data
def user_query_emb(self,model_name:str = 'paraphrase-MiniLM-L6-v2'):
try:
model = SentenceTransformer(model_name_or_path=model_name)
embedding = model.encode(self.data)
return embedding
except Exception as e:
print(e)
def convert_data(self,model_name:str = 'paraphrase-MiniLM-L6-v2'):
try:
model = SentenceTransformer(model_name)
embeddings = model.encode(self.data)
return embeddings
except Exception as e:
print(e)
if __name__ == "__main__":
emb = GetEmbedding("lalit")
print( emb)