Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# pip install -q transformers
|
2 |
+
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
3 |
+
|
4 |
+
checkpoint = "CohereForAI/aya-101"
|
5 |
+
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
7 |
+
aya_model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint)
|
8 |
+
|
9 |
+
# Turkish to English translation
|
10 |
+
tur_inputs = tokenizer.encode("Translate to English: Aya cok dilli bir dil modelidir.", return_tensors="pt")
|
11 |
+
tur_outputs = aya_model.generate(tur_inputs, max_new_tokens=128)
|
12 |
+
print(tokenizer.decode(tur_outputs[0]))
|
13 |
+
# Aya is a multi-lingual language model
|
14 |
+
|
15 |
+
# Q: Why are there so many languages in India?
|
16 |
+
hin_inputs = tokenizer.encode("भारत में इतनी सारी भाषाएँ क्यों हैं?", return_tensors="pt")
|
17 |
+
hin_outputs = aya_model.generate(hin_inputs, max_new_tokens=128)
|
18 |
+
print(tokenizer.decode(hin_outputs[0]))
|
19 |
+
# Expected output: भारत में कई भाषाएँ हैं और विभिन्न भाषाओं के बोली जाने वाले लोग हैं। यह विभिन्नता भाषाई विविधता और सांस्कृतिक विविधता का परिणाम है। Translates to "India has many languages and people speaking different languages. This diversity is the result of linguistic diversity and cultural diversity."
|