# TypeError: The `eval_dataset` must be a `Dataset` or `IterableDataset` object, but got <class 'list'>

- **ID:** `huggingface/trainer-eval-dataloader-type`
- **Domain:** huggingface
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 93%

## Root Cause

The Trainer's `evaluate()` method expects a datasets.Dataset or IterableDataset object, but a plain Python list was passed, which lacks the required dataset interface.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| transformers>=4.28.0 | active | — | — |
| datasets>=2.0.0 | active | — | — |

## Workarounds

1. **Convert the list to a Dataset object: from datasets import Dataset; eval_dataset = Dataset.from_list(your_list). Then pass it to Trainer.** (95% success)
   ```
   Convert the list to a Dataset object: from datasets import Dataset; eval_dataset = Dataset.from_list(your_list). Then pass it to Trainer.
   ```
2. **If using a list of tensors, create a Dataset from a dictionary: dataset = Dataset.from_dict({'input_ids': tensor_list, 'labels': label_list})** (90% success)
   ```
   If using a list of tensors, create a Dataset from a dictionary: dataset = Dataset.from_dict({'input_ids': tensor_list, 'labels': label_list})
   ```

## Dead Ends

- **Pass a list of dictionaries as eval_dataset and expect Trainer to convert it automatically** — Trainer does not perform implicit conversion; it strictly checks the type and raises TypeError. (100% fail)
- **Set `eval_dataset` to `None` to skip evaluation** — This avoids the error but prevents evaluation entirely, which may hide issues in model performance. (90% fail)
- **Wrap the list in `torch.utils.data.TensorDataset`** — TensorDataset is not compatible with Trainer's expected interface; it lacks methods like `map()` and `select()`. (80% fail)
