GithubHelp home page GithubHelp logo

microsoft / table-pretraining Goto Github PK

View Code? Open in Web Editor NEW
281.0 6.0 40.0 19.94 MB

ICLR 2022 Paper, SOTA Table Pre-training Model, TAPEX: Table Pre-training via Learning a Neural SQL Executor

Home Page: https://table-pretraining.github.io

License: MIT License

Python 100.00%
table-pretraining semantic-parsing fact-verification table-qa

table-pretraining's Introduction

TAPEX: Table Pre-training via Learning a Neural SQL Executor

🤗 transformers support stars FORK Issues

The official repository which contains the code and pre-trained models for our paper TAPEX: Table Pre-training via Learning a Neural SQL Executor.

PWC PWC PWC PWC

🔥 Updates

  • [2022-10-10]: We released the data generator code for SQL execution data synthesis. You can check it out and try to synthesize your own pre-training data.
  • [2022-04-19]: TAPEX is officially supported by 🤗 transformers! Now you can find the example fine-tuning script and the tapex model on the huggingface master branch. Have fun!
  • [2022-03-09]: We have fixed the issue in tapex-large! Now you can view here to see how to fine-tune TAPEX using 🤗 transformers and 🤗 datasets! They will be merged into the main library soon!
  • [2022-02-20]: Our paper is accepted by ICLR 2022! We also provided a fine-tuning script based on 🤗 transformers, which is not merged now. You can see the preview version here. ⚠️ It is worth noting that tapex-large is not well-prepared now. We found there is a strange bug in bart-large, which also affects tapex-large. Hope it is solved in the near future.
  • [2021-10-25]: We released the code for Table Pre-training. You can check it out and try pre-training on your data!
  • [2021-10-01]: We released the code for TableFT and the fine-tuned model weights on TabFact!
  • [2021-08-28]: We released the fine-tuned model weights on WikiSQL, SQA and WikiTableQuestions!
  • [2021-08-27]: We released the code, the pre-training corpus, and the pre-trained TAPEX model weights. Thanks for your patience!
  • [2021-07-16]: We released our paper and home page. Check it out!

🏴󠁶󠁵󠁭󠁡󠁰󠁿 Overview

In the paper, we present TAPEX (for Table Pre-training via Execution), a conceptually simple and empirically powerful pre-training approach to empower existing generative pre-trained models (e.g., BART in our paper) with table reasoning skills. TAPEX realizes table pre-training by learning a neural SQL executor over a synthetic corpus, which is obtained by automatically synthesizing executable SQL queries.

Fig 1. The schematic illustration of TAPEX. Tables not shown for brevity.

The central point of TAPEX is to train a model to mimic the SQL query execution process over a table. We believe that if a model can be trained to faithfully execute SQL queries, then it must have a deep understanding of table structures and possess an inductive bias towards table structures.

Meanwhile, since the diversity of SQL queries can be guaranteed systemically, and thus a diverse and high-quality pre-training corpus can be automatically synthesized for TAPEX.

Project

This project contains two parts, tapex library and examples to employ it on different table-related applications (e.g., Table Question Answering).

  • For tapex, there is an overview:
|-- common
    |-- dbengine.py # the database engine to return answer for a SQL query
    |-- download.py # download helper for automatic resource
|-- data_utils
    |-- wikisql
        |-- executor.py # the re-implementation of WikiSQL style SQL execution to obtain ground-truth answers in the dataset
    |-- format_converter.py # convert dataset formats into HuggingFace style
    |-- preprocess_binary.py # wrapper for the fairseq preprocess script
    |-- preprocess_bpe.py # wrapper for the BPE preprocess
|-- processor
    |-- table_linearize.py # the class to flatten a table into a linearized form, which should keep consistent during pre-training, fine-tuning and evaluating
    |-- table_truncate.py # the class to truncate a long table into a shorter version to satisfy model's input length limit (e.g., BART can accept at most 1024 tokens)
    |-- table_processor.py # the wrapper for the above two table utility function classes
|-- model_eval.py # evaluate the denotation accuracy of model
|-- model_interface.py # wrap a model interface for interaction based on HubInterface
  • For examples, please refer to here for more details.

⚡️ Quickstart

Prepare Environment

First, you should set up a python environment. This code base has been tested under python 3.x, and we officially support python 3.8.

After installing python 3.8, we strongly recommend you to use virtualenv (a tool to create isolated Python environments) to manage the python environment. You could use following commands to create an environment venv and activate it.

