priya-dwivedi / Deep-Learning

MIT License
3.35k stars 2.5k forks source link

ref:GPT2-HarryPotter-Training/examples/run_generation.py #97

Open remotejob opened 4 years ago

remotejob commented 4 years ago

Namespace(device=device(type='cpu'), length=300, model_name_or_path='output', model_type='gpt2', n_gpu=0, no_cuda=False, num_samples=1, padding_text='', prompt='Standing in the doorway, illuminated by the shivering flames in Lupin’s hand, was a cloaked figure that towered to the ceiling.', repetition_penalty=1.0, seed=42, stop_token=None, temperature=1.0, top_k=0, top_p=0.9, xlm_lang='')

File "run_generation.py", line 261, in <module> main() File "run_generation.py", line 246, in main device=args.device, File "run_generation.py", line 146, in sample_sequence filtered_logits = top_k_top_p_filtering(next_token_logits, top_k=top_k, top_p=top_p) File "run_generation.py", line 105, in top_k_top_p_filtering indices_to_remove = sorted_indices_to_remove.scatter(dim=1, index=sorted_indices, src=sorted_indices_to_remove) TypeError: scatter() got an unexpected keyword argument 'src'

Must be 'source*' instead of 'src'

indices_to_remove = sorted_indices_to_remove.scatter(dim=1, index=sorted_indices, source=sorted_indices_to_remove)

priya-dwivedi commented 4 years ago

did u train your own model first and have that at the output path?

Dipeshpal commented 4 years ago

While running run_generation.py, I am getting this error-

2020-06-11 11:45:50.931184: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1 Traceback (most recent call last): File "run_generation.py", line 46, in ALL_MODELS = sum((tuple(conf.pretrained_config_archive_map.keys()) for conf in (GPT2Config, OpenAIGPTConfig, XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig)), ()) File "run_generation.py", line 46, in ALL_MODELS = sum((tuple(conf.pretrained_config_archive_map.keys()) for conf in (GPT2Config, OpenAIGPTConfig, XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig)), ()) AttributeError: type object 'GPT2Config' has no attribute 'pretrained_config_archive_map'

This is how I am running- !python run_generation.py --model_type gpt2 --model_name_or_path output/pytorch_model.bin --length 300 --prompt "My name is Dipesh, I am magician"

holnburger commented 4 years ago

I do get the same error. After running the initial training and using run_generation.py, the result is this:

07/01/2020 06:43:44 - INFO - __main__ -   ***** Eval results  *****
07/01/2020 06:43:44 - INFO - __main__ -     perplexity = tensor(32.7754)
xxx@xx:~/path/to/project/examples$ python3 run_generation.py --model_type gpt2 --model_name_or_path output --length 300 --prompt "Das wichtigste Buch des Jahres"Traceback (most recent call last):
  File "run_generation.py", line 46, in <module>
    ALL_MODELS = sum((tuple(conf.pretrained_config_archive_map.keys()) for conf in (GPT2Config, OpenAIGPTConfig, XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig)), ())
  File "run_generation.py", line 46, in <genexpr>
    ALL_MODELS = sum((tuple(conf.pretrained_config_archive_map.keys()) for conf in (GPT2Config, OpenAIGPTConfig, XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig)), ())
AttributeError: type object 'GPT2Config' has no attribute 'pretrained_config_archive_map'

Did you find a solution @Dipeshpal?

Dipeshpal commented 4 years ago

I do get the same error. After running the initial training and using run_generation.py, the result is this:

07/01/2020 06:43:44 - INFO - __main__ -   ***** Eval results  *****
07/01/2020 06:43:44 - INFO - __main__ -     perplexity = tensor(32.7754)
xxx@xx:~/path/to/project/examples$ python3 run_generation.py --model_type gpt2 --model_name_or_path output --length 300 --prompt "Das wichtigste Buch des Jahres"Traceback (most recent call last):
  File "run_generation.py", line 46, in <module>
    ALL_MODELS = sum((tuple(conf.pretrained_config_archive_map.keys()) for conf in (GPT2Config, OpenAIGPTConfig, XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig)), ())
  File "run_generation.py", line 46, in <genexpr>
    ALL_MODELS = sum((tuple(conf.pretrained_config_archive_map.keys()) for conf in (GPT2Config, OpenAIGPTConfig, XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig)), ())
AttributeError: type object 'GPT2Config' has no attribute 'pretrained_config_archive_map'

Did you find a solution @Dipeshpal?

I do get the same error. After running the initial training and using run_generation.py, the result is this:

