Model Overview
Model Features
Model Capabilities
Use Cases
🚀 Gemma Model Card
Gemma-APS is a generative model for abstractive proposition segmentation. It can break down text into meaningful components, useful for various research and application scenarios.
🚀 Quick Start
To quickly start running the Gemma-APS model, first ensure you have installed the necessary libraries:
pip install -U transformers nltk
Then, you can use the provided code snippets according to your specific use case.
✨ Features
- Abstractive Proposition Segmentation: Given a text passage, the model segments the content into individual facts, statements, and ideas, and restates them in full sentences.
- Research Tool: Useful for grounding, retrieval, fact - checking, and evaluation of generation tasks.
- Long Context Support: Trained on a context length of 8192 tokens.
📦 Installation
To use the Gemma-APS model, you need to install the transformers
and nltk
libraries:
pip install -U transformers nltk
💻 Usage Examples
Basic Usage
We define two helper functions for pre - processing input and post - processing output of the model:
import nltk
import re
nltk.download('punkt')
start_marker = '<s>'
end_marker = '</s>'
separator = '\n'
def create_propositions_input(text: str) -> str:
input_sents = nltk.tokenize.sent_tokenize(text)
propositions_input = ''
for sent in input_sents:
propositions_input += f'{start_marker} ' + sent + f' {end_marker}{separator}'
propositions_input = propositions_input.strip(f'{separator}')
return propositions_input
def process_propositions_output(text):
pattern = re.compile(f'{re.escape(start_marker)}(.*?){re.escape(end_marker)}', re.DOTALL)
output_grouped_strs = re.findall(pattern, text)
predicted_grouped_propositions = []
for grouped_str in output_grouped_strs:
grouped_str = grouped_str.strip(separator)
props = [x[2:] for x in grouped_str.split(separator)]
predicted_grouped_propositions.append(props)
return predicted_grouped_propositions
Usage with the pipeline
API
from transformers import pipeline
import torch
generator = pipeline('text-generation', 'google/gemma-7b-aps-it', device_map='auto', torch_dtype=torch.bfloat16)
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.'
messages = [{'role': 'user', 'content': create_propositions_input(passage)}]
output = generator(messages, max_new_tokens=4096, return_full_text=False)
result = process_propositions_output(output[0]['generated_text'])
print(result)
Example output
```json [ [ "Sarah Stage welcomed James Hunter into the world.", "Sarah Stage is 30 years old.", "James Hunter was welcomed on Tuesday." ], [ "James Hunter weighed eight pounds seven ounces.", "James Hunter was 22 inches long." ] ] ```Usage with AutoModel
and AutoTokenizer
APIs
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = 'google/gemma-7b-aps-it'
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
device_map='auto',
torch_dtype=torch.bfloat16,
)
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."
messages = [{'role': 'user', 'content': create_propositions_input(passage)}]
inputs = tokenizer.apply_chat_template(messages, return_tensors='pt', add_generation_prompt=True, return_dict=True).to(model.device)
output = model.generate(**inputs, max_new_tokens=4096, do_sample=False)
generated_text = tokenizer.batch_decode(output[:, inputs['input_ids'].shape[1]:], skip_special_tokens=True)[0]
result = process_propositions_output(generated_text)
print(result)
Example output
```json [ [ "The lyrics of American Pie have been puzzled over for more than 40 years." ], [ "The handwritten lyrics sold for more than $1 million.", "The handwritten lyrics sold at auction.", "The handwritten lyrics sold this week." ], [ "The verses contain hidden references to seminal events of the 50s.", "The verses contain hidden references to seminal events of the 60s." ], [ "The lyrics include nods to Buddy Holly.", "The lyrics include nods to Charles Manson.", "The lyrics include nods to Martin Luther King." ] ] ```📚 Documentation
Model Information
Description
Gemma-APS is a generative model and a research tool for abstractive proposition segmentation (APS for short), also known as claim extraction. Given a text passage, it segments the content into individual facts, statements, and ideas, and restates them in full sentences with minor changes to the original text.
This model can be used in research where text content needs to be broken down into meaningful components. Applications include grounding, retrieval, fact - checking, and evaluation of generation tasks (such as summarization). For more information, refer to the research paper.
Context Length
The models are trained on a context length of 8192 tokens.
Inputs and outputs
- Input: A text passage.
- Output: A list of propositions for all the sentences in the text passage, with the propositions for each sentence grouped separately.
Model Data
Training Dataset
- The training data contains synthetically generated examples, with each example having (input passage, propositions list) pairs. The propositions list contains propositions for all the sentences in the input passage (one group of propositions for each sentence).
- The input passages are generated by few - shot prompting Gemini Ultra.
- The propositions list is generated by applying a teacher LLM (a Gemini Pro model trained on a filtered version of the ROSE dataset) on the input passage.
See the research paper for detailed information.
Data Preprocessing
- Example passages with >=4 token overlap with any of the few - shot examples used for prompting Gemini Ultra are filtered.
- The ROSE dataset is used for training the teacher LLM (Gemini Pro). ROSE examples are filtered using an entailment model to remove cases that do not meet the desired properties of propositions.
Implementation Information
Hardware
Similar to Gemma, Gemma - APS was trained on TPUv5e.
Training large language models requires significant computational power. TPUs offer several advantages in this domain:
- Performance: TPUs are designed to handle the massive computations in training LLMs, speeding up training compared to CPUs.
- Memory: They often have large amounts of high - bandwidth memory, enabling the handling of large models and batch sizes during training, which can improve model quality.
- Scalability: TPU Pods provide a scalable solution for handling the growing complexity of large foundation models. Training can be distributed across multiple TPU devices for faster and more efficient processing.
- Cost - effectiveness: In many scenarios, TPUs are a more cost - effective solution for training large models compared to CPU - based infrastructure.
These advantages align with Google's commitments to operate sustainably.
Software
Training was done using JAX. JAX allows researchers to leverage the latest generation of hardware, including TPUs, for faster and more efficient training of large models.
Evaluation
Model evaluation was performed on one existing in - domain dataset (the 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, based on new metrics for the abstractive proposition segmentation task.
Ethics and Safety
Evaluation Approach
These models are only suitable for abstractive proposition segmentation of English text, not for any other task or language. Although the models have been tested on three evaluation datasets and have shown positive results compared to strong baselines, they may still have errors in some examples.
Usage and Limitations
Intended Usage
These models are only suitable for abstractive proposition segmentation of English text, not for any other task or language. Despite positive test results on three evaluation datasets compared to strong baselines, the models may still produce errors in some cases.
Limitations
- Training Data:
- The quality and diversity of the training data significantly affect the model's capabilities. Biases or gaps in the training data can lead to limitations in the model's responses.
- The scope of the training dataset determines the subject areas the model can handle effectively.
- The models have been tested on passages from different domains, where passages contain a few sentences.
- This model supports abstractive proposition segmentation in English only.
- Language Ambiguity and Nuance: Natural language is complex, and LLMs may struggle to understand subtle nuances, sarcasm, or figurative language.
- Factual Accuracy: LLMs generate responses based on their training datasets and may produce incorrect or outdated factual statements.
- Common Sense: LLMs rely on statistical patterns in language and may lack the ability to apply common sense reasoning in certain situations.
Ethical Considerations and Risks
- Bias and Fairness: LLMs trained on large - scale, real - world text data can reflect socio - cultural biases in the training material. These models have undergone careful scrutiny, input data pre - processing, and posterior evaluations, as reported in this card.
- Misinformation and Misuse: LLMs can be misused to generate false, misleading, or harmful text. Guidelines for responsible use are provided in the Responsible Generative AI Toolkit.
- Transparency and Accountability: This model card summarizes details about the models' architecture, capabilities, limitations, and evaluation processes. A responsibly developed open model makes LLM technology accessible to developers and researchers across the AI ecosystem.
Risks identified and mitigations:
- Perpetuation of biases: Continuous monitoring (using evaluation metrics, human review) and exploration of de - biasing techniques during model training, fine - tuning, and other use cases are encouraged.
- Generation of harmful content: Mechanisms and guidelines for content safety are essential. Developers are encouraged to exercise caution.
🔧 Technical Details
Model Page
This model card corresponds to the 7B finetuned version of the Gemma - APS model. You can also visit the model card of the 2B finetuned model.
Resources and Technical Documentation
- Scalable and Domain - General Abstractive Proposition Segmentation
- Gemma Technical Report
- Responsible Generative AI Toolkit
- Gemma on Kaggle
Terms of Use
Authors
Mohammad Javad Hosseini, Yang Gao, Tim Baumgärtner, Alex Fabrikant, Reinald Kim Amplayo
📄 License
The model uses the gemma license.
⚠️ Important Note
To access Gemma on Hugging Face, you’re required to review and agree to Google’s usage license. To do this, please ensure you’re logged in to Hugging Face and click here. Requests are processed immediately.
Property | Details |
---|---|
Base Model | google/gemma - 7b |
Library Name | transformers |
License | gemma |
Pipeline Tag | text - generation |

