模型:

microsoft/tapex-large-finetuned-wikisql

英文

TAPEX(大型模型)

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执行器来实现表格预训练,合成语料库是通过自动合成可执行的SQL查询获得的。

TAPEX基于BART架构,是一种转换器编码器-编码器(seq2seq)模型,具有双向(类似BERT)编码器和自回归(类似GPT)解码器。

该模型是在 WikiSQL 数据集上微调的 tapex-base 模型。

预期用途

您可以在相对简单的问题上使用该模型进行表格问答。以下是一些可解决的问题示例(对应的表格暂未显示):

Question Answer
tell me what the notes are for south australia no slogan on current series
what position does the player who played for butler cc (ks) play? guard-forward
how many schools did player number 3 play at? 1.0
how many winning drivers in the kraco twin 125 (r2) race were there? 1.0
for the episode(s) aired in the u.s. on 4 april 2008, what were the names? "bust a move" part one, "bust a move" part two

如何使用

以下是在transformers中使用此模型的方法:

from transformers import TapexTokenizer, BartForConditionalGeneration
import pandas as pd

tokenizer = TapexTokenizer.from_pretrained("microsoft/tapex-large-finetuned-wikisql")
model = BartForConditionalGeneration.from_pretrained("microsoft/tapex-large-finetuned-wikisql")

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 = "In which year did beijing host the Olympic Games?"
encoding = tokenizer(table=table, query=query, return_tensors="pt")

outputs = model.generate(**encoding)

print(tokenizer.batch_decode(outputs, skip_special_tokens=True))
# [' 2008.0']

如何评估

请查找评估脚本 here

BibTeX条目和引用信息

@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}
}