danish-foundation-models/danish-dynaword
Viewer • Updated • 22.2M • 7.34k • 22
How to use kardosdrur/handsker-pretrained-300d with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("kardosdrur/handsker-pretrained-300d")
sentences = [
"The weather is lovely today.",
"It's so sunny outside!",
"He drove to the stadium."
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]This is a GloVe model trained on the entirety of Danish Dynaword for 10 epochs converted into a sentence-transformers model with mean pooling. The model was trained using the GlovPy Python library. The model uses a Bert-style tokenizer that was also trained on Dynaword.
SentenceTransformer(
(0): WordEmbeddings({'tokenizer_class': 'sentence_transformers.sentence_transformer.modules.tokenizer.whitespace.WhitespaceTokenizer', 'update_embeddings': False, 'max_seq_length': 1000000})
(1): Pooling({'embedding_dimension': 300, 'pooling_mode': 'mean', 'include_prompt': True})
)
First install the Sentence Transformers library:
pip install -U sentence-transformers
Then you can load this model and run inference.
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("kardosdrur/handsker-pretrained-300d")
# 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, 300]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.6504, 0.7633],
# [0.6504, 1.0000, 0.5803],
# [0.7633, 0.5803, 1.0000]])