https://github.com/google-research/tapas

End-to-end neural table-text understanding models.

https://github.com/google-research/tapas

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.0%) to scientific vocabulary

Keywords

nlp-machine-learning question-answering table-parsing tensorflow
Last synced: 6 months ago · JSON representation

Repository

End-to-end neural table-text understanding models.

Basic Info
  • Host: GitHub
  • Owner: google-research
  • License: apache-2.0
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 631 KB
Statistics
  • Stars: 1,198
  • Watchers: 42
  • Forks: 217
  • Open Issues: 58
  • Releases: 0
Archived
Topics
nlp-machine-learning question-answering table-parsing tensorflow
Created about 6 years ago · Last pushed almost 2 years ago
Metadata Files
Readme Contributing License Authors

README.md

TAble PArSing (TAPAS)

Code and checkpoints for training the transformer-based Table QA models introduced in the paper TAPAS: Weakly Supervised Table Parsing via Pre-training.

News

2021/09/15

2021/08/24

  • Added a colab to try predictions on open domain question answering.

2021/08/20

2021/07/23

2021/05/13

2021/03/23

2020/12/17

2020/10/19

  • Small change to WTQ training example creation
    • Questions with ambiguous cell matches will now be discarded
    • This improves denotation accuracy by ~1 point
    • For more details see this issue.
  • Added option to filter table columns by textual overlap with question

2020/10/09

2020/08/26

  • Added a colab to try predictions on WTQ

2020/08/05

  • New pre-trained models (see Data section below)
  • reset_position_index_per_cell: New option that allows to train models that instead of using absolute position indices reset the position index when a new cell starts.

2020/06/10

  • Bump TensorFlow to v2.2

2020/06/08

2020/05/07

  • Added a colab to try predictions on SQA

Installation

The easiest way to try out TAPAS with free GPU/TPU is in our Colab, which shows how to do predictions on SQA.

The repository uses protocol buffers, and requires the protoc compiler to run. You can download the latest binary for your OS here. On Ubuntu/Debian, it can be installed with:

bash sudo apt-get install protobuf-compiler

Afterwards, clone and install the git repository:

bash git clone https://github.com/google-research/tapas cd tapas pip install -e .

To run the test suite we use the tox library which can be run by calling: bash pip install tox tox

Models

We provide pre-trained models for different model sizes.

The metrics are computed by our tool and not the official metrics of the respective tasks. We provide them so one can verify whether one's own runs are in the right ballpark. They are medians over three individual runs.

Models with intermediate pre-training (2020/10/07).

New models based on the ideas discussed in Understanding tables with intermediate pre-training. Learn more about the methods use here.

WTQ

Trained from Mask LM, intermediate data, SQA, WikiSQL.

Size | Reset | Dev Accuracy | Link -------- | --------| -------- | ---- LARGE | noreset | 0.5062 | tapaswtqwikisqlsqaintermasklmlarge.zip LARGE | reset | 0.5097 | tapaswtqwikisqlsqaintermasklmlarge_reset.zip BASE | noreset | 0.4525 | tapaswtqwikisqlsqaintermasklmbase.zip BASE | reset | 0.4638 | tapaswtqwikisqlsqaintermasklmbase_reset.zip MEDIUM | noreset | 0.4324 | tapaswtqwikisqlsqaintermasklmmedium.zip MEDIUM | reset | 0.4324 | tapaswtqwikisqlsqaintermasklmmedium_reset.zip SMALL | noreset | 0.3681 | tapaswtqwikisqlsqaintermasklmsmall.zip SMALL | reset | 0.3762 | tapaswtqwikisqlsqaintermasklmsmall_reset.zip MINI | noreset | 0.2783 | tapaswtqwikisqlsqaintermasklmmini.zip MINI | reset | 0.2854 | tapaswtqwikisqlsqaintermasklmmini_reset.zip TINY | noreset | 0.0823 | tapaswtqwikisqlsqaintermasklmtiny.zip TINY | reset | 0.1039 | tapaswtqwikisqlsqaintermasklmtiny_reset.zip

WIKISQL

Trained from Mask LM, intermediate data, SQA.

