hi @lewtun
So here is the data that I want to squadify (as per squad 2), https://raw.githubusercontent.com/deepset-ai/COVID-QA/master/data/question-answering/200423_covidQA.json
I run the same program as you did above but since there are no titles in this dataset, so I just appended to make it fine for the squad format.
import json
from datasets import load_dataset

input_filename = "/content/drive/COVID-QA.json"
output_filename = "dev.json"

with open(input_filename) as f:
    dataset = json.load(f)

with open(output_filename, "w") as f:
    for article in dataset["data"]:
        #title = article["title"]
        title = "title" #this covid json file has no title but Squad 2.0 requires title, so I put fake one
        for paragraph in article["paragraphs"]:
            context = paragraph["context"]
            answers = {}
            for qa in paragraph["qas"]:
                question = qa["question"]
                idx = qa["id"]
                answers["text"] = [a["text"] for a in qa["answers"]]
                answers["answer_start"] = [a["answer_start"] for a in qa["answers"]]
                f.write(
                    json.dumps(
                        {
                            "id": idx,
                            "title": title,
                            "context": context,
                            "question": question,
                            "answers": answers,
                        }
                    )
                )
                f.write("\n")

ds = load_dataset("json", data_files=output_filename)

but when I try to open it simply using a python json.loads function, it shows me above error. I also run this code, same error
from transformers import squad_convert_examples_to_features
from transformers.data.processors.squad import SquadV2Processor
processor = SquadV2Processor()
examples = processor.get_dev_examples('/content/')
features, dataset = squad_convert_examples_to_features(
    examples=examples,
    tokenizer=tokenizer,
    max_seq_length=512,
    doc_stride = 128,
    max_query_length=256,
    is_training=False,
    return_dataset='pt',
    threads=4, # number of CPU cores to use
)

I also run this command but same error

python run_squad.py  \
--model_type 'roberta-base-squad2-covid'   \

--model_name_or_path 'deepset/roberta-base-squad2-covid'  \

--output_dir models/bert/ \

--overwrite_output_dir \

--overwrite_cache \

--do_lower_case  \

--do_eval   \


    --predict_file dev-v2.0.json   \

    --per_gpu_train_batch_size 2   \

    --learning_rate 3e-5   \

    --num_train_epochs 2.0   \

    --max_seq_length 384   \

    --doc_stride 128   \

    --threads 10   \

    --save_steps 5000

the error is in all methods

image995×477 47.7 KB

is it format issue?