huggingface
data_error
ai_generated
true
ValueError:数据集的特征与预期模式不匹配。缺失列:['text', 'label']。多余列:['id', 'metadata']
ValueError: The features of the dataset do not match the expected schema. Missing columns: ['text', 'label']. Extra columns: ['id', 'metadata']
ID: huggingface/dataset-features-mismatch
88%修复率
86%置信度
1证据数
2024-01-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| datasets>=2.10.0 | active | — | — | — |
| transformers>=4.30.0 | active | — | — | — |
| python>=3.8 | active | — | — | — |
根因分析
从 Hugging Face Datasets 加载的数据集具有与模型或训练脚本所需的预期模式不匹配的列。
English
The dataset loaded from Hugging Face Datasets has columns that do not match the expected schema required by the model or training script.
官方文档
https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset.select_columns解决方案
-
使用 dataset.select_columns(['text', 'label']) 仅保留所需列,然后添加缺失列并赋予默认值:dataset = dataset.add_column('label', [0]*len(dataset))。 -
将多余列映射到所需列:dataset = dataset.map(lambda x: {'text': x['metadata'], 'label': 0})。
无效尝试
常见但无效的做法:
-
50% 失败
Missing columns still need to be added or mapped from existing columns.
-
60% 失败
If the column name is misspelled, the error persists.