# KeyError: "Split 'validation' not found in dataset. Available splits: ['train', 'test']"

- **ID:** `huggingface/dataset-split-key-error`
- **Domain:** huggingface
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 95%

## Root Cause

The requested dataset split name (e.g., 'validation') does not exist in the dataset configuration; the dataset may use a different naming convention like 'val' or 'test'.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| datasets>=2.14.0 | active | — | — |
| transformers>=4.30.0 | active | — | — |
| Python>=3.8 | active | — | — |

## Workarounds

1. **Check available splits before loading and use the correct name:
from datasets import get_dataset_split_names
splits = get_dataset_split_names('org/dataset')
print(splits)  # e.g., ['train', 'test']
# Then use the correct split:
dataset = load_dataset('org/dataset', split='test')** (95% success)
   ```
   Check available splits before loading and use the correct name:
from datasets import get_dataset_split_names
splits = get_dataset_split_names('org/dataset')
print(splits)  # e.g., ['train', 'test']
# Then use the correct split:
dataset = load_dataset('org/dataset', split='test')
   ```
2. **If no validation split exists, create one from the training data:
from datasets import load_dataset
dataset = load_dataset('org/dataset', split='train')
train_val = dataset.train_test_split(test_size=0.1, seed=42)
train_dataset = train_val['train']
val_dataset = train_val['test']** (90% success)
   ```
   If no validation split exists, create one from the training data:
from datasets import load_dataset
dataset = load_dataset('org/dataset', split='train')
train_val = dataset.train_test_split(test_size=0.1, seed=42)
train_dataset = train_val['train']
val_dataset = train_val['test']
   ```

## Dead Ends

- **** — Using split='all' to load all data and then manually splitting may cause data leakage if the dataset has predefined splits. (60% fail)
- **** — Renaming the split after loading with rename_column does not create a new split; it only renames a column. (90% fail)
