🚀 IndicTrans2
このモデルはIndicTrans2 En-Indic 1.1Bバリアントのモデルカードです。
特定のチェックポイントのメトリクスはこちらです。
モデルのトレーニング、意図された使用方法、データ、メトリクス、制限事項、および推奨事項の詳細については、プレプリントのAppendix D: Model Card
を参照してください。
🚀 クイックスタート
サポート言語
言語 |
詳細 |
サポート言語 |
as, bn, brx, doi, en, gom, gu, hi, kn, ks, kas, mai, ml, mr, mni, mnb, ne, or, pa, sa, sat, sd, snd, ta, te, ur |
言語詳細 |
asm_Beng, ben_Beng, brx_Deva, doi_Deva, eng_Latn, gom_Deva, guj_Gujr, hin_Deva, kan_Knda, kas_Arab, kas_Deva, mai_Deva, mal_Mlym, mar_Deva, mni_Beng, mni_Mtei, npi_Deva, ory_Orya, pan_Guru, san_Deva, sat_Olck, snd_Arab, snd_Deva, tam_Taml, tel_Telu, urd_Arab |
タグ
- indictrans2
- translation
- ai4bharat
- multilingual
ライセンス
データセット
- flores-200
- IN22-Gen
- IN22-Conv
評価指標
推論
✨ 主な機能
- このモデルはIndicTrans2 En-Indic 1.1Bバリアントで、特定のチェックポイントのメトリクスを提供します。
- モデルのトレーニング、意図された使用方法、データ、メトリクス、制限事項、および推奨事項の詳細は、プレプリントの
Appendix D: Model Card
で確認できます。
- 新しいRoPEベースのIndicTrans2モデルは、最大2048トークンのシーケンス長を処理できます。
📦 インストール
このドキュメントには具体的なインストール手順が記載されていないため、このセクションをスキップします。
💻 使用例
基本的な使用法
import torch
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
from IndicTransToolkit.processor import IndicProcessor
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
src_lang, tgt_lang = "eng_Latn", "hin_Deva"
model_name = "ai4bharat/indictrans2-en-indic-1B"
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
model = AutoModelForSeq2SeqLM.from_pretrained(
model_name,
trust_remote_code=True,
torch_dtype=torch.float16,
attn_implementation="flash_attention_2"
).to(DEVICE)
ip = IndicProcessor(inference=True)
input_sentences = [
"When I was young, I used to go to the park every day.",
"We watched a new movie last week, which was very inspiring.",
"If you had met me at that time, we would have gone out to eat.",
"My friend has invited me to his birthday party, and I will give him a gift.",
]
batch = ip.preprocess_batch(
input_sentences,
src_lang=src_lang,
tgt_lang=tgt_lang,
)
inputs = tokenizer(
batch,
truncation=True,
padding="longest",
return_tensors="pt",
return_attention_mask=True,
).to(DEVICE)
with torch.no_grad():
generated_tokens = model.generate(
**inputs,
use_cache=True,
min_length=0,
max_length=256,
num_beams=5,
num_return_sequences=1,
)
generated_tokens = tokenizer.batch_decode(
generated_tokens,
skip_special_tokens=True,
clean_up_tokenization_spaces=True,
)
translations = ip.postprocess_batch(generated_tokens, lang=tgt_lang)
for input_sentence, translation in zip(input_sentences, translations):
print(f"{src_lang}: {input_sentence}")
print(f"{tgt_lang}: {translation}")
高度な使用法
- 新しいRoPEベースのIndicTrans2モデルは、こちらで入手できます。これらのモデルは最大2048トークンのシーケンス長を処理できます。
- これらのモデルを使用するには、
model_name
パラメータを変更するだけです。生成に関する詳細情報は、RoPE - IT2モデルのモデルカードを参照してください。
- これらのモデルは、効率的な生成のために
flash_attention_2
で実行することをおすすめします。
📚 ドキュメント
使用方法の詳細な説明については、GitHubリポジトリを参照してください。
🔧 技術詳細
このドキュメントには具体的な技術詳細が記載されていないため、このセクションをスキップします。
📄 ライセンス
このモデルはMITライセンスの下で提供されています。
引用
もしこのモデルを使用する場合は、以下のように引用してください。
@article{gala2023indictrans,
title={IndicTrans2: Towards High-Quality and Accessible Machine Translation Models for all 22 Scheduled Indian Languages},
author={Jay Gala and Pranjal A Chitale and A K Raghavan and Varun Gumma and Sumanth Doddapaneni and Aswanth Kumar M and Janki Atul Nawale and Anupama Sujatha and Ratish Puduppully and Vivek Raghavan and Pratyush Kumar and Mitesh M Khapra and Raj Dabre and Anoop Kunchukuttan},
journal={Transactions on Machine Learning Research},
issn={2835-8856},
year={2023},
url={https://openreview.net/forum?id=vfT4YuzAYA},
note={}
}