NLP Fundamentals: Tokenization, Embeddings, and Attention
Natural Language Processing (NLP) is the branch of AI concerned with enabling computers to understand, interpret, and generate human language. Before any model can process text, the raw string must be converted into numbers through tokenization. Modern tokenizers like Byte-Pair Encoding (BPE) and SentencePiece split text into subword units — neither full words nor individual characters, but a learned vocabulary of common fragments. For example, "unhappiness" might become ["un", "happiness"] or ["un", "happ", "iness"]. This balances vocabulary size with the ability to handle rare or unseen words.
Once tokenized, each token is mapped to a dense vector called an embedding. Unlike one-hot encoding (which treats every word as equally different from every other), embeddings place semantically similar words close together in a continuous vector space. "King" and "queen" are nearby; "king" and "refrigerator" are far apart. These embeddings are learned during training and capture rich semantic relationships. Word2Vec and GloVe were pioneering embedding methods; modern systems learn contextual embeddings where the same word gets different vectors depending on context (e.g., "bank" near "river" vs. "bank" near "money").
The attention mechanism is the breakthrough that made modern NLP possible. Attention allows the model to dynamically focus on the most relevant parts of the input when producing each output. Self-attention (used in transformers) lets every token attend to every other token in the sequence, computing relevance scores that determine how much each token should influence the representation of every other token. Multi-head attention runs multiple attention operations in parallel, each learning to focus on different types of relationships (syntactic, semantic, positional). This mechanism is what enables LLMs to understand context, resolve ambiguity, and maintain coherence over long passages.
From RNNs to Transformers: The Architecture Revolution
The history of NLP architectures is a story of progressively better ways to model context and scale computation. Rule-based systems (1960s-1990s) used hand-crafted grammars and dictionaries. Statistical methods (1990s-2010s) like n-gram models and TF-IDF learned patterns from data but struggled with long-range dependencies and required extensive feature engineering.
RNN-based models (2013-2017) brought neural approaches to NLP. Sequence-to-sequence architectures with LSTM encoders and decoders, augmented with attention, powered the first neural machine translation systems (Google Translate switched to neural MT in 2016). However, RNNs process tokens sequentially, creating a bottleneck that limits parallelization and makes training on very large datasets impractical.
The transformer architecture (Vaswani et al., 2017) eliminated recurrence entirely. By relying solely on self-attention and feedforward layers, transformers process all tokens in parallel. This unlocked massive scaling: models could now be trained on billions of tokens using hundreds of GPUs efficiently. The architecture has two main configurations: encoder-only models (like BERT) that produce rich representations for understanding tasks, decoder-only models (like GPT) that generate text autoregressively, and encoder-decoder models (like T5) that map input sequences to output sequences.
The transformer's impact cannot be overstated — it's the foundation of virtually every state-of-the-art NLP system today. As a PM, understanding this architecture helps you grasp why LLMs have specific characteristics: why they have context window limits (self-attention is quadratic in sequence length), why they generate text one token at a time (autoregressive decoding), and why scaling them up consistently improves performance (more parameters can capture more patterns).
How LLMs Work: Pre-training, Scaling Laws, and Emergent Abilities
Large Language Models are transformer-based neural networks trained on vast corpora of text data. The pre-training objective for decoder models (GPT-style) is deceptively simple: predict the next token. Given a sequence of tokens, predict what comes next. Despite this simplicity, next-token prediction at massive scale forces the model to learn grammar, facts, reasoning patterns, coding ability, and more — because predicting the next token accurately requires understanding all of these.
Pre-training happens in two main phases. Pre-training on large web corpora (trillions of tokens from books, websites, code repositories) teaches the model general language understanding and world knowledge. Post-training (including supervised fine-tuning on instruction-following data and RLHF) aligns the model with human preferences, making it helpful, harmless, and honest. This two-phase approach is why models like GPT-4 and Claude can follow instructions and engage in conversation despite being fundamentally next-token predictors.
Scaling laws (Kaplan et al., 2020; Hoffmann et al., 2022) revealed a remarkable finding: model performance improves predictably with increases in model size (parameters), dataset size (tokens), and compute (FLOPs). These power-law relationships have guided the industry's push toward ever-larger models. The "Chinchilla" paper showed that many early LLMs were undertrained — given a fixed compute budget, it's better to train a smaller model on more data than a larger model on less data.
Emergent abilities are capabilities that appear suddenly at certain scales rather than improving gradually. Few-shot learning, chain-of-thought reasoning, and code generation are examples of capabilities that seem absent in smaller models but emerge in larger ones. This is both exciting (new capabilities appear unexpectedly) and concerning (it's hard to predict what a model can and can't do without testing). As a PM, this means you should always empirically test capabilities rather than assuming them based on model size or benchmarks.
Key Models: GPT, Claude, Gemini, and the Open-Source Ecosystem
The LLM landscape is defined by a few frontier model families and a vibrant open-source ecosystem. Understanding their differences is essential for PM decisions about which model to use.
OpenAI's GPT series (GPT-3.5, GPT-4, GPT-4o) pioneered the commercial LLM market. GPT-4 is a multimodal model accepting text and images, known for strong reasoning and coding capabilities. OpenAI offers models through an API with usage-based pricing and has the largest developer ecosystem. Claude (by Anthropic) emphasizes safety, instruction-following, and long-context capabilities. Claude models are known for careful, nuanced responses and strong performance on complex analysis tasks. Claude supports very large context windows (up to 200K tokens). Gemini (by Google DeepMind) is natively multimodal (text, images, audio, video) and tightly integrated with Google's ecosystem. It excels at multimodal reasoning and has variants optimized for different use cases (Ultra, Pro, Flash).
The open-source ecosystem includes Meta's Llama series, Mistral's models, and others. Open models can be self-hosted, fine-tuned, and customized without API dependencies. They're typically smaller than frontier models but offer advantages in cost, privacy, latency, and control. For many production use cases, a fine-tuned open model can match or exceed a general-purpose frontier model on specific tasks.
As a PM, model selection involves balancing quality (does it perform well enough on your task?), cost (API pricing vs. self-hosting infrastructure), latency (response time requirements), privacy (can you send data to a third-party API?), reliability (uptime SLAs, rate limits), and vendor risk (dependency on a single provider's pricing and policies). Many production systems use multiple models: a frontier model for complex tasks and a smaller, cheaper model for simpler ones, often with a routing layer that directs requests appropriately.
Capabilities, Limitations, and the Hallucination Problem
LLMs demonstrate remarkable capabilities: natural language understanding, text generation, summarization, translation, code generation, reasoning, and creative writing. They can follow complex instructions, maintain context across long conversations, and adapt to new tasks with minimal examples (few-shot learning). These capabilities have enabled entirely new product categories — from AI assistants and code copilots to automated customer support and content generation tools.
However, LLMs have fundamental limitations that every PM must understand. Hallucination — generating confident, plausible-sounding but factually incorrect content — is perhaps the most critical. LLMs don't "know" facts the way a database does; they generate statistically likely continuations. This means they can fabricate citations, invent statistics, and state falsehoods with complete confidence. Hallucination rates vary by domain and query type, but no current LLM is hallucination-free.
Context window limitations constrain how much text a model can process at once. While windows have grown from 4K to 200K+ tokens, performance can degrade on very long contexts (the "lost in the middle" phenomenon, where information in the middle of long contexts is less likely to be used). Knowledge cutoffs mean models don't know about events after their training data was collected. Reasoning limitations appear in complex multi-step logic, mathematical computation, and tasks requiring precise counting or tracking of state.
For PMs, these limitations demand specific product design strategies: implement grounding (connecting LLM outputs to verified data sources), add citations so users can verify claims, use confidence indicators to communicate uncertainty, design human-in-the-loop workflows for high-stakes decisions, and clearly set user expectations about what the AI can and cannot do reliably. The products that succeed with LLMs aren't the ones that ignore limitations — they're the ones that design thoughtfully around them.