aashish1904 commited on
Commit
5a19546
1 Parent(s): 0ca54dc

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +330 -0
README.md ADDED
@@ -0,0 +1,330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ ---
3
+
4
+ base_model: google/gemma-7b
5
+ library_name: transformers
6
+ license: gemma
7
+ pipeline_tag: text-generation
8
+ extra_gated_heading: Access Gemma on Hugging Face
9
+ extra_gated_prompt: To access Gemma on Hugging Face, you’re required to review and
10
+ agree to Google’s usage license. To do this, please ensure you’re logged in to Hugging
11
+ Face and click below. Requests are processed immediately.
12
+ extra_gated_button_content: Acknowledge license
13
+
14
+ ---
15
+
16
+ [![QuantFactory Banner](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeiuCm7c8lEwEJuRey9kiVZsRn2W-b4pWlu3-X534V3YmVuVc2ZL-NXg2RkzSOOS2JXGHutDuyyNAUtdJI65jGTo8jT9Y99tMi4H4MqL44Uc5QKG77B0d6-JfIkZHFaUA71-RtjyYZWVIhqsNZcx8-OMaA?key=xt3VSDoCbmTY7o-cwwOFwQ)](https://hf.co/QuantFactory)
17
+
18
+
19
+ # QuantFactory/gemma-7b-aps-it-GGUF
20
+ This is quantized version of [google/gemma-7b-aps-it](https://huggingface.co/google/gemma-7b-aps-it) created using llama.cpp
21
+
22
+ # Original Model Card
23
+
24
+
25
+ # Gemma Model Card
26
+
27
+ **Model Page**: [Gemma](https://ai.google.dev/gemma/docs)
28
+
29
+ This model card corresponds to the 7B finetuned version of the Gemma-APS model.
30
+ You can also visit the model card of the [2B finetuned model](https://huggingface.co/google/gemma-2b-aps-it).
31
+
32
+ **Resources and Technical Documentation**:
33
+
34
+ * [Scalable and Domain-General Abstractive Proposition Segmentation](https://arxiv.org/abs/2406.19803)
35
+ * [Gemma Technical Report](https://storage.googleapis.com/deepmind-media/gemma/gemma-report.pdf)
36
+ * [Responsible Generative AI Toolkit](https://ai.google.dev/responsible)
37
+ * [Gemma on Kaggle](https://www.kaggle.com/models/google/gemma)
38
+
39
+ **Terms of Use**: [Terms](https://www.kaggle.com/models/google/gemma/license/consent/verify/huggingface?returnModelRepoId=google/gemma-7b-aps-it)
40
+
41
+ **Authors**: Mohammad Javad Hosseini, Yang Gao, Tim Baumgärtner, Alex Fabrikant, Reinald Kim Amplayo
42
+
43
+ ## Model Information
44
+
45
+ Summary description and brief definition of inputs and outputs.
46
+
47
+ ### Description
48
+
49
+ Gemma-APS is a generative model and a research tool for **abstractive proposition segmentation** (APS for short), a.k.a. claim extraction.
50
+ Given a text passage, the model segments the content into the individual facts, statements, and ideas expressed in the text, and restates
51
+ them in full sentences with small changes to the original text.
52
+
53
+ This model can be used for research where there is a need to break down text content into meaningful components. Applications include
54
+ grounding, retrieval, fact-checking, and evaluation of generation tasks (such as summarization) where it can be useful to divide up
55
+ individual propositions (claims) so that they can be processed independently. For more information, check out the [research paper](https://arxiv.org/abs/2406.19803).
56
+
57
+ ### Context Length
58
+
59
+ Models are trained on a context length of 8192 tokens.
60
+
61
+ ### Usage
62
+
63
+ Below we share some code snippets on how to get quickly started with running the model. First make sure to `pip install -U transformers nltk`,
64
+ then copy the snippet from the section that is relevant for your usecase.
65
+
66
+ For ease-of-use, we define two helper functions for pre-processing input and post-processing output of the model:
67
+
68
+ ```py
69
+ import nltk
70
+ import re
71
+
72
+ nltk.download('punkt')
73
+
74
+ start_marker = '<s>'
75
+ end_marker = '</s>'
76
+ separator = '\n'
77
+
78
+ def create_propositions_input(text: str) -> str:
79
+ input_sents = nltk.tokenize.sent_tokenize(text)
80
+ propositions_input = ''
81
+ for sent in input_sents:
82
+ propositions_input += f'{start_marker} ' + sent + f' {end_marker}{separator}'
83
+ propositions_input = propositions_input.strip(f'{separator}')
84
+ return propositions_input
85
+
86
+ def process_propositions_output(text):
87
+ pattern = re.compile(f'{re.escape(start_marker)}(.*?){re.escape(end_marker)}', re.DOTALL)
88
+ output_grouped_strs = re.findall(pattern, text)
89
+ predicted_grouped_propositions = []
90
+ for grouped_str in output_grouped_strs:
91
+ grouped_str = grouped_str.strip(separator)
92
+ props = [x[2:] for x in grouped_str.split(separator)]
93
+ predicted_grouped_propositions.append(props)
94
+ return predicted_grouped_propositions
95
+ ```
96
+
97
+ #### Usage with the `pipeline` API
98
+
99
+ ```py
100
+ from transformers import pipeline
101
+ import torch
102
+
103
+ generator = pipeline('text-generation', 'google/gemma-7b-aps-it', device_map='auto', torch_dtype=torch.bfloat16)
104
+
105
+ passage = 'Sarah Stage, 30, welcomed James Hunter into the world on Tuesday.\nThe baby boy weighed eight pounds seven ounces and was 22 inches long.'
106
+ messages = [{'role': 'user', 'content': create_propositions_input(passage)}]
107
+ output = generator(messages, max_new_tokens=4096, return_full_text=False)
108
+ result = process_propositions_output(output[0]['generated_text'])
109
+ print(result)
110
+ ```
111
+
112
+
113
+ <details>
114
+
115
+ <summary>Example output</summary>
116
+
117
+ ```json
118
+ [
119
+ [
120
+ "Sarah Stage welcomed James Hunter into the world.",
121
+ "Sarah Stage is 30 years old.",
122
+ "James Hunter was welcomed on Tuesday."
123
+ ],
124
+ [
125
+ "James Hunter weighed eight pounds seven ounces.",
126
+ "James Hunter was 22 inches long."
127
+ ]
128
+ ]
129
+ ```
130
+ </details>
131
+
132
+
133
+ #### Usage with `AutoModel` and `AutoTokenizer` APIs
134
+
135
+ ```python
136
+ from transformers import AutoTokenizer, AutoModelForCausalLM
137
+ import torch
138
+
139
+ model_id = 'google/gemma-7b-aps-it'
140
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
141
+ model = AutoModelForCausalLM.from_pretrained(
142
+ model_id,
143
+ device_map='auto',
144
+ torch_dtype=torch.bfloat16,
145
+ )
146
+
147
+ passage = "For more than 40 years, the lyrics of American Pie have been puzzled over. This week the handwritten lyrics sold for more than $1 million at auction. The verses contain hidden references to seminal events of the 50s and 60s. It includes nods to Buddy Holly, Charles Manson and Martin Luther King."
148
+ messages = [{'role': 'user', 'content': create_propositions_input(passage)}]
149
+ inputs = tokenizer.apply_chat_template(messages, return_tensors='pt', add_generation_prompt=True, return_dict=True).to(model.device)
150
+
151
+ output = model.generate(**inputs, max_new_tokens=4096, do_sample=False)
152
+ generated_text = tokenizer.batch_decode(output[:, inputs['input_ids'].shape[1]:], skip_special_tokens=True)[0]
153
+ result = process_propositions_output(generated_text)
154
+ print(result)
155
+ ```
156
+
157
+ <details>
158
+
159
+ <summary>Example output</summary>
160
+
161
+ ```json
162
+ [
163
+ [
164
+ "The lyrics of American Pie have been puzzled over for more than 40 years."
165
+ ],
166
+ [
167
+ "The handwritten lyrics sold for more than $1 million.",
168
+ "The handwritten lyrics sold at auction.",
169
+ "The handwritten lyrics sold this week."
170
+ ],
171
+ [
172
+ "The verses contain hidden references to seminal events of the 50s.",
173
+ "The verses contain hidden references to seminal events of the 60s."
174
+ ],
175
+ [
176
+ "The lyrics include nods to Buddy Holly.",
177
+ "The lyrics include nods to Charles Manson.",
178
+ "The lyrics include nods to Martin Luther King."
179
+ ]
180
+ ]
181
+ ```
182
+
183
+ </details>
184
+
185
+
186
+ ### Inputs and outputs
187
+
188
+ * **Input:** A text passage.
189
+ * **Output:** List of propositions for all the sentences in the text passage. The propositions for each sentence are grouped separately.
190
+
191
+
192
+ ## Model Data
193
+
194
+ Data used for model training and how the data was processed.
195
+
196
+ ### Training Dataset
197
+
198
+ * The training data contains synthetically generated examples, where each example has (input passage, propositions list) pairs, with the
199
+ propositions list containing propositions for all the sentences in the input passage (one group of propositions for each sentence).
200
+ * The input passages are generated by few-shot prompting Gemini Ultra.
201
+ * The propositions list is generated by applying a teacher LLM on the input passage. The teacher LLM is a Gemini Pro model trained on
202
+ a filtered version of the ROSE dataset.
203
+
204
+ See the [research paper](https://arxiv.org/abs/2406.19803) for all the details.
205
+
206
+ ### Data Preprocessing
207
+
208
+ * We filtered example passages that have >=4 tokens overlap with any of the few-shot examples used for prompting Gemini Ultra.
209
+ * We used the ROSE dataset for training the teacher LLM (Gemini Pro). We filtered ROSE examples using an entailment model to remove
210
+ cases that do not satisfy desired properties of propositions.
211
+
212
+
213
+ ## Implementation Information
214
+
215
+ Details about the model internals.
216
+
217
+ ### Hardware
218
+
219
+ Similar to Gemma, Gemma-APS was trained on [TPUv5e](https://cloud.google.com/tpu/docs/intro-to-tpu?_gl=1*18wi411*_ga*MzE3NDU5OTY1LjE2MzQwNDA4NDY.*_ga_WH2QY8WWF5*MTcxMTA0MjUxMy4xNy4wLjE3MTEwNDI1MTkuMC4wLjA.&_ga=2.239449409.-317459965.1634040846).
220
+
221
+ Training large language models requires significant computational power. TPUs, designed specifically for matrix operations common in machine learning, offer several advantages in this domain:
222
+
223
+ Performance: TPUs are specifically designed to handle the massive computations involved in training LLMs. They can speed up training considerably compared to CPUs.
224
+ Memory: TPUs often come with large amounts of high-bandwidth memory, allowing for the handling of large models and batch sizes during training. This can lead to better model quality.
225
+ Scalability: TPU Pods (large clusters of TPUs) provide a scalable solution for handling the growing complexity of large foundation models. You can distribute training across multiple TPU devices for faster and more efficient processing.
226
+ Cost-effectiveness: In many scenarios, TPUs can provide a more cost-effective solution for training large models compared to CPU-based infrastructure, especially when considering the time and resources saved due to faster training.
227
+ These advantages are aligned with [Google's commitments to operate sustainably](https://sustainability.google/operating-sustainably/).
228
+
229
+ ### Software
230
+
231
+ Training was done using [JAX](https://github.com/jax-ml/jax).
232
+
233
+ JAX allows researchers to leverage the latest generation of hardware, including TPUs, for faster and more efficient training of large models.
234
+
235
+
236
+ ## Evaluation
237
+
238
+ Model evaluation metrics and results.
239
+
240
+ ### Benchmark Results
241
+
242
+ Evaluation was done on one existing in-domain dataset (development set of the [ROSE](https://github.com/Yale-LILY/ROSE) dataset filtered by an entailment model) and two out-of-domain datasets introduced in the paper. Evaluation was performed based on our new metrics for the abstractive proposition segmentation task.
243
+
244
+
245
+ ## Ethics and Safety
246
+
247
+ Ethics and safety evaluation approach and results.
248
+
249
+ ### Evaluation Approach
250
+
251
+ These models are only suitable for abstractive proposition segmentation for English text, not any other task or language. While we have tested the models on three evaluation datasets and have obtained positive results compared to strong baselines, the model might still have errors on some examples.
252
+
253
+
254
+ ## Usage and Limitations
255
+
256
+ These models have certain limitations that users should be aware of.
257
+
258
+ ### Intended Usage
259
+
260
+ These models are only suitable for abstractive proposition segmentation for English text, not any other task or language.
261
+ While we have tested it on three evaluation datasets and have obtained positive results compared to strong baselines,
262
+ the models might still have errors on some examples.
263
+
264
+ ### Limitations
265
+
266
+ These models have certain limitations that users should be aware of.
267
+
268
+ * Training Data
269
+ * The quality and diversity of the training data significantly influence the
270
+ model's capabilities. Biases or gaps in the training data can lead to
271
+ limitations in the model's responses.
272
+ * The scope of the training dataset determines the subject areas the model can
273
+ handle effectively.
274
+ * We have tested our models on passages from different domains, where passages
275
+ contain a few sentences.
276
+ * This model supports abstractive proposition segmentation in English, not any
277
+ other language.
278
+ * Language Ambiguity and Nuance
279
+ * Natural language is inherently complex. LLMs might struggle to grasp subtle
280
+ nuances, sarcasm, or figurative language.
281
+ * Factual Accuracy
282
+ * LLMs generate responses based on information they learned from their
283
+ training datasets, but they are not knowledge bases. They may generate
284
+ incorrect or outdated factual statements.
285
+ * Common Sense
286
+ * LLMs rely on statistical patterns in language. They might lack the ability
287
+ to apply common sense reasoning in certain situations.
288
+
289
+ ### Ethical Considerations and Risks
290
+
291
+ The development of large language models (LLMs) raises several ethical concerns.
292
+ In creating an open model, we have carefully considered the following:
293
+
294
+ * Bias and Fairness
295
+ * LLMs trained on large-scale, real-world text data can reflect socio-cultural
296
+ biases embedded in the training material. These models underwent careful
297
+ scrutiny, input data pre-processing described and posterior evaluations
298
+ reported in this card.
299
+ * Misinformation and Misuse
300
+ * LLMs can be misused to generate text that is false, misleading, or harmful.
301
+ * Guidelines are provided for responsible use with the model, see the
302
+ [Responsible Generative AI Toolkit](http://ai.google.dev/gemma/responsible).
303
+ * Transparency and Accountability:
304
+ * This model card summarizes details on the models' architecture,
305
+ capabilities, limitations, and evaluation processes.
306
+ * A responsibly developed open model offers the opportunity to share
307
+ innovation by making LLM technology accessible to developers and researchers
308
+ across the AI ecosystem.
309
+
310
+ Risks identified and mitigations:
311
+
312
+ * Perpetuation of biases: It's encouraged to perform continuous monitoring
313
+ (using evaluation metrics, human review) and the exploration of de-biasing
314
+ techniques during model training, fine-tuning, and other use cases.
315
+ * Generation of harmful content: Mechanisms and guidelines for content safety
316
+ are essential. Developers are encouraged to exercise caution and implement
317
+ appropriate content safety safeguards based on their specific product policies
318
+ and application use cases.
319
+ * Misuse for malicious purposes: Technical limitations and developer and
320
+ end-user education can help mitigate against malicious applications of LLMs.
321
+ Educational resources and reporting mechanisms for users to flag misuse are
322
+ provided. Prohibited uses of Gemma models are outlined in the
323
+ [Gemma Prohibited Use Policy](https://ai.google.dev/gemma/prohibited_use_policy).
324
+ * Privacy violations: Models were trained on data filtered for removal of PII
325
+ (Personally Identifiable Information). Developers are encouraged to adhere to
326
+ privacy regulations with privacy-preserving techniques.
327
+
328
+ ### Benefits
329
+
330
+ These models are useful for academics working on abstractive proposition segmentation (claim extraction) research or other problems (e.g., grounding, retrieval, fact-checking) that could benefit from this task.