|
--- |
|
library_name: transformers |
|
license: apache-2.0 |
|
language: |
|
- mn |
|
--- |
|
|
|
# Model Card for Model ID |
|
|
|
<!-- Provide a quick summary of what the model is/does. --> |
|
|
|
|
|
|
|
## Model Details |
|
|
|
### Model Description |
|
|
|
<!-- Provide a longer summary of what this model is. --> |
|
|
|
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated. |
|
|
|
- **Developed by:** [Sainbayar B. (Б. Сайнбаяр) https://www.instagram.com/only_sainaa/] |
|
- **Funded by [optional]:** [More Information Needed] |
|
- **Shared by [optional]:** [More Information Needed] |
|
- **Model type:** [Mongolian Cyrillic to Traditional Mongolian Script conversion (Монгол кириллээс монгол бичиг рүү хөрвүүлэгч загвар)] |
|
- **Language(s) (NLP):** [Mongolian /Монгол/] |
|
- **License:** [More Information Needed] |
|
- **Finetuned from model [google-t5-small]:** [More Information Needed] |
|
|
|
|
|
```python |
|
#Load model directly |
|
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM |
|
|
|
tokenizer = AutoTokenizer.from_pretrained("onlysainaa/cyrillic_to_script-t5-model") |
|
model = AutoModelForSeq2SeqLM.from_pretrained("onlysainaa/cyrillic_to_script-t5-model") |
|
|
|
#Check if CUDA (GPU) is available |
|
device = torch.device("cuda" if torch.cuda.is_available() else "cpu") |
|
|
|
#Move the model to the same device (GPU or CPU) |
|
model.to(device) |
|
|
|
#Prepare text input |
|
input_text = "сайн уу" #Mongolian greeting |
|
|
|
#Tokenize the input text |
|
inputs = tokenizer(input_text, return_tensors="pt") |
|
|
|
#Move the input tensors to the same device as the model |
|
inputs = {k: v.to(device) for k, v in inputs.items() if k in ['input_ids', 'attention_mask']} |
|
|
|
#Generate translation |
|
outputs = model.generate(**inputs) |
|
|
|
#Decode the output to human-readable text |
|
translated_text = tokenizer.decode(outputs[0], skip_special_tokens=True) |
|
|
|
#Print the translated text |
|
print(f"Translated Text: {translated_text}") |
|
``` |