Question Answering
Transformers
Safetensors
English
llama
text-generation
rag
text-generation-inference
Instructions to use DISLab/Ext2Gen-8B-R2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use DISLab/Ext2Gen-8B-R2 with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "question-answering" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("question-answering", model="DISLab/Ext2Gen-8B-R2")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("DISLab/Ext2Gen-8B-R2") model = AutoModelForCausalLM.from_pretrained("DISLab/Ext2Gen-8B-R2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from DISLab/Ext2Gen-8B-R2: direct link, hf CLI and curl.
- Browser
- Download file 3.38 kB
-
https://huggingface.co/DISLab/Ext2Gen-8B-R2/resolve/22cb3d8a7e2ced627112e84ef537ec0d5030b089/README.md
- Command line
-
hf download hf://DISLab/Ext2Gen-8B-R2@22cb3d8a7e2ced627112e84ef537ec0d5030b089/README.md
-
curl -L -o README.md https://huggingface.co/DISLab/Ext2Gen-8B-R2/resolve/22cb3d8a7e2ced627112e84ef537ec0d5030b089/README.md
3.38 kB
metadata
license: apache-2.0
language:
- en
base_model:
- meta-llama/Llama-3.1-8B-Instruct
pipeline_tag: text-generation
tags:
- rag
Ext2Gen-8B-R2
Note: We are still working on this.
Are you looking for a more robust and reliable generation model for RAG system?
Here is a Ext2Gen-8B-R2 model that effectively mitigates hallucinations caused by retrieval noise and information overload.
See the details in our paper Link
What is Ext2Gen-8B-R2?
Ext2Gen-8B-R2 is built upon Llama3.2-8B-Instruct, incorporating preference-aligned fine-tuning through pairwise feedback learning.
This training strategy enables the model to:
- Extract highly relevant sentences from retrieved chunks before generating an answer.
- Filter out irrelevant or misleading information, reducing hallucinations.
- Align generation with human preferences by optimizing for faithfulness, completeness, and conciseness.
Why does Ext2Gen-8B-R2 outperform standard RAG models?
Standard RAG models often struggle due to:
- Uncertain Placement – Relevant information may appear in unpredictable locations within retrieved chunks, making it difficult for LLMs to utilize it effectively.
- Information Overload – The presence of irrelevant chunks can distract the model, leading to errors or hallucinations.
- Lack of Alignment – Most generation models are not explicitly trained to prioritize relevant content over noise.
Prompt
- query: the query to answer
- chunk_list: the list of retrieved chunks, e.g., ["chunk 1", "chunk 2", "chunk 3"]
def format_prompt_template(query, chunk_list):
chunk_list = ['[Chunk ID: '+ str(idx+1) + '] ' + chunk_text for idx, chunk_text in enumerate(chunk_list)]
chunk_list = '\n\n'.join(chunk_list)
prompt = '''
You are an expert assistant trained to extract essential sentences from document chunks and generate answers based on the extracted sentences.
Your task is twofold:
- Extraction: Identify sentences that contribute to constructing a precise and accurate response to the given query.
- Generation: Formulate a concise and coherent answer based on the extracted sentences.
### Extraction Instruction:
- A query will be provided for you to answer.
- Extract only the sentences that contribute to forming an answer to the query.
- Ensure that the extracted sentences are sufficient to derive a correct and complete answer.
- If no relevant sentences are found in the provided chunks, return an empty list.
### Generation Instruction:
- Use the extracted sentences to generate a well-formed answer to the query.
- If no sentences are extracted, return "No Answer".
### Output Example:
Extracted Sentences:
- Sentence 1
- Sentence 2
Answer: Your Answer
### Query:
%s
### Chunk List:
%s
### Output:
''' % (query, chunk_list)
return prompt.strip()
Performance Benchmark
Our evaluations demonstrate that Ext2Gen-8B-R2 significantly enhances robustness in RAG systems:
- We conduct a QA task using RAG Systems on NQ, MS-MARCO, HotpotQA datasets.
- The difference is the generation backbone: Llama3.1-8B-Instruct vs. Ext2Gen-8B-R2
See the results in the Figure below:
