Indicbartss
IndicBARTSS是一个专注于印度语言和英语的多语言序列到序列预训练模型,支持11种印度语言和英语,适用于自然语言生成任务。
下载量 564
发布时间 : 3/15/2022
模型简介
IndicBARTSS基于mBART架构,是一个多语言序列到序列预训练模型,专门针对印度语言和英语设计。它支持多种自然语言生成任务,如机器翻译、摘要和问题生成等。
模型特点
多语言支持
支持11种印度语言和英语,这些语言并非全部被mBART50和mT5支持。
计算效率高
模型比mBART和mT5(基础版)小得多,因此在微调和解码时计算成本更低。
大规模预训练
在大型印度语言语料库(4.52亿句子和90亿标记)上训练,其中包括印度英语内容。
原生文字支持
每种语言都使用其自己的文字书写,不需要进行任何与梵文的文字映射。
模型能力
文本生成
机器翻译
文本摘要
问题生成
使用案例
自然语言处理
机器翻译
将英语翻译为多种印度语言,或将印度语言翻译为英语。
文本摘要
生成印度语言或英语文本的摘要。
问题生成
基于给定的文本生成相关问题。
🚀 IndicBARTSS模型
IndicBARTSS是一个多语言的序列到序列预训练模型,专注于印度语言和英语。它基于mBART架构,目前支持11种印度语言。你可以使用IndicBARTSS模型,通过有监督的训练数据对模型进行微调,来构建印度语言的自然语言生成应用,适用于机器翻译、文本摘要、问题生成等任务。
🚀 快速开始
你可以在这篇论文中了解更多关于IndicBARTSS的信息。 详细文档请查看:https://github.com/AI4Bharat/indic-bart/ 和 https://indicnlp.ai4bharat.org/indic-bart/
✨ 主要特性
- 支持的语言广泛:支持阿萨姆语、孟加拉语、古吉拉特语、印地语、马拉地语、奥里亚语、旁遮普语、卡纳达语、马拉雅拉姆语、泰米尔语、泰卢固语和英语。并非所有这些语言都被mBART50和mT5支持。
- 模型规模小:该模型比mBART和mT5(-base)模型小得多,因此在微调和解码时计算成本更低。
- 训练数据丰富:在大型印度语言语料库(4.52亿个句子和90亿个标记)上进行训练,其中还包括印度英语内容。
- 无需脚本映射:与ai4bharat/IndicBART不同,每种语言都使用其自己的文字书写,因此你无需执行任何与天城文之间的脚本映射。
📦 安装指南
文档中未提及具体安装命令,此章节跳过。
💻 使用示例
基础用法
from transformers import MBartForConditionalGeneration, AutoModelForSeq2SeqLM
from transformers import AlbertTokenizer, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("ai4bharat/IndicBARTSS", do_lower_case=False, use_fast=False, keep_accents=True)
# Or use tokenizer = AlbertTokenizer.from_pretrained("ai4bharat/IndicBARTSS", do_lower_case=False, use_fast=False, keep_accents=True)
model = AutoModelForSeq2SeqLM.from_pretrained("ai4bharat/IndicBARTSS")
# Or use model = MBartForConditionalGeneration.from_pretrained("ai4bharat/IndicBARTSS")
# 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 IndicBARTSS 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]])
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
高级用法
# 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) # मला ओळखलं पाहिजे
📚 详细文档
注意事项
- 该模型与最新版本的transformers兼容,但开发时使用的是4.3.2版本,因此如果可能的话,建议使用4.3.2版本。
- 虽然文档中仅展示了如何获取logits和损失以及如何生成输出,但你可以执行MBartForConditionalGeneration类所能执行的几乎所有操作,详情请参考https://huggingface.co/docs/transformers/model_doc/mbart#transformers.MBartForConditionalGeneration 。
- 注意,这里使用的分词器基于SentencePiece,而不是BPE。因此,使用的是AlbertTokenizer类,而不是MBartTokenizer类。
下游任务微调
贡献者
- Raj Dabre
- Himani Shrotriya
- Anoop Kunchukuttan
- Ratish Puduppully
- Mitesh M. Khapra
- Pratyush Kumar
论文引用
如果你使用了IndicBARTSS,请引用以下论文:
@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}
}
🔧 技术细节
预训练语料库
使用了涵盖12种语言的IndicCorp数据,包含4.52亿个句子(90亿个标记)。该模型使用了mBART中采用的文本填充目标进行训练。
📄 许可证
该模型遵循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发布的开放预训练Transformer语言模型套件,参数量从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开发的文本到文本转换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架构的中文抽取式问答模型,适用于从给定文本中提取答案的任务。
问答系统 中文
R
uer
2,694
98