Size | Reset | Dev Accuracy | Link -------- | --------| -------- | ---- LARGE | noreset | 0.8948 | tapaswikisqlsqaintermasklm_large.zip LARGE | reset | 0.8979 | tapaswikisqlsqaintermasklmlargereset.zip BASE | noreset | 0.8859 | tapaswikisqlsqaintermasklm_base.zip BASE | reset | 0.8855 | tapaswikisqlsqaintermasklmbasereset.zip MEDIUM | noreset | 0.8766 | tapaswikisqlsqaintermasklm_medium.zip MEDIUM | reset | 0.8773 | tapaswikisqlsqaintermasklmmediumreset.zip SMALL | noreset | 0.8552 | tapaswikisqlsqaintermasklm_small.zip SMALL | reset | 0.8615 | tapaswikisqlsqaintermasklmsmallreset.zip MINI | noreset | 0.8063 | tapaswikisqlsqaintermasklm_mini.zip MINI | reset | 0.82 | tapaswikisqlsqaintermasklmminireset.zip TINY | noreset | 0.3198 | tapaswikisqlsqaintermasklm_tiny.zip TINY | reset | 0.6046 | tapaswikisqlsqaintermasklmtinyreset.zip

TABFACT

Trained from Mask LM, intermediate data.

Size | Reset | Dev Accuracy | Link -------- | --------| -------- | ---- LARGE | noreset | 0.8101 | tapastabfactintermasklmlarge.zip LARGE | reset | 0.8159 | tapastabfactintermasklmlarge_reset.zip BASE | noreset | 0.7856 | tapastabfactintermasklmbase.zip BASE | reset | 0.7918 | tapastabfactintermasklmbase_reset.zip MEDIUM | noreset | 0.7585 | tapastabfactintermasklmmedium.zip MEDIUM | reset | 0.7587 | tapastabfactintermasklmmedium_reset.zip SMALL | noreset | 0.7321 | tapastabfactintermasklmsmall.zip SMALL | reset | 0.7346 | tapastabfactintermasklmsmall_reset.zip MINI | noreset | 0.6166 | tapastabfactintermasklmmini.zip MINI | reset | 0.6845 | tapastabfactintermasklmmini_reset.zip TINY | noreset | 0.5425 | tapastabfactintermasklmtiny.zip TINY | reset | 0.5528 | tapastabfactintermasklmtiny_reset.zip

SQA

Trained from Mask LM, intermediate data.

Size | Reset | Dev Accuracy | Link -------- | --------| -------- | ---- LARGE | noreset | 0.7223 | tapassqaintermasklmlarge.zip LARGE | reset | 0.7289 | tapassqaintermasklmlarge_reset.zip BASE | noreset | 0.6737 | tapassqaintermasklmbase.zip BASE | reset | 0.6874 | tapassqaintermasklmbase_reset.zip MEDIUM | noreset | 0.6464 | tapassqaintermasklmmedium.zip MEDIUM | reset | 0.6561 | tapassqaintermasklmmedium_reset.zip SMALL | noreset | 0.5876 | tapassqaintermasklmsmall.zip SMALL | reset | 0.6155 | tapassqaintermasklmsmall_reset.zip MINI | noreset | 0.4574 | tapassqaintermasklmmini.zip MINI | reset | 0.5148 | tapassqaintermasklmmini_reset.zip TINY | noreset | 0.2004 | tapassqaintermasklmtiny.zip TINY | reset | 0.2375 | tapassqaintermasklmtiny_reset.zip

INTERMEDIATE

Trained from Mask LM.

Size | Reset | Dev Accuracy | Link -------- | --------| -------- | ---- LARGE | noreset | 0.9309 | tapasintermasklm_large.zip LARGE | reset | 0.9317 | tapasintermasklmlargereset.zip BASE | noreset | 0.9134 | tapasintermasklm_base.zip BASE | reset | 0.9163 | tapasintermasklmbasereset.zip MEDIUM | noreset | 0.8988 | tapasintermasklm_medium.zip MEDIUM | reset | 0.9005 | tapasintermasklmmediumreset.zip SMALL | noreset | 0.8788 | tapasintermasklm_small.zip SMALL | reset | 0.8798 | tapasintermasklmsmallreset.zip MINI | noreset | 0.8218 | tapasintermasklm_mini.zip MINI | reset | 0.8333 | tapasintermasklmminireset.zip TINY | noreset | 0.6359 | tapasintermasklm_tiny.zip TINY | reset | 0.6615 | tapasintermasklmtinyreset.zip

Small Models & position index reset (2020/08/08)

