AyoubChLin's picture
Update app.py
53ee911
raw
history blame contribute delete
872 Bytes
import streamlit as st
from sentence_transformers import SentenceTransformer, util
# Load the model
model = SentenceTransformer('sentence-transformers/msmarco-distilbert-dot-v5')
# Define the Streamlit app
def main():
st.title("Text Embedding Generator")
# Get user input
text_input = st.text_area("Enter text to generate embeddings:", "")
if st.button("Generate Embedding"):
if text_input:
# Call the function to get the embedding
embedding = get_emb(text_input)
# Display the embedding
st.success("Embedding generated successfully:")
st.write(embedding)
else:
st.warning("Please enter text to generate embeddings.")
# Function to get the embedding
def get_emb(text):
return model.encode(text)
# Run the Streamlit app
if __name__ == "__main__":
main()