模型:
microsoft/tapex-large-finetuned-tabfact
TAPEX是由Qian Liu、Bei Chen、Jiaqi Guo、Morteza Ziyadi、Zeqi Lin、Weizhu Chen和Jian-Guang Lou于 TAPEX: Table Pre-training via Learning a Neural SQL Executor 提出的。原始存储库可以在 here 找到。
TAPEX(通过执行进行表格预训练)是一种概念上简单且实证强大的预训练方法,用于为现有模型赋予表格推理能力。TAPEX通过学习神经SQL执行器来实现表格预训练,该预训练通过自动合成可执行的SQL查询语句来获得合成语料库。
TAPEX基于BART架构,这是一个具有双向(类似BERT)编码器和自回归(类似GPT)解码器的transformer编码器-编码器(seq2seq)模型。
这个模型是在 Tabfact 数据集上微调的tapex-base模型。
您可以将该模型用于表格事实验证。
以下是在transformers中使用此模型的方法:
from transformers import TapexTokenizer, BartForSequenceClassification import pandas as pd tokenizer = TapexTokenizer.from_pretrained("microsoft/tapex-large-finetuned-tabfact") model = BartForSequenceClassification.from_pretrained("microsoft/tapex-large-finetuned-tabfact") data = { "year": [1896, 1900, 1904, 2004, 2008, 2012], "city": ["athens", "paris", "st. louis", "athens", "beijing", "london"] } table = pd.DataFrame.from_dict(data) # tapex accepts uncased input since it is pre-trained on the uncased corpus query = "beijing hosts the olympic games in 2012" encoding = tokenizer(table=table, query=query, return_tensors="pt") outputs = model(**encoding) output_id = int(outputs.logits[0].argmax(dim=0)) print(model.config.id2label[output_id]) # Refused
请查找评估脚本 here 。
@inproceedings{ liu2022tapex, title={{TAPEX}: Table Pre-training via Learning a Neural {SQL} Executor}, author={Qian Liu and Bei Chen and Jiaqi Guo and Morteza Ziyadi and Zeqi Lin and Weizhu Chen and Jian-Guang Lou}, booktitle={International Conference on Learning Representations}, year={2022}, url={https://openreview.net/forum?id=O50443AsCP} }