🚀 MyModel
MyModel(BART-TL-ng
)是一个用于主题标签生成的模型,通过生成式方法解决主题标签任务,而非像以往工作那样从标签池中选择。它基于论文中的方法训练,有不同版本可供使用。
🚀 快速开始
本模型旨在使用生成式方法解决主题标签任务,而非像以往的先进工作那样从标签池中进行选择。若想了解更多未涵盖的详细信息,你可以阅读论文或查看开源实现:BART-TL-topic-label-generation。
论文中提供了两个模型:
✨ 主要特性
- 生成式方法:采用生成式方法解决主题标签任务,而非传统的从标签池中选择。
- 弱监督微调:基于Facebook的大型BART模型进行弱监督微调。
📦 安装指南
使用本模型前,你需要安装transformers
库,可使用以下命令进行安装:
pip install transformers
💻 使用示例
基础用法
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
mname = "cristian-popa/bart-tl-ng"
tokenizer = AutoTokenizer.from_pretrained(mname)
model = AutoModelForSeq2SeqLM.from_pretrained(mname)
input = "site web google search website online internet social content user"
enc = tokenizer(input, return_tensors="pt", truncation=True, padding="max_length", max_length=128)
outputs = model.generate(
input_ids=enc.input_ids,
attention_mask=enc.attention_mask,
max_length=15,
min_length=1,
do_sample=False,
num_beams=25,
length_penalty=1.0,
repetition_penalty=1.5
)
decoded = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(decoded)
高级用法
模型输入的主题需以空格分隔的单词序列表示,可使用LDA生成此类主题,就像为模型收集微调数据集时所做的那样。
📚 详细文档
预期用途
模型输入为以空格分隔的单词序列表示的主题,可使用LDA生成此类主题。
局限性和偏差
模型可能无法为与微调领域无关的主题(如美食领域)生成准确的标签。
训练数据
模型在5个不同的StackExchange语料库上进行了微调,分别是英语、生物学、经济学、法律和摄影。从每个语料库中使用LDA提取100个主题,经过连贯性过滤后用于训练最终模型。
训练过程
大型Facebook BART模型以弱监督方式进行微调,利用了NETL方法的无监督候选选择以及主题中的n-gram。数据集是从主题到标签的一对多映射。更多训练和参数细节可在论文中找到,或参考此笔记本。
评估结果
模型 |
前1平均 |
前3平均 |
前5平均 |
nDCG-1 |
nDCG-3 |
nDCG-5 |
NETL (U) |
2.66 |
2.59 |
2.50 |
0.83 |
0.85 |
0.87 |
NETL (S) |
2.74 |
2.57 |
2.49 |
0.88 |
0.85 |
0.88 |
BART-TL-all |
2.64 |
2.52 |
2.43 |
0.83 |
0.84 |
0.87 |
BART-TL-ng |
2.62 |
2.50 |
2.33 |
0.82 |
0.84 |
0.85 |
BibTeX引用和引用信息
@inproceedings{popa-rebedea-2021-bart,
title = "{BART}-{TL}: Weakly-Supervised Topic Label Generation",
author = "Popa, Cristian and
Rebedea, Traian",
booktitle = "Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: Main Volume",
month = apr,
year = "2021",
address = "Online",
publisher = "Association for Computational Linguistics",
url = "https://www.aclweb.org/anthology/2021.eacl-main.121",
pages = "1418--1425",
abstract = "We propose a novel solution for assigning labels to topic models by using multiple weak labelers. The method leverages generative transformers to learn accurate representations of the most important topic terms and candidate labels. This is achieved by fine-tuning pre-trained BART models on a large number of potential labels generated by state of the art non-neural models for topic labeling, enriched with different techniques. The proposed BART-TL model is able to generate valuable and novel labels in a weakly-supervised manner and can be improved by adding other weak labelers or distant supervision on similar tasks.",
}
📄 许可证
本项目采用Apache-2.0许可证。