How LLM works explained in 2 mins or less:
Large Language Models (LLMs) are like smart autocomplete.
They make predictions based on the massive data they got trained on.
It doesn't know facts, but predicts probabilities.
——
Here's how it works:
1 Pre-training
↳ A model learns language patterns from large amounts of text.
↳ Text from books, articles & websites gets collected and split into tokens.
↳ A token is a piece of text (word, part of a word, or punctuation) that an LLM reads.
↳ Transformer looks at the tokens in a sentence & learns how they relate to each other.
↳ Model predicts next token and then adjusts its parameters to improve future predictions.
——
2 Reinforcement Learning from Human Feedback (RLHF)
↳ RLHF is fine-tuning a pre-trained model to align its responses with human preferences.
↳ Humans review model responses to same prompt and rank them from best to worst.
↳ A separate model is trained on those rankings to learn which responses humans prefer.
↳ Then, this separate model scores the LLM responses and update model's parameters.
——
3 Retrieval-Augmented Generation (RAG)
↳ External data is added to prompt to help model generate accurate responses.
↳ AI system sends the query to Search APIs such as SerpApi.
↳ SerpApi provides real-time, structured results.
↳ Retrieved content gets inserted into prompt to reduce hallucinations.
——
4 Inference
↳ Trained model generates a response to the prompt.
↳ System combines system instructions, user question, retrieved data and converts them into tokens.
↳ Transformer processes these tokens and predicts the most probable next token.
↳ Tokens are generated one-by-one and converted back into text until response is complete
——
5 Guardrails & Evaluation
↳ Apply safety filters to prevent harmful or off-scope responses.
↳ Use metrics (faithfulness, relevance) to ensure grounded, reliable output.
——
• Model: Trained AI system that learns patterns from data to make predictions or generate outputs.
• Transformer: A neural network architecture that looks at tokens in a sentence & learns how they relate to each other.
• Parameters: Numerical weight in model that gets adjusted during training to improve predictions.
What else would you add?