$ python3.8 -m venv venv
$ source venv/bin/activate

Install TAPEX

The main requirements of our code base is fairseq, which may be difficult for beginners to get started in an hour.

However, do not worry, we already wrap all necessary commands for developers. In other words, you do not need to study fairseq to start your journey about TAPEX! You can simply run the following command (in the virtual environment) to use TAPEX:

$ pip install --editable ./

The argument --editable is important for your potential follow-up modification on the tapex library. The command will not only install dependencies, but also install tapex as a library, which can be imported easily.

Use TAPEX

Once tapex is successfully installed, you could go into examples to enjoy fine-tuning TAPEX models and using them on different applications!

🏰 Resource

Pre-training Corpus

Our synthetic pre-training corpus which includes nearly 5,000,000 tuples of (SQL queries, flattened tables, SQL execution results) can be downloaded from here. You can use it for research purpose, but you should be careful about the data license.

Below is an example from the pre-training corpus:

  • The SQL plus flattened Table as INPUT:
select ( select number where number = 4 ) - ( select number where number = 3 ) col : number | date | name | age (at execution) | age (at offense) | race | state | method row 1 : 1 | november 2, 1984 | velma margie barfield | 52 | 45 | white | north carolina | lethal injection row 2 : 2 | february 3, 1998 | karla faye tucker | 38 | 23 | white | texas | lethal injection row 3 : 3 | march 30, 1998 | judias v. buenoano | 54 | 28 | white | florida | electrocution row 4 : 4 | february 24, 2000 | betty lou beets | 62 | 46 | white | texas | lethal injection row 5 : 5 | may 2, 2000 | christina marie riggs | 28 | 26 | white | arkansas | lethal injection row 6 : 6 | january 11, 2001 | wanda jean allen | 41 | 29 | black | oklahoma | lethal injection row 7 : 7 | may 1, 2001 | marilyn kay plantz | 40 | 27 | white | oklahoma | lethal injection row 8 : 8 | december 4, 2001 | lois nadean smith | 61 | 41 | white | oklahoma | lethal injection row 9 : 9 | may 10, 2002 | lynda lyon block | 54 | 45 | white | alabama | electrocution row 10 : 10 | october 9, 2002 | aileen carol wuornos | 46 | 33 | white | florida | lethal injection row 11 : 11 | september 14, 2005 | frances elaine newton | 40 | 21 | black | texas | lethal injection row 12 : 12 | september 23, 2010 | teresa wilson bean lewis | 41 | 33 | white | virginia | lethal injection row 13 : 13 | june 26, 2013 | kimberly lagayle mccarthy | 52 | 36 | black | texas | lethal injection row 14 : 14 | february 5, 2014 | suzanne margaret basso | 59 | 44 | white | texas | lethal injection
  • The SQL Execution Result as OUTPUT:
1.0

Here we want to acknowledge the huge effort of paper On the Potential of Lexico-logical Alignments for Semantic Parsing to SQL Queries, which provides the rich resources of SQL templates for us to synthesize the pre-training corpus. If you are interested, please give a STAR to their repo.

Pre-trained models

The pre-trained models trained on the above pre-training corpus.

Model Description # Params Download
tapex.base 6 encoder and decoder layers 140M tapex.base.tar.gz
tapex.large 12 encoder and decoder layers 400M tapex.large.tar.gz

Fine-tuned Models

We provide fine-tuned model weights and their performance on different datasets below. The following Accuracy (Acc) refers to denotation accuracy computed by our script model_eval.py. Meanwhile, it is worth noting that we need truncating long tables during preprocessing with some randomness. Therefore, we also provide preprocessed datasets for reproducing our experimental results.

Model Dev Acc Test Acc Dataset Download Data Download Model
tapex.large.wtq 58.0 57.2 WikiTableQuestions wtq.preprocessed.zip tapex.large.wtq.tar.gz
tapex.large.sqa 70.7 74.0 SQA sqa.preprocessed.zip tapex.large.sqa.tar.gz
tapex.large.wikisql 89.3 89.2 WikiSQL wikisql.preprocessed.zip tapex.large.wikisql.tar.gz
tapex.large.tabfact 84.2 84.0 TabFact tabfact.preprocessed.zip tapex.large.tabfact.tar.gz

Given these fine-tuned model weights, you can play with them using the predict mode in examples/tableqa/run_model.py.

For example, you can use the following command and see its log:

