Show HN: I built a tiny LLM to demystify how language models work | Hacker News

Source: original

| Hacker Newsnew | past | comments | ask | show | jobs | submit| login

Show HN: I built a tiny LLM to demystify how language models work (github.com/arman-bd)

915 points by armanified 65 days ago | hide | past | favorite | 134 comments Built a ~9M param LLM from scratch to understand how they actually work. Vanilla transformer, 60K synthetic conversations, ~130 lines of PyTorch. Trains in 5 min on a free Colab T4. The fish thinks the meaning of life is food.Fork it and swap the personality for your own character.

| fg137 64 days ago | next [–] How does this compare to Andrej Karpathy's microgpt (https://karpathy.github.io/2026/02/12/microgpt/) or minGPT (https://github.com/karpathy/minGPT)?

| armanified 64 days ago | parent | next [–] I haven't compared it with anything yet. Thanks for the suggestion; I'll look into these.

| BrokenCogs 64 days ago | parent | prev | next [–] Who cares how it compares, it's not a product it's a cool project

| tantalor 64 days ago | root | parent | next [–] Even cool projects can learn from others. Maybe they missed something that could benefit the project, or made some interesting technical choice that gives a different result.For the readers/learners, it's useful to understand the differences so we know what details matter, and which are just stylistic choices.This isn't art; it's science & engineering.

| BrokenCogs 64 days ago | root | parent | next [–] But it isn't the OP's responsibility to compare their project to all other projects. The GP could themselves perform the comparison and post their thoughts instead of asking an open ended question.

| philipallstar 64 days ago | root | parent | next [–]

it isn't the OP's responsibility to compare their project to all other projectsNo one, including the GP, said it was.

| fg137 64 days ago | root | parent | prev | next [–] It isn't, but such information will be immensely helpful to anyone who wants to learn from such projects. Some tutorials are objectively better than others, and learners can benefit from such information.

| tantalor 64 days ago | root | parent | prev | next [–] 100% agree, I didn't mean to imply that OP is responsible for that, or that the (lack of) comparison detracts in any way from the work.

| stronglikedan 64 days ago | root | parent | prev | next [–]

Who cares how it comparesWell, the person who asked the question, for one. I'm sure they're not the only one. Best not to assume why people are asking though, so you can save time by not writing irrelevant comments.

| layer8 64 days ago | root | parent | prev | next [–] Microgpt isn’t a product either. Are you saying that differences between cool projects aren’t worth thinking and conversing about?

| thomasfl 64 days ago | prev | next [–] Is there some documentation for this? The code is probably the simplest (Not So) Large Language Model implementation possible, but it is not straight forward to understand for developers not familiar with multi-head attention, ReLU FFN, LayerNorm and learned positional embeddings.This projects shares similarities with Minix. Minix is still used at universities as an educational tool for teaching operating system design. Minix is the operating system that taught Linus Torvalds how to design (monolithic) operating systems. Similarly having students adding capabilities to GuppyLM is a good way to learn LLM design.

| achenatx 64 days ago | parent | next [–] give the code to an LLM and have a discussion about it.

| dominotw 64 days ago | root | parent | next [–] does this work? there is no more need for writing high level docs?

| arcanemachiner 64 days ago | root | parent | next [–]

does this work?Absolutely. If you loaded this into an agentic coding harness with a decent model, I can practically guarantee it would be able to help you figure out what's going on.> there is no more need for writing high level docs?Absolutely not. That would be like exploring a cave without a flashlight, knowing that you could just feel your way around in the dark instead.Code is not always self-documenting, and can often tell you how it was written, but not why.

| stronglikedan 64 days ago | root | parent | next [–]

If you loaded this into an agentic coding harness with a decent model, I can practically guarantee it would be able to help you figure out what's going on.My non-coder but technically savvy boss has been doing this lately to great success. It's nice because I spend less time on it since the model has taken my place for the most part.

| libria 64 days ago | root | parent | next [–]

since the model has taken my place for the most partHah, you realize the same thing is going on in your boss's head right? The pie chart of Things-I-Need-stronglikedan-For just shrank tiny bit...

| dominotw 64 days ago | root | parent | next [–] my last employer was using ai to rank developers on most impactful code their prs are shipping.

