lyuqin / hydranet-wikisql Goto Github PK
View Code? Open in Web Editor NEWCode and trained model for Hybrid ranking network for text-to-SQL on WikiSQL
Home Page: https://arxiv.org/abs/2008.04759
License: MIT License
Code and trained model for Hybrid ranking network for text-to-SQL on WikiSQL
Home Page: https://arxiv.org/abs/2008.04759
License: MIT License
a lot of papers show the results of HydraNet on Chinese dataset--TableQA,I want to ask if you have the code on Chinese datasets.Or do you kown how the paper get the results? Change the code by themselves or others?
Thank you!
When running wikisql_prediction.py
with trained model, I got the error KeyError: 'token_type_ids'
. The details are as follows.
Traceback (most recent call last):
File "/home/HydraNet-WikiSQL-master/wikisql_prediction.py", line 61, in <module>
pred_data = SQLDataset(in_file, config, featurizer, False)
File "/home/HydraNet-WikiSQL-master/featurizer.py", line 262, in __init__
self.input_features, self.model_inputs, self.pos = self.featurizer.load_data(data_paths, config, include_label)
File "/home/HydraNet-WikiSQL-master/featurizer.py", line 221, in load_data
input_feature = self.get_input_feature(example, config)
File "/home/HydraNet-WikiSQL-master/featurizer.py", line 134, in get_input_feature
segment_ids = tokenize_result["token_type_ids"]
File "/home/anaconda3/lib/python3.7/site-packages/transformers/tokenization_utils_base.py", line 273, in __getitem__
return self.data[item]
KeyError: 'token_type_ids'
It seems that the output of the function tokenizer.encode_plus
in line 116 of featurizer.py
doesn't has the key token_type_ids
.
Please share if there is any solution to this issue.
Thanks and Regards
Hi!
With your feedback on issue#7, I can experiment safely hydra-net with your code.
I really appreciate it 👍
Recently I am focusing on Semantic parsing task(especially, Text-to-SQL).
So I am doing some experiments with several models on Wiki-SQL dataset.
and now I am trying to get 'Top-k accuracy' on Predicted SQL query output of Hydra-net.
I am graduate student,, So my question would be a little-bit bothersome.. I understand :(
Nevertheless, let me begin my question .. !
In your model, I understand that 'Ranking' is very important.
So, I am trying to get "where can I find and get ranking scores ..!?"
My brain says "you can find ranking scores in this line...!"..
SELECT ranking score is 'select_id_prob'
HydraNet-WikiSQL/modeling/base_model.py
Line 169 in afdf1e5
and WHERE ranking score is 'where_id_prob'
HydraNet-WikiSQL/modeling/base_model.py
Line 136 in afdf1e5
Is my guess right..!?
It is very basic and elementary question for you. But it will be very helpful for me : )
Thank you for reading me.
Hello there.
I've been trying to run the training for a few hours. My specs are:
Nvidia RTX 2070, 32GB of Ram and a ryzen 3700X.
Fedora 36 with proprietary Nvidia drivers (510.68.02 CUDA Version: 11.6).
When I run the command python main.py train --conf conf/wikisql.conf --gpu 0
, it stops shortly after printing start training
. It says it failed to allocate memory on the GPU.
If I don't specify --gpu 0
, it gives the same output, which leads me to think that it's using the GPU either way.
This is the stack trace produced:
start training
Traceback (most recent call last):
File "/home/djouze/dev/HydraNet-WikiSQL/main.py", line 70, in <module>
cur_loss = model.train_on_batch(batch)
File "/home/djouze/dev/HydraNet-WikiSQL/modeling/torch_model.py", line 41, in train_on_batch
batch_loss = torch.mean(self.model(**batch)["loss"])
File "/home/djouze/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "/home/djouze/dev/HydraNet-WikiSQL/modeling/torch_model.py", line 114, in forward
bert_output, pooled_output = self.base_model(
File "/home/djouze/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "/home/djouze/.local/lib/python3.10/site-packages/transformers/models/roberta/modeling_roberta.py", line 815, in forward
encoder_outputs = self.encoder(
File "/home/djouze/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "/home/djouze/.local/lib/python3.10/site-packages/transformers/models/roberta/modeling_roberta.py", line 508, in forward
layer_outputs = layer_module(
File "/home/djouze/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "/home/djouze/.local/lib/python3.10/site-packages/transformers/models/roberta/modeling_roberta.py", line 395, in forward
self_attention_outputs = self.attention(
File "/home/djouze/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "/home/djouze/.local/lib/python3.10/site-packages/transformers/models/roberta/modeling_roberta.py", line 323, in forward
self_outputs = self.self(
File "/home/djouze/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "/home/djouze/.local/lib/python3.10/site-packages/transformers/models/roberta/modeling_roberta.py", line 253, in forward
attention_probs = self.dropout(attention_probs)
File "/home/djouze/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "/home/djouze/.local/lib/python3.10/site-packages/torch/nn/modules/dropout.py", line 58, in forward
return F.dropout(input, self.p, self.training, self.inplace)
File "/home/djouze/.local/lib/python3.10/site-packages/torch/nn/functional.py", line 1279, in dropout
return _VF.dropout_(input, p, training) if inplace else _VF.dropout(input, p, training)
RuntimeError: CUDA out of memory. Tried to allocate 144.00 MiB (GPU 0; 7.79 GiB total capacity; 6.05 GiB already allocated; 158.19 MiB free; 6.08 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
My last try was using the docker image, after the training started, my memory consumption got to 31GB, but the docker seems to have crashed without producing any output.
Could you help me find out why that's happening? I assume it would be able to run on single GPU spec, although in that case it would likely take more time (correct me if I'm wrong).
Thank you for your attention,
José
Hello,
is there any function or way to get a single sql query from a single question? Like run the trainend model on db-schema and a single question.
Or is only way by adding a line at the end of the "/wikisql/test.jsonl" and "/wikisql/test.tables.jsonl" file and run "wikisql_prediction.py", according to #issue3?
Thank you!
I run the code successfully, but the result is far from yours result mentioned in the paper, could you add the trained model to the repo, or publish the train parameters
Hi,
I want to know after I downloading the model , can I predict using the model on windows with cpu only?
What changes need to be made?
Thank you very much.
Hello,
I would like to export my trained model to onnx model.
Export Function call:
dummy_input2 = torch.LongTensor(2, 2)
dummy_input2.requires_grad = False
torch.onnx.export(model.model,
(dummy_input0, dummy_input1, dummy_input2),
"Text-to-SQL.onnx",
input_names = ["input_ids", "input_mask", "segment_ids"],
output_names = ["output"]
)
“RuntimeError: Cannot insert a Tensor that requires grad as a constant. Consider making it a parameter or input, or detaching the gradient”.
Do you some advices or a guide for exporting this model to onnx?
Best regards!
if i want to use bert model as base_class, how should i modify the wikisql.config file?
Thank you!
Hi,
I want to know can I use the model to test a new question and a new table?
Can I do this by adding a line at the end of the "wikitest.jsonl" file and run "wikisql_prediction.py"?
When I train the model on multi GPUs, a sub task metric val accuracy is extremely low while the other metrics are high. (python main.py train --conf conf/wikisql.conf --gpu 0,1,2,3 --note "some note")
But when I train it on single GPU, the bug disappears.(python main.py train --conf conf/wikisql.conf --gpu 0 --note "some note")
I have to use a small batch size to train on a single GPU so the performance is 3% lower in dev/test logical form acc. I want to train it on multi GPUs but I don't know why the bug occurs and how to solve it?
I really appreciate your code and model(HydraNet). with your code, I can study and understand a lot. Thank you.
But I have a problem with accuracy score on EG cases.
Is there any issue or report on accuracy score on EG cases ?
I just change batch_size because of my CUDA memory limit. But I do not change any line.
I can get right accuracy scores in no EG cases. But, in EG cases.. I have very low (abnormal) accuracy scroe..
For example, when I open the "output/test_out.jsonl.eg",
then "conds : [ ]" of all predicted quries have empty list.
So, I get 0.00825.. score in wcn_acc, wcc_acc, wco_acc, wcv_acc metrics.
Debugging is on me. but, if you give me some advice, It will be very helpful ! :)
Thank you!
Hello! I want to use some other model as for base model. For some commen models such as bert that it is easy to work. So if j just have .pt and source code ,how do i put it into utils.py-->create_base_mode(config) ? if there will have some data format question in these process?
I want to use mt-dnn for the base model and just have .pt. i'm very hope for you help! Thanks!
Hi!
After I downloaded the model and want to evaluate , something error.
The details are as follows:
(python37) guest05@oem-04:~/yaoProjects/HydraNet-WikiSQL$ python wikisql_prediction.py
To use data.metrics please install scikit-learn. See https://scikit-learn.org/stable/index.html
5000
10000
15000
data/wikitest.jsonl loaded. Data shapes:
input_ids (101072, 96)
input_mask (101072, 96)
segment_ids (101072, 96)
num of samples: 15878
Traceback (most recent call last):
File "/home/guest05/anaconda3/envs/python37/lib/python3.7/site-packages/transformers/modeling_utils.py", line 415, in from_pretrained
state_dict = torch.load(resolved_archive_file, map_location='cpu')
File "/home/guest05/anaconda3/envs/python37/lib/python3.7/site-packages/torch/serialization.py", line 593, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "/home/guest05/anaconda3/envs/python37/lib/python3.7/site-packages/torch/serialization.py", line 779, in _legacy_load
deserialized_objects[key]._set_from_file(f, offset, f_should_read_directly)
RuntimeError: unexpected EOF, expected 3539973 more bytes. The file might be corrupted.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "wikisql_prediction.py", line 64, in
model = create_model(config, is_train=False)
File "/home/guest05/yaoProjects/HydraNet-WikiSQL/modeling/model_factory.py", line 6, in create_model
return HydraTorch(config)
File "/home/guest05/yaoProjects/HydraNet-WikiSQL/modeling/torch_model.py", line 12, in init
self.model = HydraNet(config)
File "/home/guest05/yaoProjects/HydraNet-WikiSQL/modeling/torch_model.py", line 84, in init
self.base_model = utils.create_base_model(config)
File "/home/guest05/yaoProjects/HydraNet-WikiSQL/utils.py", line 36, in create_base_model
return transformers.RobertaModel.from_pretrained(weights_name)
File "/home/guest05/anaconda3/envs/python37/lib/python3.7/site-packages/transformers/modeling_utils.py", line 417, in from_pretrained
raise OSError("Unable to load weights from pytorch checkpoint file. "
OSError: Unable to load weights from pytorch checkpoint file. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.
malloc(): unsorted double linked list corrupted
已放弃 (核心已转储)
Can you give me some suggestions?Thank you very much.
Hello!
I read the paper you published and i also git clone the code .I run the code successfully.But the result I got is far from your result.
[wikidev.jsonl, epoch 4] overall:76.1, agg:89.1, sel:96.3, wn:97.1, wc:92.1, op:98.4, val:91.1.
I find that the where_col result and the where_val is worse than other.
What do you think about these issues?
input_ids (101072, 96)
input_mask (101072, 96)
segment_ids (101072, 96)
num of samples: 15878
PyTorch model loaded from output/20200207_105347\model_4.pt
model prediction start
Traceback (most recent call last):
File "wikisql_prediction.py", line 73, in
model_outputs = model.dataset_inference(pred_data)
File "C:\Users\mohdf\OneDrive\Desktop\Hydranet_sql\HydraNet-WikiSQL\modeling\base_model.py", line 24, in dataset_inference
model_outputs = self.model_inference(dataset.model_inputs)
File "C:\Users\mohdf\OneDrive\Desktop\Hydranet_sql\HydraNet-WikiSQL\modeling\torch_model.py", line 57, in model_inference
model_output = self.model(**input_tensor)
File "C:\Users\mohdf\anaconda3\envs\hydranet2\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Users\mohdf\OneDrive\Desktop\Hydranet_sql\HydraNet-WikiSQL\modeling\torch_model.py", line 114, in forward
bert_output, pooled_output = self.base_model(
File "C:\Users\mohdf\anaconda3\envs\hydranet2\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Users\mohdf\anaconda3\envs\hydranet2\lib\site-packages\transformers\models\roberta\modeling_roberta.py", line 815, in forward
encoder_outputs = self.encoder(
File "C:\Users\mohdf\anaconda3\envs\hydranet2\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Users\mohdf\anaconda3\envs\hydranet2\lib\site-packages\transformers\models\roberta\modeling_roberta.py", line 508, in forward
layer_outputs = layer_module(
File "C:\Users\mohdf\anaconda3\envs\hydranet2\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Users\mohdf\anaconda3\envs\hydranet2\lib\site-packages\transformers\models\roberta\modeling_roberta.py", line 395, in forward
self_attention_outputs = self.attention(
File "C:\Users\mohdf\anaconda3\envs\hydranet2\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Users\mohdf\anaconda3\envs\hydranet2\lib\site-packages\transformers\models\roberta\modeling_roberta.py", line 323, in forward
self_outputs = self.self(
File "C:\Users\mohdf\anaconda3\envs\hydranet2\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Users\mohdf\anaconda3\envs\hydranet2\lib\site-packages\transformers\models\roberta\modeling_roberta.py", line 187, in forward
mixed_query_layer = self.query(hidden_states)
File "C:\Users\mohdf\anaconda3\envs\hydranet2\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Users\mohdf\anaconda3\envs\hydranet2\lib\site-packages\torch\nn\modules\linear.py", line 103, in forward
return F.linear(input, self.weight, self.bias)
File "C:\Users\mohdf\anaconda3\envs\hydranet2\lib\site-packages\torch\nn\functional.py", line 1848, in linear
return torch._C._nn.linear(input, weight, bias)
RuntimeError: CUDA error: CUBLAS_STATUS_ALLOC_FAILED when calling cublasCreate(handle)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.