mapama247 commited on
Commit
5b1b3c1
1 Parent(s): 5fe44a1

init commit

Browse files
Files changed (4) hide show
  1. .gitattributes +1 -0
  2. README.md +172 -0
  3. wikihow_es.jsonl +3 -0
  4. wikihow_es.py +114 -0
.gitattributes CHANGED
@@ -53,3 +53,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
53
  *.jpg filter=lfs diff=lfs merge=lfs -text
54
  *.jpeg filter=lfs diff=lfs merge=lfs -text
55
  *.webp filter=lfs diff=lfs merge=lfs -text
 
 
53
  *.jpg filter=lfs diff=lfs merge=lfs -text
54
  *.jpeg filter=lfs diff=lfs merge=lfs -text
55
  *.webp filter=lfs diff=lfs merge=lfs -text
56
+ *.jsonl filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,175 @@
1
  ---
 
2
  license: cc-by-nc-sa-3.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ pretty_name: WikiHow-ES
3
  license: cc-by-nc-sa-3.0
4
+ size_categories: 1K<n<10K
5
+ language: es
6
+ multilinguality: monolingual
7
+ task_categories:
8
+ - text-classification
9
+ - question-answering
10
+ - conversational
11
+ - summarization
12
+ tags:
13
+ - Spanish
14
+ - WikiHow
15
+ - Wiki Articles
16
+ - Tutorials
17
+ - Step-By-Step
18
+ - Instruction Tuning
19
  ---
