Sentence_Similarity_Demo / RoSEtta-base-ja.py
schroneko's picture
add files
babe057
raw
history blame contribute delete
683 Bytes
# RoSEtta-base-ja.py
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
# model = SentenceTransformer("pkshatech/RoSEtta-base")
# 自分の環境では `trust_remote_code=True)` を追加しないとエラーが発生しました
model = SentenceTransformer("pkshatech/RoSEtta-base", trust_remote_code=True)
# Run inference
sentences = [
'The weather is lovely today.',
"It's so sunny outside!",
'He drove to the stadium.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]