🚀 クワドリフォリオ - 英語からイタリア語への翻訳用小型モデル
クワドリフォリオは、bigscience/mt0-small
をベースにした、英語とイタリア語のテキスト翻訳用のエンコーダ - デコーダ型トランスフォーマーモデルです。Helsinki-NLP/opus-100
とHelsinki-NLP/europarl
のen-it
セクションで学習されました。
🚀 クイックスタート
クワドリフォリオは、英語とイタリア語のテキスト翻訳用のエンコーダ - デコーダ型トランスフォーマーモデルです。bigscience/mt0-small
をベースに構築され、Helsinki-NLP/opus-100
とHelsinki-NLP/europarl
のen-it
セクションで訓練されました。
✨ 主な機能
- 英語からイタリア語へのテキスト翻訳を行うことができます。
bigscience/mt0-small
をベースにしているため、軽量で高速な推論が可能です。
💻 使用例
基本的な使用法
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("LeonardPuettmann/Quadrifoglio-mt-en-it")
model = AutoModelForSeq2SeqLM.from_pretrained("LeonardPuettmann/Quadrifoglio-mt-en-it")
def generate_response(input_text):
input_ids = tokenizer("translate English to Italian:" + input_text, return_tensors="pt").input_ids
output = model.generate(input_ids, max_new_tokens=256)
return tokenizer.decode(output[0], skip_special_tokens=True)
text_to_translate = "I would like a cup of green tea, please."
response = generate_response(text_to_translate)
print(response)
高度な使用法
このモデルは文ペアの翻訳で学習されているため、長いテキストを個々の文に分割することが最適です。理想的にはSpaCyを使用します。その後、文を翻訳し、最後に翻訳結果を結合することができます。
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
import spacy
nlp = spacy.load("en_core_web_sm")
tokenizer = AutoTokenizer.from_pretrained("LeonardPuettmann/Quadrifoglio-mt-en-it")
model = AutoModelForSeq2SeqLM.from_pretrained("LeonardPuettmann/Quadrifoglio-mt-en-it")
def generate_response(input_text):
input_ids = tokenizer("translate Italian to English: " + input_text, return_tensors="pt").input_ids
output = model.generate(input_ids, max_new_tokens=256)
return tokenizer.decode(output[0], skip_special_tokens=True)
text = "How are you doing? Today is a beautiful day. I hope you are doing fine."
doc = nlp(text)
sentences = [sent.text for sent in doc.sents]
sentence_translations = []
for i, sentence in enumerate(sentences):
sentence_translation = generate_response(sentence)
sentence_translations.append(sentence_translation)
full_translation = " ".join(sentence_translations)
print(full_translation)
📚 詳細ドキュメント
評価
Opus 100のテストセットで評価を行いました。
評価指標 |
クワドリフォリオ (このモデル) |
mt0-small |
DeepL |
BLEU Score |
0.4816 |
0.0159 |
0.5210 |
Precision 1 |
0.7305 |
0.2350 |
0.7613 |
Precision 2 |
0.5413 |
0.0290 |
0.5853 |
Precision 3 |
0.4289 |
0.0076 |
0.4800 |
Precision 4 |
0.3417 |
0.0013 |
0.3971 |
📄 ライセンス
このモデルはapache-2.0
ライセンスの下で提供されています。