Spaces:
Running
Running
Download app.py from Amna252003/Semantic_Analyzer: direct link, hf CLI and curl.
- Browser
- Download file 564 Bytes
-
https://huggingface.co/spaces/Amna252003/Semantic_Analyzer/resolve/main/app.py
- Command line
-
hf download hf://spaces/Amna252003/Semantic_Analyzer/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Amna252003/Semantic_Analyzer/resolve/main/app.py
564 Bytes
| import streamlit as st | |
| from sentence_transformers import SentenceTransformer, util | |
| model = SentenceTransformer("all-MiniLM-L6-v2") | |
| st.title("Semantic Analyzer") | |
| sentence1 = st.text_input("Enter first sentence") | |
| sentence2 = st.text_input("Enter second sentence") | |
| if st.button("Analyze"): | |
| embedding1 = model.encode(sentence1, convert_to_tensor=True) | |
| embedding2 = model.encode(sentence2, convert_to_tensor=True) | |
| similarity = util.cos_sim(embedding1, embedding2) | |
| score = float(similarity[0][0]) | |
| st.write("Similarity Score:", round(score, 2)) |