File size: 683 Bytes
babe057
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 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]