| sigmoid10 64 days ago | root | parent | prev | next [–] There are so many blogs and tutorials about this stuff in particular, I wouldn't worry about it being outside the training data distribution for modern LLMs. If you have a scarce topic in some obscure language I'd be more careful when learning from LLMs.

| bigmadshoe 64 days ago | root | parent | prev | next [–] LLMs can tell you what the code does but not why the developer chose to do it that way.Also, large codebases are harder to understand. But projects like these are simple to discuss with an LLM.

| stronglikedan 64 days ago | root | parent | next [–]

LLMs can tell you what the code does but not why the developer chose to do it that way.Do LLMs not take comments into consideration? (Serious question - I'm just getting into this stuff)

| bigmadshoe 63 days ago | root | parent | next [–] They do. Think of it like a very intelligent but somewhat unreliable engineer you can hire to look at your code. They have no context about the codebase beyond what’s written in the source code, or any docs you give them.What I meant was the docs might provide explanations about the problems the codebase solves, design decisions, the abstractions chosen, etc that wouldn’t live in a particular source file. Any discussion someone has with an LLM about the codebase will lack this context in the explanations given if docs don’t exist.

| dr_hooo 64 days ago | root | parent | prev | next [–] They do (it's just text), if they are there...

| BorisMelnik 63 days ago | parent | prev | next [–] I haven't heard minix in so long!

| totetsu 64 days ago | prev | next [–] https://bbycroft.net/llm has 3d Visualization of tiny example LLM layers that do a very good job at showing what is going on (https://news.ycombinator.com/item?id=38505211)

| armanified 64 days ago | parent | next [–] Pretty neat! I'll definitely take a deeper look into this.

| maverickxone 64 days ago | parent | prev | next [–] have little to do with this, but i have to say your project are indeed pretty cool! Consider adding some more UI?

| devsteru 63 days ago | parent | prev | next [–] Thanks for sharing

| skramzy 64 days ago | parent | prev | next [–] Neat!

| ordinarily 65 days ago | prev | next [–] It's genuinely a great introduction to LLMs. I built my own awhile ago based off Milton's Paradise Lost: https://www.wvrk.org/works/milton

| mudkipdev 64 days ago | prev | next [–] This is probably a consequence of the training data being fully lowercase:You> hello Guppy> hi. did you bring micro pellets.You> HELLO Guppy> i don't know what it means but it's mine.

| functional_dev 64 days ago | parent | next [–] Great find! It appears uppercase tokens are completely unknonw to the tokenizer.But the character still comes through in response :)

| algoth1 64 days ago | prev | next [–] This really makes me think if it would be feasible to make an llm trained exclusively on toki pona (https://en.wikipedia.org/wiki/Toki_Pona)

| MarkusQ 64 days ago | parent | next [–] There isn't enough training data though, is there? The "secret sauce" of LLMs is the vast amount of training data available + the compute to process it all.

| algoth1 64 days ago | root | parent | next [–] I think you could probably feed a copy of a toki pona grammar book to a big model, and have it produce ‘infinite’ training data

| MarkusQ 64 days ago | root | parent | next [–] This is essentially a distillation on the bigger model; you'd wind up surfacing a lot of artifacts from the host model, amplifying them in the same way repeated photocopying introduces errors.https://dailyai.com/2025/05/create-a-replica-of-this-image-d...

| eden-u4 64 days ago | root | parent | prev | next [–] There are not enough samples in that book to generate new "infinite" data.

| mudkipdev 63 days ago | parent | prev | next [–] People have made toki pona translation models before, not exclusively trained though

| neurworlds 64 days ago | prev | next [–] Cool project. I'm working on something where multiple LLM agents share a world and interact with each other autonomously. One thing that surprised me is how much the "world" matters — same model, same prompt, but put it in a system with resource constraints, other agents, and persistent memory, the behavior changes dramatically. Made me realize we spend too much time optimizing the model and not enough thinking about the environment it operates in.

| SilentM68 65 days ago | prev | next [–] Would have been funny if it were called "DORY" due to memory recall issues of the fish vs LLMs similar recall issues :)

| armanified 64 days ago | parent | next [–] OMG! Why didn't I thought fo this first :P

| zwaps 64 days ago | prev | next [–] I like the idea, just that the examples are reproduced from the training data set.How does it handle unknown queries?

| armanified 64 days ago | parent | next [–] It mostly doesn't, at 9M it has very limited capacity. The whole idea of this project is to demonstrate how Language Models work.

| brcmthrowaway 64 days ago | prev | next [–] Why are there so many dead comments from new accounts?

| 59nadir 64 days ago | parent | next [–] Because despite what HN users seem to think, HN is a LLM-infested hellscape to the same degree as Reddit, if not more.

| wiseowise 64 days ago | root | parent | next [–] You’re absolutely right! HN isn’t just LLM-infested hellscape, it’s a completely new paradigm of machine assisted chocolate-infused information generation.

| toyg 64 days ago | root | parent | next [–] Just let me know which type of information goo you'd like me to generate, and I'll tailor the perfect one for you.

| siva7 64 days ago | root | parent | prev | next [–] But what should we do? The parent company isn't transparent about communicating the seriousness of this problem

| loveparade 64 days ago | parent | prev | next [–] It really seems it's mostly AI comments on this. Maybe this topic is attractive to all the bots.

| armanified 64 days ago | root | parent | next [–] This title might have triggered something in those bots; most of them have sneaky AI SaaS links in their bio.Honestly, I never expected this post to become so popular. It was just the outcome of a weekend practice session.

| AlecSchueler 64 days ago | parent | prev | next [–] They all seem to be slop comments.

| AndrewKemendo 65 days ago | prev | next [–] I love these kinds of educational implementations.I want to really praise the (unintentional?) nod to Nagel, by limiting capabilities to representation of a fish, the user is immediately able to understand the constraints. It can only talk like a fish cause it’s very simpleEspecially compared to public models, thats a really simple correspondence to grok intuitively (small LLM > only as verbose as a fish, larger LLM > more verbose) so kudos to the author for making that simple and fun.

| dvt 65 days ago | parent | next [–]

the user is immediately able to understand the constraintsNagel's point was quite literally the opposite[1] of this, though. We can't understand what it must "be like to be a bat" because their mental model is so fundamentally different than ours. So using all the human language tokens in the world can't get us to truly understand what it's like to be a bat, or a guppy, or whatever. In fact, Nagel's point is arguably even stronger: there's no possible mental mapping between the experience of a bat and the experience of a human.[1] https://www.sas.upenn.edu/~cavitch/pdf-library/Nagel_Bat.pdf

| Terr_ 64 days ago | root | parent | next [–] IMO we're a step before that: We don't even have a real fish involved, we have a character that is fictionally a fish.In LLM-discussions, obviously-fictional characters can be useful for this, like if someone builds a "Chat with Count Dracula" app. To truly believe that a typical "AI" is some entity that "wants to be helpful" is just as mistaken as believing the same architecture creates an entity that "feels the dark thirst for the blood of the living."Or, in this case, that it really enjoys food-pellets.

| andoando 64 days ago | root | parent | prev | next [–] Id highly disagree with that. Were all living in the same shared universe, and underlying every intelligence must be precisely an understanding of events happening in this space-time.

| vixen99 64 days ago | root | parent | next [–] What does 'precisely' mean? Everyone has the same understanding of events - a precise one?

| andoando 64 days ago | root | parent | next [–] No I am saying the basis of intelligence must be shared, not that we have the same exact mental model.I might for example say a human entered a building, a bat might on the other hand think "some big block with two sticks moved through a hole", but both are experiencing a shared physical observation, and there is some mapping between the two.Its like when people say, if there are aliens they would find the same mathematical constants thet we do

| AndrewKemendo 65 days ago | root | parent | prev | next [–] Different argumentI’m not going to argue other than to say that you need to view the point from a third party perspective evaluating “fish” vs “more verbose thing,” such that the composition is the determinant of the complexity of interaction (which has a unique qualia per nagel)Hence why it’s a “unintentional nod” not an instantiation

| bblb 64 days ago | prev | next [–] Could it be possible to train LLM only through the chat messages without any other data or input?If Guppy doesn't know regular expressions yet, could I teach it to it just by conversation? It's a fish so it wouldn't probably understand much about my blabbing, but would be interesting to give it a try.Or is there some hard architectural limit in the current LLM's, that the training needs to be done offline and with fairly large training set.

| roetlich 64 days ago | parent | next [–] What does "done offline" mean? Otherwise you are limited by context window.

| cbdevidal 65 days ago | prev | next [–]

you're my favorite big shape. my mouth are happy when you're here.Laughed loudly :-D

| vunderba 65 days ago | parent | next [–] This is a direct output from the synthetic training data though - wonder if there is a bit of overfitting going on or it’s just a natural limitation of a much smaller model.

| CaseFlatline 64 days ago | prev | next [–] I am trying to find how the synthetic data was created (looking through the repo) and didn't find it. Maybe I am missing it - Would love to see the prompts and process on that aspect of the training data generation!

| vunderba 64 days ago | parent | next [–] It's here:https://github.com/arman-bd/guppylm/blob/main/guppylm/genera...Uses a sort of mad-libs templatized style to generate all the permutations.

| rpdaiml 64 days ago | prev | next [–] This is a nice idea. A tiny implementation can be way more useful for learning than yet another wrapper around a big model, especially if it keeps the training loop and inference path small enough to read end to end.

| jzer0cool 64 days ago | prev | next [–] Does this work by just training once with next token prediction? Want to understand better how it creates fluent sentences if anyone can provide insights.

| BiraIgnacio 64 days ago | prev | next [–] Nice work and thanks for sharing it!Now, I ask, have LLMs ben demystified to you? :DI am still impressed how much (for the most part) trivial statistics and a lot of compute can do.

| kaipereira 64 days ago | prev | next [–] This is so cool! I'd love to see a write-up on how made it, and what you referenced because designing neural networks always feel like a maze ;)

| ankitsanghi 64 days ago | prev | next [–] Love it! I think it's important to understand how the tools we use (and will only increasingly use) work under the hood.

| NyxVox 65 days ago | prev | next [–] Hm, I can actually try the training on my GPU. One of the things I want to try next. Maybe a bit more complex than a fish :)

