Differences Between AI and Large Language Models: Concepts, Architecture, and Practice

    This article explains how artificial intelligence (AI) and large language models (LLMs) differ. It covers the hierarchy of AI concepts, the three scale characteristics of LLMs (parameters, training data, and compute), and the self-attention mechanism of the Transformer architecture that underpins most LLMs, with a simplified Python implementation.

    1. Start with the hierarchy: AI is a field, LLMs are a specific implementation

    Artificial intelligence (AI) is an interdisciplinary field that studies how to design theories, methods, and systems that enable machines to perform tasks requiring human intelligence, such as reasoning, perception, decision-making, and language understanding. It is not a single technology but a collection of multiple technical approaches.

    AI has developed in roughly three stages. The early stage was dominated by symbolism, represented by expert systems that reasoned using manually written rules. Connectionism then emerged, in which neural networks began learning patterns automatically from data. The current stage is led by deep learning, which has given rise to subfields such as computer vision, natural language processing, and speech recognition. In recent years, hybrid approaches that combine symbolic methods with neural networks, and multimodal models that process text, images, and speech together, have also developed rapidly.

    The table below shows the hierarchical relationships among several common concepts:

    Concept Definition Typical examples
    Artificial Intelligence (AI) A field that aims to simulate human intelligence in machines Rule engines, machine learning, deep learning
    Machine Learning Methods that learn patterns from data Linear regression, decision trees
    Deep Learning Machine learning methods that use multi-layer neural networks Convolutional neural networks, Transformers
    Large Language Model (LLM) A language model based on the Transformer, trained on large-scale text GPT series, etc.

    Therefore, LLMs are a subset of AI. Saying a system “uses AI” covers a broad scope, whereas saying it is a “large language model” refers to a specific class of models.

    2. Three scale characteristics of large language models

    Large language models (LLMs) are an implementation of deep learning for natural language processing. Their “large” scale mainly shows up in three areas: parameters, data, and compute.

    1. Parameter count
      Parameters are the learnable weights of a neural network. GPT-3, released in 2020, has 175 billion parameters, which was considered very large at the time. Publicly released large models since then range from several billion to several hundred billion parameters. A larger parameter count usually increases model capacity, but this does not guarantee better results. Training data quality, training methods, and inference cost also affect the final performance.

    2. Training data
      Training corpora typically include web pages, books, code, and academic papers. Data scale is often measured in tokens, but a token is not the same as a word. A token is the basic unit produced when a tokenizer splits text, and the same passage can produce very different token counts under different tokenizers. For common tokenizers, one English word corresponds to roughly 1 to 1.5 tokens, and one Chinese character corresponds to roughly 1 to 2 tokens. Therefore, stating only “tens of trillions of tokens” without specifying the tokenizer and counting method does not allow conversion to word counts.

    3. Compute resources
      Training a model with hundreds of billions of parameters typically requires thousands of high-performance accelerator cards working together, and the process can take from several weeks to several months. Training relies on distributed techniques such as data parallelism, tensor parallelism, and pipeline parallelism, which spread compute and memory load across multiple cards.

    3. The foundation: the self-attention mechanism of the Transformer

    The Transformer was introduced in 2017 in the paper “Attention Is All You Need,” by a research team at Google. It changed how sequence data is processed and forms the basis of most current large language models.

    Before the Transformer, text processing relied mainly on recurrent neural networks (RNNs) and their variants, LSTM and GRU. RNNs must process words one by one in order, and each step must finish before the next can start, which makes parallel computation difficult. In addition, information decays over long distances, so models struggle to capture relationships between words that are far apart.

    The core of the Transformer is the self-attention mechanism. When processing a given word, the model computes how relevant it is to every other word in the sequence, then aggregates information weighted by those relevance scores. Each input vector generates three separate representations: Query (Q), Key (K), and Value (V). The core formula is:

    Attention(Q, K, V) = softmax(QKᵀ / √d_k) V

    Here, d_k is the dimension of the key vectors. Dividing by √d_k prevents the dot products from becoming too large, which keeps the gradients of softmax stable.

    The code below gives a simplified implementation that can be run directly. For demonstration purposes, the input matrix X is used directly as Q, K, and V. In actual models, Q, K, and V are obtained by multiplying the input by learnable weight matrices.

    1. import numpy as np
    2. def softmax(x, axis=-1):
    3. # Subtract the maximum value first to prevent overflow in the exponential operation
    4. x_shifted = x - np.max(x, axis=axis, keepdims=True)
    5. exp_x = np.exp(x_shifted)
    6. return exp_x / np.sum(exp_x, axis=axis, keepdims=True)
    7. def self_attention(Q, K, V):
    8. d_k = K.shape[-1] # dimension of the key vectors