Based on the pre-trained checkpoints available at the BERT github page. See the page or the paper for detailed information on the model dimensions.

Reset refers to whether the parameter reset_position_index_per_cell was set to true or false during training. In general it's recommended to set it to true.

The accuracy depends on the respective task. It's denotation accuracy for WTQ and WIKISQL, average position accuracy with gold labels for the previous answers for SQA and Mask-LM accuracy for Mask-LM.

The models were trained in a chain as indicated by the model name. For example, sqa_masklm means the model was first trained on the Mask-LM task and then on SQA. No destillation was performed.

WTQ

Size | Reset | Dev Accuracy | Link -------- | --------| -------- | ---- LARGE | noreset | 0.4822 | tapaswtqwikisqlsqamasklm_large.zip LARGE | reset | 0.4952 | tapaswtqwikisqlsqamasklmlargereset.zip BASE | noreset | 0.4288 | tapaswtqwikisqlsqamasklm_base.zip BASE | reset | 0.4433 | tapaswtqwikisqlsqamasklmbasereset.zip MEDIUM | noreset | 0.4158 | tapaswtqwikisqlsqamasklm_medium.zip MEDIUM | reset | 0.4097 | tapaswtqwikisqlsqamasklmmediumreset.zip SMALL | noreset | 0.3267 | tapaswtqwikisqlsqamasklm_small.zip SMALL | reset | 0.3670 | tapaswtqwikisqlsqamasklmsmallreset.zip MINI | noreset | 0.2275 | tapaswtqwikisqlsqamasklm_mini.zip MINI | reset | 0.2409 | tapaswtqwikisqlsqamasklmminireset.zip TINY | noreset | 0.0901 | tapaswtqwikisqlsqamasklm_tiny.zip TINY | reset | 0.0947 | tapaswtqwikisqlsqamasklmtinyreset.zip

WIKISQL

Size | Reset | Dev Accuracy | Link -------- | --------| -------- | ---- LARGE | noreset | 0.8862 | tapaswikisqlsqamasklmlarge.zip LARGE | reset | 0.8917 | tapaswikisqlsqamasklmlarge_reset.zip BASE | noreset | 0.8772 | tapaswikisqlsqamasklmbase.zip BASE | reset | 0.8809 | tapaswikisqlsqamasklmbase_reset.zip MEDIUM | noreset | 0.8687 | tapaswikisqlsqamasklmmedium.zip MEDIUM | reset | 0.8736 | tapaswikisqlsqamasklmmedium_reset.zip SMALL | noreset | 0.8285 | tapaswikisqlsqamasklmsmall.zip SMALL | reset | 0.8550 | tapaswikisqlsqamasklmsmall_reset.zip MINI | noreset | 0.7672 | tapaswikisqlsqamasklmmini.zip MINI | reset | 0.7944 | tapaswikisqlsqamasklmmini_reset.zip TINY | noreset | 0.3237 | tapaswikisqlsqamasklmtiny.zip TINY | reset | 0.3608 | tapaswikisqlsqamasklmtiny_reset.zip

SQA

Size | Reset | Dev Accuracy | Link -------- | --------| -------- | ---- LARGE | noreset | 0.7002 | tapassqamasklm_large.zip LARGE | reset | 0.7130 | tapassqamasklmlargereset.zip BASE | noreset | 0.6393 | tapassqamasklm_base.zip BASE | reset | 0.6689 | tapassqamasklmbasereset.zip MEDIUM | noreset | 0.6026 | tapassqamasklm_medium.zip MEDIUM | reset | 0.6141 | tapassqamasklmmediumreset.zip SMALL | noreset | 0.4976 | tapassqamasklm_small.zip SMALL | reset | 0.5589 | tapassqamasklmsmallreset.zip MINI | noreset | 0.3779 | tapassqamasklm_mini.zip MINI | reset | 0.3687 | tapassqamasklmminireset.zip TINY | noreset | 0.2013 | tapassqamasklm_tiny.zip TINY | reset | 0.2194 | tapassqamasklmtinyreset.zip

MASKLM