$ python examples/tableqa/run_model.py predict --resource-dir ./tapex.large.wtq --checkpoint-name model.pt
2021-08-29 17:39:47 | INFO | __main__ | Receive question as : Greece held its last Summer Olympics in which year?
2021-08-29 17:39:47 | INFO | __main__ | The answer should be : 2004

🤗 Run TAPEX using Huggingface

First, you should run the following commands to install the latest lib developed for TAPEX.

pip install datasets
pip install transformers

Then, you could find the detailed tutorial on how to reproduce our results on benchmarks at here.

🐣 Synthesize your own pre-training data

Go to this folder and install the requirements using the provided file:

$ pip install -r requirements.txt

Then directly run the script main.py! By default, you will obtain a file with nearly 5 million examples consisting of (SQL query, Table, Answer) and the flattened fairseq input and output. More details can be found in the argument parser as below:

  --template_file TEMPLATE_FILE
                        SQL query file which provides the template for synthesizing more SQL queries
  --mode {train,dev}    train or dev for pre-training
  --dev_id_file DEV_ID_FILE
                        the dev id file to avoid potential data leakage
  --instance_number INSTANCE_NUMBER
                        the expected instance number corresponding to each template
  --max_source_length MAX_SOURCE_LENGTH
                        the maximum length for the flattened table plus input SQL query

💬 Citation

If our work is useful for you, please consider citing our paper:

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

❓ Frequently Asked Questions

1. AttributeError: 'NoneType' object has no attribute 'bpe'

You should firstly check the version of fairseq, which should be equal or greater than 0.12.0 when you use pip list to show it.

👍 Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

📝 License

Please note that there are TWO LICENSES for code and pre-training corpus. The code and pre-trained models are open-sourced under MIT License, while the pre-training corpus is released under CC BY-SA 4.0.

™️ Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

table-pretraining's People

Contributors

codingqinghao avatar dragove avatar microsoftopensource avatar siviltaram avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

table-pretraining's Issues

A small question about table structure

hi, I have a small question, for a new table, how do you know whether the first row or first column or both of them are headers. Do you suppose that we should use a standard table with the first row as headers? Since it may affect the representation of the table. thx!

tapex.base model performance poorly with "run_model.py predict"

Hello,

I follow the instruction and trained a tapex.base model on wikisql dataset. The "run_model.py eval" reports Denotation Accuracy : 0.879. However when I use ''run_model.py predict" command to perform online prediction, the result is very poor. Is there any thing I can try to sovle this problem?

Thanks

Nian

aggregate operator in model_interface.py

Hi,
Thank you for providing the code. I have tried the sample interface provided for online prediction and it worked.
Question: currently, I don't know how the model will return the aggregate operator. For example:

For following example, the wikisql data has aggregator function like AVG. How is this returned by model?

 question = "What is the average Nations? " <-- The model should return AVG(14,24,12,201,204,204) 
    table_context = {
        "header": ["Year", "City", "Country", "Nations"],
        "rows": [
            [1896, "Athens", "Greece", 14],
            [1900, "Paris", "France", 24],
            [1904, "St. Louis", "USA", 12],
            [2004, "Athens", "Greece", 201],
            [2008, "Beijing", "China", 204],
            [2012, "London", "UK", 204]
        ]
    }

Tapex performance on large tables

Hello team, I've csv files with more than 30K rows and 10 columns. I am in need of your help to understand what is the best way to approach this problem since the table is too large. Is Tapex able to handle large tables or there are work around that I can adapt?

The first thought that comes into my mind is splitting the huge table into multiple sub-tables(meaning column names will remain the same) and then perform inference on it. The predictions further can be aggregated for final results.
Could you please share your expertise on this problem. In general, how are the large tableQA performed, please suggest.

Additionally, can we list/view the corresponding SQL queries of predicted answers?

I get a bug when I use the fine-tuned model to predict.

I download the fine-tuned model and dataset, such as tapex.large.wtq and wtq.preprocess. And I run python examples/tableqa/run_model.py predict --resource-dir ./tapex.large.wtq --checkpoint-name model.pt. Then I get the following bug:

