File size: 5,938 Bytes
fe4d5d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253b242
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
---
dataset_info:
  features:
  - name: pubid
    dtype: string
  - name: question
    dtype: string
  - name: contexts_labels
    list: string
  - name: contexts
    list: string
  - name: long_answer
    dtype: string
  - name: tags
    list: string
  - name: final_decision
    dtype: string
  splits:
  - name: pqaa
    num_bytes: 445181053
    num_examples: 211269
  - name: pqal
    num_bytes: 2060110
    num_examples: 1000
  - name: test
    num_bytes: 1034634
    num_examples: 500
  download_size: 234895703
  dataset_size: 448275797
configs:
- config_name: default
  data_files:
  - split: pqaa
    path: data/pqaa-*
  - split: pqal
    path: data/pqal-*
  - split: test
    path: data/test-*
---


# pubmedqa 

PubmedQA dataset derived from the files contained or linked in the official pubmedqa repo:
https://github.com/pubmedqa/pubmedqa


# Dataset Explanation 
(modified from https://huggingface.co/datasets/bigbio/pubmed_qa)

PubMedQA is a biomedical question answering (QA) dataset collected from PubMed abstracts. The task of PubMedQA is to answer research biomedical questions with yes/no/maybe using the corresponding abstracts. PubMedQA has 1k expert-annotated (PQA-L), 61.2k unlabeled (PQA-U) and 211.3k artificially generated QA instances (PQA-A).

Each PubMedQA instance is composed of: (1) a question which is either an existing research article title or derived from one, (2) a context which is the corresponding PubMed abstract without its conclusion, (3) a long answer, which is the conclusion of the abstract and, presumably, answers the research question, and (4) a yes/no/maybe answer which summarizes the conclusion.

PubMedQA is the first QA dataset where reasoning over biomedical research texts, especially their quantitative contents, is required to answer the questions.

The uploaded PubMedQA datasets comprise the following subsets: 
* (1) **PubMedQA Labeled (PQA-L)**: A labeled PubMedQA subset comprises of 1k manually annotated yes/no/maybe QA data collected from PubMed articles.
* (1b) **PubMedQA Test Set**: A 500 item subset of PQA-L used for model evaluation.
* (2) **PubMedQA Artificial (PQA-A)**: An artificially labelled PubMedQA subset comprises of 211.3k PubMed articles with automatically generated questions from the statement titles and yes/no answer labels generated using a simple heuristic.

**TBD: Questions were generated how?**


# Known Limitations

* Ambigious questions
* Abstracts may contian more or less informaiton of the results, and sometimes may even contain the result themselves.
* Scientific studies typically don't result in a perfect yes or no answer.
* Artificially generated content will vary a lot in quality.

# Dataset Example Usage

```python
from datasets import load_dataset
dataset = load_dataset("rschf/pubmedqa", split="test")
```

# Dataset Postprocessing

This dataset is based on the following files contained or linked in the [official pubmedqa repo](https://github.com/pubmedqa/pubmedqa):

* `ori_pqal.json` - human annotated subset
* `ori_pqaa.json` - artificially labeled subset
* `test_groundtruth_json` =r"test_ground_truth.json - pubmedids and human annotation labels for the 500 item subset from pqal used for testing

Code to reproduce the dataset based on those files:

```python
import json
from datasets import Dataset, DatasetDict

def transform_into_ds(data_dict):

    data_list = [
        {
            "pubid": pubid,
            "question": entry["QUESTION"],
            "contexts_labels": entry["LABELS"],
            "contexts": entry["CONTEXTS"],
            "long_answer": entry["LONG_ANSWER"],
            "tags": entry["MESHES"],
            "final_decision": entry["final_decision"],
        }
        for pubid, entry in data_dict.items()
    ]

    return data_list

# from https://github.com/pubmedqa/pubmedqa/tree/master
pqal_json_fn=r"ori_pqal.json" # human annotated subset
pqaa_json_fn=r"ori_pqaa.json" # artificially labeled subset

# pubmedids and human annotation labels for the 500 item subset from pqal used for testing
test_groundtruth_json =r"test_ground_truth.json" 

data_dict_pqal = json.load(open(pqal_json_fn))
data_dict_pqaa = json.load(open(pqaa_json_fn))

test_groundtruth = json.load(open(test_groundtruth_json))

# make sure ground truth agrees
for pubid, groundtruth in test_groundtruth.items():
    assert data_dict_pqal[pubid]["final_decision"] == groundtruth, f"ground truth {groundtruth} does not match final_decision {data_dict_pqal[pubid]["final_decision"]} for pubid {pubid}"


test_pubids = list(test_groundtruth.keys());

data_list_pqaa = transform_into_ds(data_dict_pqaa)
data_list_pqal = transform_into_ds(data_dict_pqal)
data_list_test = transform_into_ds({k:v for k,v in data_dict_pqal.items() if k in test_pubids})

print("pqaa", len(data_list_pqaa), "\t", data_list_pqaa[0].keys())
print("pqal", len(data_list_pqal), "\t", data_list_pqal[0].keys())
print("test", len(data_list_test), "\t", data_list_test[0].keys())
# pqaa 211269 	 dict_keys(['pubid', 'question', 'contexts_labels', 'contexts', 'long_answer', 'tags', 'final_decision'])
# pqal 1000 	 dict_keys(['pubid', 'question', 'contexts_labels', 'contexts', 'long_answer', 'tags', 'final_decision'])
# test 500 	 dict_keys(['pubid', 'question', 'contexts_labels', 'contexts', 'long_answer', 'tags', 'final_decision'])

# 5. Create HF DatasetDict
ds = DatasetDict({
    "pqaa": Dataset.from_list(data_list_pqaa),
    "pqal": Dataset.from_list(data_list_pqal),
    "test": Dataset.from_list(data_list_test)
})

from huggingface_hub import login
login(token="XXX")

# Push to HuggingFace Hub
ds.push_to_hub("rschf/pubmedqa")
```


# Original Publication

```bibtex
@article{jin2019pubmedqa,
  title={Pubmedqa: A dataset for biomedical research question answering},
  author={Jin, Qiao and Dhingra, Bhuwan and Liu, Zhengping and Cohen, William W and Lu, Xinghua},
  journal={arXiv preprint arXiv:1909.06146},
  year={2019}
}
```