{"slug": "reflections-on-training-a-1b-llm-on-100b-tokens-from-scratch", "title": "Reflections on training a 1B LLM on 100B tokens from scratch", "summary": "An independent developer trained Malama, a 1B-parameter language model, from scratch on 100B tokens using Modal credits, then ran supervised fine-tuning and reinforcement learning on coding problems; the model is published on Hugging Face as malama-v0.0.1. Malama uses the GLM tokenizer and Kimi Delta Attention alongside full attention, and the developer reports it is competitive on HumanEval and MBPP for its size but trails recent models on LiveCodeBench despite coding being its training niche. The developer concluded that high-quality, information-dense data matters more than novel architecture, noting that roughly 1B tokens of scraped EU documents made the model worse, and that the whole run fit on a single 8xH100 box.", "body_md": "notes from the margins\n\n*and yes, it is not very good, but SOTA for something. There are many like it, but this one is mine.*\n\nI recently found myself with some time and [Modal](https://modal.com) credits, so I decided to train an LLM from scratch. While I had the pleasure of being involved in post-training (and a tiny bit of pre-training) and eval of models in the past years, I wanted to see if I can do it myself end to end.\nThe outcome is [Malama](https://huggingface.co/jfrick/malama-v0.0.1), named after the beach where I was thinking through most of the decisions for it.\nIt is a 1B parameter model that uses the GLM tokenizer and Kimi Delta Attention alongside full attention and was pretrained on 100B tokens before running SFT and RL on coding problems.\nThis set of choices probably does not make sense for a commercial effort but it was not really the goal to build a practical model.\nMalama is fundamentally undertrained for its size as I spent credits on the end to end process rather than optimizing for pretraining. It was a lot of fun, especially [exploring different avenues](https://github.com/koogle/lm-exploration).\n\nI was able to make it competitive on the [HumanEval](https://github.com/openai/human-eval) and [MBPP](https://github.com/google-research/google-research/tree/master/mbpp) benchmarks (for its size).\nOn coding ([LiveCodeBench](https://livecodebench.github.io/)) it trails recent models even though this is the niche it was trained on.\nThe training mostly relied on existing datasets, especially from [NVIDIA](https://huggingface.co/nvidia). I admit, I was looking at some distillation by proxy in the form of incorporating open source repositories that had signs of recent contribution by frontier models. Especially for the SFT stage I used larger open source models (Qwen3-30B-A3B, DeepSeek V4 Flash, and public DeepSeek-R1 datasets) to provide reasoning trajectories, and Qwen3-30B-A3B to filter problems for the RL stage, where rewards came from running unit tests in a sandbox.\n\nThe exercise really emphasized the importance of good high quality data, especially ones that contain a lot of information per token. I tried myself to add to the public collection of datasets and scraped together about 1B tokens of EU published documents, but I found that they make the model actually worse not better. Most of the documents are semi-autogenerated and have a lot of low information boilerplate. In hindsight this is not very surprising. It updated my bias that critical breakthroughs in the next years will not come from novel architecture or techniques but from finding high quality pools of data that are information dense or increasing sample efficiency on existing data.\n\nDoing some initial size and training token estimates and then seeing it come through in the training run felt like training models is a lot more science than art.\n\nIt was a delight how agents were able to help me formulate experiments and side quests, and run them quickly on Modal. For example, I was able to play around with making an earlier version a looped model - there was no benefit, as the problems are currently still in the pretraining phase rather than in the reasoning changes. Models are also insanely good at writing custom kernels given a verification function to improve speed in all parts of the process.\n\nBesides the choice of data, architecture and training regimes, a decent part of the time was spent on fixing various problems with resuming and parallelizing training runs. I consider myself lucky that everything fit on an 8xH100 box and I did not worry about training across multiple hosts. Maintaining and fixing the training runs felt very similar to large scale data processing pipelines that I spent a lot of my early career dealing with.\n\nI deliberately wanted training to be defined as workflows of the form:\n\nas to be able to explore the space of ideas, which meant taking on a bunch of complexity enabling the work to fit together.\n\nSeeing the model go from gibberish to slowly forming sentences and more complex answers as the parameter and pretraining token count increased felt like noise coalescing into a beautiful picture.\nBoth attention and state space models feel like [very pure articulations of reasoning](https://alexwang.ai/posts/associative-memory/). Especially state space models to me are one of the most clear mathematical definitions of memory / state and I was delighted to find how [KDA](https://github.com/koogle/lm-exploration/blob/main/training/references/kda.md) is a descendant of SSMs and attention.\n\nTo me, training an LLM was unexpectedly beautiful.\n\nThank you to [Modal](https://modal.com) for providing credits and more importantly easy to use infrastructure and for the many people working on open source LLMs that have contributed to the [shared understanding](https://github.com/koogle/lm-exploration/tree/main/training/references) of how to create these models, especially the new crop of open source neo labs ([Thinking Machines](https://thinkingmachines.ai), [Mirendil](https://mirendil.com), [Recursive](https://recursive.com), [Ricursive](https://www.ricursive.com), [Flapping Airplanes](https://flappingairplanes.com), and [Open Athena](https://openathena.ai) / [Marin](https://github.com/marin-community/marin)).\n\nHere are two unedited passing generations from Malama v0.0.1 (taken from the evaluation logs in [`jfrick/lm-exploration-results`](https://huggingface.co/datasets/jfrick/lm-exploration-results)). You can also try prompting Malama v0.0.1 and earlier checkpoints in the [playground](https://huggingface.co/spaces/jfrick/malama-versions).\n\n`abc387_b` — easy)\n**Prompt:** Given an integer `X`, find the sum of all integers in the 9×9 multiplication table that are not equal to `X`.\n\n`<think>`)\n\n```\nOkay, I need to solve this problem. Let me read the question carefully.\n\nThe problem is about 9x9 multiplication table. Each cell has i*j. I need to find the sum of all numbers in the grid that are not equal to X. So, if X is present in the grid, I subtract all occurrences of X from the total sum of all numbers, then add the rest. Wait, no. Wait the problem says: \"sum of those that are not X\". So total_sum_total = sum of all 81 numbers in the grid. Then subtract the sum of all cells that have value X. So the answer is (total_sum_total - sum_of_X_cells) ?\n\nYes, that makes sense. So first, I need to calculate the total sum of all 81 numbers in the grid. Then subtract the sum of all numbers in cells where the value is X.\n\n...\n\nTesting sample 1: when X=1, the code loops i from 1-9, j from 1-9.\n\nOnly cell (1,1) has val=1. So sum_x += 1. All other cells are not 1. So total_sum is 81 + 7*18 = 81 + 126 = 202? Wait maybe not. Let me compute the total_sum.\n\nWait perhaps not. The sample 1's explanation says the answer is 2024, which suggests that the total_sum is 2024 + 1 = 2025? No. Wait sample 1's explanation says sum of all except 1 is 2024. So total_sum must be 2025 (sum of 1 is 1, so 2025-1=2024). So yes, the code's answer is correct.\n\nThus, the code seems to handle all samples correctly.\n\nEdge cases: when X is not in the grid. For example, X=11. Then sum_x is 0. So answer is total_sum.\n\nAnother edge case: X=81. Then check if any cell has 81. But 9*9=81. So if X=81, then that cell (9,9) has value 81. So sum_x includes that. So answer is total_sum - 81.\n\nYes, the code handles that.\n\nThus, the Python code is as written above.\nX = int(input())\n\ntotal_sum = 0\nsum_x = 0\n\nfor i in range(1, 10):\n    for j in range(1, 10):\n        val = i * j\n        total_sum += val\n        if val == X:\n            sum_x += val\n\nanswer = total_sum - sum_x\nprint(answer)\n```\n\n`HumanEval/4` — `mean_absolute_deviation`)\n**Prompt:** For a given list of input numbers, calculate the Mean Absolute Deviation around the mean of this dataset.\n\n```\nOkay, I need to write a Python function called mean_absolute_deviation that takes a list of numbers and computes the mean absolute deviation. Let me think about the steps here.\n\nSo, the problem says for each number in the list, I have to compute the absolute difference between each number and the mean of all the numbers. Then take the average of those absolute differences. Wait, maybe not. Wait the formula is something like the average of the absolute deviations of each number from the mean value.\n\nAlternatively maybe the steps are:\n\n1. Compute the mean of all the numbers in the list.\n2. Compute the sum of absolute differences between each number and the mean.\n3. Divide that sum by the number of elements to get the average absolute deviation.\n\n...\n\nTesting the sample input: [1,2,3,4]\n\nMean is 2.5\nEach number's difference: 1-2.5 is 1.5, absolute 1.5; 2-2.5 is 0.5, absolute 0.5; 3-2.5 is 0.5, absolute 0.5; 4-2.5 is 1.5. So sum is 1.5+0.5+0.5+1.5 = 4.0? Wait maybe not. Wait 1.5+0.5+0.5+1.5 = 4.0. Then divided by 4 gives 1.0. Which matches the sample output. So the code works for the sample.\n\nEdge cases: like all numbers same. Like [5,5,5] mean 5, differences 0. So 0.0. Another case like [0,0,1] mean 0.5, differences 0.5, 0.5, sum 1.0 /3= 0.333333... which would be 0.3333333333.\n\nYes, the code seems right.\npython\ndef mean_absolute_deviation(numbers):\n    if not numbers:\n        return 0.0\n    mean = sum(numbers) / len(numbers)\n    total_diff = 0\n    for num in numbers:\n        total_diff += abs(num - mean)\n    return total_diff / len(numbers)\n```\n\n", "url": "https://wpnews.pro/news/reflections-on-training-a-1b-llm-on-100b-tokens-from-scratch", "canonical_source": "https://www.marginalintelligence.com/posts/malama-model", "published_at": "2026-11-30 02:01:39+00:00", "updated_at": "2026-11-30 02:16:10.239381+00:00", "lang": "en", "topics": ["large-language-models", "machine-learning", "ai-research"], "entities": ["Malama", "Modal", "Hugging Face", "GLM", "Kimi Delta Attention", "Qwen3-30B-A3B", "DeepSeek V4 Flash", "NVIDIA"], "also_reported_by": [], "takeaway": "Training a 1B model on 100B tokens with SFT and RL on coding problems fit on a single 8xH100 box, and adding about 1B tokens of scraped EU documents degraded the model because the semi-autogenerated text was low-information boilerplate.", "recommendation": {"advice": "Prioritize information-dense training data over volume: the author's roughly 1B tokens of scraped EU documents made the model worse, so filter out semi-autogenerated boilerplate before pretraining.", "playbook": "training-data", "playbook_url": "https://wpnews.pro/playbooks/training-data"}, "alternates": {"html": "https://wpnews.pro/news/reflections-on-training-a-1b-llm-on-100b-tokens-from-scratch", "markdown": "https://wpnews.pro/news/reflections-on-training-a-1b-llm-on-100b-tokens-from-scratch.md", "text": "https://wpnews.pro/news/reflections-on-training-a-1b-llm-on-100b-tokens-from-scratch.txt", "jsonld": "https://wpnews.pro/news/reflections-on-training-a-1b-llm-on-100b-tokens-from-scratch.jsonld"}}