Traceback (most recent call last):
  File "/data2/huchaowen/Table-Pretraining/examples/tableqa/run_model.py", line 181, in <module>
    predict_demo(args)
  File "/data2/huchaowen/Table-Pretraining/examples/tableqa/run_model.py", line 161, in predict_demo
    answer = demo_interface.predict(question=question,
  File "/data2/huchaowen/Table-Pretraining/tapex/model_interface.py", line 34, in predict
    model_output = self.model.translate(
  File "/data2/huchaowen/anaconda3/envs/tapex/lib/python3.8/site-packages/fairseq/hub_utils.py", line 124, in translate
    return self.sample(sentences, beam, verbose, **kwargs)
  File "/data2/huchaowen/anaconda3/envs/tapex/lib/python3.8/site-packages/fairseq/hub_utils.py", line 132, in sample
    batched_hypos = self.generate(tokenized_sentences, beam, verbose, **kwargs)
  File "/data2/huchaowen/anaconda3/envs/tapex/lib/python3.8/site-packages/fairseq/models/bart/hub_interface.py", line 107, in generate
    results = super().generate(
  File "/data2/huchaowen/anaconda3/envs/tapex/lib/python3.8/site-packages/fairseq/hub_utils.py", line 189, in generate
    translations = self.task.inference_step(
  File "/data2/huchaowen/anaconda3/envs/tapex/lib/python3.8/site-packages/fairseq/tasks/fairseq_task.py", line 540, in inference_step
    return generator.generate(
  File "/data2/huchaowen/anaconda3/envs/tapex/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "/data2/huchaowen/anaconda3/envs/tapex/lib/python3.8/site-packages/fairseq/sequence_generator.py", line 204, in generate
    return self._generate(sample, **kwargs)
  File "/data2/huchaowen/anaconda3/envs/tapex/lib/python3.8/site-packages/fairseq/sequence_generator.py", line 274, in _generate
    encoder_outs = self.model.forward_encoder(net_input)
  File "/data2/huchaowen/anaconda3/envs/tapex/lib/python3.8/site-packages/fairseq/sequence_generator.py", line 801, in forward_encoder
    return [model.encoder.forward_torchscript(net_input) for model in self.models]
  File "/data2/huchaowen/anaconda3/envs/tapex/lib/python3.8/site-packages/fairseq/sequence_generator.py", line 801, in <listcomp>
    return [model.encoder.forward_torchscript(net_input) for model in self.models]
  File "/data2/huchaowen/anaconda3/envs/tapex/lib/python3.8/site-packages/fairseq/models/fairseq_encoder.py", line 55, in forward_torchscript
    return self.forward_non_torchscript(net_input)
  File "/data2/huchaowen/anaconda3/envs/tapex/lib/python3.8/site-packages/fairseq/models/fairseq_encoder.py", line 62, in forward_non_torchscript
    return self.forward(**encoder_input)
  File "/data2/huchaowen/anaconda3/envs/tapex/lib/python3.8/site-packages/fairseq/models/transformer/transformer_encoder.py", line 165, in forward
    return self.forward_scriptable(
  File "/data2/huchaowen/anaconda3/envs/tapex/lib/python3.8/site-packages/fairseq/models/transformer/transformer_encoder.py", line 294, in forward_scriptable
    lr = layer(x, encoder_padding_mask=encoder_padding_mask_out)
  File "/data2/huchaowen/anaconda3/envs/tapex/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "/data2/huchaowen/anaconda3/envs/tapex/lib/python3.8/site-packages/fairseq/modules/transformer_layer.py", line 351, in forward
    x, _ = self.self_attn(
  File "/data2/huchaowen/anaconda3/envs/tapex/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "/data2/huchaowen/anaconda3/envs/tapex/lib/python3.8/site-packages/fairseq/modules/multihead_attention.py", line 538, in forward
    return F.multi_head_attention_forward(
  File "/data2/huchaowen/anaconda3/envs/tapex/lib/python3.8/site-packages/torch/nn/functional.py", line 5160, in multi_head_attention_forward
    attn_output_weights = torch.bmm(q_scaled, k.transpose(-2, -1))
RuntimeError: CUDA error: CUBLAS_STATUS_INVALID_VALUE when calling `cublasSgemmStridedBatched( handle, opa, opb, m, n, k, &alpha, a, lda, stridea, b, ldb, strideb, &beta, c, ldc, stridec, num_batches)`

fairseq==0.12.2, transformers==4.24.0

Label Encoding for fact verifacation over TabFact

The Trained Tapex large model (especially availaible at Huggingface) has 0 label corresponding to Entailed class or 0 label corresponding to Refute class?
As by default, the TabFact when loaded through huggingface dataset has 0 corresponding to Refute class.
Please tell us this.

Question about cell truncation and answer truncation

Hi, thank you for the nicely written repo and the nice work!

I am reading through the part on table truncation and have a question about how cell and answer truncations are performed for long cells. Specifically, you have:

My question is that for an answer that may come from a very long cell, if I understand correctly, the cell might already be truncated, yet the answer still remains the original length, right? This may not be an issue for testing/inference, but may be an issue during training, because in this case we are asking the model to generate things that do not exist in the input (because some tokens were truncated).

Is this a known limitation, or am I missing something? If it is a known limitation, is there an easy way I can remedy this using this codebase? Thanks for your time.

Adding TAPEX to HuggingFace Transformers

Hi!

First of all, congratulations on the great paper and results! If you need any help regarding converting the models to the HuggingFace API, let me know. My very first contribution to HuggingFace Transformers was actually TAPAS, the table question answering model from Google. We also create a subsequent table-question answering task on the hub, as well as an inference widget which let's users directly try out TAPAS in the browser.

We could do the same for TAPEX! TAPEX also looks way simpler as it's a generative model. The only thing required would be to write a conversion script (which I can help you with).

Also, are you interested in joining the Microsoft organization on the hub?

Btw, the README is also very comprehensive and well written. Wish more authors did that ;)

Kind regards,

Niels
ML Engineer @ HuggingFace

pip install --editable ./

How to solve 'ERROR: No matching distribution found for fairseq (unavailable)' when I pip install --editable ./

Computation of accuracy over WikiTableQuestions dataset

Hey, just wanted to clarify whether the model for the task of table question answering on the WikiTableQuestions dataset was trained in a generative way or was is span-based.

If it is trained in a generative manner, then how is the accuracy computed?

Thanks.

How to not encode the entire dataset each time ?

On huggingface, each time the entire table is being encoded for every query.

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 = "select year where city = beijing"
encoding = tokenizer(table=table, query=query, return_tensors="pt")

How to encode the dataset only once and then query against it multiple times ?

pretrain dataset error

Hi,

I meet a problem when I want to pretrain a model via your introduction. Error stacks are as follows.

File "/home/user/anaconda3/envs/tapex/lib/python3.8/site-packages/fairseq/tasks/translation.py", line 156, in load_langpair_dataset return LanguagePairDataset( File "/home/user/anaconda3/envs/tapex/lib/python3.8/site-packages/fairseq/data/language_pair_dataset.py", line 232, in __init__ assert len(src) == len( AssertionError: Source and target must contain the same number of examples

I check the preprocess log, and preprocess log is as follows.

Namespace(align_suffix=None, alignfile=None, all_gather_list_size=16384, amp=False, amp_batch_retries=2, amp_init_scale=128, amp_scale_window=None, azureml_logging=False, bf16=False, bpe=None, cpu=False, criterion='cross_entropy', dataset_impl='mmap', destdir='dataset/pretrain/bart.base/bin', dict_only=False, empty_cache_freq=0, fp16=False, fp16_init_scale=128, fp16_no_flatten_grads=False, fp16_scale_tolerance=0.0, fp16_scale_window=None, joined_dictionary=False, log_file=None, log_format=None, log_interval=100, lr_scheduler='fixed', memory_efficient_bf16=False, memory_efficient_fp16=False, min_loss_scale=0.0001, model_parallel_size=1, no_progress_bar=False, nwordssrc=-1, nwordstgt=-1, on_cpu_convert_precision=False, only_source=False, optimizer=None, padding_factor=8, plasma_path='/tmp/plasma', profile=False, quantization_config_path=None, reset_logging=False, scoring='bleu', seed=1, source_lang='src', srcdict='bart.base/dict.src.txt', suppress_crashes=False, target_lang='tgt', task='translation', tensorboard_logdir=None, testpref=None, tgtdict='bart.base/dict.tgt.txt', threshold_loss_scale=None, thresholdsrc=0, thresholdtgt=0, tokenizer=None, tpu=False, trainpref='dataset/pretrain/train.bpe', use_plasma_view=False, user_dir=None, validpref='dataset/pretrain/valid.bpe', wandb_project=None, workers=1) [src] Dictionary: 51200 types [src] dataset/pretrain/train.bpe.src: 4949629 sents, 2195465273 tokens, 0.0% replaced by <unk> [src] Dictionary: 51200 types [src] dataset/pretrain/valid.bpe.src: 20000 sents, 8907694 tokens, 0.0% replaced by <unk> [tgt] Dictionary: 51200 types [tgt] dataset/pretrain/train.bpe.tgt: 4946227 sents, 31818856 tokens, 0.0% replaced by <unk> [tgt] Dictionary: 51200 types [tgt] dataset/pretrain/valid.bpe.tgt: 19987 sents, 127668 tokens, 0.0% replaced by <unk> Wrote preprocessed data to dataset/pretrain/bart.base/bin

The difference between train and valid bpe dataset is due to [num_filtered_EMPTY] filtered when preprocessing dataset. So I am not sure if it is right.
I successfully finish process_pretrain_data step, and some problems occur when I run the script run_model.py in tapex/examples/pretrain/ folder.

Could your please tell me which step is wrong?

load pretrained model errors

Dear authors,
Thanks for contributing to the development of table pretraining and release the code.

When I try to reimplement the code of github,I get a problem of "AttributeError: 'NoneType' object has no attribute 'bpe'". It seems the load_checkpoint_to_cpu return a NoneType when loading the pretrained model.pt.
Because state = load_checkpoint_to_cpu(filename, arg_overrides) missing the key "args".

Could you give any advice?

fairseq version does not exist

fairseq@git+git://github.com/pytorch/fairseq@801a64683164680562c77b688d9ca77fc3e0cea7 seems to be not existing, could you update another version that is compatible to the code? Thanks a lot!

Getting started with TAPEX for inference (handling a sum)

Hello and thank you for TAPEX.

I am pretty new to the world of table answering and transformers and am looking for some general thoughts.

When using the pretrained model (tapex-large-finetuned-wikisql) TAPEX returns an incorrect sum.

It is entirely likely that I need to fine tune the model, or perhaps it was not designed to answer these types of questions.

Are you able to help me understand, generally, why this might be the case?

Any insights would be much appreciated 🙌.

HuggingFace widget:

Python example from docs

from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("microsoft/tapex-large-finetuned-wtq")
model = AutoModelForSeq2SeqLM.from_pretrained("microsoft/tapex-large-finetuned-wtq")

data={'Repository': ['Transformers', 'Datasets', 'Tokenizers'],
      'Stars': ['36542', '4512', '3934'],
      'Contributors': ['651', '77', '34'],
      'Programming language': ['Python', 'Rust', 'NodeJS']
}

table = pd.DataFrame.from_dict(data)

query='what is the sum of stars for the Datasets and Tokenizers repositories?'

encoding = tokenizer(table=table, query=query, return_tensors="pt")

outputs = model.generate(**encoding)

print(tokenizer.batch_decode(outputs, skip_special_tokens=True))

Output:

[' 6338']

Expected output:

[' 8446']

GPU memory usage about this model

Hi, I used 3090 to infer this model(hugging face version) on tabFact now(using test_examples.json file), and I found that my CUDA was out of memory(24G) for both batch inference and single inference. Could you please tell me how much memory I need to fine-tune this model so that I can apply for more instances? Thank you in advance!

get "samples have invalid sizes and will be skipped, max_positions=(512, 512)" when training

First, thanks for your great job.
I get
WARNING | fairseq.tasks.fairseq_task | 6,694 samples have invalid sizes and will be skipped, max_positions=(512, 512), first few sample ids=[11595, 7191, 8792, 9399, 5120, 1831, 8568, 3430, 597, 11937]
and the same WARNING for the train set when I train a bart-large model with the default parameters, it looks like the model skip many examples because the max_positions=(512, 512),
How can I solve this warning? Thanks.

Error preprocessing data for TabFact

Hi, thank you for sharing your code! I am trying to run your trained model tapex.large on TabFact's test set, and I am pre-processing the file test.jsonl for that. When I run the file python process_tabfact_data.py to do this pre-processing, I get the following error:

FileNotFoundError: [Errno 2] No such file or directory: 'tapex.large/dict.src.txt'

I downloaded your preprocessed data from this link (https://github.com/microsoft/Table-Pretraining/releases/download/preprocessed-data/tabfact.preprocessed.zip) but I did not find this file tapex.large/dict.src.txt anywhere.

Could you please help me solve this? Thank you very much!

What‘s the training corpus of single GETAR?

Hi, thanks for your sharing~
Your pretext task designing is very ingenious! But I'm confused about the training corpus' difference between GETAR and GETAR+TAPEX.
In this paper, the accuracy of the single GETAR on TabFact is 80.8%. Is it obtained by directly fine-tuning BART on TabFact? If so, why could BART achieve such competitive performance with TAPAS(81%, pre-train on 3.7M tables), since BART isn't typical for table understanding?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.