Understanding Large Language Models.

Vikas KumarVikas Kumar
6 min read

What is this?🤨

A Large Language Model is a specialized form of Artificial Intelligence which is excellent in processing, comprehending and generating human readable outputs. These Models are built on deep learning algorithms, which are a part of machine learning. Deep learning utilizes neural networks trained on extensive datasets to identify complex patterns within data. The primary function of LLMs is to recognize, summarize, translate, predict, and produce text and other forms of content (that we all see nowdays), drawing upon the vast knowledge acquired during their training. Their design enables them to generate coherent and contextually appropriate sentences and paragraphs in response to user prompts. Which is totally magic🥳.

The main question where they come from - LLMs themselve are the result of massive training on large datasets of text and code. datasets frequently encompass nearly all text available on the internet over an extended period. This extensive training involves processing billions, or even trillions, of data parameters. Such a colossal scale allows LLMs to discern highly intricate patterns within language, enabling them to execute a wide array of lauage-related tasks with remarkable proficiency. To make these models usable for solving the real worls problem, they need to be deployed on powerful infrastucture, which is where LLM servers comes in.

Poweful in predicting the Next word/Token🎶

LLMs function by analyzing large volumes of training data to predict the most probable response to any given request. During their training phase, these models are designed to learn to anticipate the next word, or more precisely, the next "token," token is just a jorgan in AI term- in a sequence based on the context provided by the preceding tokens. This operational principle can be conceptualized as a highly advanced form of predictive text. The model leverages its extensive training on a vast body of text, or "corpus," to generate coherent responses that can span multiple paragraphs and cover a wide array of subjects.

Role of Training Data🐝

Large Language Models become smart by learning from an enormous amount of text. They are trained on datasets so huge that they include almost everything written on the internet over many years, plus books and research papers. All this text is fed into the AI during training. The main way they learn is called unsupervised learning. This means the model gets the data without anyone giving it step-by-step instructions or labels. Instead, it figures things out by itself. While reading, it notices how words are related and what ideas they represent. For example, it can tell that the word “bark” means something different when talking about a dog versus a tree.

More specifically, LLMs use a method called self-supervised learning. In this method, the model creates its own “training tasks” from the text. One common task is next token prediction — the AI tries to guess the next word in a sentence based on the words before it. It repeats this billions of times. By doing so, it learns grammar, sentence structure, meaning, and even some common sense.

This learning process is not about memorizing rules. Instead, the model learns by spotting patterns in how words appear together. Over time, it builds an internal map of language that helps it understand context and produce sentences that sound thoughtful and make sense. This is very different from old-fashioned systems where people had to program every single rule by hand.

However, learning from such massive internet-based data also has problems. The internet contains mistakes, bias, and unfair opinions. If the training text includes wrong information or stereotypes, the model can learn them too. This can cause it to make up facts (called hallucinations) or repeat biased ideas.

The Inner Workings🤖

Think of the Transformer as the brain that makes today’s AI like ChatGPT, Gemini Grok and Deepseek soooooo smart.
Before Transformers, older AI read sentences one word at a time, like reading a book slowly. Transformers, however, can look at the whole sentence at once, which makes them much faster and better at understanding how all the words connect — even if they are far apart in the sentence.

Inside the Brain🧠

Self-Attention:

Imagine you’re reading a story. To understand one word, you might look at other words in the sentence to figure out its meaning.
For example, in “The dog’s bark was loud”, “bark” means sound, not tree skin.
Self-attention lets the AI do the same thing — it checks every word against every other word to understand the full meaning.

In simple form:

  • Query (Q): The word we are focusing on.

  • Key (K): The “labels” of all words it can compare to.

  • Value (V): The actual meaning or information the AI pulls once it finds a match.

Positional Encoding:

Since Transformers read all words at once, they need a way to remember which word comes first, second, third, etc.
Positional encoding gives each word a little “position tag” — like numbering seats in a theater — so the AI knows the correct order.

Multi-Head Attention:

This is like having many pairs of eyes looking at the same sentence in different ways.
One “eye” might focus on grammar, another on meaning, another on emotion. Combining these gives the AI a richer understanding.

MLP Layer:

After attention finds connections between words, the MLP (a small extra brain inside the big brain) works on improving each word’s meaning before sending it on.

Main workers⚒️

Encoders and Decoders

  • Encoder: Reads and understands the input (like listening to a sentence and fully getting its meaning).

  • Decoder: Takes that understanding and writes or speaks back an answer, one word at a time.

Some AIs use only encoders (for understanding), some use only decoders (for creating text), and some use both (for tasks like translation).

How AI Picks the Next Word (Token Prediction)✅

Once the Transformer has understood your text:

  1. It sends it through a final layer that guesses which word might come next.

  2. It assigns a score (probability) to each possible word.

  3. A special math step turns those scores into probabilities that add up to 100%.

  4. The AI then chooses the next word using different strategies.

Three Main Types of LLM Architectures🛸

TypeHow It WorksBest AtExamples
Encoder-OnlyJust understands input, no text generation.Classifying text, spotting names in sentences, finding answers in a paragraph.BERT, DistilBERT
Decoder-OnlyOnly creates text, looking at previous words to guess the next one.Writing stories, chatting, answering questions creatively.GPT, Llama
Encoder-DecoderUnderstands first, then generates text.Translating languages, summarizing books.BART, T5

I hope you find this useful. I will try to explain more concepts further in easy way.

0
Subscribe to my newsletter

Read articles from Vikas Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Vikas Kumar
Vikas Kumar

As a Frontend Web Developer, I bring a unique blend of technical expertise and creative vision to design and implement robust web applications. My proficiency in core web technologies including HTML, CSS, and JavaScript, combined with hands-on experience in React and NodeJs, allows me to deliver high-performance, responsive, and intuitive user interfaces. I am also dedicated to continuous learning and community engagement, regularly publishing technical blogs to share insights and foster collaborative growth.