PICARD - Parsing Incrementally for Constrained Auto-Regressive Decoding from Language Models

Related tags

Deep Learning picard
Overview


make it parse

build license

This is the official implementation of the following paper:

Torsten Scholak, Nathan Schucher, Dzmitry Bahdanau. PICARD - Parsing Incrementally for Constrained Auto-Regressive Decoding from Language Models. Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing (EMNLP).

If you use this code, please cite:

@inproceedings{Scholak2021:PICARD,
  author = {Torsten Scholak and Nathan Schucher and Dzmitry Bahdanau},
  title = {PICARD - Parsing Incrementally for Constrained Auto-Regressive Decoding from Language Models},
  booktitle = {Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing},
  year = {2021},
  publisher = {Association for Computational Linguistics},
}

Overview

This code implements:

  • The PICARD algorithm for constrained decoding from language models.
  • A text-to-SQL semantic parser based on pre-trained sequence-to-sequence models and PICARD achieving state-of-the-art performance on both the Spider and the CoSQL datasets.

About PICARD

TL;DR: We introduce PICARD -- a new method for simple and effective constrained decoding from large pre-trained language models. On the challenging Spider and CoSQL text-to-SQL datasets, PICARD significantly improves the performance of fine-tuned but otherwise unmodified T5 models. Using PICARD, our T5-3B models achieved state-of-the-art performance on both Spider and CoSQL.

In text-to-SQL translation, the goal is to translate a natural language question into a SQL query. There are two main challenges to this task:

  1. The generated SQL needs to be semantically correct, that is, correctly reflect the meaning of the question.
  2. The SQL also needs to be valid, that is, it must not result in an execution error.

So far, there has been a trade-off between these two goals: The second problem can be solved by using a special decoder architecture that -- by construction -- always produces valid SQL. This is the approach taken by most prior work. Those decoders are called "constrained decoders", and they need to be trained from scratch on the text-to-SQL dataset. However, this limits the generality of the decoders, which is a problem for the first goal.

A better approach would be to use a pre-trained encoder-decoder model and to constrain its decoder to produce valid SQL after fine-tuning the model on the text-to-SQL task. This is the approach taken by the PICARD algorithm.

How is PICARD different from existing constrained decoders?

  • It’s an incremental parsing algorithm that integrates with ordinary beam search.
  • It doesn’t require any training.
  • It doesn’t require modifying the model.
  • It works with any model that generates a sequence of tokens (including language models).
  • It doesn’t require a special vocabulary.
  • It works with character-, sub-word-, and word-level language models.

How does PICARD work?

The following picture shows how PICARD is integrated with beam search.



Decoding starts from the left and proceeds to the right. The algorithm begins with a single token (usually <s>), and then keeps expanding the beam with hypotheses generated token-by-token by the decoder. At each decoding step and for each hypothesis, PICARD checks whether the next top-k tokens are valid. In the image above, only 3 token predictions are shown, and k is set to 2. Valid tokens () are added to the beam. Invalid ones (☒) are discarded. The k+1-th, k+2-th, ... tokens are discarded, too. Like in normal beam search, the beam is pruned to contain only the top-n hypotheses. n is the beam size, and in the image above it is set to 2 as well. Hypotheses that are terminated with the end-of-sentence token (usually </s>) are not expanded further. The algorithm stops when the all hypotheses are terminated or when the maximum number of tokens has been reached.

How does PICARD know whether a token is valid?

In PICARD, checking, accepting, and rejecting of tokens and token sequences is achieved through parsing. Parsing means that we attempt to assemble a data structure from the tokens that are currently in the beam or are about to be added to it. This data structure (and the parsing rules that are used to build it) encode the constraints we want to enforce.

In the case of SQL, the data structure we parse to is the abstract syntax tree (AST) of the SQL query. The parsing rules are defined in a computer program called a parser. Database engines, such as PostgreSQL, MySQL, and SQLite, have their own built-in parser that they use internally to process SQL queries. For Spider and CoSQL, we have implemented a parser that supports a subset of the SQLite syntax and that checks additional constraints on the AST. In our implementation, the parsing rules are made up from simpler rules and primitives that are provided by a third-party parsing library.

PICARD uses a parsing library called attoparsec that supports incremental input. This is a special capability that is not available in many other parsing libraries. You can feed attoparsec a string that represents only part of the expected input to parse. When parsing reaches the end of an input fragment, attoparsec will return a continuation function that can be used to continue parsing. Think of the continuation function as a suspended computation that can be resumed later. Input fragments can be parsed one after the other when they become available until the input is complete.

