File size: 2,940 Bytes
9fcd148 bc4fe51 4315839 bc4fe51 9fcd148 4315839 9fcd148 fee309c 9fcd148 bc4fe51 fee309c 40df27e 03025ca 40df27e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
---
library_name: transformers
datasets:
- DebasishDhal99/German_Names_Central_And_Eastern_Europe
- DebasishDhal99/german-polish-paired-placenames
language:
- pl
- de
base_model:
- Helsinki-NLP/opus-mt-pl-de
pipeline_tag: translation
---
# Model Card for Model ID
<!-- Provide a quick summary of what the model is/does. -->
Input = Polish toponym (say Stare Miasto, literally Old city)
Output = Equivalent toponym (say Altstadt, meaning Old city)
Table of sample outputs at the bottom
# Inference Code
```
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
import torch
model_path = "DebasishDhal99/polish-to-german-toponym-model-opus-mt-pl-de"
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = AutoModelForSeq2SeqLM.from_pretrained(model_path).to(device)
tokenizer = AutoTokenizer.from_pretrained(model_path)
polish_name = "Stare miasteczko" #Change this to any polish place name
inputs = tokenizer(polish_name, return_tensors="pt", padding=True, truncation=True)
inputs = {k: v.to(device) for k, v in inputs.items()}
with torch.no_grad():
outputs = model.generate(**inputs, max_length=50)
german_name = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(german_name)
```
## Model Details
- Total epochs = 10
- Loss data
- Epoch 1/10, Loss: 0.1758
- Epoch 2/10, Loss: 0.0997
- Epoch 3/10, Loss: 0.0810
- Epoch 4/10, Loss: 0.0673
- Epoch 5/10, Loss: 0.0556
- Epoch 6/10, Loss: 0.0455
- Epoch 7/10, Loss: 0.0364
- Epoch 8/10, Loss: 0.0298
- Epoch 9/10, Loss: 0.0246
- Epoch 10/10, Loss: 0.0197
- Time = Approx. 30 minutes
- Device = 1 × P100 (Available on Kaggle)
- Further training is needed for better performance, I'll make one more such model with more epochs.
## Output Samples
| Polish Input | German Output | Notes |
|---------------------|------------------|---------------------------------------------------------|
| Warszawa | Warschau | Accurate, Capital of Poland |
| Kraków | Krakau | Accurate
| Poznań | Posen | Accurate |
| Stare Miasteczko | Ebersberg | Inaccurate, "Stare Miasteczko" means "Old Town" |
| Stary rynek | Altmarker | Accurate, means "Old Market" |
| Szczecin | Stettin | Accurate, Historic name for Szczecin |
| Olsztyn | Ellerstein | Inaccurate, correct name is "Allenstein" |
| Rybowo | Riebowen | Inaccurate, Fischdorf would be more accurate |
| Głogowo | Gögenhagen | Inaccurate, historical translation is Glogau |
| Wrocław | Breslau | Accurate, Historic German name for Wrocław | |