| Leomuck 64 days ago | prev | next [–] Wow that is such a cool idea! And honestly very much needed. LLMs seem to be this blackbox nobody understands. So I love every effort to make that whole thing less mysterious. I will definitely have a look at dabbling with this, may it not be a goldfish LLM :)

| Duplicake 64 days ago | prev | next [–] I love this! Seems like it can't understand uppercase letters though

| armanified 64 days ago | parent | next [–] Uppercase letters were intentionally ignored.

| ergocoder 64 days ago | prev | next [–] It's just so amazing that 5 years ago it would be extremely to build a conversational bot like this.But right now people make it a hobby, and that thing can run on a laptop.This is just so wild.

| gnarlouse 65 days ago | prev | next [–] I... wow, you made an LLM that can actually tell jokes?

| murkt 64 days ago | parent | next [–] With 9M params it just repeats the joke from a training dataset.

| kubrador 64 days ago | prev | next [–] how's it handle longer context or does it start hallucinating after like 2 sentences? curious what the ceiling is before the 9M params

| bharat1010 64 days ago | prev | next [–] This is such a smart way to demystify LLMs. I really like that GuppyLM makes the whole pipeline feel approachable..great work

| drincanngao 64 days ago | prev | next [–] I was going to suggest implementing RoPE to fix the context limit, but realized that would make it anatomically incorrect.

