codeblacks's picture
Update app.py
a43c7ab verified
raw
history blame
610 Bytes
import streamlit as st
import numpy as np
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)
# Convert to 2D NumPy array
embeddings_array = np.array(embeddings)
st.write(embeddings_array)