Views
No views yet
1python transformers/examples/question-answering/run_squad.py \
2 --model_type roberta \
3 --model_name_or_path 'nyu-mll/roberta-base-1B-1' \
4 --do_eval \
5 --do_train \
6 --do_lower_case \
7 --train_file /content/dataset/train-v1.1.json \
8 --predict_file /content/dataset/dev-v1.1.json \
9 --per_gpu_train_batch_size 16 \
10 --learning_rate 3e-5 \
11 --num_train_epochs 10 \
12 --max_seq_length 384 \
13 --doc_stride 128 \
14 --output_dir /content/output \
15 --overwrite_output_dir \
16 --save_steps 1000| Metric | # Value |
|---|---|
| EM | 72.62 |
| F1 | 82.19 |
1{
2'exact': 72.62062440870388,
3'f1': 82.19430877136834,
4'total': 10570,
5'HasAns_exact': 72.62062440870388,
6'HasAns_f1': 82.19430877136834,
7'HasAns_total': 10570,
8'best_exact': 72.62062440870388,
9'best_exact_thresh': 0.0,
10'best_f1': 82.19430877136834,
11'best_f1_thresh': 0.0
12}
131from transformers import pipeline
2
3QnA_pipeline = pipeline('question-answering', model='mrm8488/roberta-base-1B-1-finetuned-squadv1')
4
5QnA_pipeline({
6 'context': 'A new strain of flu that has the potential to become a pandemic has been identified in China by scientists.',
7 'question': 'What has been discovered by scientists from China ?'
8})
9# Output:
10
11{'answer': 'A new strain of flu', 'end': 19, 'score': 0.04702283976040074, 'start': 0}