Herein lies the key to PICARD: Incremental parsing of input fragments is exactly what we need to check tokens one by one during decoding.

In PICARD, parsing is initialized with an empty string, and attoparsec will return the first continuation function. We then call that continuation function with all the token predictions we want to check in the first decoding step. For those tokens that are valid, the continuation function will return a new continuation function that we can use to continue parsing in the next decoding step. For those tokens that are invalid, the continuation function will return a failure value which cannot be used to continue parsing. Such failures are discarded and never end up in the beam. We repeat the process until the end of the input is reached. The input is complete once the model predicts the end-of-sentence token. When that happens, we finalize the parsing by calling the continuation function with an empty string. If the parsing is successful, it will return the final AST. If not, it will return a failure value.

The parsing rules are described at a high level in the PICARD paper. For details, see the PICARD code, specifically the Language.SQL.SpiderSQL.Parse module.

How well does PICARD work?

Let's look at the numbers:

On Spider

URL Exact-set Match Accuracy Execution Accuracy
Dev Test Dev Test
tscholak/cxmefzzi w PICARD 75.5 % 71.9 % 79.3 % 75.1 %
tscholak/cxmefzzi w/o PICARD 71.5 % 68.0 % 74.4 % 70.1 %

Click on the links to download the model.

On CoSQL Dialogue State Tracking

URL Question Match Accuracy Interaction Match Accuracy
Dev Test Dev Test
tscholak/2e826ioa w PICARD 56.9 % 54.6 % 24.2 % 23.7 %
tscholak/2e826ioa w/o PICARD 53.8 % 51.4 % 21.8 % 21.7 %

Click on the links to download the model.

Quick Start

Prerequisites

This repository uses git submodules. Clone it like this:

$ git clone [email protected]:ElementAI/picard.git
$ cd picard
$ git submodule update --init --recursive

Training

The training script is located in seq2seq/run_seq2seq.py. You can run it with:

$ make train

The model will be trained on the Spider dataset by default. You can also train on CoSQL by running make train-cosql.

The training script will create the directory train in the current directory. Training artifacts like checkpoints will be stored in this directory.

The default configuration is stored in configs/train.json. The settings are optimized for a GPU with 40GB of memory.

These training settings should result in a model with at least 71% exact-set-match accuracy on the Spider development set. With PICARD, the accuracy should go up to at least 75%.

We have uploaded a model trained on the Spider dataset to the huggingface model hub, tscholak/cxmefzzi. A model trained on the CoSQL dialog state tracking dataset is available, too, tscholak/2e826ioa.

Evaluation

The evaluation script is located in seq2seq/run_seq2seq.py. You can run it with:

$ make eval

By default, the evaluation will be run on the Spider evaluation set. Evaluation on the CoSQL evaluation set can be run with make eval-cosql.

The evaluation script will create the directory eval in the current directory. The evaluation results will be stored there.

The default configuration is stored in configs/eval.json.

Docker

There are three docker images that can be used to run the code:

  • tscholak/text-to-sql-dev: Base image with development dependencies. Use this for development. Pull it with make pull-dev-image from the docker hub. Rebuild the image with make build-dev-image.
  • tsscholak/text-to-sql-train: Training image with development dependencies but without Picard dependencies. Use this for fine-tuning a model. Pull it with make pull-train-image from the docker hub. Rebuild the image with make build-train-image.
  • tscholak/text-to-sql-eval: Training/evaluation image with all dependencies. Use this for evaluating a fine-tuned model with Picard. This image can also be used for training if you want to run evaluation during training with Picard. Pull it with make pull-eval-image from the docker hub. Rebuild the image with make build-eval-image.

All images are tagged with the current commit hash. The images are built with the buildx tool which is available in the latest docker-ce. Use make init-buildkit to initialize the buildx tool on your machine. You can then use make build-dev-image, make build-train-image, etc. to rebuild the images. Local changes to the code will not be reflected in the docker images unless they are committed to git.

