Iker commited on
Commit
a9d4c58
1 Parent(s): 16bc651

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +97 -4
README.md CHANGED
@@ -75,7 +75,6 @@ Que los estudiantes vuelven a clase.
75
 
76
 
77
  # Data explanation
78
-
79
  - **web_url** (int): The URL of the news article
80
  - **web_headline** (str): The headline of the article, which is a Clickbait.
81
  - **web_text** (int): The body of the article.
@@ -83,11 +82,107 @@ Que los estudiantes vuelven a clase.
83
  - **summary** (str): The summary written by humans that answers the clickbait headline.
84
 
85
  # Dataset Description
86
-
87
  - **Curated by:** [Iker García-Ferrero](https://ikergarcia1996.github.io/Iker-Garcia-Ferrero/)
88
  - **Language(s) (NLP):** Spanish
89
  - **License:** apache-2.0
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  # Uses
92
  This dataset is intended to build models tailored for academic research that can extract information from large texts. The objective is to research whether current LLMs, given a question formulated as a Clickbait headline, can locate the answer within the article body and summarize the information in a few words. The dataset also aims to serve as a task to evaluate the performance of current LLMs in Spanish.
93
 
@@ -95,13 +190,11 @@ This dataset is intended to build models tailored for academic research that can
95
  You cannot use this dataset to develop systems that directly harm the newspapers included in the dataset. This includes using the dataset to train profit-oriented LLMs capable of generating articles from a short text or headline, as well as developing profit-oriented bots that automatically summarize articles without the permission of the article's owner. Additionally, you are not permitted to train a system with this dataset that generates clickbait headlines.
96
 
97
  # Dataset Creation
98
-
99
  The dataset has been meticulously created by hand. We utilize two sources to compile Clickbait articles:
100
  - The Twitter user [@ahorrandoclick1](https://twitter.com/ahorrandoclick1), who reposts Clickbait articles along with a hand-crafted summary. Although we use their summaries as a reference, most of them have been rewritten (750 examples from this source).
101
  - The web demo [⚔️ClickbaitFighter⚔️](https://iker-clickbaitfighter.hf.space/), which operates a pre-trained model using an early iteration of our dataset. We collect all the model inputs/outputs and manually correct them (100 examples from this source).
102
 
103
  # Who are the annotators?
104
-
105
  The dataset was annotated by [Iker García-Ferrero](https://ikergarcia1996.github.io/Iker-Garcia-Ferrero/) and validated by .
106
  The annotation took ~40 hours.
107
 
 
75
 
76
 
77
  # Data explanation
 
78
  - **web_url** (int): The URL of the news article
79
  - **web_headline** (str): The headline of the article, which is a Clickbait.
80
  - **web_text** (int): The body of the article.
 
82
  - **summary** (str): The summary written by humans that answers the clickbait headline.
83
 
84
  # Dataset Description
 
85
  - **Curated by:** [Iker García-Ferrero](https://ikergarcia1996.github.io/Iker-Garcia-Ferrero/)
86
  - **Language(s) (NLP):** Spanish
87
  - **License:** apache-2.0
88
 
89
+ # Dataset Usage
90
+
91
+ 1. The easiest way to evaluate an LLM with this dataset if using the Language Model Evaluation Harness library: https://github.com/EleutherAI/lm-evaluation-harness
92
+
93
+ ```bash
94
+ ```
95
+
96
+ 2. If you want to train an LLM or reproduce the results in our paper, you can use our code. See the repository for more info: [https://github.com/ikergarcia1996/NoticIA](https://github.com/ikergarcia1996/NoticIA)
97
+
98
+ 3. If you want to manually load the dataset and run inference with an LLM:
99
+ You can load the dataset with the following command:
100
+ ```Python
101
+ from datasets import load_dataset
102
+ dataset = load_dataset("Iker/NoticIA")
103
+ ```
104
+
105
+ In order to perform inference with LLMs, you need to build a prompt. The one we use in our paper is:
106
+ ```Python
107
+ def clickbait_prompt(
108
+ headline: str,
109
+ body: str,
110
+ ) -> str:
111
+ """
112
+ Generate the prompt for the model.
113
+ Args:
114
+ headline (`str`):
115
+ The headline of the article.
116
+ body (`str`):
117
+ The body of the article.
118
+ Returns:
119
+ `str`: The formatted prompt.
120
+ """
121
+ return (
122
+ f"Ahora eres una Inteligencia Artificial experta en desmontar titulares sensacionalistas o clickbait. "
123
+ f"Tu tarea consiste en analizar noticias con titulares sensacionalistas y "
124
+ f"generar un resumen de una sola frase que revele la verdad detrás del titular.\n"
125
+ f"Este es el titular de la noticia: {headline}\n"
126
+ f"El titular plantea una pregunta o proporciona información incompleta. "
127
+ f"Debes buscar en el cuerpo de la noticia una frase que responda lo que se sugiere en el título. "
128
+ f"Responde siempre que puedas parafraseando el texto original. "
129
+ f"Usa siempre las mínimas palabras posibles. "
130
+ f"Recuerda responder siempre en Español.\n"
131
+ f"Este es el cuerpo de la noticia:\n"
132
+ f"{body}\n"
133
+ )
134
+ ```
135
+
136
+ Here is a practical end-to-end example using the text generation pipeline.
137
+ ```python
138
+ from transformers import pipeline
139
+ from datasets import load_dataset
140
+
141
+ generator = pipeline(model="google/gemma-2b-it",device_map="auto")
142
+ dataset = load_dataset("Iker/NoticIA")
143
+
144
+ example = dataset["test"][0]
145
+ prompt = clickbait_prompt(headline=example["web_headline"],body=example["web_text"])
146
+ outputs = generator(prompt, return_full_text=False,max_length=4096)
147
+ print(outputs)
148
+
149
+ # [{'generated_text': 'La tuitera ha recibido un número considerable de comentarios y mensajes de apoyo.'}]
150
+ ```
151
+
152
+ Here is a practical end-to-end example using the generate function
153
+ ```python
154
+ from transformers import AutoTokenizer, AutoModelForCausalLM
155
+ from datasets import load_dataset
156
+
157
+ tokenizer = AutoTokenizer.from_pretrained("google/gemma-2b-it")
158
+ model = AutoModelForCausalLM.from_pretrained("google/gemma-2b-it",device_map="auto",quantization_config={"load_in_4bit": True})
159
+ dataset = load_dataset("Iker/NoticIA")
160
+
161
+ example = dataset["test"][0]
162
+ prompt = clickbait_prompt(headline=example["web_headline"],body=example["web_text"])
163
+ prompt = tokenizer.apply_chat_template(
164
+ [{"role": "user", "content": prompt}],
165
+ tokenize=False,
166
+ add_generation_prompt=True,
167
+ )
168
+ model_inputs = tokenizer(
169
+ text=prompt,
170
+ max_length=3096,
171
+ truncation=True,
172
+ padding=False,
173
+ return_tensors="pt",
174
+ add_special_tokens=False,
175
+ )
176
+
177
+ outputs = model.generate(**model_inputs,max_length=4096)
178
+ output_text = tokenizer.batch_decode(outputs)
179
+
180
+ print(output_text[0])
181
+
182
+ # La usuaria ha comprado un abrigo para su abuela de 97 años, pero la "yaya" no está de acuerdo.
183
+ ```
184
+
185
+
186
  # Uses
187
  This dataset is intended to build models tailored for academic research that can extract information from large texts. The objective is to research whether current LLMs, given a question formulated as a Clickbait headline, can locate the answer within the article body and summarize the information in a few words. The dataset also aims to serve as a task to evaluate the performance of current LLMs in Spanish.
188
 
 
190
  You cannot use this dataset to develop systems that directly harm the newspapers included in the dataset. This includes using the dataset to train profit-oriented LLMs capable of generating articles from a short text or headline, as well as developing profit-oriented bots that automatically summarize articles without the permission of the article's owner. Additionally, you are not permitted to train a system with this dataset that generates clickbait headlines.
191
 
192
  # Dataset Creation
 
193
  The dataset has been meticulously created by hand. We utilize two sources to compile Clickbait articles:
194
  - The Twitter user [@ahorrandoclick1](https://twitter.com/ahorrandoclick1), who reposts Clickbait articles along with a hand-crafted summary. Although we use their summaries as a reference, most of them have been rewritten (750 examples from this source).
195
  - The web demo [⚔️ClickbaitFighter⚔️](https://iker-clickbaitfighter.hf.space/), which operates a pre-trained model using an early iteration of our dataset. We collect all the model inputs/outputs and manually correct them (100 examples from this source).
196
 
197
  # Who are the annotators?
 
198
  The dataset was annotated by [Iker García-Ferrero](https://ikergarcia1996.github.io/Iker-Garcia-Ferrero/) and validated by .
199
  The annotation took ~40 hours.
200