{"type":"session","harness":"opencode","id":"ai-004","name":"preparing good training dataset for LLMs"} {"type":"message","message":{"role":"system","content":"You're a helpful assistant"}} {"type":"message","message":{"role":"user","content":"preparing good training dataset for training LLMs"}} {"type":"message","message":{"role":"assistant","content":"If you're preparing a **good training dataset for an LLM**, the biggest gains usually come from **data quality and structure**, not just throwing more text into the furnace and hoping intelligence emerges.\n\n### A solid dataset pipeline\n\n1. **Collect**\n\n * High-quality source material\n * Code + documentation\n * Math/problem-solving examples\n * Conversations\n * Reasoning traces where legally and practically usable\n\n2. **Normalize**\n\n * Unicode normalization\n * Consistent formatting\n * Remove malformed JSON/HTML/markup\n * Normalize whitespace\n * Preserve meaningful structure\n\n3. **Filter**\n\n * Language identification\n * Minimum/maximum length\n * Toxicity/spam filtering where appropriate\n * Broken/incoherent samples\n * Boilerplate\n * Generated garbage\n\n4. **Deduplicate**\n Use multiple levels:\n\n * Exact document deduplication\n * Normalized-text hashing\n * Near-duplicate detection with MinHash/SimHash\n * Semantic deduplication for especially repetitive corpora\n\n5. **Quality-score**\n\n Keep metadata such as:\n\n ```json\n {\n \"text\": \"...\",\n \"source\": \"math\",\n \"quality\": 0.92,\n \"language\": \"en\",\n \"tokens\": 847\n }\n ```\n\n This lets you later experiment with filtering instead of permanently deleting data.\n\n6. **Structure training examples**\n\n For instruction data, something like:\n\n ```json\n {\n \"messages\": [\n {\"role\": \"user\", \"content\": \"Solve x² - 5x + 6 = 0.\"},\n {\"role\": \"assistant\", \"content\": \"...\"}\n ]\n }\n ```\n\n For coding/agent traces, preserve the **sequence of actions and observations**, rather than flattening everything into one answer:\n\n ```json\n {\n \"task\": \"...\",\n \"steps\": [\n {\"type\": \"analysis\", \"content\": \"...\"},\n {\"type\": \"tool_call\", \"tool\": \"python\", \"input\": \"...\"},\n {\"type\": \"tool_result\", \"content\": \"...\"},\n {\"type\": \"analysis\", \"content\": \"...\"},\n {\"type\": \"final\", \"content\": \"...\"}\n ]\n }\n ```\n\n7. **Split correctly**\n\n Create train/validation/test splits **after deduplication**. Otherwise nearly identical examples can leak between splits and make your validation score look wonderfully intelligent. Humanity has invented many ways to fool itself.\n\nFor coding specifically, I'd also retain **failed attempts followed by corrections**. A model needs to learn that `segfault → inspect pointer → find bug → patch → test` is a normal workflow, rather than developing the charming belief that programmers simply emit correct code on their first try.\n"}}