Training LLMs with RHEL AI

// archive From the original Code Walker docs. Kept for reference, so some versions and commands may be out of date.

Red Hat Enterprise Linux AI#

Red Hat Enterprise Linux AI (RHEL AI) is a version of RHEL that is optimized for the development, training, and execution of large language models (LLMs). It provides the following key benefits:

  • Designed for the creation of custom LLMs by fine-tuning Granite models, which offer enterprise support and benefits such as transparency and intellectual property (IP) indemnification by Red Hat.

  • Preconfigured AI accelerator support, including NVIDIA and AMD GPUs. You do not need to install or maintain dependencies and drivers.

  • Efficient, accurate, cost-efficient fine-tuning process. Technical and non-technical users can add their knowledge to pretrained models, creating specialized custom models that match or surpass the performance of larger, proprietary models, such as GPT-4.

  • Available as a bootable RHEL image that is ready to install on cloud providers and bare-metal environments, plus the stability, enterprise support, and reliability of RHEL.

RHEL AI Images#

RHEL AI supports different NVIDIA GPUs, such as H200, A100, H100, and L40S, you’ll need the cuda image, for example:

rhel-ai-cuda-3.2-1768468335-x86_64-boot.iso.gz
rhel-ai-cuda-3.2-1768468352-x86_64-kvm.qcow2

It also supports AMD MI300X, you’ll need the rocm image, for example:

rhel-ai-rocm-3.2-1768468410-x86_64-boot.iso.gz
rhel-ai-rocm-3.2-1768468414-x86_64-kvm.qcow2

RHEL AI Components#

  • RHEL AI bootable container image
  • Support for hardware accelerators
  • InstructLab
  • Granite models
  • Red Hat ecosystem catalog

The LAB Methodology#

InstructLab, the core piece of RHEL AI, is based on the Large-Scale Alignment for ChatBots (LAB) methodology.

The RHEL AI Configuration Process#

  • Creates the directory structure to store the InstructLab artifacts, such as configuration, models, datasets, taxonomy, and checkpoints.

  • Clones the community taxonomy repository from https://github.com/instructlab/taxonomy.git.

  • Initializes the environment for InstructLab by generating the configuration files.

To comprehend the InstructLab configuration process, you should understand the following core concepts:

Taxonomy InstructLab is driven by taxonomies, which are data curated by humans as the foundation of new knowledge and skills for customizing pretrained models. InstructLab implements its taxonomy as a structured tree of directories and qna.yaml YAML files. These files contain questions and answers to teach the model new knowledge or skills.

Synthetic datasets InstructLab uses a synthetic data generation (SDG) process to convert the limited number of taxonomy samples into hundreds or thousands of synthetic question-and-answer pairs, required for model training. To perform the SDG process, InstructLab uses teacher models that generate synthetic question-and-answer examples based on a few samples. The mixtral-8x7b-instruct-v0-1 model is an example of such a teacher model.

Trained Models With the taxonomy and the synthetic datasets ready, you can train a pretrained model. The result of this training is a newly trained model that can give answers based on the new knowledge or skills provided.

Judge Models To evaluate the performance of the newly trained model, you might use a judge model such as prometheus-8x7b-v2-0.

Initializing the InstructLab Configuration#

  • edit: Launch your OS text editor to edit the configuration file.

  • init: Initialize the InstructLab environment configuration.

  • show: Display the current configuration in YAML format with an option to extract a specific key.

ilab config init

Your end up with:

~/.config/instructlab/config.yaml
~/.cache/instructlab/models/
~/.local/share/instructlab/datasets
~/.local/share/instructlab/taxonomy
~/.local/share/instructlab/phased/<phase1-or-phase2>/checkpoints/

Commands:

ilab config show -k generate.taxonomy_path
ilab taxonomy diff
ilab model list
ilab model serve --model-path ~/.cache/instructlab/models/granite-7b-lab-Q4_K_M.gguf

If another terminal:

ilab model chat --model ~/.cache/instructlab/models/granite-7b-lab-Q4_K_M.gguf

Taxonomy#

  • Add custom knowledge to a private taxonomy.
  • Add custom skills to a private taxonomy.
  • Validate the private taxonomy.

A Taxonomy is a structured, human-curated directory of skills and knowledge. Think of it as the manual or “cheat sheet” you provide to the model to tell it what it needs to learn.

Format: Written in simple YAML files (qna.yaml).

Structure: Organized as a tree (folders/subfolders) that categorize data into:

Knowledge: Factual information grounded in documents (e.g., “Company safety protocols”).

Skills: Task-based abilities (e.g., “Write this in a corporate email style” or “Translate this into Java code”).

Seed Examples: You only need to provide a few (typically 5) high-quality “Question and Answer” pairs. These act as the “seeds” for the next step.

Generating a Synthetic Dataset#

Synthetic Data Generation (SDG) is the automated process of taking those 5 seed examples from your Taxonomy and turning them into thousands of high-quality training examples.

The Teacher Model: RHEL AI uses a larger “Teacher” model (like Mixtral-8x7b-Instruct) to look at your seeds and brainstorm thousands of similar questions and answers.

The Process:

Creation: The teacher generates new Q&A pairs.

Filtering/Criticism: A “Critic” model (often the teacher itself) reviews the generated data for quality, safety, and relevance.

Output: It produces a massive dataset (often in .jsonl format) ready for training.

The Benefit: It solves the “data scarcity” problem. You don’t need to manually write 10,000 examples; you write 5, and the system generates the rest.

How They Work Together#

  • You write a Taxonomy YAML with a few examples.
  • RHEL AI runs the ilab data generate command.
  • The Synthetic Data Generation (SDG) process creates a massive synthetic dataset.
  • The model is trained (fine-tuned) on this dataset, effectively “absorbing” the new knowledge or skills you defined in the Taxonomy.
note

RHEL AI uses its own specific Synthetic Data Generation (SDG) pipeline, referred to as the agentic pipeline.

Training a Model#

After generating the synthetic dataset, the next step in InstructLab and Red Hat Enterprise Linux AI (RHEL AI) is to infuse the dataset into the model. This step, known as training or fine-tuning, results in a custom model that has learned the knowledge and skills that you previously added to the taxonomy.

RHEL AI Models for LAB Training#

The following models are involved in the RHEL AI training process:

  • Granite-starter model
  • Judge model
  • Granite-lab
important

Important Do not use Granite-lab for further training. It is intended only for inference and evaluation purposes.