Indicbart
IndicBARTはインドの言語と英語に特化した多言語シーケンス・ツー・シーケンス事前学習モデルで、11のインド言語をサポートし、mBARTアーキテクチャに基づいて構築されています。
ダウンロード数 4,120
リリース時間 : 3/2/2022
モデル概要
IndicBARTは、機械翻訳、要約生成、質問生成などの自然言語生成タスクに特化した、インドの言語と英語のための多言語シーケンス・ツー・シーケンス事前学習モデルです。
モデル特徴
多言語サポート
アッサム語、ベンガル語、グジャラート語など11のインド言語と英語をサポートしています。
効率的な計算
モデルはmBARTやmT5(ベース版)よりもはるかに小さいため、ファインチューニングやデコード時の計算コストが低くなります。
大規模事前学習
インド英語コンテンツを含む大規模なインド言語コーパス(4億5200万文、90億トークン)でトレーニングされています。
統一書記体系
英語を除くすべての言語はデーヴァナーガリ文字で記述されており、関連言語間の転移学習を促進します。
モデル能力
テキスト生成
機械翻訳
要約生成
質問生成
使用事例
自然言語処理
機械翻訳
英語からインド言語へ、またはインド言語から英語へ翻訳します。
要約生成
インド言語のテキストの要約を生成します。
質問生成
インド言語のテキストに基づいて関連する質問を生成します。
🚀 IndicBART
IndicBARTは、インド諸言語と英語に焦点を当てた多言語のシーケンスツーシーケンスの事前学習モデルです。現在は11のインドの言語をサポートしており、mBARTアーキテクチャに基づいています。IndicBARTモデルを使用して、機械翻訳、要約、質問生成などのタスクの教師付き学習データでモデルを微調整することで、インドの言語の自然言語生成アプリケーションを構築することができます。
🚀 クイックスタート
IndicBARTは、インド諸言語と英語に特化した多言語事前学習モデルです。以下に、基本的な使用方法を示します。
from transformers import MBartForConditionalGeneration, AutoModelForSeq2SeqLM
from transformers import AlbertTokenizer, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("ai4bharat/IndicBART", do_lower_case=False, use_fast=False, keep_accents=True)
# Or use tokenizer = AlbertTokenizer.from_pretrained("ai4bharat/IndicBART", do_lower_case=False, use_fast=False, keep_accents=True)
model = AutoModelForSeq2SeqLM.from_pretrained("ai4bharat/IndicBART")
# Some initial mapping
bos_id = tokenizer._convert_token_to_id_with_added_voc("<s>")
eos_id = tokenizer._convert_token_to_id_with_added_voc("</s>")
pad_id = tokenizer._convert_token_to_id_with_added_voc("<pad>")
# To get lang_id use any of ['<2as>', '<2bn>', '<2en>', '<2gu>', '<2hi>', '<2kn>', '<2ml>', '<2mr>', '<2or>', '<2pa>', '<2ta>', '<2te>']
# First tokenize the input and outputs. The format below is how IndicBART was trained so the input should be "Sentence </s> <2xx>" where xx is the language code. Similarly, the output should be "<2yy> Sentence </s>".
inp = tokenizer("I am a boy </s> <2en>", add_special_tokens=False, return_tensors="pt", padding=True).input_ids # tensor([[ 466, 1981, 80, 25573, 64001, 64004]])
out = tokenizer("<2hi> मैं एक लड़का हूँ </s>", add_special_tokens=False, return_tensors="pt", padding=True).input_ids # tensor([[64006, 942, 43, 32720, 8384, 64001]])
# Note that if you use any language other than Hindi or Marathi, you should convert its script to Devanagari using the Indic NLP Library.
model_outputs=model(input_ids=inp, decoder_input_ids=out[:,0:-1], labels=out[:,1:])
# For loss
model_outputs.loss ## This is not label smoothed.
# For logits
model_outputs.logits
# For generation. Pardon the messiness. Note the decoder_start_token_id.
model.eval() # Set dropouts to zero
model_output=model.generate(inp, use_cache=True, num_beams=4, max_length=20, min_length=1, early_stopping=True, pad_token_id=pad_id, bos_token_id=bos_id, eos_token_id=eos_id, decoder_start_token_id=tokenizer._convert_token_to_id_with_added_voc("<2en>"))
# Decode to get output strings
decoded_output=tokenizer.decode(model_output[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
print(decoded_output) # I am a boy
# Note that if your output language is not Hindi or Marathi, you should convert its script from Devanagari to the desired language using the Indic NLP Library.
# What if we mask?
inp = tokenizer("I am [MASK] </s> <2en>", add_special_tokens=False, return_tensors="pt", padding=True).input_ids
model_output=model.generate(inp, use_cache=True, num_beams=4, max_length=20, min_length=1, early_stopping=True, pad_token_id=pad_id, bos_token_id=bos_id, eos_token_id=eos_id, decoder_start_token_id=tokenizer._convert_token_to_id_with_added_voc("<2en>"))
decoded_output=tokenizer.decode(model_output[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
print(decoded_output) # I am happy
inp = tokenizer("मैं [MASK] हूँ </s> <2hi>", add_special_tokens=False, return_tensors="pt", padding=True).input_ids
model_output=model.generate(inp, use_cache=True, num_beams=4, max_length=20, min_length=1, early_stopping=True, pad_token_id=pad_id, bos_token_id=bos_id, eos_token_id=eos_id, decoder_start_token_id=tokenizer._convert_token_to_id_with_added_voc("<2en>"))
decoded_output=tokenizer.decode(model_output[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
print(decoded_output) # मैं जानता हूँ
inp = tokenizer("मला [MASK] पाहिजे </s> <2mr>", add_special_tokens=False, return_tensors="pt", padding=True).input_ids
model_output=model.generate(inp, use_cache=True, num_beams=4, max_length=20, min_length=1, early_stopping=True, pad_token_id=pad_id, bos_token_id=bos_id, eos_token_id=eos_id, decoder_start_token_id=tokenizer._convert_token_to_id_with_added_voc("<2en>"))
decoded_output=tokenizer.decode(model_output[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
print(decoded_output) # मला ओळखलं पाहिजे
✨ 主な機能
- サポート言語:アッサム語、ベンガル語、グジャラート語、ヒンディー語、マラーティー語、オリヤー語、パンジャブ語、カンナダ語、マラヤーラム語、タミル語、テルグ語、英語。mBART50やmT5はこれらのすべての言語をサポートしていません。
- 軽量モデル:mBARTやmT5(-base)モデルよりもはるかに小さいため、微調整やデコードの際の計算コストが低くなります。
- 大規模コーパスで学習:4億5200万文と90億トークンの大規模なインド言語コーパス(インド英語の内容も含む)で学習されています。
- 天城体表記:英語を除くすべての言語が天城体で表現されており、関連する言語間の転移学習を促進しています。
📦 事前学習コーパス
このモデルは、IndicCorpデータ(12の言語にまたがり、4億5200万文(90億トークン))を使用して、mBARTで用いられるテキスト埋め込み目的で学習されました。
📚 ドキュメント
詳細なドキュメントはこちらを参照してください:
- https://github.com/AI4Bharat/indic-bart/
- https://indicnlp.ai4bharat.org/indic-bart/
🔧 注意事項
⚠️ 重要提示
- このモデルは最新バージョンのtransformersと互換性がありますが、バージョン4.3.2で開発されているため、可能であれば4.3.2を使用することを検討してください。
- ここではロジットと損失の取得方法、出力の生成方法のみを示しましたが、https://huggingface.co/docs/transformers/model_doc/mbart#transformers.MBartForConditionalGeneration で説明されているMBartForConditionalGenerationクラスができることはほぼすべて行うことができます。
- 使用しているトークナイザーはsentencepieceに基づいており、BPEではありません。そのため、MBartTokenizerクラスではなくAlbertTokenizerクラスを使用しています。
- 天城体以外の文字で書かれた言語(英語を除く)を使用する場合は、まずIndic NLP Libraryを使用して天城体に変換する必要があります。出力を得た後は、元の文字に戻す必要があります。
🔧 下流タスクでの微調整
- このモデルを微調整したい場合は、YANMTTツールキットを使用して、ここの指示に従って行うことができます。
- (未検証)あるいは、翻訳と要約の公式huggingfaceスクリプトを使用することもできます。
🔧 貢献者
- Raj Dabre
- Himani Shrotriya
- Anoop Kunchukuttan
- Ratish Puduppully
- Mitesh M. Khapra
- Pratyush Kumar
🔧 論文
IndicBARTを使用する場合は、以下の論文を引用してください。
@misc{dabre2021indicbart,
title={IndicBART: A Pre-trained Model for Natural Language Generation of Indic Languages},
author={Raj Dabre and Himani Shrotriya and Anoop Kunchukuttan and Ratish Puduppully and Mitesh M. Khapra and Pratyush Kumar},
year={2021},
eprint={2109.02903},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
📄 ライセンス
このモデルはMITライセンスの下で利用可能です。
Phi 2 GGUF
その他
Phi-2はマイクロソフトが開発した小型ながら強力な言語モデルで、27億のパラメータを持ち、効率的な推論と高品質なテキスト生成に特化しています。
大規模言語モデル 複数言語対応
P
TheBloke
41.5M
205
Roberta Large
MIT
マスク言語モデリングの目標で事前学習された大型英語言語モデルで、改良されたBERTの学習方法を採用しています。
大規模言語モデル 英語
R
FacebookAI
19.4M
212
Distilbert Base Uncased
Apache-2.0
DistilBERTはBERT基礎モデルの蒸留バージョンで、同等の性能を維持しながら、より軽量で高効率です。シーケンス分類、タグ分類などの自然言語処理タスクに適しています。
大規模言語モデル 英語
D
distilbert
11.1M
669
Llama 3.1 8B Instruct GGUF
Meta Llama 3.1 8B Instructは多言語大規模言語モデルで、多言語対話ユースケースに最適化されており、一般的な業界ベンチマークで優れた性能を発揮します。
大規模言語モデル 英語
L
modularai
9.7M
4
Xlm Roberta Base
MIT
XLM - RoBERTaは、100言語の2.5TBのフィルタリングされたCommonCrawlデータを使って事前学習された多言語モデルで、マスク言語モデリングの目標で学習されています。
大規模言語モデル 複数言語対応
X
FacebookAI
9.6M
664
Roberta Base
MIT
Transformerアーキテクチャに基づく英語の事前学習モデルで、マスク言語モデリングの目標を通じて大量のテキストでトレーニングされ、テキスト特徴抽出と下流タスクの微調整をサポートします。
大規模言語モデル 英語
R
FacebookAI
9.3M
488
Opt 125m
その他
OPTはMeta AIが公開したオープンプリトレーニングトランスフォーマー言語モデルスイートで、パラメータ数は1.25億から1750億まであり、GPT-3シリーズの性能に対抗することを目指しつつ、大規模言語モデルのオープンな研究を促進するものです。
大規模言語モデル 英語
O
facebook
6.3M
198
1
transformersライブラリに基づく事前学習モデルで、様々なNLPタスクに適用可能
大規模言語モデル
Transformers

1
unslothai
6.2M
1
Llama 3.1 8B Instruct
Llama 3.1はMetaが発表した多言語大規模言語モデルシリーズで、8B、70B、405Bのパラメータ規模を持ち、8種類の言語とコード生成をサポートし、多言語対話シーンを最適化しています。
大規模言語モデル
Transformers 複数言語対応

L
meta-llama
5.7M
3,898
T5 Base
Apache-2.0
T5ベーシック版はGoogleによって開発されたテキスト-to-テキスト変換Transformerモデルで、パラメータ規模は2.2億で、多言語NLPタスクをサポートしています。
大規模言語モデル 複数言語対応
T
google-t5
5.4M
702
おすすめAIモデル
Llama 3 Typhoon V1.5x 8b Instruct
タイ語専用に設計された80億パラメータの命令モデルで、GPT-3.5-turboに匹敵する性能を持ち、アプリケーションシナリオ、検索拡張生成、制限付き生成、推論タスクを最適化
大規模言語モデル
Transformers 複数言語対応

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-TinyはSODAデータセットでトレーニングされた超小型対話モデルで、エッジデバイス推論向けに設計されており、体積はCosmo-3Bモデルの約2%です。
対話システム
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
RoBERTaアーキテクチャに基づく中国語抽出型QAモデルで、与えられたテキストから回答を抽出するタスクに適しています。
質問応答システム 中国語
R
uer
2,694
98