auto-grader / app.py
Kuaaangwen's picture
Update app.py
9983408
raw
history blame
710 Bytes
import streamlit as st
from transformers import pipeline
from textblob import TextBlob
from sentence_transformers import SentenceTransformer
from sklearn.metrics.pairwise import cosine_similarity
sentences = \
[
"I have a bigger house than you",
"You have a bigger house than me"
]
sentence_embeddings = model.encode(sentences)
for sentence, embedding in zip(sentences, sentence_embeddings):
print("Sentence:", sentence)
print("Embedding:", embedding)
print("")
print('Similarity between {} and {} is {}'.format(sentences[0],
sentences[1],
cosine_similarity(sentence_embeddings[0].reshape(1, -1),
sentence_embeddings[1].reshape(1, -1))[0][0]))