Size | Reset | Dev Accuracy | Link -------- | --------| -------- | ---- LARGE | noreset | 0.7513 | tapasmasklmlarge.zip LARGE | reset | 0.7528 | tapasmasklmlarge_reset.zip BASE | noreset | 0.7323 | tapasmasklmbase.zip BASE | reset | 0.7335 | tapasmasklmbase_reset.zip MEDIUM | noreset | 0.7059 | tapasmasklmmedium.zip MEDIUM | reset | 0.7054 | tapasmasklmmedium_reset.zip SMALL | noreset | 0.6818 | tapasmasklmsmall.zip SMALL | reset | 0.6856 | tapasmasklmsmall_reset.zip MINI | noreset | 0.6382 | tapasmasklmmini.zip MINI | reset | 0.6425 | tapasmasklmmini_reset.zip TINY | noreset | 0.4826 | tapasmasklmtiny.zip TINY | reset | 0.5282 | tapasmasklmtiny_reset.zip

Original Models

The pre-trained TAPAS checkpoints can be downloaded here:

The first two models are pre-trained on the Mask-LM task and the last two on the Mask-LM task first and SQA second.

Fine-Tuning Data

You also need to download the task data for the fine-tuning tasks:

Pre-Training

Note that you can skip pre-training and just use one of the pre-trained checkpoints provided above.

Information about the pre-taining data can be found here.

The TF examples for pre-training can be created using Google Dataflow:

bash python3 setup.py sdist python3 tapas/create_pretrain_examples_main.py \ --input_file="gs://tapas_models/2020_05_11/interactions.txtpb.gz" \ --vocab_file="gs://tapas_models/2020_05_11/vocab.txt" \ --output_dir="gs://your_bucket/output" \ --runner_type="DATAFLOW" \ --gc_project="you-project" \ --gc_region="us-west1" \ --gc_job_name="create-pretrain" \ --gc_staging_location="gs://your_bucket/staging" \ --gc_temp_location="gs://your_bucket/tmp" \ --extra_packages=dist/tapas-0.0.1.dev0.tar.gz

You can also run the pipeline locally but that will take a long time:

bash python3 tapas/create_pretrain_examples_main.py \ --input_file="$data/interactions.txtpb.gz" \ --output_dir="$data/" \ --vocab_file="$data/vocab.txt" \ --runner_type="DIRECT"

This will create two tfrecord files for training and testing. The pre-training can then be started with the command below. The init checkpoint should be a standard BERT checkpoint.

bash python3 tapas/experiments/tapas_pretraining_experiment.py \ --eval_batch_size=32 \ --train_batch_size=512 \ --tpu_iterations_per_loop=5000 \ --num_eval_steps=100 \ --save_checkpoints_steps=5000 \ --num_train_examples=512000000 \ --max_seq_length=128 \ --input_file_train="${data}/train.tfrecord" \ --input_file_eval="${data}/test.tfrecord" \ --init_checkpoint="${tapas_data_dir}/model.ckpt" \ --bert_config_file="${tapas_data_dir}/bert_config.json" \ --model_dir="..." \ --compression_type="" \ --do_train

Where compression_type should be set to GZIP if the tfrecords are compressed. You can start a separate eval job by setting --nodo_train --doeval.

Running a fine-tuning task

We need to create the TF examples before starting the training. For example, for SQA that would look like:

bash python3 tapas/run_task_main.py \ --task="SQA" \ --input_dir="${sqa_data_dir}" \ --output_dir="${output_dir}" \ --bert_vocab_file="${tapas_data_dir}/vocab.txt" \ --mode="create_data"

Optionally, to handle big tables, we can add a --prune_columns flag to apply the HEM method described section 3.3 of our paper to discard some columns based on textual overlap with the sentence.

Afterwards, training can be started by running:

bash python3 tapas/run_task_main.py \ --task="SQA" \ --output_dir="${output_dir}" \ --init_checkpoint="${tapas_data_dir}/model.ckpt" \ --bert_config_file="${tapas_data_dir}/bert_config.json" \ --mode="train" \ --use_tpu

This will use the preset hyper-parameters set in hparam_utils.py.

It's recommended to start a separate eval job to continuously produce predictions for the checkpoints created by the training job. Alternatively, you can run the eval job after training to only get the final results.

bash python3 tapas/run_task_main.py \ --task="SQA" \ --output_dir="${output_dir}" \ --init_checkpoint="${tapas_data_dir}/model.ckpt" \ --bert_config_file="${tapas_data_dir}/bert_config.json" \ --mode="predict_and_evaluate"

Another tool to run experiments is tapas_classifier_experiment.py. It's more flexible than run_task_main.py but also requires setting all the hyper-parameters (via the respective command line flags).

