{
  "schema_version": "1.0",
  "id": "T-e368ce8ed7b7",
  "url": "https://gpuatlas.top/articles/T-e368ce8ed7b7/",
  "title": "从零训练一个模型，训练集和验证集应该怎么分才不误判效果？",
  "summary": "数据划分先处理重复与文档关系，再建立固定验证和独立测试；随机切分及固定种子不能防止泄漏。",
  "language": "zh-Hans",
  "category": {
    "id": "c-21",
    "name": "从零训练与继续预训练",
    "url": "https://gpuatlas.top/categories/c-21/"
  },
  "topics": [
    {
      "id": "task-796e01d5af",
      "name": "训练",
      "kind": "task",
      "description": "模型训练时的资源占用与推理不同。查看优化器、激活值、并行策略和中断恢复相关问题。",
      "url": "https://gpuatlas.top/topics/task-796e01d5af/"
    }
  ],
  "body_text": "先按文档关系去重和分组，再划分训练、验证与测试。不要先把同一长文切成小块再随机分散，否则相似内容可能同时出现在训练和验证，loss很好看，却不能说明模型学会了泛化。\n\n分组依据取决于用途，可以是同一文档、近重复网页、来源、时间或任务关系。先检查重复和高度相关样本，保留分组清单，再决定哪些组进入各集合。目标是让验证反映未来真正要面对的数据，而不是机械追求一个固定比例。\n\n数据工具提供train_test_split等操作，固定种子有助于复现抽样，却不能修复重复泄漏。保存数据版本、分组规则、清单与种子，分词和打包后再检查，避免处理过程跨集合拼接或重新引入重复。\n\n验证集用于调整训练，最终测试集保持独立，不能反复根据测试成绩选模型后仍把它当未知数据。语言、来源、长短与任务类别分别看，平均loss可能掩盖某类数据明显退步。\n\n最后用独立实际任务检查生成，保证不同实验的预处理和计数口径一致。比例由样本数量、相关性和用途决定；先保证独立性和覆盖，再讨论划分多少，比只有随机种子和比例更能解释训练效果。",
  "published_at": null,
  "modified_at": "2026-11-26T15:17:38.690397+00:00",
  "evidence": {
    "type": "documentation_and_conditional_estimates",
    "hardware_tested": false,
    "note": "资料解释与条件估算，非硬件实测。"
  },
  "sources": [
    {
      "id": "hf-dataset-split",
      "url": "https://huggingface.co/docs/datasets/process",
      "retrieved_at": "2026-11-25T15:58:33.081746+00:00"
    },
    {
      "id": "transformers-causal-training",
      "url": "https://raw.githubusercontent.com/huggingface/transformers/main/docs/source/en/tasks/language_modeling.md",
      "retrieved_at": "2026-11-25T10:51:53.600205+00:00"
    }
  ],
  "revision_note": "完善阅读结构；非硬件实测。",
  "representations": {
    "html": "https://gpuatlas.top/articles/T-e368ce8ed7b7/",
    "json": "https://gpuatlas.top/data/articles/T-e368ce8ed7b7.json",
    "markdown": "https://gpuatlas.top/data/articles/T-e368ce8ed7b7.md"
  }
}
