Skip to content

Instantly share code, notes, and snippets.

@igomez10
Created July 18, 2025 04:37
Show Gist options
  • Select an option

  • Save igomez10/e62b04b048c2b07c98000bcfea6e4e6f to your computer and use it in GitHub Desktop.

Select an option

Save igomez10/e62b04b048c2b07c98000bcfea6e4e6f to your computer and use it in GitHub Desktop.
# alias vectorize='/opt/anaconda3/bin/python ~/hackathon-cloduflare/mcp-server-demo/encode.py'
import sys
from sentence_transformers import SentenceTransformer
# Load a pre-trained model
model = SentenceTransformer('all-MiniLM-L6-v2')
# Your input text
if len(sys.argv) < 2:
print("Usage: python encode.py <text>")
sys.exit(1)
text = sys.argv[1]
# Generate the embedding
vector = model.encode(text)
# join the vector elements into a string for better readability
vector = ', '.join(map(str, vector))
vector = f"[{vector}]"
# Print the vector
print(vector)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment