LLM Field Guide

1 Β· What is a Large Language Model?

A Large Language Model (LLM) is a neural network trained on enormous amounts of text to do one thing extremely well: predict the next token in a sequence[reference:0]. Tokens are pieces of words β€” for example, "unbelievable" might become ["un", "believ", "able"].

That single objective β€” next-token prediction β€” is powerful enough to produce coherent essays, working code, translations, and conversations. The model learns the statistical patterns of language so thoroughly that it can generate text that feels intelligent, even though it has no conscious understanding[reference:1].

πŸ’‘ The core idea in one sentence An LLM is a probability engine: given a sequence of tokens, it assigns probabilities to every possible next token and picks one[reference:2].

2 Β· How LLMs Work

2.1 Β· Tokens: the model's building blocks

Before anything else, text is split into tokens. A token can be a whole word, a subword, or even a single character. On average, 100 tokens β‰ˆ 75 English words[reference:3]. Every token is mapped to an integer ID, then to a vector (a list of numbers) called an embedding.

2.2 Β· The Transformer & attention

The breakthrough architecture behind modern LLMs is the Transformer (introduced in the 2017 paper "Attention Is All You Need")[reference:4]. Its key innovation is self-attention: when processing each token, the model looks at every other token in the sequence and learns which ones matter most for predicting what comes next[reference:5].

Think of it this way: in the sentence "The bank wouldn't approve the loan because it was too risky," attention lets the model connect "it" to "loan" rather than "bank." Early RNNs processed text word-by-word and forgot earlier context; Transformers process the whole sequence in parallel and keep everything relevant in view.

2.3 Β· Training pipeline

StageWhat happensAnalogy
Pre-training Model reads trillions of tokens (web pages, books, code) and learns to predict the next token. This is the most compute-intensive phase. Reading every book in a library
Supervised Fine-tuning (SFT) Model is trained on question–answer pairs to learn the format of helpful dialogue. Learning to answer exam questions
RLHF Humans rank model outputs; the model learns to produce answers that people prefer β€” safer, more helpful, more natural. Getting feedback from a writing tutor

These stages are described in detail in beginner-oriented LLM literature[reference:6].

2.4 Β· Inference: generating text

When you send a prompt, the model runs inference β€” it generates one token at a time, feeding each new token back into the context to produce the next one. This loop repeats until a stop condition is met[reference:7].

Your prompt β†’ tokenize β†’ Transformer β†’ pick next token β†’ append β†’ repeat β†’ detokenize β†’ your answer

2.5 Β· Key parameters you can control

ParameterWhat it doesTypical values
Temperature Controls randomness. Low (0.0–0.3) = focused, deterministic. High (0.7–1.0+) = creative, varied. 0.2 for factual Q&A, 0.9 for brainstorming
Max tokens Limits how long the response can be. 500–4000 depending on task
Top-p Alternative to temperature; restricts sampling to the most probable tokens whose cumulative probability reaches p. 0.9

Temperature is the most widely used generation setting, and understanding it is essential for getting useful outputs[reference:8].

3 Β· How to Make the Best Use of LLMs

3.1 Β· Prompt engineering fundamentals

Prompt engineering is the practice of designing your input to get better outputs. It requires no extra training data or infrastructure β€” just clearer thinking[reference:9].

Be explicit

Don't assume the model will infer what you want. State it directly, with action verbs and concrete requirements[reference:10].

Vague vs. explicit

Vague: Make a dashboard.

Explicit: Create an analytics dashboard. Include at least five metrics, a date-range filter, and a bar chart showing weekly trends.

Use a system message

A system message sets the model's role, tone, boundaries, and output format. It's the highest-level instruction and should come first[reference:11].

System message example
You are a friendly travel advisor for Margie's Travel.
Answer only travel-related questions.
Use a warm, conversational tone.
If you lack information, ask a clarifying question.
Format hotel recommendations as a bulleted list.

Source: Microsoft Learn prompt engineering guide[reference:12].

Provide context and motivation

Explain why you want something β€” not just what. This helps modern models reason about your underlying goal[reference:13].

Context changes the output

Without: NEVER use bullet points.

With: I prefer natural paragraph form rather than bullet points because flowing prose is easier for me to read when learning.

3.2 Β· Common prompt patterns

PatternHow to use itWhen to use it
Persona "You are a senior software engineer reviewing this code…" When you want expert-level tone or domain-specific reasoning.
Few-shot Provide 2–3 input/output examples before your actual request. When the desired format is hard to describe but easy to show.
Chain-of-thought "Think step by step before giving the final answer." Reasoning, math, logic problems.
Format template Specify exact output structure (JSON, markdown table, etc.). When downstream code needs to parse the response.

These patterns are documented in Microsoft's prompt engineering training module[reference:14].

3.3 Β· Known limitations to watch for

LimitationWhat it meansMitigation
Knowledge cutoff The model only knows what it was trained on up to a certain date. Use RAG (retrieval-augmented generation) to inject current data.
Hallucination The model confidently generates false information. Ask for sources; verify critical facts; use groundedness detection.
Context window limit The model can only "see" a fixed number of tokens at once. Summarise long conversations; use larger-context models for big documents.
No learning from interaction The model doesn't remember previous chats unless you send history each time. Include relevant prior context in your prompt.

These limitations are discussed in Microsoft's generative AI concepts guide[reference:15].

3.4 Β· Practical tips for beginners

4 Β· Working Environments

You can interact with LLMs through several different channels. Each has different trade-offs in cost, privacy, latency, and capability.

EnvironmentHow it worksBest for
Chat UI (ChatGPT, Claude, Gemini) Web interface; you type messages and read responses. Exploration, brainstorming, learning.
Cloud API (OpenAI, Anthropic, Google) You send HTTP requests from your code; the provider runs the model. Apps, automation, production systems.
Local runtime (Ollama, llama.cpp, LM Studio) Model runs on your own machine. No data leaves your device. Privacy, offline use, experimentation.
Hybrid / SDK (xlocllm, Foundry Local) Local inference behind an OpenAI-compatible API, so existing code works unchanged. Development with privacy and cost control.

4.1 Β· Cloud APIs

The most common approach for applications. You call a REST endpoint, pay per token, and the provider handles scaling. Example using the OpenAI Python SDK:

from openai import OpenAI

client = OpenAI(api_key="sk-...")

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Explain attention in simple terms."}
    ],
    temperature=0.3
)
print(response.choices[0].message.content)

4.2 Β· Local runtimes

Tools like Ollama let you run open-weight models (e.g. Llama, Mistral, Qwen) on your own hardware. This avoids per-token costs and keeps data private, but you need sufficient RAM/VRAM and accept lower speed.

# Example with Ollama
ollama run llama3.2
# Then chat with the model in your terminal

4.3 Β· Hybrid SDKs

Some SDKs bridge local and remote inference. For instance, xlocllm exposes an OpenAI-compatible endpoint on localhost while running model weights in a browser via WebGPU. Your existing OpenAI client code works without changes[reference:19].

4.4 Β· Choosing an environment

5 Β· Glossary of Terms & Acronyms

API β€” Application Programming Interface
A way for your code to talk to another service. When you call openai.chat.completions.create(), you're using an API[reference:20].
Attention
The mechanism inside transformers that lets each token decide which other tokens are most relevant for predicting the next one. The core idea of the "Attention Is All You Need" paper[reference:21].
Base Model
A model that has been pre-trained on text but not fine-tuned to follow instructions. It just continues text β€” it doesn't have a helpful persona[reference:22].
Chain-of-Thought (CoT)
A prompting technique where you ask the model to "think step by step." Dramatically improves reasoning performance[reference:23].
Context Window
The maximum number of tokens a model can process in a single call β€” including your prompt, the conversation history, and any documents you provide[reference:24].
Embedding
A numerical vector that represents the meaning of text. Texts with similar meanings have similar embeddings. Used for search, clustering, and RAG[reference:25].
Fine-tuning
Further training a pre-trained model on a smaller, task-specific dataset to specialise it for a domain or behaviour[reference:26].
Hallucination
When an LLM generates information that sounds confident but is factually incorrect or ungrounded in its training data[reference:27].
Inference
The act of running a trained model to generate output. Every time you send a prompt and get a response, that's inference[reference:28].
LLM β€” Large Language Model
A neural network with billions of parameters, trained on vast text data, capable of generating coherent language[reference:29].
LLMOps β€” LLM Operations
Practices and workflows for developing, deploying, and managing LLM applications throughout their lifecycle[reference:30].
LoRA β€” Low-Rank Adaptation
A parameter-efficient fine-tuning method that adds small trainable matrices instead of retraining all weights. Makes fine-tuning accessible on limited hardware[reference:31].
MoE β€” Mixture of Experts
An architecture where only a subset of the model's parameters (the "experts") are activated for each input, allowing high capacity with lower per-inference compute[reference:32].
Multimodal
A model that can process more than one type of data β€” text, images, audio β€” simultaneously[reference:33].
Parameters
The trainable weights of a neural network, adjusted during training. Large LLMs have billions to trillions of parameters[reference:34].
Prompt Engineering
The practice of designing and refining prompts to improve the quality, accuracy, and relevance of model outputs[reference:35].
RAG β€” Retrieval-Augmented Generation
A technique that retrieves relevant documents and injects them into the prompt, giving the model access to up-to-date or private information[reference:36].
RLHF β€” Reinforcement Learning from Human Feedback
A training stage where humans rank model outputs, and the model learns to produce responses that align with human preferences[reference:37].
System Message
Instructions at the start of a conversation that define the model's role, tone, boundaries, and output format[reference:38].
Temperature
A parameter controlling randomness. Low = focused and deterministic; high = creative and varied[reference:39].
Token
The smallest unit of text a model processes. Can be a whole word, a subword, or a character. 100 tokens β‰ˆ 75 English words[reference:40].
Transformer
The neural network architecture behind all modern LLMs. Uses self-attention to process sequences in parallel[reference:41].
← Back LLM Field Guide ⌂ Encyclopedia Next →