onlysainaa commited on
Commit
e756c52
1 Parent(s): 27ff03a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +13 -11
README.md CHANGED
@@ -28,32 +28,34 @@ This is the model card of a 🤗 transformers model that has been pushed on the
28
  - **Finetuned from model [google-t5-small]:** [More Information Needed]
29
 
30
 
31
- - ** Load model directly
 
32
  from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
33
 
34
  tokenizer = AutoTokenizer.from_pretrained("onlysainaa/cyrillic_to_script-t5-model")
35
  model = AutoModelForSeq2SeqLM.from_pretrained("onlysainaa/cyrillic_to_script-t5-model")
36
 
37
- - ** Check if CUDA (GPU) is available
38
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
39
 
40
- - ** Move the model to the same device (GPU or CPU)
41
  model.to(device)
42
 
43
- - ** Prepare text input
44
- input_text = "сайн уу" - ** Mongolian greeting
45
 
46
- - ** Tokenize the input text
47
  inputs = tokenizer(input_text, return_tensors="pt")
48
 
49
- - ** Move the input tensors to the same device as the model
50
  inputs = {k: v.to(device) for k, v in inputs.items() if k in ['input_ids', 'attention_mask']}
51
 
52
- - ** Generate translation
53
  outputs = model.generate(**inputs)
54
 
55
- - ** Decode the output to human-readable text
56
  translated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
57
 
58
- - ** Print the translated text
59
- print(f"Translated Text: {translated_text}")
 
 
28
  - **Finetuned from model [google-t5-small]:** [More Information Needed]
29
 
30
 
31
+ ```
32
+ #Load model directly
33
  from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
34
 
35
  tokenizer = AutoTokenizer.from_pretrained("onlysainaa/cyrillic_to_script-t5-model")
36
  model = AutoModelForSeq2SeqLM.from_pretrained("onlysainaa/cyrillic_to_script-t5-model")
37
 
38
+ #Check if CUDA (GPU) is available
39
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
40
 
41
+ #Move the model to the same device (GPU or CPU)
42
  model.to(device)
43
 
44
+ #Prepare text input
45
+ input_text = "сайн уу" #Mongolian greeting
46
 
47
+ #Tokenize the input text
48
  inputs = tokenizer(input_text, return_tensors="pt")
49
 
50
+ #Move the input tensors to the same device as the model
51
  inputs = {k: v.to(device) for k, v in inputs.items() if k in ['input_ids', 'attention_mask']}
52
 
53
+ #Generate translation
54
  outputs = model.generate(**inputs)
55
 
56
+ #Decode the output to human-readable text
57
  translated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
58
 
59
+ #Print the translated text
60
+ print(f"Translated Text: {translated_text}")
61
+ ```