Docs / Knowledge Base / Machine Learning: LLMs
Knowledge Base
Contents
- At a glance
- Online references (live)
- Offline snapshots (link-rot shield)
- Applications at Keyne Digital Assets
- The rise of GPT, is it open source?
- Open source alternatives
- Quick tip: Einstein Notation & Penrose Notation
- How LLMs work
- Comparing with NLP
- Going deeper into Embeddings
- Brief history
- Timeline
- Part index
Machine Learning: LLMs
Part: Computer Science · Chapter: Machine Learning: LLMs · Edition: 2026-07-12
Keywords: transformer, pretraining, alignment, tokenization, context
Glossary:transformer,pretraining,token,alignment— see GLOSSARY
At a glance
- Large language models learn linguistic patterns from large corpora, without an explicit grammar.
- The chapter indexes architecture, training, open and proprietary systems, and contrasts with earlier NLP libraries.
- It is orientation, not a product comparison and not a deployment guide.
Online references (live)
Offline snapshots (link-rot shield)
Offline snapshot omitted in this web edition. Offline snapshot · Large language model · https://en.wikipedia.org/wiki/Large_language_model · retrieved 2026-07-12
Offline snapshot omitted in this web edition. Offline snapshot · Transformer (deep learning) · https://en.wikipedia.org/wiki/Transformer_(deep_learning_architecture) · retrieved 2026-07-12
Transformer (deep learning architecture)
Offline snapshot omitted in this web edition. Offline snapshot · Attention (machine learning) · https://en.wikipedia.org/wiki/Attention_(machine_learning) · retrieved 2026-07-12
This chapter is an index of large language models and their place in natural-language processing: architecture, training, open and proprietary systems, and how they differ from earlier NLP libraries. It is orientation, not a product comparison and not a guide to deploying a model in production.
Applications at Keyne Digital Assets
Language models are one of the tools we use when we classify, summarize or retrieve public language. This chapter orients that work. It is not a claim that Situation Monitor implements every model listed here, and it is not a benchmark report.
The rise of GPT, is it open source?
GPT (Generative Pre-trained Transformer), developed by OpenAI, is not open source. While OpenAI has released smaller models like GPT-2 and GPT-3 (with certain limitations) for research and experimentation purposes, the complete and most advanced versions, including GPT-4, are proprietary and not publicly available as open-source software.
Running a GPT model locally on a single machine depends on several factors:
- Model Size: Smaller models like GPT-2 can be feasibly run on a single machine with a capable GPU. However, larger models like GPT-3 or GPT-4 require significantly more computational resources, which may not be practical or feasible for an individual setup.
- Computational Resources: To run a GPT model, you need a powerful GPU and substantial RAM, especially for larger models. The computational requirements increase with the model size.
- Access to the Model: As mentioned, while smaller models might be available for download, larger models like GPT-3 and GPT-4 are accessed via API, and OpenAI does not provide the complete model for local installation.
- Cost and Efficiency: Even if it were feasible to run larger models locally, the cost of the required hardware and the electricity to power and cool it would likely be prohibitive for most individual users. Furthermore, OpenAI’s cloud-based setup is optimized for efficiency and performance, something difficult to replicate on a single machine.
In summary, while it is technically possible to run smaller versions of GPT locally, doing so with the most advanced versions like GPT-4 is not currently feasible due to their proprietary nature and the significant computational resources required.
Open source alternatives
The design of models like GPT (Generative Pre-trained Transformer) involves several key components and processes:
- Architecture: GPT models are based on the Transformer architecture, which was introduced in a paper by Vaswani et al. in 2017. The Transformer architecture is particularly effective for handling sequential data, making it well-suited for natural language processing tasks.
- Pre-training: These models undergo a pre-training phase where they learn from a vast corpus of text. This phase involves unsupervised learning, where the model learns to predict the next word in a sentence, given the words that come before it. This process helps the model learn language patterns, grammar, and even some factual information.
- Fine-tuning: After pre-training, the model can be fine-tuned on specific tasks, like question answering or language translation, using a smaller, task-specific dataset. This fine-tuning adjusts the model weights to better perform the desired task.
- Large Scale Data and Compute: One of the key aspects of models like GPT-3 and GPT-4 is their scale. They are trained on vast datasets and require significant computational power, often involving large clusters of high-performance GPUs.
For those interested in experimenting with similar technologies, there are several powerful open-source alternatives:
- GPT-2: OpenAI has released smaller versions of GPT-2, which are quite powerful and can be used for a variety of natural language processing tasks.
- BERT (Bidirectional Encoder Representations from Transformers): Developed by Google, BERT is particularly good at understanding the context of a word in a sentence. It’s bidirectional, meaning it looks at the context from both sides of a word.
- T5 (Text-To-Text Transfer Transformer): Also from Google, T5 frames all NLP tasks as a text-to-text problem, converting every task into the format of “input text to output text.”
- XLNet: This is an extension of the Transformer model that outperforms BERT on several benchmarks. It uses a permutation-based training approach which is different from the traditional Transformer models.
- ELECTRA: Another model from Google, ELECTRA trains more efficiently and at a lower computational cost than models like BERT and GPT-2, while achieving comparable performance.
- Hugging Face’s Transformers Library: This is a widely-used library that provides access to many pre-trained models, including BERT, GPT-2, T5, and others. It’s a great resource for both research and application development in natural language processing.
These models and libraries offer a range of capabilities similar to those of GPT models, and they are more accessible for experimentation and use in various projects.
Quick tip: Einstein Notation & Penrose Notation
“The number of people in the world who understand machine learning might be increased massively if the undergraduate linear algebra pedagogy replaced the core rows-and-columns ontology with Einstein notation and Penrose notation”
This touches on a fascinating topic related to the methods used to teach and understand mathematical concepts, especially as they relate to machine learning.
Let’s unpack some of the ideas here:
- Einstein Notation: Also known as the “summation convention,” Einstein notation is a notational convention used primarily in tensor calculus. Instead of writing out long summations, it simplifies expressions and makes operations on tensors much more compact. Given the significance of tensors in many machine learning contexts, especially deep learning, understanding this notation can be very beneficial.
- Penrose Notation (Graphical Notation): Roger Penrose developed a visual or diagrammatic notation to describe tensors and their contractions. These are particularly effective when dealing with complex tensor operations, and can make many mathematical operations in general relativity and quantum mechanics more intuitive.
- Rows-and-Columns Ontology: Traditional linear algebra is often taught with a strong emphasis on matrices and their properties, thinking in terms of rows and columns. This viewpoint is intuitive and well-suited to many applications, especially when first introducing the subject. However, it’s true that certain abstract ideas and generalizations can be challenging to communicate when restricted to this framework.
The idea of revamping the way we teach linear algebra at an undergraduate level to include or focus more on Einstein and Penrose notations is intriguing. Here are some potential advantages and challenges:
Advantages:
- Relevance to Modern Applications: As machine learning and artificial intelligence grow in popularity, there’s a stronger argument for teaching mathematical concepts in a way that’s directly applicable to these fields.
- Improved Abstraction: Both Einstein and Penrose notations encourage thinking in terms of abstract tensors rather than just matrices, potentially providing a deeper understanding.
- Efficiency: For certain operations and concepts, these notations can be far more concise.
Challenges:
- Initial Complexity: For many students, the visual and symbolic simplicity of the matrix format is more immediately graspable. Shifting away from this could increase the initial learning curve.
- Tradition: The current methods have been refined over many years and have a vast body of pedagogical resources and expertise behind them. Transitioning would be a significant undertaking.
- Applicability: While it’s true that machine learning is a growing field, not all students studying linear algebra will pursue it. The rows-and-columns approach is still very relevant for numerous other applications.
In conclusion, it might be worthwhile to offer specialized courses or modules that emphasize these notations for students particularly interested in fields where they are beneficial, like machine learning or advanced physics. As with many educational considerations, a balanced approach that takes into account various student needs and interests might be most effective.
How LLMs work
A Large Language Model (LLM) like GPT-4 is not solely based on computation between perceptrons and the frequency of word occurrences in specific positions. The architecture of these models is much more sophisticated, integrating a combination of techniques that include deep neural networks and both supervised and unsupervised learning algorithms.
Here are some key points to understand how an LLM works:
- Transformer Neural Networks: Modern LLMs, like GPT-4, are based on the Transformer architecture, which is a deep neural network specifically designed to handle sequences of data, such as text. This architecture uses attention mechanisms that allow the model to focus on different parts of the input as needed, which is crucial for capturing long-range dependencies in text.
- Word Embeddings: Words in the text are converted into high-dimensional vectors called embeddings. These embeddings capture the semantic relationships between words, enabling the model to understand complex contexts, even when individual words are rare or polysemous.
- Context and Long-Range Dependencies: One of the major advancements in LLMs is their ability to maintain and utilize long-term context. Instead of just considering word frequencies or bigrams/trigrams, the model assesses how words and phrases relate within the entire provided context, which is fundamental for generating coherent responses.
- Statistics and Learning of Complex Patterns: Although LLMs use a statistical foundation, they are not limited to simple word frequencies. During training, the model learns to recognize complex patterns in language, which can include not only the surface structure of sentences but also more abstract patterns such as syntax, semantics, and even pragmatic aspects of discourse.
- Absence of Explicit Grammatical Analysis: Unlike traditional NLP methods, which may involve explicit rules for grammatical analysis (such as identifying subjects, objects, and predicates), LLMs implicitly learn these patterns from the training data. The model does not have an explicit representation of “subject,” “verb,” “object,” etc., but through training on vast corpora of text, it learns to generate responses that respect these structures.
- Generation Based on Conditional Probabilities: Accuracy in responses is achieved because the model generates text based on conditional probabilities learned during training. For each word to be generated, the model considers all previous words and their relationships to predict the next most likely word, thereby maintaining coherence and fluency in the response. This prevents the text from being merely a random combination of words and ensures that the result makes sense in context.
In summary, LLMs utilize an advanced combination of techniques based on neural networks to understand and generate language in a way that goes beyond mere word counting or simple perceptron applications. Accuracy and coherence are achieved through deep learning of linguistic patterns from large volumes of text, enabling the model to generate responses that appear increasingly natural and contextually appropriate.
Comparing with NLP
In the context of machine learning, particularly natural language processing (NLP), models and tokens are fundamental concepts.
Models in Machine Learning/NLP:
- What is a Model? A model in machine learning is a mathematical representation of a real-world process. In the case of NLP, it’s designed to understand, interpret, analyze, generate, or translate human language.
- Training Models: To create a model, it’s necessary to train it using a large dataset. During training, the model learns to make predictions or generate text based on the input it receives. This process adjusts the model’s parameters (which can number in the billions for large models) to minimize the difference between its output and the desired output.
- Neural Networks: Many modern NLP models are a specific type of model known as neural networks, which are inspired by the neural structure of the human brain. They consist of layers of interconnected nodes (neurons), and the strength of the connections (weights) is what the model “learns” during training.
- Deep Learning: When a neural network has many layers, it’s called a deep neural network, and the field is known as deep learning. These models can capture complex patterns in data, which is why they excel at tasks like language modeling.
Tokens in NLP:
- What is a Token? In the context of NLP, a token is a piece of text, which can be as small as a character or as large as a word or even a sentence. The process of breaking down text into tokens is called tokenization.
- Tokenization: This is a critical pre-processing step in NLP. It involves splitting text into individual elements that can be analyzed. For example, the sentence “GPT-4 is amazing!” might be tokenized into [“GPT-4”, “is”, “amazing”, “!”].
- Tokens as Model Input: Tokens are used as the input for NLP models. A model processes these tokens to understand or generate text. In the case of language models like GPT-4, each token can be thought of as a piece of the puzzle that the model uses to predict the next piece.
- Embeddings: Tokens are often converted into vectors through embeddings, which are dense representations that capture the semantic meaning of the tokens. These vectors are what the model actually processes.
- Context Window: The context window is the number of tokens a model can consider at one time. In models like GPT-3 or GPT-4, this is a fixed size (e.g., 2048 tokens for GPT-3). Larger context windows allow models to consider more text for each prediction, which can lead to better understanding and coherence in generated text.
- Parameters: Parameters in an NLP model are the parts of the model that are learned from training data. They are what the model uses to make decisions. More parameters generally mean the model can capture more complexity and nuances in language, but this also requires more computational resources to train and run.
In summary, a model is like a highly skilled artisan trained through exposure to a vast array of linguistic examples, while tokens are the raw materials it works with to craft sentences, paragraphs, or entire narratives. The model’s ability to handle tokens efficiently and effectively determines the quality of the output, whether that be understanding natural language or generating it.
Going deeper into Embeddings
Embeddings are a central technique in natural language processing and deep learning models. They are used to transform words or other linguistic elements into high-dimensional vectors, allowing the model to capture and manipulate the semantics of words in a vector space.
The Concept of Embeddings
Embeddings map words or phrases to vectors in a continuous high-dimensional space. The basic idea is that words with similar meanings should have vector representations close to each other in this space. This proximity is measured by some metric, such as Euclidean distance or the cosine of the angle between vectors.
How Embeddings Work
- Vector Representation: Each word is represented by a dense vector of real numbers. For example, the word “cat” might be represented by a vector like ([0.21, -0.45, 0.33, …]). The dimension of these vectors is typically in the order of a few hundred, such as 300 or 768 dimensions, depending on the model.
- Training of Embeddings:
* Embeddings are trained using large text corpora, where the model tries to predict a word based on its context (skip-gram method) or predict the surrounding context of a word (CBOW method - Continuous Bag of Words).
* Popular models like Word2Vec and GloVe were some of the first widely adopted approaches for creating embeddings. These models learn the vector representations of words through optimizing a loss function that tries to maximize the probability of predicting nearby words in the text. - Semantic Space: In the embedding space, words with similar meanings (e.g., “king” and “monarch”) will have nearby vectors. Additionally, the model can capture more complex relationships between words. A classic example is the vector operation: . This type of operation shows that the model captures semantic aspects of words, such as gender or hierarchy.
- Subwords and Context: More modern models, like BERT or GPT, use subword embeddings and are based on techniques like Transformers. In these cases, the representation of a word or phrase can be sensitive to the context in which it appears, allowing the model to capture different meanings of the same word depending on the context (e.g., “bank” as a financial institution or “bank” as a bench).
Types of Embeddings
- Word Embeddings:
* These are the simplest types of embeddings, where each word has a fixed vector independent of the context. Examples include Word2Vec, GloVe, and FastText. - Contextual Embeddings:
* In more advanced models like BERT, GPT, and ELMo, words are represented by vectors that depend on the context in which they appear. This means that the same word can have different embeddings depending on how it is used in the sentence. - Subword Embeddings:
* Models like FastText consider not only whole words but also subwords, which allows for better handling of rare or unknown words and better capturing of the morphology of words.
Applications of Embeddings
- Semantic Similarity: Embeddings can be used to measure the similarity between words, phrases, or documents. For example, we can use cosine similarity between word vectors to determine how similar two words are.
- Text Classification: Embeddings are often used as input for text classifiers, where word or phrase vectors are fed into neural networks to perform tasks like sentiment analysis or document categorization.
- Machine Translation: In the field of machine translation, multilingual embeddings can map words in different languages into a common vector space, allowing direct translation between languages.
- Text Generation: Generative models, like GPT, use embeddings to generate text in a contextual and coherent manner, in tasks such as sentence completion, article writing, or answering questions.
Summary
Embeddings are fundamental to the success of modern language models. They allow words to be represented in a vector space where semantic and syntactic relationships can be efficiently captured and manipulated. This technique is one of the main reasons why deep neural networks have achieved such significant advances in natural language processing tasks in recent years.
Brief history
Large Language Models (LLMs) like GPT-3 and GPT-4 are advanced forms of neural networks specifically designed to understand, predict, and generate human language. They represent a significant evolution in the field of natural language processing (NLP), moving from rule-based systems to machine learning models, and eventually to deep learning-based models.
Here’s a brief overview of this evolution:
Early NLP Systems and Libraries like NLTK
- Rule-Based Systems: Early NLP systems were largely rule-based, using hand-coded rules to process language. They were very limited and could only handle the specific cases they were programmed for.
- Statistical NLP: Over time, NLP began to incorporate statistical methods. Tools like the Natural Language Toolkit (NLTK) in Python provided libraries of functions and methods for symbolic and statistical natural language processing for English. It was designed to support research and teaching in NLP or closely related areas.
- Corpora and Resources: NLTK included resources for tokenization, parsing, tagging, and machine learning, but it was heavily reliant on curated corpora and linguistic data. While powerful, it did not learn from the data; rather, it used preset algorithms and resources to process language.
The Shift to Machine Learning and Neural Networks
- Machine Learning Models: With the advent of machine learning, NLP started shifting towards models that could learn from data. These included algorithms like Naïve Bayes, Decision Trees, and SVMs for classification tasks such as spam detection or sentiment analysis.
- Feature Engineering: Early machine learning models required extensive feature engineering. This meant that practitioners had to manually identify and encode linguistic features that the model would use to make predictions.
The Emergence of Neural Networks and Deep Learning
- Word Embeddings: The introduction of word embeddings, such as Word2Vec, allowed words to be represented as continuous vector spaces. These representations captured semantic meaning based on word usage in large corpora.
- Recurrent Neural Networks (RNNs): RNNs and their variants like Long Short-Term Memory (LSTM) networks became popular for processing sequential data. They were better at handling context and sequence in text than traditional machine learning models.
- Attention Mechanisms and Transformers: The development of attention mechanisms allowed models to focus on different parts of the input sequence, improving their ability to handle long-range dependencies. The Transformer architecture, introduced in the paper “Attention is All You Need,” utilized self-attention to process all tokens simultaneously, leading to significant performance improvements.
Large Language Models (LLMs)
- Scaling Up: LLMs, including the GPT and BERT families, scale up the Transformer architecture. They have billions of parameters and are trained on vast amounts of text data.
- Self-Supervised Learning: LLMs often use self-supervised learning, meaning they generate their own labels from the data. For instance, they might predict the next word in a sentence, using the sentence itself as context.
- Fine-Tuning: While LLMs can be used out-of-the-box for many tasks, they often perform better when fine-tuned on a specific task with additional training data.
- Generalization and Adaptation: LLMs have shown remarkable ability to generalize from the data they were trained on, performing tasks they were never explicitly programmed to do, such as translation, question-answering, and even writing code.
- Beyond Text: More recent models, sometimes referred to as Multimodal LLMs, can handle not just text but also other types of data such as images (e.g., DALL-E for image generation based on textual descriptions).
LLMs represent a significant leap over traditional NLP libraries like NLTK. They are more powerful, flexible, and capable of learning from the data itself rather than relying on pre-programmed linguistic knowledge. This makes them both more capable and more widely applicable to a variety of language tasks. However, this power comes with increased complexity and the need for substantial computational resources to train and run the models.
Timeline
Certainly, here’s a revised timeline in ascending order, adding a few more relevant technologies that have been instrumental in the evolution of NLP:
Rule-Based Systems and Early Attempts at NLP
- 1950s-1960s: The earliest computer-based translation and NLP tasks were based on rule-based systems.
Foundations of Machine Learning for NLP
- 1980s: The theoretical underpinnings for Recurrent Neural Networks (RNNs) were developed, providing a framework for processing sequences of data, such as text.
The Rise of Statistical NLP and Corpora
- 1990s: Statistical methods for NLP gain prominence. Algorithms such as Hidden Markov Models (HMMs) and later Support Vector Machines (SVMs) were applied to language tasks.
Introduction of Practical Machine Learning Models
- 1997: Long Short-Term Memory (LSTM) networks were introduced, allowing for better handling of long-term dependencies in sequence data.
Natural Language Toolkit (NLTK)
- 2001: NLTK was released, offering tools and resources for symbolic and statistical NLP.
Word Embeddings and Deep Learning
- 2003: Latent Semantic Analysis (LSA) was already known, but methods like it gained more attention as precursors to word embeddings.
- 2013: Word2Vec, developed by a team at Google, popularized word embeddings, dramatically changing how machines represented and processed language.
Neural Machine Translation and Attention Mechanisms
- 2014: Neural Machine Translation started to replace phrase-based statistical approaches. Attention mechanisms improved the model’s focus on relevant parts of the input.
Development of the Transformer Architecture
- 2017: The Transformer model, presented in the paper “Attention is All You Need,” introduced a new architecture based entirely on attention mechanisms without the use of RNNs.
Introduction of Large Pre-trained Models
- 2018: BERT (Bidirectional Encoder Representations from Transformers) was released by Google, introducing the concept of pre-training on a large corpus and then fine-tuning on specific tasks.
Generative Pre-trained Transformers
- June 2020: GPT-3 was introduced by OpenAI, with 175 billion parameters, making it one of the most powerful LLMs at the time.
Multimodal Models and Beyond
- January 2021: OpenAI introduced DALL-E, a model that generates images from textual descriptions.
Continuous and Incremental Advances
- 2021-2023: The field has continued to see incremental advances in various areas including model efficiency, ethical considerations, and domain-specific applications. Additionally, models have been developed to handle multiple modalities beyond text, such as audio and video processing.
Each step in this timeline represents a major leap in capability or a shift in how computers understand and generate human language. The field of NLP continues to evolve rapidly, with new models and techniques emerging regularly.
Part index
The scientific map, the equations, and the bibliographic spine for this part of the Knowledge Base are collected in the part indexes:
Wikipedia snapshots in the chapter card offer offline orientation; the part indexes carry the full citation trails.
On this page
- At a glance
- Online references (live)
- Offline snapshots (link-rot shield)
- Applications at Keyne Digital Assets
- The rise of GPT, is it open source?
- Open source alternatives
- Quick tip: Einstein Notation & Penrose Notation
- How LLMs work
- Comparing with NLP
- Going deeper into Embeddings
- Brief history
- Timeline
- Part index