| armanified 64 days ago | parent | next [–] I intentionally removed all optimizations to keep it vanilla.

| fawabc 64 days ago | prev | next [–] how did you generate the synthetic data?

| abkolan 62 days ago | parent | next [–] It's here https://github.com/arman-bd/guppylm/blob/main/guppylm/genera...

| rclkrtrzckr 64 days ago | prev | next [–] I could fork it and create TrumpLM. Not a big leap, I suppose.

| search_facility 64 days ago | parent | next [–] probably 8M params are too much even :)

| danparsonson 64 days ago | root | parent | next [–] As long as you use the best parameters then it doesn't matter

| wiseowise 64 days ago | root | parent | prev | next [–] Grab her by the pointer.

| amelius 64 days ago | prev | next [–]

A 9M model can't conditionally follow instructionsHow many parameters would you need for that?

| armanified 64 days ago | parent | next [–] My initial idea was to train a navigation decision model with 25M parameters for a Raspberry Pi, which, in testing, was getting about 60% of tool calls correct. IMO, it seems like around 20M parameters would be a good size for following some narrow & basic language instructions.

| amelius 64 days ago | root | parent | next [–] Ok. This makes me wonder about a broader question. Is there a scientific approach showing a pyramid of cognitive functions, and how many parameters are (minimally) required for each layer in this pyramid?

