Instructions to use CadenzaBaron/M2M100-418M-for-GameTranslation-Finetuned-Zh-En with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use CadenzaBaron/M2M100-418M-for-GameTranslation-Finetuned-Zh-En with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "translation" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # 'pip install "transformers<5.0.0' from transformers import pipeline pipe = pipeline("translation", model="CadenzaBaron/M2M100-418M-for-GameTranslation-Finetuned-Zh-En")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("CadenzaBaron/M2M100-418M-for-GameTranslation-Finetuned-Zh-En") model = AutoModelForSeq2SeqLM.from_pretrained("CadenzaBaron/M2M100-418M-for-GameTranslation-Finetuned-Zh-En") - Notebooks
- Google Colab
- Kaggle
Nightmare commited on
Commit ·
228263d
1
Parent(s): eaec037
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
This is a finetuned version of Facebook/M2M100.
|
| 2 |
+
It has been trained on a parallel corpus on several Chinese video games translations. All of them are from human/fan translations.
|
| 3 |
+
|
| 4 |
+
Sample generation script :
|
| 5 |
+
|
| 6 |
+
```from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
| 7 |
+
tokenizer = transformers.AutoTokenizer.from_pretrained(r"path\to\checkpoint")
|
| 8 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(r"path\to\checkpoint")
|
| 9 |
+
tokenizer.src_lang = "zh"
|
| 10 |
+
tokenizer.tgt_lang = "en"
|
| 11 |
+
test_string = "地阶上品遁术,施展后便可立于所持之剑上,以极快的速度自由飞行。"
|
| 12 |
+
|
| 13 |
+
inputs = tokenizer(test_string, return_tensors="pt")
|
| 14 |
+
translated_tokens = model.generate(**inputs, num_beams=10, do_sample=True)
|
| 15 |
+
translation = tokenizer.batch_decode(translated_tokens, skip_special_tokens=True)[0]
|
| 16 |
+
|
| 17 |
+
print("CH : ", test_string , " // EN : ", translation)```
|
| 18 |
+
|