You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defload_model(model_name="sentence-transformers/all-MiniLM-L6-v2"):
returnSentenceTransformer(model_name)
defgenerate_embedding(model, text):
# Clean the text (similar to String.trim in Elixir)text=text.strip()
# Compute the embedding with L2 normalizationembedding=model.encode(text, normalize_embeddings=True)
returnembedding
model=load_model()
text="This is an example sentence for embedding."embedding=generate_embedding(model, text)
print("Embedding:", embedding)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
We will check that Elixir returns the same values as Python (considered as the source of truth).
Python code:
jupyter notebook
Elixiir code:
livebook server
Results
Beta Was this translation helpful? Give feedback.
All reactions