AyoubChLin commited on
Commit
6fd5df1
·
1 Parent(s): 0274260

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from sentence_transformers import SentenceTransformer
3
+
4
+ # Load the model
5
+ model = SentenceTransformer('sentence-transformers/msmarco-distilbert-dot-v5')
6
+
7
+ # Define the Streamlit app
8
+ def main():
9
+ st.title("Text Embedding Generator")
10
+
11
+ # Get user input
12
+ text_input = st.text_area("Enter text to generate embeddings:", "")
13
+
14
+ if st.button("Generate Embedding"):
15
+ if text_input:
16
+ # Call the function to get the embedding
17
+ embedding = get_emb(text_input)
18
+
19
+ # Display the embedding
20
+ st.success("Embedding generated successfully:")
21
+ st.write(embedding)
22
+ else:
23
+ st.warning("Please enter text to generate embeddings.")
24
+
25
+ # Function to get the embedding
26
+ def get_emb(text):
27
+ text_emb = model.encode(text)
28
+ return text_emb
29
+
30
+ # Run the Streamlit app
31
+ if __name__ == "__main__":
32
+ main()