07/01/2020 06:43:44 - INFO - __main__ -   ***** Eval results  *****
07/01/2020 06:43:44 - INFO - __main__ -     perplexity = tensor(32.7754)
xxx@xx:~/path/to/project/examples$ python3 run_generation.py --model_type gpt2 --model_name_or_path output --length 300 --prompt "Das wichtigste Buch des Jahres"Traceback (most recent call last):
  File "run_generation.py", line 46, in <module>
    ALL_MODELS = sum((tuple(conf.pretrained_config_archive_map.keys()) for conf in (GPT2Config, OpenAIGPTConfig, XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig)), ())
  File "run_generation.py", line 46, in <genexpr>
    ALL_MODELS = sum((tuple(conf.pretrained_config_archive_map.keys()) for conf in (GPT2Config, OpenAIGPTConfig, XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig)), ())
AttributeError: type object 'GPT2Config' has no attribute 'pretrained_config_archive_map'

Did you find a solution @Dipeshpal?

No, if you have something please share.

nikhila99 commented 3 years ago

I do get the same error. After running the initial training and using run_generation.py, the result is this:

07/01/2020 06:43:44 - INFO - __main__ -   ***** Eval results  *****
07/01/2020 06:43:44 - INFO - __main__ -     perplexity = tensor(32.7754)
xxx@xx:~/path/to/project/examples$ python3 run_generation.py --model_type gpt2 --model_name_or_path output --length 300 --prompt "Das wichtigste Buch des Jahres"Traceback (most recent call last):
  File "run_generation.py", line 46, in <module>
    ALL_MODELS = sum((tuple(conf.pretrained_config_archive_map.keys()) for conf in (GPT2Config, OpenAIGPTConfig, XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig)), ())
  File "run_generation.py", line 46, in <genexpr>
    ALL_MODELS = sum((tuple(conf.pretrained_config_archive_map.keys()) for conf in (GPT2Config, OpenAIGPTConfig, XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig)), ())
AttributeError: type object 'GPT2Config' has no attribute 'pretrained_config_archive_map'

Did you find a solution @Dipeshpal?

I do get the same error. After running the initial training and using run_generation.py, the result is this:

07/01/2020 06:43:44 - INFO - __main__ -   ***** Eval results  *****
07/01/2020 06:43:44 - INFO - __main__ -     perplexity = tensor(32.7754)
xxx@xx:~/path/to/project/examples$ python3 run_generation.py --model_type gpt2 --model_name_or_path output --length 300 --prompt "Das wichtigste Buch des Jahres"Traceback (most recent call last):
  File "run_generation.py", line 46, in <module>
    ALL_MODELS = sum((tuple(conf.pretrained_config_archive_map.keys()) for conf in (GPT2Config, OpenAIGPTConfig, XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig)), ())
  File "run_generation.py", line 46, in <genexpr>
    ALL_MODELS = sum((tuple(conf.pretrained_config_archive_map.keys()) for conf in (GPT2Config, OpenAIGPTConfig, XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig)), ())
AttributeError: type object 'GPT2Config' has no attribute 'pretrained_config_archive_map'

Did you find a solution @Dipeshpal?

No, if you have something please share.

Hi @Dipeshpal.. I also faced the same issue, Here's what I found : https://forum.rasa.com/t/rasa-nlu-paraphrasing/30128 . Follow the link, seems like there is some change in hugging-face transformers code. However after changing that piece of code(Line 47 in run_generation.py according to the above link), I am getting the following error: Traceback (most recent call last): File "run_generation.py", line 261, in main() File "run_generation.py", line 161, in main help="Path to pre-trained model or shortcut name selected in the list: " + ", ".join(ALL_MODELS)) TypeError: sequence item 0: expected str instance, dict found

PS: I have also removed XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig these from ALL_MODELS. Are they mandatory ? Please share if any solutions found...

En-J-A commented 3 years ago

I do get the same error. After running the initial training and using run_generation.py, the result is this:

07/01/2020 06:43:44 - INFO - __main__ -   ***** Eval results  *****
07/01/2020 06:43:44 - INFO - __main__ -     perplexity = tensor(32.7754)
xxx@xx:~/path/to/project/examples$ python3 run_generation.py --model_type gpt2 --model_name_or_path output --length 300 --prompt "Das wichtigste Buch des Jahres"Traceback (most recent call last):
  File "run_generation.py", line 46, in <module>
    ALL_MODELS = sum((tuple(conf.pretrained_config_archive_map.keys()) for conf in (GPT2Config, OpenAIGPTConfig, XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig)), ())
  File "run_generation.py", line 46, in <genexpr>
    ALL_MODELS = sum((tuple(conf.pretrained_config_archive_map.keys()) for conf in (GPT2Config, OpenAIGPTConfig, XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig)), ())
AttributeError: type object 'GPT2Config' has no attribute 'pretrained_config_archive_map'

Did you find a solution @Dipeshpal?

I do get the same error. After running the initial training and using run_generation.py, the result is this:

