onlysainaa's picture
Update README.md
7213ed9 verified
|
raw
history blame
1.67 kB
metadata
library_name: transformers
license: apache-2.0
language:
  - mn

Model Card for Model ID

Model Details

Model Description

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]

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}")