Ask2Transformers是一个基于Transformers的零点分类库。
a2t的Python项目详细描述
ASK2变压器-预培训变压器的零爆炸主题分类
正在进行中。在
这个库包含Ask2Transformers项目的代码。在
基于非特定任务预训练模型的主题分类
>>>froma2t.topic_classificationimportNLITopicClassifier>>>topics=['politics','culture','economy','biology','legal','medicine','business']>>>context="hospital: a health facility where patients receive treatment.">>>clf=NLITopicClassifier('roberta-large-mnli',topics)>>>predictions=clf(context)[0]>>>print(sorted(list(zip(predictions,topics)),reverse=True))[(0.77885467,'medicine'),(0.08395168,'biology'),(0.040319894,'business'),(0.027866213,'economy'),(0.02357693,'politics'),(0.023382403,'legal'),(0.02204825,'culture')]
安装
使用Pip(检查最后一个版本)
^{pr2}$或者关闭存储库
git clone https://github.com/osainz59/Ask2Transformers.git
cd Ask2Transformers
python -m pip install .
评价
使用以下命令,您可以轻松地使用数据集计算模型。例如在WordNet上计算 包含BabelDomains的数据集:
python3 -m a2t.topic_classification.run_evaluation \ data/babeldomains.domain.gloss.tsv \ data/babel_topics.txt \ --config path_to_config
配置文件应该是一个JSON,看起来像:
[{"name":"mnli_roberta-large-mnli","classification_model":"mnli","pretrained_model":"roberta-large-mnli","query_phrase":"Topic or domain about","batch_size":1,"use_cuda":true,"entailment_position":2,...},...]
在experiments/
目录中有一些示例。在
WordNet数据集(BabelNet域)
- 1540注释注释注释
- 34个领域(类)
结果(微平均):
Method | Precision | Recall | F1-Score |
---|---|---|---|
Distributional (Camacho-Collados et al. 2016) | 84.0 | 59.8 | 69.9 |
BabelDomains (Camacho-Collados et al. 2017) | 81.7 | 68.7 | 74.6 |
Ask2Transformers | 92.14 | 92.14 | 92.14 |
- 项目
标签: