codeblacks commited on
Commit
9763abf
·
verified ·
1 Parent(s): 9fe393c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from sentence_transformers import SentenceTransformer
3
+
4
+ # Load the pre-trained model
5
+ model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
6
+
7
+ st.title("Sentence Embeddings")
8
+
9
+ # Input from the user
10
+ sentences = st.text_area("Enter sentences (one per line)")
11
+
12
+ if sentences:
13
+ # Split sentences by new line
14
+ sentences_list = [s.strip() for s in sentences.split('\n') if s.strip()]
15
+ # Get embeddings
16
+ embeddings = model.encode(sentences_list).tolist()
17
+ st.json(embeddings)