openai / gpt-2

Code for the paper "Language Models are Unsupervised Multitask Learners"
https://openai.com/blog/better-language-models/
Other
22.57k stars 5.53k forks source link

KeyError: 'para_index' coming when using Question-Generation(interact.py) #266

Open Vivaswan13 opened 4 years ago

Vivaswan13 commented 4 years ago

I was curious to try using the question generation component. Based on the overall README, I might expect to be able to run interact.py without any arguments, but this doesn't work:

ERROR:pytorch_pretrained_bert.modeling_openai:Model name '' was not found in model name list (openai-gpt). We assumed '' was a path or url but couldn't find files pytorch_model.bin and config.json at this path or url.
Traceback (most recent call last):
  File "question-generation/interact.py", line 238, in <module>
    run()
  File "question-generation/interact.py", line 149, in run
    model.to(args.device)
AttributeError: 'NoneType' object has no attribute 'to'

That is ok, I downloaded a pretrained model myself from Google drive and tried interact.py again (python3 question-generation/interact.py --model_checkpoint ~/Downloads/gpt2_corefs_question_generation/). When I did so, I first hit the below issue:

File "question-generation/interact.py", line 238, in <module>
    run()
  File "question-generation/interact.py", line 152, in run
    data = get_positional_dataset_from_file(tokenizer, args.filename)
  File "/Users/amooren/Code/squash-generation/question-generation/dataloader.py", line 81, in get_positional_dataset_from_file
    with open(file, 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'data/instances_dev.pkl'

Reading the overall README, I inferred that I needed to download instances_dev.pkl, and I found something closely named instances_dev.pickle and instances_coref_dev.pickle here. I assumed I'd need the coref labeled one, as the pretrained folder is named "gpt2_corefs_question_generation". But when I tried to use this, I hit the next issue:

Traceback (most recent call last):
  File "question-generation/interact.py", line 238, in <module>
    run()
  File "question-generation/interact.py", line 168, in run
    para_index = inst["para_index"]
KeyError: 'para_index'

Would you mind clarifying the steps to test out just this component? It would greatly speed up my efforts.

Mozoku commented 4 years ago

How did you solve this?