|
|
--- |
|
|
license: mit |
|
|
--- |
|
|
|
|
|
# RAG Storage |
|
|
|
|
|
This repository contains the processed data and storage components for a Retrieval Augmented Generation (RAG) system focused on science question answering. |
|
|
|
|
|
## Datasets Used |
|
|
|
|
|
### 1. SciQ Dataset (`allenai/sciq`) |
|
|
- **HuggingFace Link**: [https://huggingface.co/datasets/allenai/sciq](https://huggingface.co/datasets/allenai/sciq) |
|
|
- **Size**: 13,679 crowdsourced science exam questions |
|
|
- **Topics**: Physics, Chemistry, Biology, and other sciences |
|
|
- **Format**: Multiple-choice with 4 answer options each |
|
|
- **Features**: Most questions include supporting evidence paragraphs for the correct answer |
|
|
|
|
|
### 2. AI2 ARC Dataset (`allenai/ai2_arc`) |
|
|
- **HuggingFace Link**: [https://huggingface.co/datasets/allenai/ai2_arc](https://huggingface.co/datasets/allenai/ai2_arc) |
|
|
- **Size**: 7,787 genuine grade-school level science questions |
|
|
- **Format**: Multiple-choice science questions |
|
|
- **Splits Used**: |
|
|
- `ARC_challenge`: Questions that were incorrectly answered by both retrieval-based and word co-occurrence algorithms |
|
|
- `ARC_easy`: Easier subset of the questions |
|
|
- **Additional Resources**: Corpus of over 14 million science sentences relevant to the task |
|
|
|
|
|
### Additional Dataset Considered |
|
|
|
|
|
**ScienceQA Dataset** ([derek-thomas/ScienceQA](https://huggingface.co/datasets/derek-thomas/ScienceQA)): A comprehensive multimodal dataset with 21,208 science questions covering K-12 STEM fields including natural sciences, social science, and language science. While this dataset offers excellent coverage across many STEM fields and includes rich contextual information (lectures, solutions, hints), it was not used in this project due to its multimodal nature requiring image processing capabilities, which falls outside the scope of this text-only RAG system. |
|
|
|
|
|
## Preprocessing |
|
|
|
|
|
### Data Transformation Process |
|
|
|
|
|
The original structured dataset formats are transformed into a simplified text format optimized for retrieval augmented generation. This transformation process standardizes both datasets into a consistent format that's easier for embedding models to process and retrieve from. |
|
|
|
|
|
#### Transformation Strategy by Dataset: |
|
|
|
|
|
**SciQ Dataset**: Uses the rich explanatory 'support' text as the primary content, as it contains detailed scientific knowledge that's valuable for retrieval. |
|
|
|
|
|
**ARC Dataset**: Converts question-answer pairs into a standardized Q&A format since ARC lacks explanatory support text. |
|
|
|
|
|
### Example Data Formats |
|
|
|
|
|
#### SciQ Row Example: |
|
|
**Original Format:** |
|
|
``` |
|
|
{'question': 'What type of organism is commonly used in preparation of foods such as cheese and yogurt?', |
|
|
'distractor3': 'viruses', |
|
|
'distractor1': 'protozoa', |
|
|
'distractor2': 'gymnosperms', |
|
|
'correct_answer': 'mesophilic organisms', |
|
|
'support': 'Mesophiles grow best in moderate temperature, typically between 25°C and 40°C (77°F and 104°F). Mesophiles are often found living in or on the bodies of humans or other animals. The optimal growth temperature of many pathogenic mesophiles is 37°C (98°F), the normal human body temperature. Mesophilic organisms have important uses in food preparation, including cheese, yogurt, beer and wine.'} |
|
|
``` |
|
|
|
|
|
**Transformed Format:** |
|
|
``` |
|
|
{ |
|
|
"text": "Mesophiles grow best in moderate temperature, typically between 25°C and 40°C (77°F and 104°F). Mesophiles are often found living in or on the bodies of humans or other animals. The optimal growth temperature of many pathogenic mesophiles is 37°C (98°F), the normal human body temperature. Mesophilic organisms have important uses in food preparation, including cheese, yogurt, beer and wine", |
|
|
"source": "sciq" |
|
|
} |
|
|
``` |
|
|
|
|
|
#### ARC Row Example: |
|
|
**Original Format:** |
|
|
``` |
|
|
{'id': 'Mercury_SC_415702', |
|
|
'question': 'George wants to warm his hands quickly by rubbing them. Which skin surface will produce the most heat?', |
|
|
'choices': {'text': ['dry palms', |
|
|
'wet palms', |
|
|
'palms covered with oil', |
|
|
'palms covered with lotion'], |
|
|
'label': ['A', 'B', 'C', 'D']}, |
|
|
'answerKey': 'A'} |
|
|
``` |
|
|
|
|
|
**Transformed Format:** |
|
|
``` |
|
|
{ |
|
|
"text": "Question: George wants to warm his hands quickly by rubbing them. Which skin surface will produce the most heat?\n\nAnswer: dry palms", |
|
|
"source": "arc_Mercury_SC_415702" |
|
|
} |
|
|
``` |
|
|
|
|
|
#### Transformation Benefits: |
|
|
- **Content Optimization**: SciQ's explanatory text provides rich knowledge chunks, while ARC's Q&A format creates factual knowledge pairs |
|
|
- **Consistent Structure**: Both datasets result in simple text-source pairs despite different source structures |
|
|
- **Knowledge Density**: SciQ chunks contain detailed scientific explanations, while ARC chunks provide specific factual answers |
|
|
- **Source Traceability**: Each chunk can be traced back to its original dataset and question |
|
|
- **RAG Optimization**: Both formats are optimized for semantic retrieval and knowledge extraction |
|
|
|
|
|
## Token Information |
|
|
|
|
|
- **Tokenizer**: Qwen/Qwen3-0.6B |
|
|
- **Chunking Strategy**: Fixed overlapping window |
|
|
- **Window Size**: 512 tokens |
|
|
- **Step Sizes**: 128 and 256 tokens (overlapping chunks for better coverage) |
|
|
- **Total Chunks**: |
|
|
- 21,466 chunks (256 token step size) |
|
|
- 21,475 chunks (128 token step size) |
|
|
- **Dataset Comparison**: Our combined dataset (SciQ + ARC) produces significantly fewer chunks (21,466-21,475) compared to the `m-ric/huggingface_doc` dataset (36,892 and 19,307 chunks). |
|
|
|
|
|
## Usage |
|
|
|
|
|
This processed dataset is designed for training and evaluating question-answering systems, particularly those focused on scientific knowledge retrieval and reasoning. |