File size: 610 Bytes
9763abf
a43c7ab
9763abf
 
 
 
 
 
 
 
 
 
 
 
 
 
a43c7ab
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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)