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

Trainer evaluation doesn't return eval loss for question-answering. #5104

Closed
avacaondata opened this issue Jun 18, 2020 · 6 comments
Closed
Labels

Comments

@avacaondata
Copy link

avacaondata commented Jun 18, 2020

As mentioned in this issue:
"""
Just a note that I tried python run_squad_trainer.py --model_name_or_path bert-base-uncased --model_type bert --data_dir squad --output_dir /tmp/debug_squad/ --overwrite_output_dir --do_train --do_eval --evaluate_during_training --logging_steps 100.

For some reason I don't get any evaluation metric during training (I was expecting loss or eval_loss).

Originally posted by @borisdayma in #4829 (comment)
"""
I'm facing the same problem. I'm trying to train with Trainer class over a QA dataset different from SQUAD. Everything works fine, the model learns based on train loss. However, I haven't been able to get the eval loss. I hope these pieces of code show how I'm configuring Trainer. Can somebody tell me if I'm doing something wrong?

training_args = TrainingArguments(
    output_dir="./models/prueba_2",  
    per_gpu_train_batch_size=16,
    per_gpu_eval_batch_size=32,  
    num_train_epochs=10, 
    logging_steps=10,  
    save_steps=25, 
    do_eval=True,
    evaluate_during_training=True,
)

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=train_dataset,
    eval_dataset=eval_dataset,
    data_collator=collator,
    prediction_loss_only=True,
    compute_metrics = EvalPrediction
)

I also tried without EvalPrediction in compute_metrics.
Thanks in advance !

@avacaondata
Copy link
Author

I solved it editing trainer.py, in this line https://github.com/huggingface/transformers/blob/master/src/transformers/trainer.py#L765 . I added start_positions and end_positions to that "possible labels names" list, and it worked. Review the bug, please.

@patil-suraj
Copy link
Contributor

Thanks @alexvaca0 !

cc @julien-c , @sgugger

@stale
Copy link

stale bot commented Aug 18, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Aug 18, 2020
@stale stale bot closed this as completed Aug 27, 2020
@gungor2
Copy link

gungor2 commented Sep 16, 2020

I solved it editing trainer.py, in this line https://github.com/huggingface/transformers/blob/master/src/transformers/trainer.py#L765 . I added start_positions and end_positions to that "possible labels names" list, and it worked. Review the bug, please.

I am having the same issue. Can you elaborate on how you solved this problem? I could not locate a possible label list and start/end positions?

@sgugger
Copy link
Collaborator

sgugger commented Sep 17, 2020

#7191 should solve the problem described here.

@mamoon115
Copy link

@sgugger How can we calculate validation and evaluation loss for question answering finetuning pipeline (run_qa.py)

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

No branches or pull requests

5 participants