Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot import name 'RobertaForQuestionAnswering' from 'pytorch_transformers' #11

Open
moh-yani opened this issue Jan 7, 2021 · 1 comment

Comments

@moh-yani
Copy link

moh-yani commented Jan 7, 2021

Dear,

I have followed the instruction on your site https://github.com/facebookresearch/UnsupervisedDecomposition till the step below:
# Answer sub-Qs DATA_FOLDER=data/hotpot.umt.all.model=$MODEL_NO.st=$ST.beam=$BEAM.lp=$LP.seed=$SEED for SPLIT in "dev" "train"; do for NUM_PARAGRAPHS in 1 3; do # For fp16: Add "--fp16 --fp16_opt_level O2" below python examples/run_squad.py --model_type roberta --model_name_or_path roberta-large --train_file $DATA_FOLDER/train.json --predict_file $DATA_FOLDER/$SPLIT.json --do_eval --do_lower_case --version_2_with_negative --output_dir checkpoint/roberta_large.hotpot_easy_and_squad.num_paragraphs=$NUM_PARAGRAPHS --per_gpu_train_batch_size 64 --per_gpu_eval_batch_size 32 --learning_rate 1.5e-5 --max_query_length 234 --max_seq_length 512 --doc_stride 50 --num_shards 1 --seed 0 --max_grad_norm inf --adam_epsilon 1e-6 --adam_beta_2 0.98 --weight_decay 0.01 --warmup_proportion 0.06 --num_train_epochs 2 --write_dir $DATA_FOLDER/roberta_predict.np=$NUM_PARAGRAPHS --no_answer_file done done

I have installed the Pytorch-transformers by:
pip install pytorch-transformers

However, I found an error:
cannot import name 'RobertaForQuestionAnswering' from 'pytorch_transformers'

Any idea for this?

Regards,

Mohammad Yani

@ethanjperez
Copy link
Contributor

ethanjperez commented Mar 23, 2021

Hi Mohammad, you'll need to install our specific version of pytorch-transformers (located in this repo here), by installing from source. For example:

cd $MAIN_DIR/pytorch_transformers
pip install --editable .

That should fix the issue. Please let me know if it doesn't work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants