LogoLogo
Continuum WebsiteContinuum ApplicationsContinuum KnowledgeAxolotl Platform
Continuum Knowledge
Continuum Knowledge
  • Continuum
  • Data
    • Datasets
      • Pre Training Data
      • Types of Fine Tuning
      • Self Instruct Paper
      • Self-Alignment with Instruction Backtranslation
      • Systematic Evaluation of Instruction-Tuned Large Language Models on Open Datasets
      • Instruction Tuning
      • Instruction Fine Tuning - Alpagasus
      • Less is More For Alignment
      • Enhanced Supervised Fine Tuning
      • Visualising Data using t-SNE
      • UMAP: Uniform Manifold Approximation and Projection for Dimension Reduction
      • Training and Evaluation Datasets
      • What is perplexity?
  • MODELS
    • Foundation Models
      • The leaderboard
      • Foundation Models
      • LLama 2 - Analysis
      • Analysis of Llama 3
      • Llama 3.1 series
      • Google Gemini 1.5
      • Platypus: Quick, Cheap, and Powerful Refinement of LLMs
      • Mixtral of Experts
      • Mixture-of-Agents (MoA)
      • Phi 1.5
        • Refining the Art of AI Training: A Deep Dive into Phi 1.5's Innovative Approach
      • Phi 2.0
      • Phi-3 Technical Report
  • Training
    • The Fine Tuning Process
      • Why fine tune?
        • Does Fine-Tuning LLMs on New Knowledge Encourage Hallucinations?
        • Explanations in Fine Tuning
      • Tokenization
        • Tokenization Is More Than Compression
        • Tokenization - SentencePiece
        • Tokenization explore
        • Tokenizer Choice For LLM Training: Negligible or Crucial?
        • Getting the most out of your tokenizer for pre-training and domain adaptation
        • TokenMonster
      • Parameter Efficient Fine Tuning
        • P-Tuning
          • The Power of Scale for Parameter-Efficient Prompt Tuning
        • Prefix-Tuning: Optimizing Continuous Prompts for Generation
        • Harnessing the Power of PEFT: A Smarter Approach to Fine-tuning Pre-trained Models
        • What is Low-Rank Adaptation (LoRA) - explained by the inventor
        • Low Rank Adaptation (Lora)
        • Practical Tips for Fine-tuning LMs Using LoRA (Low-Rank Adaptation)
        • QLORA: Efficient Finetuning of Quantized LLMs
        • Bits and Bytes
        • The Magic behind Qlora
        • Practical Guide to LoRA: Tips and Tricks for Effective Model Adaptation
        • The quantization constant
        • QLORA: Efficient Finetuning of Quantized Language Models
        • QLORA and Fine-Tuning of Quantized Language Models (LMs)
        • ReLoRA: High-Rank Training Through Low-Rank Updates
        • SLoRA: Federated Parameter Efficient Fine-Tuning of Language Models
        • GaLora: Memory-Efficient LLM Training by Gradient Low-Rank Projection
      • Hyperparameters
        • Batch Size
        • Padding Tokens
        • Mixed precision training
        • FP8 Formats for Deep Learning
        • Floating Point Numbers
        • Batch Size and Model loss
        • Batch Normalisation
        • Rethinking Learning Rate Tuning in the Era of Language Models
        • Sample Packing
        • Gradient accumulation
        • A process for choosing the learning rate
        • Learning Rate Scheduler
        • Checkpoints
        • A Survey on Efficient Training of Transformers
        • Sequence Length Warmup
        • Understanding Training vs. Evaluation Data Splits
        • Cross-entropy loss
        • Weight Decay
        • Optimiser
        • Caching
      • Training Processes
        • Extending the context window
        • PyTorch Fully Sharded Data Parallel (FSDP)
        • Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
        • YaRN: Efficient Context Window Extension of Large Language Models
        • Sliding Window Attention
        • LongRoPE
        • Reinforcement Learning
        • An introduction to reinforcement learning
        • Reinforcement Learning from Human Feedback (RLHF)
        • Direct Preference Optimization: Your Language Model is Secretly a Reward Model
  • INFERENCE
    • Why is inference important?
      • Grouped Query Attention
      • Key Value Cache
      • Flash Attention
      • Flash Attention 2
      • StreamingLLM
      • Paged Attention and vLLM
      • TensorRT-LLM
      • Torchscript
      • NVIDIA L40S GPU
      • Triton Inference Server - Introduction
      • Triton Inference Server
      • FiDO: Fusion-in-Decoder optimised for stronger performance and faster inference
      • Is PUE a useful measure of data centre performance?
      • SLORA
  • KNOWLEDGE
    • Vector Databases
      • A Comprehensive Survey on Vector Databases
      • Vector database management systems: Fundamental concepts, use-cases, and current challenges
      • Using the Output Embedding to Improve Language Models
      • Decoding Sentence-BERT
      • ColBERT: Efficient and Effective Passage Search via Contextualized Late Interaction over BERT
      • SimCSE: Simple Contrastive Learning of Sentence Embeddings
      • Questions Are All You Need to Train a Dense Passage Retriever
      • Improving Text Embeddings with Large Language Models
      • Massive Text Embedding Benchmark
      • RocketQAv2: A Joint Training Method for Dense Passage Retrieval and Passage Re-ranking
      • LLM2Vec: Large Language Models Are Secretly Powerful Text Encoders
      • Embedding and Fine-Tuning in Neural Language Models
      • Embedding Model Construction
      • Demystifying Embedding Spaces using Large Language Models
      • Fine-Tuning Llama for Multi-Stage Text Retrieval
      • Large Language Model Based Text Augmentation Enhanced Personality Detection Model
      • One Embedder, Any Task: Instruction-Finetuned Text Embeddings
      • Vector Databases are not the only solution
      • Knowledge Graphs
        • Harnessing Knowledge Graphs to Elevate AI: A Technical Exploration
        • Unifying Large Language Models and Knowledge Graphs: A Roadmap
      • Approximate Nearest Neighbor (ANN)
      • High Dimensional Data
      • Principal Component Analysis (PCA)
      • Vector Similarity Search - HNSW
      • FAISS (Facebook AI Similarity Search)
      • Unsupervised Dense Retrievers
    • Retrieval Augmented Generation
      • Retrieval-Augmented Generation for Large Language Models: A Survey
      • Fine-Tuning or Retrieval?
      • Revolutionising Information Retrieval: The Power of RAG in Language Models
      • A Survey on Retrieval-Augmented Text Generation
      • REALM: Retrieval-Augmented Language Model Pre-Training
      • Retrieve Anything To Augment Large Language Models
      • Generate Rather Than Retrieve: Large Language Models Are Strong Context Generators
      • Active Retrieval Augmented Generation
      • DSPy: LM Assertions: Enhancing Language Model Pipelines with Computational Constraints
      • DSPy: Compiling Declarative Language Model Calls
      • DSPy: In-Context Learning for Extreme Multi-Label Classification
      • Optimizing Instructions and Demonstrations for Multi-Stage Language Model Programs
      • HYDE: Revolutionising Search with Hypothetical Document Embeddings
      • Enhancing Recommender Systems with Large Language Model Reasoning Graphs
      • Retrieval Augmented Generation (RAG) versus fine tuning
      • RAFT: Adapting Language Model to Domain Specific RAG
      • Summarisation Methods and RAG
      • Lessons Learned on LLM RAG Solutions
      • Stanford: Retrieval Augmented Language Models
      • Overview of RAG Approaches with Vector Databases
      • Mastering Chunking in Retrieval-Augmented Generation (RAG) Systems
    • Semantic Routing
    • Resource Description Framework (RDF)
  • AGENTS
    • What is agency?
      • Rephrase and Respond: Let Large Language Models Ask Better Questions for Themselves
      • Types of Agents
      • The risk of AI agency
      • Understanding Personality in Large Language Models: A New Frontier in AI Psychology
      • AI Agents - Reasoning, Planning, and Tool Calling
      • Personality and Brand
      • Agent Interaction via APIs
      • Bridging Minds and Machines: The Legacy of Newell, Shaw, and Simon
      • A Survey on Language Model based Autonomous Agents
      • Large Language Models as Agents
      • AI Reasoning: A Deep Dive into Chain-of-Thought Prompting
      • Enhancing AI Reasoning with Self-Taught Reasoner (STaR)
      • Exploring the Frontier of AI: The "Tree of Thoughts" Framework
      • Toolformer: Revolutionising Language Models with API Integration - An Analysis
      • TaskMatrix.AI: Bridging Foundational AI Models with Specialised Systems for Enhanced Task Completion
      • Unleashing the Power of LLMs in API Integration: The Rise of Gorilla
      • Andrew Ng's presentation on AI agents
      • Making AI accessible with Andrej Karpathy and Stephanie Zhan
  • Regulation and Ethics
    • Regulation and Ethics
      • Privacy
      • Detecting AI Generated content
      • Navigating the IP Maze in AI: The Convergence of Blockchain, Web 3.0, and LLMs
      • Adverse Reactions to generative AI
      • Navigating the Ethical Minefield: The Challenge of Security in Large Language Models
      • Navigating the Uncharted Waters: The Risks of Autonomous AI in Military Decision-Making
  • DISRUPTION
    • Data Architecture
      • What is a data pipeline?
      • What is Reverse ETL?
      • Unstructured Data and Generatve AI
      • Resource Description Framework (RDF)
      • Integrating generative AI with the Semantic Web
    • Search
      • BM25 - Search Engine Ranking Function
      • BERT as a reranking engine
      • BERT and Google
      • Generative Engine Optimisation (GEO)
      • Billion-scale similarity search with GPUs
      • FOLLOWIR: Evaluating and Teaching Information Retrieval Models to Follow Instructions
      • Neural Collaborative Filtering
      • Federated Neural Collaborative Filtering
      • Latent Space versus Embedding Space
      • Improving Text Embeddings with Large Language Models
    • Recommendation Engines
      • On Interpretation and Measurement of Soft Attributes for Recommendation
      • A Survey on Large Language Models for Recommendation
      • Model driven recommendation systems
      • Recommender AI Agent: Integrating Large Language Models for Interactive Recommendations
      • Foundation Models for Recommender Systems
      • Exploring the Impact of Large Language Models on Recommender Systems: An Extensive Review
      • AI driven recommendations - harming autonomy?
    • Logging
      • A Taxonomy of Anomalies in Log Data
      • Deeplog
      • LogBERT: Log Anomaly Detection via BERT
      • Experience Report: Deep Learning-based System Log Analysis for Anomaly Detection
      • Log-based Anomaly Detection with Deep Learning: How Far Are We?
      • Deep Learning for Anomaly Detection in Log Data: A Survey
      • LogGPT
      • Adaptive Semantic Gate Networks (ASGNet) for log-based anomaly diagnosis
  • Infrastructure
    • The modern data centre
      • Enhancing Data Centre Efficiency: Strategies to Improve PUE
      • TCO of NVIDIA GPUs and falling barriers to entry
      • Maximising GPU Utilisation with Kubernetes and NVIDIA GPU Operator
      • Data Centres
      • Liquid Cooling
    • Servers and Chips
      • The NVIDIA H100 GPU
      • NVIDIA H100 NVL
      • Lambda Hyperplane 8-H100
      • NVIDIA DGX Servers
      • NVIDIA DGX-2
      • NVIDIA DGX H-100 System
      • NVLink Switch
      • Tensor Cores
      • NVIDIA Grace Hopper Superchip
      • NVIDIA Grace CPU Superchip
      • NVIDIA GB200 NVL72
      • Hopper versus Blackwell
      • HGX: High-Performance GPU Platforms
      • ARM Chips
      • ARM versus x86
      • RISC versus CISC
      • Introduction to RISC-V
    • Networking and Connectivity
      • Infiniband versus Ethernet
      • NVIDIA Quantum InfiniBand
      • PCIe (Peripheral Component Interconnect Express)
      • NVIDIA ConnectX InfiniBand adapters
      • NVMe (Non-Volatile Memory Express)
      • NVMe over Fabrics (NVMe-oF)
      • NVIDIA Spectrum-X
      • NVIDIA GPUDirect
      • Evaluating Modern GPU Interconnect
      • Scalable Hierarchical Aggregation and Reduction Protocol (SHARP)
      • Next-generation networking in AI environments
      • NVIDIA Collective Communications Library (NCCL)
    • Data and Memory
      • NVIDIA BlueField Data Processing Units (DPUs)
      • Remote Direct Memory Access (RDMA)
      • High Bandwidth Memory (HBM3)
      • Flash Memory
      • Model Requirements
      • Calculating GPU memory for serving LLMs
      • Transformer training costs
      • GPU Performance Optimisation
    • Libraries and Complements
      • NVIDIA Base Command
      • NVIDIA AI Enterprise
      • CUDA - NVIDIA GTC 2024 presentation
      • RAPIDs
      • RAFT
    • Vast Data Platform
      • Vast Datastore
      • Vast Database
      • Vast Data Engine
      • DASE (Disaggregated and Shared Everything)
      • Dremio and VAST Data
    • Storage
      • WEKA: A High-Performance Storage Solution for AI Workloads
      • Introduction to NVIDIA GPUDirect Storage (GDS)
        • GDS cuFile API
      • NVIDIA Magnum IO GPUDirect Storage (GDS)
      • Vectors in Memory
Powered by GitBook
LogoLogo

Continuum - Accelerated Artificial Intelligence

  • Continuum Website
  • Axolotl Platform

Copyright Continuum Labs - 2023

On this page
  • Mixtral 8x7B Overview
  • Analysis of how Mixture of Experts works
  • Key Aspects of MoE in LLMs
  • Definitions
  • Summary of Wolfe Analysis
  • Back to Mixtral 8x7B–Instruct
  • Mixtral's Architecture
  • Sparse Mixture of Experts (SMoE)
  • Conclusion

Was this helpful?

  1. MODELS
  2. Foundation Models

Mixtral of Experts

PreviousPlatypus: Quick, Cheap, and Powerful Refinement of LLMsNextMixture-of-Agents (MoA)

Last updated 1 year ago

Was this helpful?

The paper introduces Mixtral 8x7B, a Sparse Mixture of Experts (SMoE) language model, showcasing advancements in the field of AI language processing.

Mixtral 8x7B Overview

Architecture: Mixtral 8x7B is built on the same architecture as Mistral 7B but includes a unique feature where each of its layers contains 8 feedforward blocks, known as experts.

Expert Selection: For every token in the input, a router network at each layer selects two experts to process the token and combine their outputs. This selective process allows the model to dynamically choose which parts of its network to use for each token.

Parameter Efficiency: While the total parameter count for the model is 47 billion, any given token is processed using only 13 billion active parameters, enhancing the model's efficiency during inference.

Training and Performance: Mixtral was trained with a large context size of 32,000 tokens and shows superior or comparable performance to Llama 2 70B and GPT-3.5 on various benchmarks, particularly excelling in mathematics, code generation, and multilingual tasks.

Analysis of how Mixture of Experts works

This excellent article from the famous Cameron Wolfe. Please visit his website here:

Here his full article on how Mixture of Experts works:

I have paraphrased his article below:

The paper delves into the Sparse Mixture of Experts (MoE) layers in the context of decoder-only transformer architecture, commonly employed in autoregressive large language models (LLMs).

It explains how MoEs enhance model capacity while maintaining computational efficiency by selectively activating a subset of parameters during the forward pass.

Key Aspects of MoE in LLMs

Expert Architecture: Each expert within an MoE layer is a feed-forward neural network with its unique set of parameters, mirroring the architecture of the standard feed-forward sub-layer in traditional transformer models.

Routing Mechanism: A router processes each token, producing a probability distribution that dictates which expert(s) will process the token. This selective routing significantly increases model capacity without proportionally increasing computational demands.

Sparse Activation: In each MoE layer, only a few experts are activated for each token, reducing the computational cost compared to a model where all parameters are always active.

Implementation in Decoder-only Architecture: MoEs are integrated into the decoder-only transformer architecture, replacing the standard feed-forward sub-layers with MoE layers. This architecture is prevalent in autoregressive LLMs.

Creating an MoE Layer: An MoE layer consists of multiple experts, and the layer replaces the conventional feed-forward sub-layer in the transformer block. This setup allows for the model to scale up the number of experts without incurring the full computational cost typically associated with larger models.

Routing Details: Routing in MoEs usually employs a softmax gating function that converts the outputs of a linear layer into a probability distribution over experts, guiding the token through the most relevant experts based on the routing mechanism's decision.

Popularity of MoEs in LLMs: MoEs offer a path to scale model capacity - a crucial factor for improving LLM performance. They allow for significant parameter expansion without commensurate increases in computational requirements during training and inference, making large-scale LLMs more feasible and efficient.

Example of MoE Implementation: An instance is provided where a model named Grok incorporates eight experts per MoE layer, demonstrating how MoEs function in a practical LLM context. Despite having 314B parameters, Grok only activates 25% of these for any given token, illustrating the efficiency gains from sparse activation.

Definitions

Dense Feed-forward Layers: These layers are standard components in neural networks where each input is connected to each output by a learned weight. In the context of transformer architectures, dense feed-forward layers are present within each transformer block and process the input sequentially, applying the same set of weights across the entire sequence.

Router: In the context of a Mixture of Experts (MoE) layer, a router is a mechanism that determines how the input is distributed among the various experts. It takes each token or piece of input data, computes a probability distribution over the experts, and routes the input to the selected experts based on this distribution. The routing process is crucial for managing the computational load and ensuring that the most relevant experts handle each piece of input.

Decoder-only Architecture: This architecture refers to transformer models that only use the decoder component, omitting the encoder. In autoregressive large language models (LLMs), the decoder-only architecture is prevalent, where each transformer block within the decoder contains layers for masked self-attention and feed-forward processing. The architecture is designed to generate output one token at a time, using previously generated tokens as context.

Sparse Activation: This concept refers to the activation of only a small subset of the available experts in an MoE layer for any given input. Despite the MoE layer having a large number of experts, sparse activation ensures that only the most relevant experts (determined by the router) are utilized during the forward pass, thus optimizing computational efficiency.

Routing Mechanism: The routing mechanism in MoE layers, typically a softmax gating function, is responsible for allocating input tokens to different experts. It involves passing the input through a linear layer to produce logits, applying a softmax function to generate a probability distribution, and then using this distribution to select and weigh the contribution of each expert in processing the input.

Summary of Wolfe Analysis

The incorporation of Sparse Mixture of Experts layers within LLMs enables a substantial increase in model capacity while managing computational expenses.

This methodology allows for the development of more powerful and nuanced language models, potentially unlocking new capabilities in natural language processing and understanding.

Back to Mixtral 8x7B–Instruct

Fine-tuned Model: A variant of Mixtral, known as Mixtral 8x7B–Instruct, is fine-tuned to follow instructions better, demonstrating enhanced performance in human evaluation benchmarks compared to other leading models.

Reduced Biases and Balanced Sentiment: The instruction-following version of Mixtral also shows improvements in reducing biases and achieving a more balanced sentiment in its outputs.

Mixtral's Architecture

Transformer Basis: At its core, Mixtral is based on the transformer architecture, known for its efficiency and effectiveness in handling sequence data. Transformers consist of layers with two main sub-blocks: a self-attention mechanism and a feedforward neural network.

Modifications: Unlike standard transformers, Mixtral replaces the feedforward blocks with Mixture-of-Expert (MoE) layers. This allows the model to dynamically select which parts of the network to use for processing each token, enhancing its adaptability and efficiency.

Context Length: Mixtral is designed to handle a fully dense context length of up to 32,000 tokens, providing it with a substantial lookback capability, beneficial for understanding and generating long sequences of text.

Sparse Mixture of Experts (SMoE)

Computational Efficiency

Execution and Parallelism

Efficiency on GPUs: The MoE layers can be efficiently executed on GPUs, using specialized kernels like Megablocks for sparse matrix operations, enhancing execution speed.

Expert Parallelism: To scale and distribute the workload, Mixtral employs Expert Parallelism, where each expert is processed on a different GPU, allowing parallel processing and reducing computation time.

Load Balancing: Ensuring an even distribution of workload across GPUs is crucial to prevent bottlenecks and maximize resource utilisation.

In summary, Mixtral's architecture, with its integration of the SMoE approach, represents a significant innovation in transformer-based models, offering a dynamic, efficient, and scalable solution for processing large-scale language data.

Conclusion

In this study, we unveiled Mixtral 8x7B, a pioneering mixture-of-experts network that achieves state-of-the-art performance among open-source models.

Notably, the Mixtral 8x7B Instruct variant surpasses other leading models like Claude-2.1, Gemini Pro, and GPT-3.5 Turbo in human evaluation benchmarks.

Remarkably, Mixtral achieves this superior performance while using only 13 billion active parameters per token, in stark contrast to its predecessor, Llama 2 70B, which uses 70 billion.

Expert Networks: In an MoE layer, there are 'n' expert networks (E0​,E1​,...,En−1​E0​,E1​,...,En−1​E0​,E1​,...,En−1​). Each expert is a specialised feedforward network capable of handling specific types of information or patterns within the data.

Gating Network: The gating network decides which experts to engage for processing each token. It outputs a gating vector G(x)G(x)G(x) which is an n-dimensional vector indicating the relevance of each expert for the current input token xxx

Output Computation: The output of the MoE layer for an input xxx is a weighted sum of the outputs from the expert networks. Mathematically, it's represented as:

y=∑i=0n−1G(x)i⋅Ei(x)y = \sum_{i=0}^{n-1} G(x)_i \cdot E_i(x) y=i=0∑n−1​G(x)i​⋅Ei​(x)

where G(x)i​G(x)i​G(x)i​ is the i-th element of the gating vector, and Ei​(x)Ei​(x)Ei​(x) is the output from the i-th expert network.

Top-K Gating: The gating mechanism selects the top KKK experts based on the gating vector's values. This selection is made using a softmax function applied to the top-K logits of a linear layer. The mathematical expression for this gating function is:

G(x)=Softmax(TopK(x⋅Wg))G(x) = \text{Softmax}(\text{TopK}(x \cdot W_g)) G(x)=Softmax(TopK(x⋅Wg​))

where Wg​Wg​Wg​ is the weight matrix for the gating network.

By using only the top KKK experts (with being much smaller than nnn), the model reduces the computational load, making it efficient while still leveraging a large parameter space.

LogoMixtral of ExpertsarXiv.org
Mixtral of Experts
LogoCameron R. Wolfe, Ph.D.Cameron R. Wolfe, Ph.D.
Cameron Wolfe is a generous AI researcher - bridging the gap between academia and practitioners
LogoNote by Cameron R. Wolfe, Ph.D. on SubstackSubstack
Mixture of Experts
Page cover image