guotong1988 / NL2SQL-RULE

Content Enhanced BERT-based Text-to-SQL Generation https://arxiv.org/abs/1910.07179
188 stars 48 forks source link

problem with knowledge when running inference #1

Closed paulfitz closed 4 years ago

paulfitz commented 4 years ago

Thanks for the pretrained model! I was trying to run inference using python3 ./train.py --trained --do_infer, but get this error:

Traceback (most recent call last):
  File "./train.py", line 799, in <module>
    beam_size=1, show_table=False, show_answer_only=False
  File "./train.py", line 632, in infer
    beam_size=beam_size)
  File "/base/sqlova/model/nl2sql/wikisql_models.py", line 115, in beam_forward
    knowledge=knowledge, knowledge_header=knowledge_header)
  File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/base/sqlova/model/nl2sql/wikisql_models.py", line 562, in forward
    knowledge = [k + (mL_n - len(k)) * [0] for k in knowledge]
TypeError: 'NoneType' object is not iterable

I've placed something in data_and_model/ctable.tables.jsonl and data_and_model/ctable.db. I've placed a ctable_knowledge.jsonl file in a few places, but I don't see how it would be read. What am I doing wrong?

guotong1988 commented 4 years ago

One data should be:

{
    "table_id": "1-1000181-1",
    "phase": 1,
    "question": "Tell me what the notes are for South Australia ",
    "question_tok": ["Tell", "me", "what", "the", "notes", "are", "for", "South", "Australia"],
    "sql": {
        "sel": 5,
        "conds": [
            [3, 0, "SOUTH AUSTRALIA"]
        ],
        "agg": 0
    },
    "query": {
        "sel": 5,
        "conds": [
            [3, 0, "SOUTH AUSTRALIA"]
        ],
        "agg": 0
    },
    "wvi_corenlp": [
        [7, 8]
    ],
    "bertindex_knowledge": [0, 0, 0, 0, 4, 0, 0, 1, 3],
    "header_knowledge": [2, 0, 0, 2, 0, 1]
}
guotong1988 commented 4 years ago

I have upload the data https://github.com/guotong1988/NL2SQL-BERT/tree/master/data_and_model

guotong1988 commented 4 years ago

But def infer API is not ready, you should refer to def test to edit def infer .