🚀 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許可證。