Comments
  • Training PICARD on different dataset

    Training PICARD on different dataset

    I'd like to train PICARD on a dataset other than Spider or CoSQL - what's the most straightforward way to do that? I'm guessing I need to make an equivalent to spider.py for my data - is there anything else that would need to be done?

    question 
    opened by majorminus66 24
  • Using the provided eval code on different dataset

    Using the provided eval code on different dataset

    Hey,

    I have tried running "make eval" and was able to retrieve numbers on Spider-Dev.

    Now, I would like to use the provided T5+PICARD for evaluation on other datasets like Spider-DK or Spider-realistic. Is there an easy and convenient way to use these dataset for eval only---for e.g., as a command-line arguments?

    Thanks

    enhancement help wanted 
    opened by salokr 20
  • Run prediction is so slow.

    Run prediction is so slow.

    Does the prediction_output only process one example every time?This speed is too slow, and I wonder to know if you run on codalab, the time it will spend? I run on my own machine and it shows that it will use 6 hours to prediction. Is there a good way to speed it up, especially on codalab platform?

    Thanks

    bug 
    opened by JiexingQi 13
  • Issue with loading dataset

    Issue with loading dataset

    After cloning the package, when I run make train I get an error. Following is the trace:

    Downloading and preparing dataset spider/spider to /transformers_cache/spider/spider/1.0.0/3c571ccbabdc104a8d1f14edff4ce10d09d7724b0c3665fc42bec1ed51c84bf3... Traceback (most recent call last): File "seq2seq/run_seq2seq.py", line 270, in main() File "seq2seq/run_seq2seq.py", line 148, in main tokenizer=tokenizer, File "/app/seq2seq/utils/dataset_loader.py", line 89, in load_dataset dataset_dict=_spider_dataset_dict(), File "/app/seq2seq/utils/dataset_loader.py", line 45, in path=data_args.dataset_paths["spider"], cache_dir=model_args.cache_dir File "/opt/conda/lib/python3.7/site-packages/datasets/load.py", line 1699, in load_dataset use_auth_token=use_auth_token, File "/opt/conda/lib/python3.7/site-packages/datasets/builder.py", line 596, in download_and_prepare dl_manager=dl_manager, verify_infos=verify_infos, **download_and_prepare_kwargs File "/opt/conda/lib/python3.7/site-packages/datasets/builder.py", line 690, in _download_and_prepare ) from None OSError: Cannot find data file. Original error: [Errno 20] Not a directory: '/transformers_cache/downloads/2328a961663d7b95ae1aa7a8f378034cc12f525cf9ce537792e7b0856332da67/spider/train_spider.json'

    Do I need to do any extra processing to get Spider dataset?

    bug 
    opened by PramuPerera 12
  • Executing 'make train'

    Executing 'make train'

    Hi, I have been working on text2sql project and after cloning the git repo I went to the step 'make train' but I am unable to execute it. The result of my execution is as follows: make: *** No rule to make target 'train'. Stop. There is a possibility that I might be doing the execution wrong. Kindly help me with the same.

    question 
    opened by surajjkumar 12
  • using trained model

    using trained model "tscholak/3vnuv1vf" hugging Face

    hello , thanks for your effort I wanna ask is there anyway to use the trained model "tscholak/3vnuv1vf" on hugging Face Using the default way that be used there. I tried to download the trained model but there is an issue in unpacking tokenizer in model ( 'list' object has no attribute 'size') for ( input_ids.size()), or i must follow seq2seq/serve_seq2seq.py ?

    question 
    opened by kirollosHossam 11
  • Training fault

    Training fault

    When I run the following command to start training:

    python -m torch.distributed.launch --nnodes=1 --nproc_per_node=8 run_seq2seq.py configs/train.json
    

    It comes to the following fault: RuntimeError: Expected to mark a variable ready only once. This error is caused by one of the following reasons: 1) Use of a module parameter outside the forward function. Please make sure model parameters are not shared across multiple concurrent forward-backward passes. or try to use _set_static_graph() as a workaround if this module graph does not change during training loop.2) Reused parameters in multiple reentrant backward passes. For example, if you use multiple checkpoint functions to wrap the same part of your model, it would result in the same set of parameters been used by different reentrant backward passes multiple times, and hence marking a variable ready multiple times. DDP does not support such use cases in default. You can try to use _set_static_graph() as a workaround if your module graph does not change over iterations.

    Have you ever seen this before?

    bug 
    opened by eyuansu62 10
  • Error: Internal server error 500 while running make serve.

    Error: Internal server error 500 while running make serve.

    Hello @tscholak and the team. I am trying to use make serve for the T5+PICARD and run into error 500 on the fastapi page. Below is crash trace and also my configs. Thank you in advance. Screen Shot 2022-01-26 at 1 55 32 PM Screen Shot 2022-01-26 at 1 50 52 PM Screen Shot 2022-01-26 at 1 50 59 PM

    NFO: 172.17.0.1:62060 - "GET /ask/transactions/what%20is%20category%20for%20Canada%3F HTTP/1.1" 500 Internal Server Error ERROR: Exception in ASGI application Traceback (most recent call last): File "/opt/conda/lib/python3.7/site-packages/uvicorn/protocols/http/h11_impl.py", line 373, in run_asgi result = await app(self.scope, self.receive, self.send) File "/opt/conda/lib/python3.7/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in call return await self.app(scope, receive, send) File "/opt/conda/lib/python3.7/site-packages/fastapi/applications.py", line 208, in call await super().call(scope, receive, send) File "/opt/conda/lib/python3.7/site-packages/starlette/applications.py", line 112, in call await self.middleware_stack(scope, receive, send) File "/opt/conda/lib/python3.7/site-packages/starlette/middleware/errors.py", line 181, in call raise exc File "/opt/conda/lib/python3.7/site-packages/starlette/middleware/errors.py", line 159, in call await self.app(scope, receive, _send) File "/opt/conda/lib/python3.7/site-packages/starlette/exceptions.py", line 82, in call raise exc File "/opt/conda/lib/python3.7/site-packages/starlette/exceptions.py", line 71, in call await self.app(scope, receive, sender) File "/opt/conda/lib/python3.7/site-packages/starlette/routing.py", line 656, in call await route.handle(scope, receive, send) File "/opt/conda/lib/python3.7/site-packages/starlette/routing.py", line 259, in handle await self.app(scope, receive, send) File "/opt/conda/lib/python3.7/site-packages/starlette/routing.py", line 61, in app response = await func(request) File "/opt/conda/lib/python3.7/site-packages/fastapi/routing.py", line 227, in app dependant=dependant, values=values, is_coroutine=is_coroutine File "/opt/conda/lib/python3.7/site-packages/fastapi/routing.py", line 161, in run_endpoint_function return await run_in_threadpool(dependant.call, **values) File "/opt/conda/lib/python3.7/site-packages/starlette/concurrency.py", line 39, in run_in_threadpool return await anyio.to_thread.run_sync(func, *args) File "/opt/conda/lib/python3.7/site-packages/anyio/to_thread.py", line 29, in run_sync limiter=limiter) File "/opt/conda/lib/python3.7/site-packages/anyio/_backends/_asyncio.py", line 818, in run_sync_in_worker_thread return await future File "/opt/conda/lib/python3.7/site-packages/anyio/_backends/_asyncio.py", line 754, in run result = context.run(func, *args) File "seq2seq/serve_seq2seq.py", line 126, in ask outputs = pipe(inputs=Text2SQLInput(utterance=question, db_id=db_id)) File "/app/seq2seq/utils/pipeline.py", line 76, in call result = super().call(inputs, **kwargs) File "/opt/conda/lib/python3.7/site-packages/transformers/pipelines/text2text_generation.py", line 137, in call result = super().call(*args, **kwargs) File "/opt/conda/lib/python3.7/site-packages/transformers/pipelines/base.py", line 1101, in call return self.run_single(inputs, preprocess_params, forward_params, postprocess_params) File "/opt/conda/lib/python3.7/site-packages/transformers/pipelines/base.py", line 1108, in run_single model_outputs = self.forward(model_inputs, **forward_params) File "/opt/conda/lib/python3.7/site-packages/transformers/pipelines/base.py", line 1034, in forward model_outputs = self._forward(model_inputs, **forward_params) File "/opt/conda/lib/python3.7/site-packages/transformers/pipelines/text2text_generation.py", line 155, in _forward output_ids = self.model.generate(**model_inputs, **generate_kwargs) File "/opt/conda/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 28, in decorate_context return func(*args, **kwargs) File "/app/seq2seq/utils/picard_model_wrapper.py", line 249, in _generate input_ids, decoder_start_token_id=decoder_start_token_id, bos_token_id=bos_token_id File "/opt/conda/lib/python3.7/site-packages/transformers/generation_utils.py", line 502, in _prepare_decoder_input_ids_for_generation return torch.ones((batch_size, 1), dtype=torch.long, device=self.device) * decoder_start_token_id TypeError: ones(): argument 'size' must be tuple of ints, but found element of type Tensor at pos 1 01/26/2022 21:50:42 - ERROR - uvicorn.error - Exception in ASGI application Traceback (most recent call last): File "/opt/conda/lib/python3.7/site-packages/uvicorn/protocols/http/h11_impl.py", line 373, in run_asgi result = await app(self.scope, self.receive, self.send) File "/opt/conda/lib/python3.7/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in call return await self.app(scope, receive, send) File "/opt/conda/lib/python3.7/site-packages/fastapi/applications.py", line 208, in call await super().call(scope, receive, send) File "/opt/conda/lib/python3.7/site-packages/starlette/applications.py", line 112, in call await self.middleware_stack(scope, receive, send) File "/opt/conda/lib/python3.7/site-packages/starlette/middleware/errors.py", line 181, in call raise exc File "/opt/conda/lib/python3.7/site-packages/starlette/middleware/errors.py", line 159, in call await self.app(scope, receive, _send) File "/opt/conda/lib/python3.7/site-packages/starlette/exceptions.py", line 82, in call raise exc File "/opt/conda/lib/python3.7/site-packages/starlette/exceptions.py", line 71, in call await self.app(scope, receive, sender) File "/opt/conda/lib/python3.7/site-packages/starlette/routing.py", line 656, in call await route.handle(scope, receive, send) File "/opt/conda/lib/python3.7/site-packages/starlette/routing.py", line 259, in handle await self.app(scope, receive, send) File "/opt/conda/lib/python3.7/site-packages/starlette/routing.py", line 61, in app response = await func(request) File "/opt/conda/lib/python3.7/site-packages/fastapi/routing.py", line 227, in app dependant=dependant, values=values, is_coroutine=is_coroutine File "/opt/conda/lib/python3.7/site-packages/fastapi/routing.py", line 161, in run_endpoint_function return await run_in_threadpool(dependant.call, **values) File "/opt/conda/lib/python3.7/site-packages/starlette/concurrency.py", line 39, in run_in_threadpool return await anyio.to_thread.run_sync(func, *args) File "/opt/conda/lib/python3.7/site-packages/anyio/to_thread.py", line 29, in run_sync limiter=limiter) File "/opt/conda/lib/python3.7/site-packages/anyio/_backends/_asyncio.py", line 818, in run_sync_in_worker_thread return await future File "/opt/conda/lib/python3.7/site-packages/anyio/_backends/_asyncio.py", line 754, in run result = context.run(func, *args) File "seq2seq/serve_seq2seq.py", line 126, in ask outputs = pipe(inputs=Text2SQLInput(utterance=question, db_id=db_id)) File "/app/seq2seq/utils/pipeline.py", line 76, in call result = super().call(inputs, **kwargs) File "/opt/conda/lib/python3.7/site-packages/transformers/pipelines/text2text_generation.py", line 137, in call result = super().call(*args, **kwargs) File "/opt/conda/lib/python3.7/site-packages/transformers/pipelines/base.py", line 1101, in call return self.run_single(inputs, preprocess_params, forward_params, postprocess_params) File "/opt/conda/lib/python3.7/site-packages/transformers/pipelines/base.py", line 1108, in run_single model_outputs = self.forward(model_inputs, **forward_params) File "/opt/conda/lib/python3.7/site-packages/transformers/pipelines/base.py", line 1034, in forward model_outputs = self._forward(model_inputs, **forward_params) File "/opt/conda/lib/python3.7/site-packages/transformers/pipelines/text2text_generation.py", line 155, in _forward output_ids = self.model.generate(**model_inputs, **generate_kwargs) File "/opt/conda/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 28, in decorate_context return func(*args, **kwargs) File "/app/seq2seq/utils/picard_model_wrapper.py", line 249, in _generate input_ids, decoder_start_token_id=decoder_start_token_id, bos_token_id=bos_token_id File "/opt/conda/lib/python3.7/site-packages/transformers/generation_utils.py", line 502, in _prepare_decoder_input_ids_for_generation return torch.ones((batch_size, 1), dtype=torch.long, device=self.device) * decoder_start_token_id TypeError: ones(): argument 'size' must be tuple of ints, but found element of type Tensor at pos 1

    opened by ishmeetk 9
  • Questions about Database access in Serve Mode

    Questions about Database access in Serve Mode

    Hey @tscholak , so I have been fiddling with your model for a while now, I love the work you guys have done, I just wanted to ask a few questions about the files that go into your ./database folder when you deploy it on serving mode, as per the ReadMe the format's supposed to be like the one shown below

    database/
      my_1st_database/
        my_1st_database.sqlite
      my_2nd_database/
        my_2nd_database.sqlite
    

    I am just wondering about the content in each of these files, are they supposed to have both the schema and the rows of data?

    And another thing is for my current use case that I want to try your model on, my data is stored on a Postgres AWS server, I can't really convert these to SQLite or even export this data to a local machine (company policy) so how would you suggest me to get the model working with such a setup, what are some of the changes that I would have to make?

    Thank you for taking out your time

    question 
    opened by adityay121 9
  • Picard Client

    Picard Client

    Hello,

    I would like to ask you how can I activate picard. I mean, from the following code I got Picard is not available. When I printed the error, I got the message No module named 'picard.clients'.

    try:
        from picard.clients import Picard
        from picard.types import (
            FeedException,
            FeedTimeoutFailure,
            FeedParseFailure,
            FeedPartialSuccess,
            FeedCompleteSuccess,
            SQLSchema,
            RegisterSQLSchemaException,
            Mode,
            ColumnType,
        )
    
        from thrift.py3.client import get_client
        from thrift.py3.common import Protocol
        from thrift.py3.exceptions import TransportError
        picard_available = True
    except Exception as e:
        logger.warning(e)
        logger.warning("Picard is not available.")
        Picard = Any
        SQLSchema = Any
        RegisterSQLSchemaFail = Any
        ColumnType = Any
        picard_available = False
    

    I will really appreciate any help. Thank you.

    question 
    opened by JessicaLopezEspejel 8
  • Empty Predictions when Applying Picard

    Empty Predictions when Applying Picard

    Hi @tscholak,

    Recently, I tried training T5-base for text2sql without using DB Schema and DB Content with your code. The evaluation metrics seem normal without Picard. When I apply Picard, I get plenty of empty predictions. What might be the problem?

    Thanks!

    Myconfig:

    {
        "run_name": "t5-spider",
        "model_name_or_path": "/ckpts/train_spider_noSch/checkpoint-6656",
        "dataset": "spider",
        "source_prefix": "",
        "schema_serialization_type": "peteshaw",
        "schema_serialization_randomized": false,
        "schema_serialization_with_db_id": false,
        "schema_serialization_with_db_content": false,
        "normalize_query": true,
        "target_with_db_id": true,
        "output_dir": "/eval/eval_spider_noSch_nopicard/",
        "cache_dir": "/transformers_cache",
        "do_train": false,
        "do_eval": true,
        "fp16": false,
        "num_train_epochs": 3072,
        "per_device_train_batch_size": 16,
        "per_device_eval_batch_size": 1,
        "gradient_accumulation_steps": 16,
        "label_smoothing_factor": 0.0,
        "learning_rate": 1e-4,
        "adafactor": true,
        "adam_eps": 1e-6,
        "lr_scheduler_type": "constant",
        "warmup_ratio": 0.0,
        "warmup_steps": 0,
        "seed": 1,
        "report_to": [],
        "logging_strategy": "steps",
        "logging_first_step": true,
        "logging_steps": 16,
        "load_best_model_at_end": true,
        "metric_for_best_model": "exact_match",
        "greater_is_better": true,
        "save_total_limit": 128,
        "save_steps": 512,
        "evaluation_strategy": "steps",
        "eval_steps": 512,
        "predict_with_generate": true,
        "num_beams": 2,
        "num_beam_groups": 1,
        "use_picard": true,
        "launch_picard": true,
        "picard_mode": "parse_with_guards",
        "picard_schedule": "incremental",
        "picard_max_tokens_to_check": 2,
        "preprocessing_num_workers" : 32,
        "max_val_samples" : 1034
    }
    

    Empty Prediction Output:

    {
            "prediction": "",
            "query": "SELECT name ,  country ,  age FROM singer ORDER BY age DESC",
            "question": "What are the names, countries, and ages for every singer in descending order of age?",
            "context": "What are the names, countries, and ages for every singer in descending order of age? | stadium : stadium_id, location, name, capacity, highest, lowest, average | singer : singer_id, name, country, song_name, song_release_year, age, is_male | concert : concert_id, concert_name, theme, stadium_id, year | singer_in_concert : concert_id, singer_id",
            "label": "concert_singer | select name, country, age from singer order by age desc",
            "db_id": "concert_singer",
            "db_path": "/mydataset/spider/database",
            ...
    

    Normal Prediction Output:

    {
            "prediction": "concert_singer | select name, country, age from singer order by age desc",
            "query": "SELECT name ,  country ,  age FROM singer ORDER BY age DESC",
            "question": "Show name, country, age for all singers ordered by age from the oldest to the youngest.",
            "context": "Show name, country, age for all singers ordered by age from the oldest to the youngest. | stadium : stadium_id, location, name, capacity, highest, lowest, average | singer : singer_id, name, country, song_name, song_release_year, age, is_male | concert : concert_id, concert_name, theme, stadium_id, year | singer_in_concert : concert_id, singer_id",
            "label": "concert_singer | select name, country, age from singer order by age desc",
            "db_id": "concert_singer",
            "db_path": "/mydataset/spider/database",
            ...
    }
    
    question 
    opened by atosystem 8
  • Can I launch a PICARD service without model?

    Can I launch a PICARD service without model?

    Hi, @tscholak, thanks for your great job! I was wondering is it possible to split model and PICARD? I want to launch a PICARD service without model in one place, while launch a model prediction service elsewhere. Is there any interface that can do this job?

    opened by Dongfeng-He 0
  • Bump certifi from 2021.10.8 to 2022.12.7

    Bump certifi from 2021.10.8 to 2022.12.7

    Bumps certifi from 2021.10.8 to 2022.12.7.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump pillow from 9.0.1 to 9.3.0

    Bump pillow from 9.0.1 to 9.3.0

    Bumps pillow from 9.0.1 to 9.3.0.

    Release notes

    Sourced from pillow's releases.

    9.3.0

    https://pillow.readthedocs.io/en/stable/releasenotes/9.3.0.html

    Changes

    ... (truncated)

    Changelog

    Sourced from pillow's changelog.

    9.3.0 (2022-10-29)

    • Limit SAMPLESPERPIXEL to avoid runtime DOS #6700 [wiredfool]

    • Initialize libtiff buffer when saving #6699 [radarhere]

    • Inline fname2char to fix memory leak #6329 [nulano]

    • Fix memory leaks related to text features #6330 [nulano]

    • Use double quotes for version check on old CPython on Windows #6695 [hugovk]

    • Remove backup implementation of Round for Windows platforms #6693 [cgohlke]

    • Fixed set_variation_by_name offset #6445 [radarhere]

    • Fix malloc in _imagingft.c:font_setvaraxes #6690 [cgohlke]

    • Release Python GIL when converting images using matrix operations #6418 [hmaarrfk]

    • Added ExifTags enums #6630 [radarhere]

    • Do not modify previous frame when calculating delta in PNG #6683 [radarhere]

    • Added support for reading BMP images with RLE4 compression #6674 [npjg, radarhere]

    • Decode JPEG compressed BLP1 data in original mode #6678 [radarhere]

    • Added GPS TIFF tag info #6661 [radarhere]

    • Added conversion between RGB/RGBA/RGBX and LAB #6647 [radarhere]

    • Do not attempt normalization if mode is already normal #6644 [radarhere]

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • inference on unseen tables

    inference on unseen tables

    Hi @tscholak ,

    first of all, thank you for the great work! So, I have 2 tables from which i can create an sqlite db. As seen in your instructions, do i just need to place them in under database directory or there are additional steps to it? In general if you can comment how is the performance of t5-picard on unseen tables directly as I do not have dataset to fine tune the model. I haven't yet tried on how hard it is to create a fine tuning dataset. I would appreciate your comments on it.

    opened by srewai 0
  • De-register schema

    De-register schema

    Hi, Is there a way to de-register schema like how we register here: https://github.com/ServiceNow/picard/blob/6a252386bed6d4233f0f13f4562d8ae8608e7445/seq2seq/utils/picard_model_wrapper.py#L129

    opened by iMayK 0
Owner
ElementAI
ElementAI
Implementation of fast algorithms for Maximum Spanning Tree (MST) parsing that includes fast ArcMax+Reweighting+Tarjan algorithm for single-root dependency parsing.

Fast MST Algorithm Implementation of fast algorithms for (Maximum Spanning Tree) MST parsing that includes fast ArcMax+Reweighting+Tarjan algorithm fo

Miloš Stanojević 11 Oct 14, 2022
PyTorch implementation of D2C: Diffuison-Decoding Models for Few-shot Conditional Generation.

D2C: Diffuison-Decoding Models for Few-shot Conditional Generation Project | Paper PyTorch implementation of D2C: Diffuison-Decoding Models for Few-sh

Jiaming Song 90 Dec 27, 2022
library for nonlinear optimization, wrapping many algorithms for global and local, constrained or unconstrained, optimization

NLopt is a library for nonlinear local and global optimization, for functions with and without gradient information. It is designed as a simple, unifi

Steven G. Johnson 1.4k Dec 25, 2022
Official implementation of the MM'21 paper Constrained Graphic Layout Generation via Latent Optimization

[MM'21] Constrained Graphic Layout Generation via Latent Optimization This repository provides the official code for the paper "Constrained Graphic La

Kotaro Kikuchi 73 Dec 27, 2022
PyTorch implementation of Constrained Policy Optimization

PyTorch implementation of Constrained Policy Optimization (CPO) This repository has a simple to understand and use implementation of CPO in PyTorch. A

Sapana Chaudhary 25 Dec 8, 2022
Locally Constrained Self-Attentive Sequential Recommendation

LOCKER This is the pytorch implementation of this paper: Locally Constrained Self-Attentive Sequential Recommendation. Zhankui He, Handong Zhao, Zhe L

Zhankui (Aaron) He 8 Jul 30, 2022
A semismooth Newton method for elliptic PDE-constrained optimization

sNewton4PDEOpt The Python module implements a semismooth Newton method for solving finite-element discretizations of the strongly convex, linear ellip

null 2 Dec 8, 2022
Prototypical python implementation of the trust-region algorithm presented in Sequential Linearization Method for Bound-Constrained Mathematical Programs with Complementarity Constraints by Larson, Leyffer, Kirches, and Manns.

Prototypical python implementation of the trust-region algorithm presented in Sequential Linearization Method for Bound-Constrained Mathematical Programs with Complementarity Constraints by Larson, Leyffer, Kirches, and Manns.

null 3 Dec 2, 2022
Official PyTorch implementation of the paper "Deep Constrained Least Squares for Blind Image Super-Resolution", CVPR 2022.

Deep Constrained Least Squares for Blind Image Super-Resolution [Paper] This is the official implementation of 'Deep Constrained Least Squares for Bli

MEGVII Research 141 Dec 30, 2022
An integration of several popular automatic augmentation methods, including OHL (Online Hyper-Parameter Learning for Auto-Augmentation Strategy) and AWS (Improving Auto Augment via Augmentation Wise Weight Sharing) by Sensetime Research.

An integration of several popular automatic augmentation methods, including OHL (Online Hyper-Parameter Learning for Auto-Augmentation Strategy) and AWS (Improving Auto Augment via Augmentation Wise Weight Sharing) by Sensetime Research.

null 45 Dec 8, 2022
codes for "Scheduled Sampling Based on Decoding Steps for Neural Machine Translation" (long paper of EMNLP-2022)

Scheduled Sampling Based on Decoding Steps for Neural Machine Translation (EMNLP-2021 main conference) Contents Overview Background Quick to Use Furth

Adaxry 13 Jul 25, 2022
Code For TDEER: An Efficient Translating Decoding Schema for Joint Extraction of Entities and Relations (EMNLP2021)

TDEER (WIP) Code For TDEER: An Efficient Translating Decoding Schema for Joint Extraction of Entities and Relations (EMNLP2021) Overview TDEER is an e

Alipay 6 Dec 17, 2022
Release of SPLASH: Dataset for semantic parse correction with natural language feedback in the context of text-to-SQL parsing

SPLASH: Semantic Parsing with Language Assistance from Humans SPLASH is dataset for the task of semantic parse correction with natural language feedba

Microsoft Research - Language and Information Technologies (MSR LIT) 35 Oct 31, 2022
Meta Language-Specific Layers in Multilingual Language Models

Meta Language-Specific Layers in Multilingual Language Models This repo contains the source codes for our paper On Negative Interference in Multilingu

Zirui Wang 20 Feb 13, 2022
The source code for Generating Training Data with Language Models: Towards Zero-Shot Language Understanding.

SuperGen The source code for Generating Training Data with Language Models: Towards Zero-Shot Language Understanding. Requirements Before running, you

Yu Meng 38 Dec 12, 2022
SIEM Logstash parsing for more than hundred technologies

LogIndexer Pipeline Logstash Parsing Configurations for Elastisearch SIEM and OpenDistro for Elasticsearch SIEM Why this project exists The overhead o

null 146 Dec 29, 2022
The official PyTorch implementation of the paper: *Xili Dai, Xiaojun Yuan, Haigang Gong, Yi Ma. "Fully Convolutional Line Parsing." *.

F-Clip — Fully Convolutional Line Parsing This repository contains the official PyTorch implementation of the paper: *Xili Dai, Xiaojun Yuan, Haigang

Xili Dai 115 Dec 28, 2022
:hot_pepper: R²SQL: "Dynamic Hybrid Relation Network for Cross-Domain Context-Dependent Semantic Parsing." (AAAI 2021)

R²SQL The PyTorch implementation of paper Dynamic Hybrid Relation Network for Cross-Domain Context-Dependent Semantic Parsing. (AAAI 2021) Requirement

huybery 60 Dec 31, 2022