jpcorb20 commited on
Commit
bc4a9b1
1 Parent(s): de0d9e9

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +61 -1
  2. med_topics.csv +0 -0
  3. medwiki_dataset.py +95 -0
README.md CHANGED
@@ -1,3 +1,63 @@
1
  ---
2
- license: cc-by-sa-4.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ dataset_info:
3
+ features:
4
+ - name: title
5
+ dtype: string
6
+ - name: text
7
+ dtype: string
8
+ - name: wiki_id
9
+ dtype: int32
10
+ - name: paragraph_id
11
+ dtype: int32
12
+ - name: topic_infer
13
+ dtype: int64
14
+ - name: prob
15
+ dtype: float64
16
+ splits:
17
+ - name: train
18
+ num_bytes: 565706758
19
+ num_examples: 1139464
20
+ download_size: 0
21
+ dataset_size: 565706758
22
+ configs:
23
+ - config_name: default
24
+ data_files:
25
+ - split: train
26
+ path: data/train-*
27
+ task_categories:
28
+ - text-generation
29
+ language:
30
+ - en
31
+ tags:
32
+ - medical
33
+ pretty_name: w
34
+ size_categories:
35
+ - 1M<n<10M
36
+ license: cc
37
  ---
38
+ # MedWiki from ClinicalCorp
39
+
40
+ This repo generates on-the-fly the filtered version of the `Cohere/wikipedia-22-12` on medical topic articles using `MaartenGr/BERTopic_Wikipedia`.
41
+
42
+ ## Original Dataset
43
+
44
+ https://huggingface.co/datasets/Cohere/wikipedia-22-12
45
+
46
+ ## Topic modelling
47
+
48
+ https://huggingface.co/MaartenGr/BERTopic_Wikipedia
49
+
50
+ Check the `med_topics.csv` in the git repo for more info on which topics where targeted by prompting `GPT3.5-turbo 0613` over word representations of topics. The original topic list can be obtained from the topic model.
51
+
52
+ # LICENSE
53
+
54
+ This dataset is under Wikipedia's licensing which is *CC-BY-SA* : https://creativecommons.org/licenses/by-sa/4.0/ .
55
+
56
+ # Citation
57
+
58
+ @article{corbeil2024iryonlp,
59
+ title={IryoNLP at MEDIQA-CORR 2024: Tackling the Medical Error Detection & Correction Task On the Shoulders of Medical Agents},
60
+ author={Jean-Philippe Corbeil},
61
+ journal={arXiv preprint arXiv:2404.15488},
62
+ year={2024}
63
+ }
med_topics.csv ADDED
The diff for this file is too large to render. See raw diff
 
medwiki_dataset.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """MedWiki."""
15
+
16
+ import os
17
+
18
+ import datasets
19
+ import pandas as pd
20
+
21
+
22
+ _CITATION = """\
23
+ @article{corbeil2024iryonlp,
24
+ title={IryoNLP at MEDIQA-CORR 2024: Tackling the Medical Error Detection & Correction Task On the Shoulders of Medical Agents},
25
+ author={Jean-Philippe Corbeil},
26
+ journal={arXiv preprint arXiv:2404.15488},
27
+ year={2024}
28
+ }
29
+ """
30
+
31
+ _DESCRIPTION = """\
32
+ This is a filtered version of the `Cohere/wikipedia-22-12` on medical topic articles using `MaartenGr/BERTopic_Wikipedia`. Keep note that some articles in the viewer might seem off topic, but usually they are related in some way (e.g. World War I is linked to the Spanish Flu). This is artefacts of some noise in the topic modelling.
33
+ """
34
+ _HOMEPAGE = ""
35
+ _LICENSE = "CC-BY-SA"
36
+ _URLS = {
37
+ "first_domain": "Cohere/wikipedia-22-12",
38
+ }
39
+
40
+
41
+ class MedWikiDataset(datasets.GeneratorBasedBuilder):
42
+ """Medical Wikipedia Articles."""
43
+
44
+ VERSION = datasets.Version("0.0.1")
45
+
46
+ BUILDER_CONFIGS = [
47
+ datasets.BuilderConfig(name="first_domain", version=VERSION, description="This part of my dataset covers a first domain"),
48
+ ]
49
+
50
+ DEFAULT_CONFIG_NAME = "first_domain"
51
+
52
+ def _info(self):
53
+ features = datasets.Features(
54
+ {
55
+ "wiki_id": datasets.Value("int32"),
56
+ "title": datasets.Value("string"),
57
+ "text": datasets.Value("string"),
58
+ "paragraph_id": datasets.Value("int32"),
59
+ }
60
+ )
61
+
62
+ return datasets.DatasetInfo(
63
+ description=_DESCRIPTION,
64
+ features=features,
65
+ homepage=_HOMEPAGE,
66
+ license=_LICENSE,
67
+ citation=_CITATION,
68
+ )
69
+
70
+ def _split_generators(self, dl_manager):
71
+ urls = _URLS[self.config.name]
72
+ dataset = datasets.load_dataset(urls, "en", trust_remote_code=True, cache_dir="/Users/jcorbeil/Documents/datasets/TEMP")
73
+ df = pd.read_csv(os.path.join(self.cache_dir, "med_topics.csv"))
74
+ med_wiki_ids = set(df["wiki_id"].values.tolist())
75
+ return [
76
+ datasets.SplitGenerator(
77
+ name=datasets.Split.TRAIN,
78
+ gen_kwargs={
79
+ "dataset": dataset["train"],
80
+ "med_wiki_ids": med_wiki_ids,
81
+ },
82
+ ),
83
+ ]
84
+
85
+ def _generate_examples(self, dataset, med_wiki_ids):
86
+ count = -1
87
+ for data in dataset:
88
+ if data["wiki_id"] in med_wiki_ids:
89
+ count += 1
90
+ yield count, {
91
+ "wiki_id": data["wiki_id"],
92
+ "title": data["title"],
93
+ "text": data["text"],
94
+ "paragraph_id": data["paragraph_id"],
95
+ }