add-dataset
Step-by-step instructions to integrate new dataset loaders for SFT and RL training.
Install
mkdir -p .claude/skills/add-dataset && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/5252" && unzip -o skill.zip -d .claude/skills/add-dataset && rm skill.zipInstalls to .claude/skills/add-dataset
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Guide for adding a new dataset loader to AReaL. Use when user wants to add a new dataset.Key capabilities
- →Provide dataset loader boilerplate
- →Integrate HuggingFace dataset sources
- →Implement SFT/RL data processing
- →Apply tokenization and loss masking
- →Filter data by sequence length
How it works
Provides a Python function template using the HuggingFace dataset library to tokenize and prepare data for model training.
Inputs & outputs
When to use add-dataset
- →Adding custom SFT training data
- →Integrating new dataset sources
- →Implementing RL data loaders
About this skill
Add Dataset
Add a new dataset loader to AReaL.
When to Use
This skill is triggered when:
- User asks "how do I add a dataset?"
- User wants to integrate a new dataset
- User mentions creating a dataset loader
Step-by-Step Guide
Step 1: Create Dataset File
Create areal/dataset/<name>.py:
from datasets import Dataset, load_dataset
def get_<name>_sft_dataset(
path: str,
split: str,
tokenizer,
max_length: int | None = None,
) -> Dataset:
"""Load dataset for SFT training.
Args:
path: Path to dataset (HuggingFace hub or local path)
split: Dataset split (train/validation/test)
tokenizer: Tokenizer for processing
max_length: Maximum sequence length (optional)
Returns:
HuggingFace Dataset with processed samples
"""
dataset = load_dataset(path=path, split=split)
def process(sample):
# Tokenize the full sequence (prompt + response)
seq_token = tokenizer.encode(
sample["question"] + sample["answer"] + tokenizer.eos_token
)
prompt_token = tokenizer.encode(sample["question"])
# Loss mask: 0 for prompt, 1 for response
loss_mask = [0] * len(prompt_token) + [1] * (len(seq_token) - len(prompt_token))
return {"input_ids": seq_token, "loss_mask": loss_mask}
dataset = dataset.map(process).remove_columns(["question", "answer"])
if max_length is not None:
dataset = dataset.filter(lambda x: len(x["input_ids"]) <= max_length)
return dataset
def get_<name>_rl_dataset(
path: str,
split: str,
tokenizer,
max_length: int | None = None,
) -> Dataset:
"""Load dataset for RL training.
Args:
path: Path to dataset
split: Dataset split
tokenizer: Tokenizer for length filtering
max_length: Maximum sequence length
Returns:
HuggingFace Dataset with prompts and answers for reward computation
"""
dataset = load_dataset(path=path, split=split)
def process(sample):
messages = [
{
"role": "user",
"content": sample["question"],
}
]
return {"messages": messages, "answer": sample["answer"]}
dataset = dataset.map(process).remove_columns(["question"])
if max_length is not None:
def filter_length(sample):
content = sample["messages"][0]["content"]
tokens = tokenizer.encode(content)
return len(tokens) <= max_length
dataset = dataset.filter(filter_length)
return dataset
Step 2: Register in init.py
Update areal/dataset/__init__.py:
# Add to VALID_DATASETS
VALID_DATASETS = [
# ... existing datasets
"<name>",
]
# Add to _get_custom_dataset function
def _get_custom_dataset(name: str, ...):
# ... existing code
elif name == "<name>":
from areal.dataset.<name> import get_<name>_sft_dataset, get_<name>_rl_dataset
if dataset_type == "sft":
return get_<name>_sft_dataset(path, split, max_length, tokenizer)
else:
return get_<name>_rl_dataset(path, split, max_length, tokenizer)
Step 3: Add Config (Optional)
If the dataset needs special configuration, add to areal/api/cli_args.py:
@dataclass
class TrainDatasetConfig:
# ... existing fields
<name>_specific_field: Optional[str] = None
Step 4: Add Tests
Create tests/test_<name>_dataset.py:
import pytest
from areal.dataset.<name> import get_<name>_sft_dataset, get_<name>_rl_dataset
def test_sft_dataset_loads(tokenizer):
dataset = get_<name>_sft_dataset("path/to/data", split="train", tokenizer=tokenizer)
assert len(dataset) > 0
assert "input_ids" in dataset.column_names
assert "loss_mask" in dataset.column_names
def test_rl_dataset_loads(tokenizer):
dataset = get_<name>_rl_dataset("path/to/data", split="train", tokenizer=tokenizer)
assert len(dataset) > 0
assert "messages" in dataset.column_names
assert "answer" in dataset.column_names
Reference Implementations
| Dataset | File | Description |
|---|---|---|
| GSM8K | areal/dataset/gsm8k.py | Math word problems |
| Geometry3K | areal/dataset/geometry3k.py | Geometry problems |
| CLEVR | areal/dataset/clevr_count_70k.py | Visual counting |
| HH-RLHF | areal/dataset/hhrlhf.py | Helpfulness/Harmlessness |
| TORL | areal/dataset/torl_data.py | Tool-use RL |
Required Fields
SFT Dataset
{
"messages": [
{"role": "user", "content": "..."},
{"role": "assistant", "content": "..."},
]
}
RL Dataset
{
"messages": [
{"role": "user", "content": "..."},
],
"answer": "ground_truth_for_reward",
# Optional metadata for reward function
}
Common Mistakes
- ❌ Returning
List[Dict]instead of HuggingFaceDataset - ❌ Using Python loops instead of
dataset.map()/filter() - ❌ Missing
"messages"field for RL datasets - ❌ Wrong message format (should be list of dicts with
roleandcontent) - ❌ Not registering in
__init__.py
<!-- ================================================================================ MAINTAINER GUIDE ================================================================================ Location: .claude/skills/add-dataset/SKILL.md Invocation: /add-dataset <name> ## Purpose Step-by-step guide for adding new dataset loaders. ## How to Update ### When Dataset API Changes 1. Update the code templates 2. Update required fields section 3. Update registration example ### When New Dataset Types Added 1. Add to "Reference Implementations" table 2. Add any new required fields ================================================================================ -->
When not to use it
- →Training on raw unformatted data
- →Frameworks other than AReaL
Prerequisites
Limitations
- →Restricted to AReaL structure
- →Requires manual implementation of processing logic
How it compares
Enforces consistent data loading interfaces required for the AReaL training loop rather than generic script creation.
Compared to similar skills
add-dataset side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| add-dataset (this skill) | 1 | 5mo | No flags | Intermediate |
| langchain | 26 | 8mo | Review | Intermediate |
| cocoindex | 6 | 9mo | Review | Intermediate |
| rag-implementation | 10 | 2mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by inclusionAI
View all by inclusionAI →You might also like
langchain
zechenzhangAGI
Framework for building LLM-powered applications with agents, chains, and RAG. Supports multiple providers (OpenAI, Anthropic, Google), 500+ integrations, ReAct agents, tool calling, memory management, and vector store retrieval. Use for building chatbots, question-answering systems, autonomous agents, or RAG applications. Best for rapid prototyping and production deployments.
cocoindex
cocoindex-io
Comprehensive toolkit for developing with the CocoIndex library. Use when users need to create data transformation pipelines (flows), write custom functions, or operate flows via CLI or API. Covers building ETL workflows for AI data processing, including embedding documents into vector databases, building knowledge graphs, creating search indexes, or processing data streams with incremental updates.
rag-implementation
wshobson
Build Retrieval-Augmented Generation (RAG) systems for LLM applications with vector databases and semantic search. Use when implementing knowledge-grounded AI, building document Q&A systems, or integrating LLMs with external knowledge bases.
llamaindex
davila7
Data framework for building LLM applications with RAG. Specializes in document ingestion (300+ connectors), indexing, and querying. Features vector indices, query engines, agents, and multi-modal support. Use for document Q&A, chatbots, knowledge retrieval, or building RAG pipelines. Best for data-centric LLM applications.
similarity-search-patterns
wshobson
Implement efficient similarity search with vector databases. Use when building semantic search, implementing nearest neighbor queries, or optimizing retrieval performance.
senior-ml-engineer
davila7
World-class ML engineering skill for productionizing ML models, MLOps, and building scalable ML systems. Expertise in PyTorch, TensorFlow, model deployment, feature stores, model monitoring, and ML infrastructure. Includes LLM integration, fine-tuning, RAG systems, and agentic AI. Use when deploying ML models, building ML platforms, implementing MLOps, or integrating LLMs into production systems.