{"slug": "show-hn-the-smallest-llm-in-javascript", "title": "Show HN: The Smallest LLM in JavaScript", "summary": "A developer published a minimal JavaScript implementation of a language model on GitHub, using a Markov-chain approach to predict the next word from a small training string. The roughly 20-line script builds a lookup table of word transitions and randomly samples successors to generate text, demonstrating the core next-token idea behind large language models without any neural network or dependencies.", "body_md": "Created\n          September 20, 2026 04:04 \n\n- \n- \nSave skorotkiewicz/dedc3b5a857be7d0f2b378334721713c to your computer and use it in GitHub Desktop.\n\n    the smallest LLM\n  \n\n      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.\n      \n\n[Learn more about bidirectional Unicode characters](https://github.co/hiddenchars)\n|  | const text = \"mama dad mama cat dad mama dog\"; | \n|  | const words = text.split(\" \"); | \n|  | const model = {}; | \n|  | for (let i = 0; i < words.length - 1; i++) { | \n|  | const a = words[i]; | \n|  | const b = words[i + 1]; | \n|  | model[a] ??= []; | \n|  | model[a].push(b); | \n|  | } | \n|  | function next(word) { | \n|  | const choices = model[word] ?? words; | \n|  | return choices[Math.floor(Math.random() * choices.length)]; | \n|  | } | \n|  | function generate(start, n = 10) { | \n|  | let word = start; | \n|  | const out = [word]; | \n|  | for (let i = 0; i < n; i++) { | \n|  | word = next(word); | \n|  | out.push(word); | \n|  | } | \n|  | return out.join(\" \"); | \n|  | } | \n|  | console.log(generate(\"mama\")); | \n\nAuthor", "url": "https://wpnews.pro/news/show-hn-the-smallest-llm-in-javascript", "canonical_source": "https://gist.github.com/skorotkiewicz/dedc3b5a857be7d0f2b378334721713c", "published_at": "2026-09-20 04:05:05+00:00", "updated_at": "2026-09-20 04:23:08.244081+00:00", "lang": "en", "topics": ["large-language-models", "artificial-intelligence", "generative-ai", "developer-tools"], "entities": ["GitHub", "JavaScript"], "alternates": {"html": "https://wpnews.pro/news/show-hn-the-smallest-llm-in-javascript", "markdown": "https://wpnews.pro/news/show-hn-the-smallest-llm-in-javascript.md", "text": "https://wpnews.pro/news/show-hn-the-smallest-llm-in-javascript.txt", "jsonld": "https://wpnews.pro/news/show-hn-the-smallest-llm-in-javascript.jsonld"}}