vlt5-base-keywords项目介绍
vlt5-base-keywords项目是一个关键词生成模型,基于Google提出的Transformer编码-解码架构(https://huggingface.co/t5-base),旨在通过科学文章的摘要和标题的结合,预测出一组关键短语。这个模型特别之处在于,它能够根据文章的摘要生成精准但并不总是全面的关键短语。
项目背景与目标
vlT5模型是一个关键词生成模型,专为从短文本中提取关键字而设计。关键词生成在自然语言处理领域具有广泛应用,因为它能够有效识别和总结文本的重点信息。vlt5-base-keywords模型以科学文章文本为训练语料,主要用于预测给定文本的关键短语集合。尽管仅根据文章的摘要生成,模型输出的关键短语依然保持高精确度。
vlT5的优点与局限
vlT5模型最大的优点在于其可迁移性,能够适用于各种领域和类型的文本。然而,该模型的文本长度与生成的关键词数量与训练数据相近,对于摘要长度的文本可生成约3到5个关键词。对于较长的文本,需要拆分成较小的片段后输入模型进行处理。
语言与数据集
- 语言模型: t5-base
- 支持语言: 波兰语(pl)、英语(en),并在其他语言上表现较好。
- 训练数据: POSMAC,波兰语公开科学元数据集合,共涵盖216,214篇科学文章的摘要。
使用方法
项目提供了一个Python代码示例,展示了如何使用该模型和T5Tokenizer进行关键词预测:
from transformers import T5Tokenizer, T5ForConditionalGeneration
model = T5ForConditionalGeneration.from_pretrained("Voicelab/vlt5-base-keywords")
tokenizer = T5Tokenizer.from_pretrained("Voicelab/vlt5-base-keywords")
task_prefix = "Keywords: "
inputs = [
"Christina Katrakis, who spoke to the BBC from Vorokhta in western Ukraine, relays the account of one family, who say Russian soldiers shot at their vehicles while they were leaving their village near Chernobyl in northern Ukraine. She says the cars had white flags and signs saying they were carrying children.",
"Decays the learning rate of each parameter group by gamma every step_size epochs. Notice that such decay can happen simultaneously with other changes to the learning rate from outside this scheduler. When last_epoch=-1, sets initial lr as lr.",
"Hello, I'd like to order a pizza with salami topping.",
]
for sample in inputs:
input_sequences = [task_prefix + sample]
input_ids = tokenizer(
input_sequences, return_tensors="pt", truncation=True
).input_ids
output = model.generate(input_ids, no_repeat_ngram_size=3, num_beams=4)
predicted = tokenizer.decode(output[0], skip_special_tokens=True)
print(sample, "\n --->", predicted)
结果展示
模型采用评估指标强调生成结果的精确度(Precision)、召回率(Recall)和F1得分。在表格中比较了多种方法下的表现,其中vlT5kw在多个指标上表现优异。
许可证与引用
该模型采用CC BY 4.0许可协议。如需引用此模型,请参考以下论文:
- Keyword Extraction from Short Texts with a Text-To-Text Transfer Transformer, ACIIDS 2022
- Transferable Keyword Extraction and Generation with Text-to-Text Language Models
团队与联系
该模型由Voicelab.ai的自然语言处理研究团队训练开发。如需联系,可以访问这里。