| EmilioOldenziel 64 days ago | prev | next [–] Building it yourself is always the best test if you really understand how it works.

| ananandreas 64 days ago | prev | next [–] Great and simple way to bridge the gap between LLMs and users coming in to the field!

| nate8bit 64 days ago | prev | next [–] This is really great! I've been wanting to do something similar for a while.

| nobodyandproud 64 days ago | prev | next [–] Thanks. Tinkering is how I learn and this is what I’ve been looking for.

| jbethune 64 days ago | prev | next [–] Forked. Very cool. I appreciate the simplicity and documentation.

| nullbyte808 65 days ago | prev | next [–] Adorable! Maybe a personality that speaks in emojis?

| armanified 64 days ago | parent | next [–] OMG! You just gave me the next idea..

| monksy 64 days ago | prev | next [–] Is this a reference from the Bobiverse?

| cpldcpu 64 days ago | prev | next [–] Love it! Great idea for the dataset.

| winter_blue 64 days ago | prev | next [–] This is amazing work. Thank you.

| gdzie-jest-sol 64 days ago | prev | next [–] * How creating dataset? I download it but it is commpresed in binary format. How training. In cloud or in my own dev How creating a gguf

| gdzie-jest-sol 64 days ago | parent | next [–] ``` uv run python -m guppylm chatTraceback (most recent call last):

File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/home/user/gupik/guppylm/guppylm/main.py", line 48, in main() File "/home/user/gupik/guppylm/guppylm/main.py", line 29, in main engine = GuppyInference("checkpoints/best_model.pt", "data/tokenizer.json") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/gupik/guppylm/guppylm/inference.py", line 17, in init self.tokenizer = Tokenizer.from_file(tokenizer_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Exception: No such file or directory (os error 2) ```

| gdzie-jest-sol 64 days ago | root | parent | next [–] meybe add training again (read best od fine) and train again# after config device checkpoint_path = "checkpoints/best_model.pt"ckpt = torch.load(checkpoint_path, map_location=device, weights_only=False)model = GuppyLM(mc).to(device) if "model_state_dict" in ckpt: model.load_state_dict(ckpt["model_state_dict"]) else: model.load_state_dict(ckpt)start_step = ckpt.get("step", 0) print(f"Encore {start_step}")

| freetonik 64 days ago | parent | prev | next [–] You sound like Guppy. Nice touch.

| rahen 64 days ago | prev | next [–] I don't mean to be 'that guy', but after a quick review, this really feels like low-effort AI slop to me.There is nothing wrong using AI tools to write code, but nothing here seems to have taken more than a generic 'write me a small LLM in PyTorch' prompt, or any specific human understanding.The bar for what constitutes an engineering feat on HN seems to have shifted significantly.

| zhainya 63 days ago | parent | next [–] I don't really understand the point of this project or how it demystifies anything. Click the browser demo and I get a generic AI chat screen. Is the readme the part that "demystifies" something? I feel like I am living in a bizarro world. Is this all AI? Are all the comments here from bots?

| Vektorceraptor 64 days ago | prev | next [–] Haha, funny name :)

| tombelieber 63 days ago | prev | next [–] looking forward to try it, great job

| Elengal 64 days ago | prev | next [–] Cool

| oyebenny 64 days ago | prev | next [–] Neat!

| hughw 64 days ago | prev | next [–] Tiny LLM is an oxymoron, just sayin.

| uxcolumbo 64 days ago | parent | next [–] How about: LLMs are on a spectrum and this one is on the tiny side?

| armanified 64 days ago | parent | prev | next [–] True, but most would ignore LM if it weren't LLM.

