Purpose
This is a visual explainer article intended to explain to general readers how the large language models (LLMs) that AI chatbots such as ChatGPT and Bard rely on work. Through visual diagrams, the article shows step by step the process from a user entering a question to the model generating an answer.
Main Content
The article first points out that large language models are the underlying architecture of chatbots such as ChatGPT and Bard. When a user enters a question into ChatGPT (such as "What is the capital of France?"), the LLM needs to process that question in order to produce an answer (such as "The capital of France is Paris").
Basic Structure
LLMs are inspired by the way the human brain works, but they are not a copy of it. The basic structure of the model consists of nodes and connections. Nodes essentially represent words, and the model's basic task is to map the "distance" between words and output the "most likely next word."
Tokens and Vectors
Words or parts of words (such as the plural marker "s" or the prefix "un-") are stored in the model as tokens. Each token is not represented as a sequence of letters, but as a vector—that is, a sequence of numbers. A vector is similar to map coordinates; for example, Paris can be represented as [2.34337,48.85663]. Vectors not only represent position, but also encode the "closeness" between tokens. But unlike two-dimensional or three-dimensional maps, vectors in an LLM have hundreds of dimensions. We do not know exactly what each dimension encodes, but it may include properties such as "substitutability"—in that dimension, "happy" may be close to "sad," even though in other dimensions they may be far apart.
Prediction and Transformer
An LLM is still essentially just judging the next most likely word or sequence of words. It performs better than predictive text in texting apps for two reasons: the Transformer and the attention mechanism.
The Transformer is a mathematical process that recalculates the vector for each token, that is, assigns a new distance to each pair of tokens based on context. For example, when asking "What is a tidy thing to eat pasta with?" and "What is a nice thing to eat pasta with?", the LLM reweights associations based on the other tokens in the question. In the first question, "tidy" may be closely related to "utility" and "tools"; in the second question, "nice" may be related to "taste" and "flavour." The word "with" itself is also reweighted based on the preceding words, moving closer to "using" or "accompanied by" respectively.
Attention Mechanism
This principle of reassessing weights based on the salience of preceding text is called "attention." The LLM applies these steps to each part of the conversation. For example, when asked "What is the capital of France?", after receiving the additional input "France," the model reassesses that "capital" may refer to a "city" rather than "financial resources." When subsequently asked "How many people live there?", the model has already assigned sufficient salience to "Paris (city)" to infer that "there" refers to "Paris."
Training
Attention is widely regarded as a breakthrough development in natural language AI, but it alone does not produce a successful model. Each model then undergoes extensive training, partly to master the question-and-answer format, and often also to filter out inappropriate responses (sometimes sexist or racist) that might arise from uncritically adopting content from the training corpus.
Applicable Scenarios
Suitable for general readers interested in how AI chatbots work, especially those who want to understand the foundational concepts of large language models (such as tokens, vectors, Transformers, and attention) through visualization.
Limitations
The article is a visual explanation and does not provide usage steps, feature lists, pricing information, or platform details for specific products. Some visualizations are illustrative, but reference conversations with industry experts and publicly available LLMs. The vector for "happy" in the article comes from the BERT language model, using the transformers Python package.