Huzi Blogs
BlogCategories
BlogCategories
Disclaimer & Data Privacy Policy
Project by huzi.pk

© 2026 blogs.huzi.pk. All Rights Reserved.

    Back to all posts
    AI

    How Large Language Models Work: A Deep Dive

    By Huzi

    Every chatbot you have ever argued with — ChatGPT, Claude, Gemini, DeepSeek — is doing one strange, simple thing: predicting the next token, again and again, at enormous speed. The essays, the bug fixes, the awkward poems all fall out of that single trick. Once you see the machinery underneath, you also see why these systems fail the way they do.

    Words become tokens

    Models cannot read; they compute. Your text is first chopped into tokens — chunks that are often words or pieces of words. "Unbelievable" may split into pieces, and Urdu or code-mixed Roman Urdu tends to shatter into many more tokens than English, which is one reason local-language prompts cost more and stumble more. Each token becomes a list of numbers, and from that point the model is doing arithmetic on numbers, nothing else.

    Attention: the 2017 idea that changed everything

    Older language models read text one word at a time and kept forgetting the start of long sentences. The 2017 research paper "Attention Is All You Need" introduced the transformer, which reads everything at once and lets each word weigh the importance of every other word. In "the cat sat on the mat because it was tired", understanding "it" means attending strongly to "cat". That weighting mechanism is called attention, and because transformers process the whole sequence in parallel, they could be scaled up on GPU clusters — and scale, it turned out, was nearly everything.

    Training happens in three passes

    Pre-training comes first: the model reads an enormous slice of the internet with one job, guess the next token, and its billions of internal weights get nudged every time it guesses wrong. Out of that dumb repetition comes grammar, facts, and a startling amount of reasoning ability. Then supervised fine-tuning teaches it to behave like an assistant, using human-written examples of good answers. Finally comes alignment: reviewers rank different responses, and the model is nudged toward the answers people prefer — RLHF, the step that made chatbots polite instead of merely fluent.

    The context window

    A model's working memory is its context window: everything it can hold in mind at once. Early chatbots managed a few thousand tokens, roughly a long email thread. Frontier models now claim windows in the millions of tokens — whole codebases, whole books — though attention dilutes as the window grows, and the marketing claim and the everyday usefulness are not always the same thing. When a chatbot forgets the start of your conversation, you have met the window's edge.

    Why they hallucinate

    Here is the uncomfortable truth: nothing in that pipeline checks facts. The model's only obligation is to produce plausible next tokens. When the truthful continuation is not in its weights, it still produces the most statistically likely one — fluent, confident, and sometimes invented. This is not a bug waiting to be patched; it is the mechanism. The defences are practical. Ask for sources and actually open them. Keep important facts out of the model and in your own documents — the retrieval pattern businesses use. And never let confident prose substitute for verification.

    A model fills the gaps in its knowledge with plausible guesses. Gaza's reality is the opposite of a guess — it is being documented by the people living it, at terrible cost. Believing witnesses over fluent noise remains a human responsibility no tool will take over for us.

    One more thing about prediction: we do it professionally. Our team at HTG Travels predicts the next problem before it lands — the cancelled flight at 2 a.m., the missed connection, the visa snag mid-trip. Save our WhatsApp number before you fly; being rebooked in minutes beats an hour of chatbot loops at a deserted airport counter.

    Advertisements


    You Might Also Like

    Fabulous Handwork Heavy Embroidered Net Bridal Maxi Suit | Silk Trouser

    Fabulous Handwork Heavy Embroidered Net Bridal Maxi Suit | Silk Trouser

    PKR 7300

    Skin-Color Dhanak Winter Dress – Subtle Embroidery, Matching Shawl

    Skin-Color Dhanak Winter Dress – Subtle Embroidery, Matching Shawl

    PKR 5199

    Black Luxury Embroidered Chiffon Wedding Dress – Unstitched Party & Wedding Wear for Women (Zari, Sequins, Thread Work)

    Black Luxury Embroidered Chiffon Wedding Dress – Unstitched Party & Wedding Wear for Women (Zari, Sequins, Thread Work)

    PKR 6600

    Luxury Heavy Embroidered Organza Wedding Dress 2026

    Luxury Heavy Embroidered Organza Wedding Dress 2026

    PKR 7900

    Formal Heavy Embroidered Organza Mehndi Suit 2026 | Plain Trouser

    Formal Heavy Embroidered Organza Mehndi Suit 2026 | Plain Trouser

    PKR 5100

    Advertisements


    Related Posts

    AI
    What is Generative AI? An Easy-to-Understand Explanation
    Generative AI makes new text, images, audio and code instead of just predicting — here is how transformers and diffusion models actually work, and the tools worth knowing: ChatGPT, Suno, Sora, Flux.

    By Huzi

    Read More
    AI
    A Gentle Introduction to Natural Language Processing (NLP)
    NLP is how computers handle human language — and it was built English-first. What that means for Urdu, Punjabi, Sindhi, and Pashto, and why Pakistan's languages are the field's interesting frontier.

    By Huzi

    Read More
    AI
    Deep Learning vs Machine Learning: What's the Difference in 2025?
    Deep learning is a subset of machine learning, not its rival — the difference is who engineers the features. A practical 2025 guide to when XGBoost still wins, when deep networks pay off, and the hybrid pattern production teams actually ship.

    By Huzi

    Read More
    AI
    The Visionary Machine: Understanding Computer Vision in 2025
    How machines actually see — pixel grids, CNNs and Vision Transformers — explained through things you already use: face recognition, portrait mode, WhatsApp scans and Hawk-Eye in cricket.

    By Huzi

    Read More
    AI
    The Rise of AI Tools: How Artificial Intelligence is Changing Productivity in 2025
    ChatGPT, Perplexity, NotebookLM, Cursor, Canva — the 2025 AI tool stack is genuinely useful and genuinely expensive. How to pick a few, use free tiers, and pay from Pakistan when cards fail.

    By Huzi

    Read More
    AI
    The Hidden Carbon Bill of Generative AI: What Every Blogger Should Know in 2025
    Data centres, GPU electricity, and cooling water: the reported environmental cost of generative AI, and the practical choices that cut most of a blogger's AI footprint without guilt.

    By Huzi

    Read More