| hahooh 63 days ago | prev | next [–] haha funny, but really cool project. why fish tho lol.

| | _2fnr 64 days ago | prev | next [14 more] [flagged]

| zkmon 64 days ago | parent | next [–] Meaning/goal of life is to reproduce. Food (and everything else) is only a means to it. Reproduction is the only root goal given by nature to any life form. All resources and qualities are provided are only to help mating.

| tantalor 64 days ago | root | parent | next [–] Reproduction is the goal of genes.Food (not dying) is the goal of organisms.

| philote 64 days ago | root | parent | next [–] I'd argue genes nor life has a "goal". They are what they are because they've been successful at continuing their existence. Would you say a rock's goal is not to get broken?

| tantalor 64 days ago | root | parent | next [–] Only because genes/organisms can make choices (changes to its programming, or decisions) to optimize their path towards their goal.A rock is maybe not a good counterexample, but a crystal is because it can grow over time. So in some sense, it tries not to break. However a crystal cannot make any choices; it's behavior is locked into the chemistry it starts with.

| hca 64 days ago | root | parent | prev | next [–] No, evolution has encoded lust. It has not yet allowed for condoms. But it's a process.

| amelius 64 days ago | root | parent | prev | next [–] Then why are reproductive rates so low in western countries?https://en.wikipedia.org/wiki/List_of_countries_by_total_fer...

| darepublic 64 days ago | root | parent | next [–] The western lifestyle is an evolutionary dead end?

| vixen99 64 days ago | root | parent | next [–] It seems that some in the West want it to be and are working hard to make it so.

| michaelhoney 64 days ago | root | parent | prev | next [–] not just western countries

| inanutshellus 63 days ago | root | parent | prev | next [–] I don't get why anyone downvoted you but maybe we can "all get along" by saying:

"the meaning of life is to continue living."

Thus the short-term answer is "food" and "reproduction" is the long-term answer.

| amelius 64 days ago | parent | prev | next [–] It's arguably even better than the most famous answer to that question.

| siva7 64 days ago | root | parent | next [–] which is?

| amelius 64 days ago | root | parent | next [–] https://medium.com/change-your-mind/the-meaning-of-life-is-4...

| aditya7303011 64 days ago | prev | next [–] Did something similar last year https://github.com/aditya699/EduMOE

| | LeonTing1010 65 days ago | prev | next [2 more] [flagged]

| secabeen 65 days ago | parent | next [–] Training data is here:https://huggingface.co/datasets/arman-bd/guppylm-60k-generic

| | areys 64 days ago | prev | next [2 more] [flagged]

| moonu 64 days ago | parent | next [–] This comment seems ai-written

| | jiusanzhou 64 days ago | prev | next [3 more] [flagged]

| ngruhn 64 days ago | parent | next [–] comment smells AI written

| 3m 64 days ago | parent | prev | next [–] AI account

| dinkumthinkum 64 days ago | prev | next [–] I think this is a nice project because it is end to end and serves its goal well. Good job! It's a good example how someone might do something similar for a specific purpose. There are other visualizers that explain different aspects of LLMs but this is a good applied example.

| Propelloni 64 days ago | prev [–] Great work! I still think that [1] does a better job of helping us understand how GPT and LLM work, but yours is funnier.Then, some criticism. I probably don't get it, but I think the HN headline does your project a disservice. Your project does not demystify anything (see below) and it diverges from your project's claim, too. Furthermore, I think you claim too much on your github. "This project exists to show that training your own language model is not magic." and then just posts a few command line statements to execute. Yeah, running a mail server is not magic, just apt-get install exim4. So, code. Looking at train_guppylm.ipynb and, oh, it's PyTorch again. I'm better off reading [2] if I'm looking into that (I know, it is a published book, but I maintain my point).So, in short, it does not help the initiated or the uninitiated. For the initiated it needs more detail for it to be useful, the uninitiated more context for it to be understood. Still a fun project, even if oversold.[1] https://spreadsheets-are-all-you-need.ai/ [2] https://github.com/rasbt/LLMs-from-scratch

| jadengeller 64 days ago | parent [–] this comment seems to be astroturfing to sell a course

| Propelloni 63 days ago | root | parent [–] What do you mean, the LLM from Scratch book?

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: