What is a token in an LLM?
Simple meaning
A token is a chunk of text the model reads and writes, often a subword rather than a full word.
Open the full page for Why, Steps, Example and Key takeaway.
Panel-ready GenAI / LLM questions for freshers and experienced developers. Practice at Coding Cadre in Faridabad, or Online from Delhi NCR.
A token is a chunk of text the model reads and writes, often a subword rather than a full word.
Open the full page for Why, Steps, Example and Key takeaway.
Tokenizers split rare words, punctuation, and code into several pieces and may merge common phrases into one piece.
Open the full page for Why, Steps, Example and Key takeaway.
Tokenization converts raw text into a sequence of integer IDs from a fixed vocabulary.
Open the full page for Why, Steps, Example and Key takeaway.
Byte Pair Encoding starts from characters or bytes and repeatedly merges the most frequent adjacent pairs into new vocabulary items.
Open the full page for Why, Steps, Example and Key takeaway.
Input tokens are the prompt, system message, history, and any retrieved context you send in.
Open the full page for Why, Steps, Example and Key takeaway.
An embedding is a dense numeric vector that represents text, an image, or another item in a continuous space.
Open the full page for Why, Steps, Example and Key takeaway.
Cosine similarity measures the angle between two vectors, not their raw length.
Open the full page for Why, Steps, Example and Key takeaway.
Keyword search needs overlapping words.
Open the full page for Why, Steps, Example and Key takeaway.
Open the full page for Why, Steps, Example and Key takeaway.
Semantic search ranks documents by meaning rather than exact keyword overlap.
Open the full page for Why, Steps, Example and Key takeaway.
A transformer is a neural architecture that uses attention to relate all positions in a sequence in parallel.
Open the full page for Why, Steps, Example and Key takeaway.
RNNs process tokens one after another, which is slow to train and weak on long-range links.
Open the full page for Why, Steps, Example and Key takeaway.
An encoder builds bidirectional representations of the full input.
Open the full page for Why, Steps, Example and Key takeaway.
Attention itself has no sense of order, so the model needs position signals.
Open the full page for Why, Steps, Example and Key takeaway.
Attention lets the model weight how much each token should influence another token.
Open the full page for Why, Steps, Example and Key takeaway.
Self-attention computes attention among tokens of the same sequence.
Open the full page for Why, Steps, Example and Key takeaway.
Each token is projected into query, key, and value vectors.
Open the full page for Why, Steps, Example and Key takeaway.
Multi-head attention runs several attention operations in parallel with different projections.
Open the full page for Why, Steps, Example and Key takeaway.
Causal attention blocks a token from seeing future tokens.
Open the full page for Why, Steps, Example and Key takeaway.
GPT stands for Generative Pre-trained Transformer.
Open the full page for Why, Steps, Example and Key takeaway.