模型:
alabnii/jmedroberta-base-sentencepiece
这是一个基于日本科学技术振兴机构(JST)收集的医学科学学术文章进行预训练的日语RoBERTa基础模型。
该模型发布在 Creative Commons 4.0 International License (CC BY-NC-SA 4.0)下。
参考资料Ja:
@InProceedings{sugimoto_nlp2023_jmedroberta,
    author =    "杉本海人 and 壹岐太一 and 知田悠生 and 金沢輝一 and 相澤彰子",
    title =     "J{M}ed{R}o{BERT}a: 日本語の医学論文にもとづいた事前学習済み言語モデルの構築と評価",
    booktitle = "言語処理学会第29回年次大会",
    year =      "2023",
    url =       "https://www.anlp.jp/proceedings/annual_meeting/2023/pdf_dir/P3-1.pdf"
}
En:
@InProceedings{sugimoto_nlp2023_jmedroberta,
    author =    "Sugimoto, Kaito and Iki, Taichi and Chida, Yuki and Kanazawa, Teruhito and Aizawa, Akiko",
    title =     "J{M}ed{R}o{BERT}a: a Japanese Pre-trained Language Model on Academic Articles in Medical Sciences (in Japanese)",
    booktitle = "Proceedings of the 29th Annual Meeting of the Association for Natural Language Processing",
    year =      "2023",
    url =       "https://www.anlp.jp/proceedings/annual_meeting/2023/pdf_dir/P3-1.pdf"
}
输入文本必须事先转换为全角字符(全角)。
您可以按照以下方式使用此模型进行遮蔽语言建模:
from transformers import AutoModelForMaskedLM, AutoTokenizer
model = AutoModelForMaskedLM.from_pretrained("alabnii/jmedroberta-base-sentencepiece")
model.eval()
tokenizer = AutoTokenizer.from_pretrained("alabnii/jmedroberta-base-sentencepiece")
texts = ['この患者は[MASK]と診断された。']
inputs = tokenizer.batch_encode_plus(texts, return_tensors='pt')
outputs = model(**inputs)
tokenizer.convert_ids_to_tokens(outputs.logits[0][1:-1].argmax(axis=-1))
# ['▁この', '患者は', 'AML', '▁', 'と診断された', '。']
或者,您可以使用 Fill-mask pipeline 。
from transformers import pipeline
fill = pipeline("fill-mask", model="alabnii/jmedroberta-base-sentencepiece", top_k=10)
fill("この患者は[MASK]と診断された。")
#[{'score': 0.04239409416913986,
#  'token': 7698,
#  'token_str': 'AML',
#  'sequence': 'この患者はAML と診断された。'},
# {'score': 0.03562006726861,
#  'token': 3298,
#  'token_str': 'SLE',
#  'sequence': 'この患者はSLE と診断された。'},
# {'score': 0.025064188987016678,
#  'token': 10303,
#  'token_str': 'MDS',
#  'sequence': 'この患者はMDS と診断された。'},
# ...
您可以在下游任务中对该模型进行微调。
另请参阅示例Colab笔记本: https://colab.research.google.com/drive/1BUD3DKOUMqcwIO3X5bYUOsR_wDzgOJcd?usp=sharing
每个句子都通过 SentencePiece (Unigram) 进行标记化。
词汇表由 SentencePiece (Unigram) 导出的30000个标记组成。
在预训练期间使用了以下超参数:
正如配置文件所示,我们的模型基于HuggingFace的BertForMaskedLM类。但是,出于以下原因,我们将模型视为RoBERTa:
此研究工作得到了日本科学技术振兴机构(JST)AIP三边AI研究(授权编号:JPMJCR20G9)以及日本的联合使用/研究中心(JHPCN)的支持(项目ID:jh221004)。在这项研究中,我们使用了“ mdx: a platform for the data-driven future ”。