20
+
21
+ ### Dataset Summary
22
+
23
+ Articles retrieved from the [Spanish WikiHow website](https://es.wikihow.com) on September 2023.
24
+
25
+ Each article contains a tutorial about a specific topic. The format is always a "How to" question
26
+ followed by a detailed step-by-step explanation. In some cases, the response includes several methods.
27
+
28
+ The main idea is to use this data for instruction tuning of Spanish LLMs, but given its nature it
29
+ could also be used for other tasks such as text classification or summarization.
30
+
31
+ ### Languages
32
+
33
+ - Spanish (ES)
34
+
35
+ ### Usage
36
+
37
+ To load the full dataset:
38
+ ```python
39
+ from datasets import load_dataset
40
+
41
+ all_articles = load_dataset("mapama247/wikihow_es")
42
+ print(all_articles.num_rows) # output: {'train': 7380}
43
+ ```
44
+
45
+ To load only examples from a specific category:
46
+ ```python
47
+ from datasets import load_dataset
48
+
49
+ sports_articles = load_dataset("mapama247/wikihow_es", "deportes")
50
+ print(sports_articles.num_rows) # output: {'train': 201}
51
+ ```
52
+
53
+ List of available categories, with the repective number of examples:
54
+ ```
55
+ computadoras-y-electrónica 821
56
+ salud 804
57
+ pasatiempos 729
58
+ cuidado-y-estilo-personal 724
59
+ carreras-y-educación 564
60
+ en-la-casa-y-el-jardín 496
61
+ finanzas-y-negocios 459
62
+ comida-y-diversión 454
63
+ relaciones 388
64
+ mascotas-y-animales 338
65
+ filosofía-y-religión 264
66
+ arte-y-entretenimiento 254
67
+ en-el-trabajo 211
68
+ adolescentes 201
69
+ deportes 201
70
+ vida-familiar 147
71
+ viajes 139
72
+ automóviles-y-otros-vehículos 100
73
+ días-de-fiesta-y-tradiciones 86
74
+ ```
75
+
76
+ ### Supported Tasks
77
+
78
+ This dataset can be used to train a model for...
79
+
80
+ - `instruction-tuning`
81
+ - `text-classification`
82
+ - `question-answering`
83
+ - `conversational`
84
+ - `summarization`
85
+
86
+ ## Dataset Structure
87
+
88
+ ### Data Instances
89
+
90
+ ```python
91
+ {
92
+ 'category': str,
93
+ 'question': str,
94
+ 'introduction': str,
95
+ 'answers': List[str],
96
+ 'short_answers': List[str],
97
+ 'url': str,
98
+ 'num_answers': int,
99
+ 'num_refs': int,
100
+ 'expert_author': bool,
101
+ }
102
+ ```
103
+
104
+ ### Data Fields
105
+
106
+ - `category`: The category (from [this list](https://es.wikihow.com/Especial:CategoryListing)) to which the example belongs to.
107
+ - `label`: Numerical representation of the category, for text classification purposes.
108
+ - `question`: The article's title, which always starts with "¿Cómo ...".
109
+ - `introduction`: Introductory text that precedes the step-by-step explanation.
110
+ - `answers`: List of complete answers, with the full explanation of each step.
111
+ - `short_answers`: List of shorter answers that only contain one-sentence steps.
112
+ - `num_answers`: The number of alternative answers provided (e.g. length of `answers`).
113
+ - `num_ref`: Number of references provided in the article.
114
+ - `expert_authors`: Whether the article's author claims to be an expert on the topic or not.
115
+ - `url`: The URL address of the original article.
116
+
117
+ ### Data Splits
118
+
119
+ There is only one split (`train`) that contains a total of 7,380 examples.
120
+
121
+ ## Dataset Creation
122
+
123
+ ### Curation Rationale
124
+
125
+ This dataset was created for language model alignment to end tasks and user preferences.
126
+
127
+ ### Source Data
128
+
129
+ How-To questions with detailed step-by-step answers, retrieved from the WikiHow website.
130
+
131
+ #### Data Collection and Normalization
132
+
133
+ All articles available in September 2023 were extracted, no filters applied.
134
+
135
+ Along with the article's content, some metadata was retrieved as well.
136
+
137
+ #### Source language producers
138
+
139
+ WikiHow users. All the content is human-generated.
140
+
141
+ ### Personal and Sensitive Information
142
+
143
+ The data does not include personal or sensitive information.
144
+
145
+ ## Considerations
146
+
147
+ ### Social Impact
148
+
149
+ The Spanish community can benefit from the high-quality data provided by this dataset.
150
+
151
+ ### Bias
152
+
153
+ No post-processing steps have been applied to mitigate potential social biases.
154
+
155
+ ## Additional Information
156
+
157
+ ### Curators
158
+
159
+ Marc Pàmes @ Barcelona Supercomputing Center.
160
+
161
+ ### License
162
+
163
+ This dataset is licensed under a **Creative Commons CC BY-NC-SA 3.0** license.
164
+
165
+ Quote from [WikiHow's Terms of Use](https://www.wikihow.com/wikiHow:Terms-of-Use):
166
+
167
+ > All text posted by Users to the Service is sub-licensed by wikiHow to other Users under a Creative Commons license as
168
+ > provided herein. The Creative Commons license allows such user generated text content to be used freely for personal,
169
+ > non-commercial purposes, so long as it is used and attributed to the original author as specified under the terms of
170
+ > the license. Allowing free republication of our articles helps wikiHow achieve its mission by providing instruction
171
+ > on solving the problems of everyday life to more people for free. In order to support this goal, wikiHow hereby grants
172
+ > each User of the Service a license to all text content that Users contribute to the Service under the terms and
173
+ > conditions of a Creative Commons CC BY-NC-SA 3.0 License. Please be sure to read the terms of the license carefully.
174
+ > You continue to own all right, title, and interest in and to your User Content, and you are free to distribute it as
175
+ > you wish, whether for commercial or non-commercial purposes.
wikihow_es.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9d857896c0bff56784249ac4e8e5fcc4ed007739ff74dcb1dce556a3ca8734c4
3
+ size 66088317
wikihow_es.py ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import re
3
+ import csv
4
+ import json
5
+ import datasets
6
+
7
+ _DESCRIPTION = "Spanish articles from WikiHow"
8
+ _HOMEPAGE = "https://www.wikihow.com"
9
+ _LICENSE = "CC BY-NC-SA 3.0"
10
+ _VERSION = "1.1.0"
11
+
12
+ _DATAPATH = "wikihow_es.jsonl"
13
+
14
+ _CATEGORIES = [
15
+ "salud",
16
+ "viajes",
17
+ "deportes",
18
+ "relaciones",
19
+ "pasatiempos",
20
+ "adolescentes",
21
+ "vida-familiar",
22
+ "en-el-trabajo",
23
+ "comida-y-diversión",
24
+ "finanzas-y-negocios",
25
+ "mascotas-y-animales",
26
+ "carreras-y-educación",
27
+ "filosofía-y-religión",
28
+ "arte-y-entretenimiento",
29
+ "en-la-casa-y-el-jardín",
30
+ "cuidado-y-estilo-personal",
31
+ "computadoras-y-electrónica",
32
+ "días-de-fiesta-y-tradiciones",
33
+ "automóviles-y-otros-vehículos",
34
+ ]
35
+
36
+ def format_methods(methods, short=False):
37
+ EOL = "\n" if short else "\n\n"
38
+ formatted = []
39
+ for method in methods:
40
+ if method["title"].lower() != "pasos":
41
+ content = f"Método {method['number']}: {method['title']}{EOL}"
42
+ else:
43
+ content = f"Sigue los siguientes pasos:{EOL}"
44
+ for step in method["steps"]:
45
+ step_content = re.sub(r"\n+", "\n", step).strip()
46
+ if short:
47
+ step_content = step_content.split("\n")[0]
48
+ content += step_content + EOL
49
+ formatted.append(content.strip())
50
+ return formatted
51
+
52
+
53
+ class WikiHowEs(datasets.GeneratorBasedBuilder):
54
+ """ WikiHowEs: Collection of Spanish tutorials. """
55
+
56
+ VERSION = datasets.Version(_VERSION)
57
+
58
+ DEFAULT_CONFIG_NAME = "all"
59
+ BUILDER_CONFIGS = [datasets.BuilderConfig(name="all", version=VERSION, description="All articles from WikiHow-ES.")]
60
+ for _CAT in _CATEGORIES:
61
+ BUILDER_CONFIGS.append(
62
+ datasets.BuilderConfig(name=_CAT, version=VERSION, description=f"Articles from the category {_CAT}")
63
+ )
64
+
65
+ @staticmethod
66
+ def _info():
67
+ features = datasets.Features(
68
+ {
69
+ "category": datasets.Value("string"),
70
+ "question": datasets.Value("string"),
71
+ "introduction": datasets.Value("string"),
72
+ "answers": datasets.features.Sequence(datasets.Value("string")),
73
+ "short_answers": datasets.features.Sequence(datasets.Value("string")),
74
+ "url": datasets.Value("string"),
75
+ "num_answers": datasets.Value("int32"),
76
+ "num_refs": datasets.Value("int32"),
77
+ "expert_author": datasets.Value("bool"),
78
+ }
79
+ )
80
+ return datasets.DatasetInfo(
81
+ description=_DESCRIPTION,
82
+ features=features,
83
+ homepage=_HOMEPAGE,
84
+ license=_LICENSE,
85
+ )
86
+
87
+ @staticmethod
88
+ def _split_generators(dl_manager):
89
+ data_dir = dl_manager.download_and_extract(_DATAPATH)
90
+ return [
91
+ datasets.SplitGenerator(
92
+ name=datasets.Split.TRAIN,
93
+ gen_kwargs={
94
+ "filepath": data_dir,
95
+ },
96
+ ),
97
+ ]
98
+
99
+ def _generate_examples(self, filepath):
100
+ with open(filepath, encoding="utf-8") as f:
101
+ for key, row in enumerate(f):
102
+ data = json.loads(row)
103
+ if self.config.name in ["all", data["category"].lower()]:
104
+ yield key, {
105
+ "category": data["category"],
106
+ "question": f"¿{data['title']}?",
107
+ "introduction": data["intro"],
108
+ "answers": format_methods(data["methods"], short=False),
109
+ "short_answers": format_methods(data["methods"], short=True),
110
+ "num_answers": data["num_methods"],
111
+ "num_refs": data["num_refs"],
112
+ "expert_author": data["expert_author"],
113
+ "url": data["url"],
114
+ }