Evaluation

Here we explain some details about different tasks.

SQA

By default, SQA will evaluate using the reference answers of the previous questions. The number in the paper (Table 5) are computed using the more realistic setup where the previous answer are model predictions. run_task_main.py will output additional prediction files for this setup as well if run on GPU.

WTQ

For the official evaluation results one should convert the TAPAS predictions to the WTQ format and run the official evaluation script. This can be done using convert_predictions.py.

WikiSQL

As discussed in the paper our code will compute evaluation metrics that deviate from the official evaluation script (Table 3 and 10).

Hardware Requirements

TAPAS is essentialy a BERT model and thus has the same requirements. This means that training the large model with 512 sequence length will require a TPU. You can use the option max_seq_length to create shorter sequences. This will reduce accuracy but also make the model trainable on GPUs. Another option is to reduce the batch size (train_batch_size), but this will likely also affect accuracy. We added an options gradient_accumulation_steps that allows you to split the gradient over multiple batches. Evaluation with the default test batch size (32) should be possible on GPU.

How to cite TAPAS?

You can cite the ACL 2020 paper and the EMNLP 2020 Findings paper for the laters work on pre-training objectives.

Disclaimer

This is not an official Google product.

Contact information

For help or issues, please submit a GitHub issue.

Owner

  • Name: Google Research
  • Login: google-research
  • Kind: organization
  • Location: Earth

GitHub Events

Total
  • Watch event: 49
  • Fork event: 3
Last Year
  • Watch event: 49
  • Fork event: 3

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 60
  • Total Committers: 11
  • Avg Commits per committer: 5.455
  • Development Distribution Score (DDS): 0.567
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
thomasmueller t****r@g****m 26
eisenjulian e****n@g****m 20
syrinekrichene s****e@g****m 4
muelletm T****m@g****m 3
Chayan Bansal 3****l@u****m 1
Kamal Raj k****7@g****m 1
Language Team n****y@g****m 1
Lysandre Debut l****e@h****o 1
Martin36 m****t@g****m 1
Susmit Vengurlekar s****y@g****m 1
thomasmueller T****r@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 8 months ago

All Time
  • Total issues: 100
  • Total pull requests: 16
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 6 days
  • Total issue authors: 75
  • Total pull request authors: 11
  • Average comments per issue: 2.61
  • Average comments per pull request: 1.38
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 2
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 1.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • NielsRogge (5)
  • apurvak (3)
  • shabbie (3)
  • omrishsu (3)
  • AhmedMasryKU (3)
  • sbhttchryy (3)
  • ManasiPat (2)
  • srirammadduri-ts (2)
  • lairikeqiA (2)
  • joshplasse (2)
  • Facico (2)
  • naserahmadi (2)
  • Maxvgrad (2)
  • ghost (2)
  • sophgit (2)
Pull Request Authors
  • Maxvgrad (8)
  • bharatji30 (2)
  • aniket371 (2)
  • NgKhTr (1)
  • ijonglin (1)
  • susmitpy (1)
  • LysandreJik (1)
  • Martin36 (1)
  • kamalkraj (1)
  • Akshaysharma29 (1)
  • m-i-c-h-ael (1)
Top Labels
Issue Labels
enhancement (1) good first issue (1)
Pull Request Labels
cla: yes (5)

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 38 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 1
    (may contain duplicates)
  • Total versions: 2
  • Total maintainers: 1
proxy.golang.org: github.com/google-research/tapas
  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 6.5%
Average: 6.7%
Dependent repos count: 7.0%
Last synced: 7 months ago
pypi.org: tapas-table-parsing

Tapas: Table-based Question Answering.

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 38 Last month
Rankings
Stargazers count: 2.0%
Forks count: 3.7%
Dependent packages count: 10.1%
Average: 11.4%
Downloads: 19.8%
Dependent repos count: 21.6%
Maintainers (1)
Last synced: 7 months ago

Dependencies

requirements.txt pypi
  • apache-beam ==2.28.0
  • beautifulsoup4 ==4.9.3
  • dataclasses *
  • frozendict ==1.2
  • gensim *
  • html5lib ==1.1
  • kaggle <1.5.8
  • lxml *
  • nltk *
  • pandas *
  • scikit-learn *
  • tensorflow *
  • tensorflow-probability ==0.10.1
  • tf-models-official *
  • tf_slim *
setup.py pypi