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

Fix xdoc run squad #1684

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion xdoc/fine_tuning/squad/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
sklearn
transformers==4.23.1
datasets==2.6.1
datasets
evaluate
numpy==1.21.6
torch
IPython
5 changes: 3 additions & 2 deletions xdoc/fine_tuning/squad/run_squad.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from typing import Optional

import datasets
from datasets import load_dataset, load_metric
from datasets import load_dataset
import evaluate

import transformers
from trainer_qa import QuestionAnsweringTrainer
Expand Down Expand Up @@ -571,7 +572,7 @@ def post_processing_function(examples, features, predictions, stage="eval"):
references = [{"id": ex["id"], "answers": ex[answer_column_name]} for ex in examples]
return EvalPrediction(predictions=formatted_predictions, label_ids=references)

metric = load_metric("squad_v2" if data_args.version_2_with_negative else "squad")
metric = evaluate.load("squad_v2" if data_args.version_2_with_negative else "squad")

def compute_metrics(p: EvalPrediction):
return metric.compute(predictions=p.predictions, references=p.label_ids)
Expand Down