codeblacks's picture
Create app.py
9763abf verified
raw
history blame
518 Bytes
import streamlit as st
from sentence_transformers import SentenceTransformer
# Load the pre-trained model
model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
st.title("Sentence Embeddings")
# Input from the user
sentences = st.text_area("Enter sentences (one per line)")
if sentences:
# Split sentences by new line
sentences_list = [s.strip() for s in sentences.split('\n') if s.strip()]
# Get embeddings
embeddings = model.encode(sentences_list).tolist()
st.json(embeddings)