Update README.md
Browse files
README.md
CHANGED
@@ -3,3 +3,35 @@ license: cc-by-4.0
|
|
3 |
language:
|
4 |
- cs
|
5 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
language:
|
4 |
- cs
|
5 |
---
|
6 |
+
|
7 |
+
## RetroMAE
|
8 |
+
|
9 |
+
RetroMAE-Small is a BERT-small model pre-trained with the [RetroMAE](https://arxiv.org/abs/2205.12035) objective on a Czech web corpus.
|
10 |
+
|
11 |
+
This model was created at Seznam.cz as part of a project to create high-quality small Czech semantic embedding models. These models perform well across various natural language processing tasks, including similarity search, retrieval, clustering, and classification. For further details or evaluation results, please visit the associated [paper]() or [GitHub repository]((https://github.com/seznam/czech-semantic-embedding-models)).
|
12 |
+
|
13 |
+
## How to Use
|
14 |
+
|
15 |
+
You can load and use the model like this:
|
16 |
+
|
17 |
+
```python
|
18 |
+
import torch
|
19 |
+
from transformers import AutoModel, AutoTokenizer
|
20 |
+
|
21 |
+
model_name = "Seznam/retromae-small-cs" # Hugging Face link
|
22 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
23 |
+
model = AutoModel.from_pretrained(model_name)
|
24 |
+
|
25 |
+
input_texts = [
|
26 |
+
"Dnes je výborné počasí na procházku po parku.",
|
27 |
+
"Večer si oblíbím dobrý film a uvařím si čaj."
|
28 |
+
]
|
29 |
+
|
30 |
+
# Tokenize the input texts
|
31 |
+
batch_dict = tokenizer(input_texts, max_length=512, padding=True, truncation=True, return_tensors='pt')
|
32 |
+
|
33 |
+
outputs = model(**batch_dict)
|
34 |
+
embeddings = outputs.last_hidden_state[:, 0] # Extract CLS token embeddings
|
35 |
+
|
36 |
+
similarity = torch.nn.functional.cosine_similarity(embeddings[0], embeddings[1], dim=0)
|
37 |
+
```
|