The Grok-1 repository contains JAX example code for loading and running the Grok-1 open-weights model, released by xai-org as an open release under the Apache 2.0 license. The repository provides a practical implementation for researchers and developers who want to work with this large-scale language model, including code for checkpoint loading and sampling from the model on test inputs.
Grok-1 is a massive language model with 314 billion parameters built on a Mixture of Experts architecture. The model uses 8 experts total, with 2 experts utilized per token during inference, which is a key design choice for managing computational efficiency at scale. The model consists of 64 layers and employs 48 attention heads for queries while using 8 attention heads for keys and values, with an embedding size of 6,144 dimensions. The tokenization is handled by a SentencePiece tokenizer configured with 131,072 tokens, providing broad vocabulary coverage. The model supports a maximum sequence length of 8,192 tokens for context, enabling it to process substantial amounts of text in a single forward pass.
The implementation includes several advanced features designed for modern large-scale language modeling. Rotary embeddings, also known as RoPE, are incorporated to improve positional encoding. The model supports activation sharding, which distributes activations across multiple devices to manage memory constraints, and 8-bit quantization, allowing for reduced memory footprint and faster computation on compatible hardware.
A critical consideration for using this repository is the computational requirements. Due to the model's enormous size of 314 billion parameters, running the example code requires a machine with substantial GPU memory. The repository's implementation of the MoE layer prioritizes correctness validation over efficiency, deliberately avoiding custom kernels to ensure the model's behavior can be thoroughly validated. This design choice makes the implementation more accessible for verification purposes but means that production deployments would benefit from optimized kernel implementations.
To use the repository, users must first download the model checkpoint and place the ckpt-0 directory in a checkpoints folder. The weights are available through two distribution methods: a torrent magnet link for peer-to-peer downloading, or directly through the HuggingFace Hub, providing flexibility in how users acquire the model files. Once the checkpoint is in place, users can run the provided example script to test the implementation.
The repository is classified across multiple interpretability and explainability categories, including ai model analysis, neural network interpretability, explainable AI, and model understanding. This classification reflects the broader context of making large language models more transparent and interpretable. The codebase is written in Python, making it accessible to the machine learning community, and serves as both a reference implementation and a practical tool for those studying or deploying the Grok-1 model. The open-source nature of both the code and weights represents a significant contribution to the field, enabling researchers to study and build upon a state-of-the-art large language model architecture.