07/01/2020 06:43:44 - INFO - __main__ -   ***** Eval results  *****
07/01/2020 06:43:44 - INFO - __main__ -     perplexity = tensor(32.7754)
xxx@xx:~/path/to/project/examples$ python3 run_generation.py --model_type gpt2 --model_name_or_path output --length 300 --prompt "Das wichtigste Buch des Jahres"Traceback (most recent call last):
  File "run_generation.py", line 46, in <module>
    ALL_MODELS = sum((tuple(conf.pretrained_config_archive_map.keys()) for conf in (GPT2Config, OpenAIGPTConfig, XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig)), ())
  File "run_generation.py", line 46, in <genexpr>
    ALL_MODELS = sum((tuple(conf.pretrained_config_archive_map.keys()) for conf in (GPT2Config, OpenAIGPTConfig, XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig)), ())
AttributeError: type object 'GPT2Config' has no attribute 'pretrained_config_archive_map'

Did you find a solution @Dipeshpal?

No, if you have something please share.

Hi @Dipeshpal.. I also faced the same issue, Here's what I found : https://forum.rasa.com/t/rasa-nlu-paraphrasing/30128 . Follow the link, seems like there is some change in hugging-face transformers code. However after changing that piece of code(Line 47 in run_generation.py according to the above link), I am getting the following error: Traceback (most recent call last): File "run_generation.py", line 261, in main() File "run_generation.py", line 161, in main help="Path to pre-trained model or shortcut name selected in the list: " + ", ".join(ALL_MODELS)) TypeError: sequence item 0: expected str instance, dict found

PS: I have also removed XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig these from ALL_MODELS. Are they mandatory ? Please share if any solutions found...

Did you find a solution?

deeprodge commented 2 years ago

I do get the same error. After running the initial training and using run_generation.py, the result is this:

07/01/2020 06:43:44 - INFO - __main__ -   ***** Eval results  *****
07/01/2020 06:43:44 - INFO - __main__ -     perplexity = tensor(32.7754)
xxx@xx:~/path/to/project/examples$ python3 run_generation.py --model_type gpt2 --model_name_or_path output --length 300 --prompt "Das wichtigste Buch des Jahres"Traceback (most recent call last):
  File "run_generation.py", line 46, in <module>
    ALL_MODELS = sum((tuple(conf.pretrained_config_archive_map.keys()) for conf in (GPT2Config, OpenAIGPTConfig, XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig)), ())
  File "run_generation.py", line 46, in <genexpr>
    ALL_MODELS = sum((tuple(conf.pretrained_config_archive_map.keys()) for conf in (GPT2Config, OpenAIGPTConfig, XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig)), ())
AttributeError: type object 'GPT2Config' has no attribute 'pretrained_config_archive_map'

Did you find a solution @Dipeshpal?

I do get the same error. After running the initial training and using run_generation.py, the result is this:

07/01/2020 06:43:44 - INFO - __main__ -   ***** Eval results  *****
07/01/2020 06:43:44 - INFO - __main__ -     perplexity = tensor(32.7754)
xxx@xx:~/path/to/project/examples$ python3 run_generation.py --model_type gpt2 --model_name_or_path output --length 300 --prompt "Das wichtigste Buch des Jahres"Traceback (most recent call last):
  File "run_generation.py", line 46, in <module>
    ALL_MODELS = sum((tuple(conf.pretrained_config_archive_map.keys()) for conf in (GPT2Config, OpenAIGPTConfig, XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig)), ())
  File "run_generation.py", line 46, in <genexpr>
    ALL_MODELS = sum((tuple(conf.pretrained_config_archive_map.keys()) for conf in (GPT2Config, OpenAIGPTConfig, XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig)), ())
AttributeError: type object 'GPT2Config' has no attribute 'pretrained_config_archive_map'

Did you find a solution @Dipeshpal?

No, if you have something please share.

Hi @Dipeshpal.. I also faced the same issue, Here's what I found : https://forum.rasa.com/t/rasa-nlu-paraphrasing/30128 . Follow the link, seems like there is some change in hugging-face transformers code. However after changing that piece of code(Line 47 in run_generation.py according to the above link), I am getting the following error: Traceback (most recent call last): File "run_generation.py", line 261, in main() File "run_generation.py", line 161, in main help="Path to pre-trained model or shortcut name selected in the list: " + ", ".join(ALL_MODELS)) TypeError: sequence item 0: expected str instance, dict found

PS: I have also removed XLNetConfig, TransfoXLConfig, XLMConfig, CTRLConfig these from ALL_MODELS. Are they mandatory ? Please share if any solutions found...

Hey @nikhila99 , Did you get the solution?

tburcham commented 2 years ago

A quick fix for this is simply to comment out the ALL_MODELS line, and then change:

parser.add_argument("--model_name_or_path", default=None, type=str, required=True,
                        help="Path to pre-trained model or shortcut name selected in the list: " + ", ".join(ALL_MODELS))

to something like

parser.add_argument("--model_name_or_path", default=None, type=str, required=True,
                        help="Path to pre-trained model or shortcut name")

As far as I can tell, HuggingFace doesn't expose a list of available pre-trained models anymore (at least couldn't find it in documentation), and the help text on --model_name_or_path is the only dependency on the line that's failing.