---
title: "Cosmopedia: how to create large-scale synthetic data for pre-training Large Language Models"
description: "Cosmopedia is an open synthetic pre-training dataset of over 30 million files and 25 billion tokens of textbooks, blog posts, stories and WikiHow-style articles generated with Mixtral-8x7B-Instruct to reproduce Phi-1.5's training data."
url: "https://swe.quest/articles/cosmopedia-how-to-create-large-scale-synthetic-data-for-pre-training-large-493c90c3fc6af777"
canonical: "https://huggingface.co/blog/cosmopedia"
source: "Hugging Face"
published: "2024-03-20"
difficulty: "medium"
kind: "Case study"
reading_minutes: 8
tags: ["model-training","llms","data-pipelines"]
---

# Cosmopedia: how to create large-scale synthetic data for pre-training Large Language Models

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2024-03-20, 8 min read, Case study. Original: [https://huggingface.co/blog/cosmopedia](https://huggingface.co/blog/cosmopedia)

## Summary

Cosmopedia is an open synthetic pre-training dataset of over 30 million files and 25 billion tokens of textbooks, blog posts, stories and WikiHow-style articles generated with Mixtral-8x7B-Instruct to reproduce Phi-1.5's training data. Most of the effort went into prompt curation to keep diversity high and duplication under 1%. Prompts were seeded from curated educational sources (Stanford, Khan Academy, OpenStax, WikiHow), from RefinedWeb samples clustered into 145 topics (112 kept, over 80% of prompts), and from UltraChat/OpenHermes for common-sense stories. Varying audience and style with explicit format instructions multiplies prompts, while naive audience swaps still produce duplicates.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Data pipelines](https://swe.quest/tags/data-pipelines.md) (Data & databases)

## Prerequisites

- LLM pre-training basics ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))
- prompt engineering
- text clustering

## Keywords

Cosmopedia, Mixtral-8x7B-Instruct, Phi-1.5, RefinedWeb, cosmo-1b, UltraChat, OpenHermes2.5, AutoMathText

## Related posts

- [SmolLM - blazingly fast and remarkably powerful](https://swe.quest/articles/smollm-blazingly-fast-and-remarkably-powerful-2ae9388cca1c805f.md): Hugging Face · 2024-07-16 · Hard · 11 min read · Model training, LLMs, Evaluation
  SmolLM is a family of small language models (135M, 360M, 1.7B parameters) trained on SmolLM-Corpus, a new dataset combining Cosmopedia v2 synthetic textbooks (28B tokens), classifier-filtered Python-Edu (4B tokens) and deduplicated FineWeb-Edu (220B tokens).
- [Open Preference Dataset for Text-to-Image Generation by the 🤗 Community](https://swe.quest/articles/open-preference-dataset-for-text-to-image-generation-by-the-community-51063f2eca79d4de.md): Hugging Face · 2024-12-09 · Easy · 7 min read · Model training, Computer vision, Evaluation, Open source
  Data is Better Together released an Apache 2.0 text-to-image preference dataset of 10K pairs, with over 30K annotations from more than 250 community members collected in under two weeks.
- [Synthetic data: save money, time and carbon with open source](https://swe.quest/articles/synthetic-data-save-money-time-and-carbon-with-open-source-281f6f3c907e5527.md): Hugging Face · 2024-02-16 · Medium · 21 min read · Model training, LLMs, Machine learning, Cost optimization, Python
  An open-source LLM (Mixtral-8x7B-Instruct) can annotate task-specific data that is then used to fine-tune a small, efficient student model.
- [Designing synthetic datasets for the real world: Mechanism design and reasoning from first principles](https://swe.quest/articles/designing-synthetic-datasets-for-the-real-world-mechanism-design-and-reasoning-5c22424857d40e45.md): Google Research · 2026-04-16 · Hard · 7 min read · Model training, LLMs, Evaluation
  Simula treats synthetic data generation as dataset-level mechanism design.
- [NVIDIA Releases 6 Million Multi-Lingual Reasoning Dataset](https://swe.quest/articles/nvidia-releases-6-million-multi-lingual-reasoning-dataset-b1b00cfb53889ff4.md): Hugging Face · 2025-08-20 · Medium · 4 min read · Model training, LLMs
  Nemotron Post-Training Dataset V2 translates NVIDIA's English reasoning post-training data into French, Spanish, German, Italian and Japanese, translating prompts and responses while keeping the original English reasoning chains.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
