Augmentoolkit Documentation

repository·master·Indexed 23 days ago

https://github.com/e-p-armstrong/augmentoolkit

A tool for creating domain-expert datasets to update AI knowledge cutoffs and transform general LLMs into specialists. It supports cloud-based and offline local generation of RAG-ready datasets. The system includes a FastAPI-based REST API for managing data generation pipelines using Huey for task queueing and Redis for state management. It features a React + Vite interface (atk-interface) and provides installation scripts for MacOS, Linux, and Windows (via WSL), requiring Python 3.11.

Tokens
32.2K
Snippets
41
Records
156
Agent score
84%

What's inside Augmentoolkit

  1. Overview of RPToolkit

    master

    RPToolkit is a synthetic data generation pipeline designed to create roleplay (RP) chat sessions inspired by the themes, styles, and content of provided input texts (e.g., novels, fanfiction, plays).

    It uses a multi-step, depth-first generation process:

    1. Emotion Analysis: Determines emotional themes from text chunks.
    2. Archetype Generation: Creates or selects character archetypes.
    3. Feature Extraction: Extracts stylistic and content features.
    4. Scene Card Synthesis: Defines the character and setting.
    5. Story Generation: Produces a multi-turn RP chatlog based on the scene card.
    6. Rating: Evaluates the story for quality, coherence, and rule-following.

    This pipeline is ideal for training specialized RP models in specific genres, capturing writing styles, or developing character personas.

  2. Overview of the Augmentoolkit Web Interface

    master

    The atk-interface is a web-based Single Page Application (SPA) designed to provide a visual interface for interacting with a locally-running Augmentoolkit server. It allows users to manage configurations, handle input/output files, and monitor pipeline execution in real-time.

    Key functional areas include:

    • Navigation: Access to Configs, Inputs, Outputs, and Pipeline monitoring.
    • Config Editing: Direct modification of configuration fields with path validation (warnings for non-existent input_dir or output_dir) and pipeline execution capabilities.
    • Input/Output Management: A file browser interface for uploading, viewing, deleting, and downloading files. The output section also tracks task IDs for the current session.
    • Pipeline Execution Monitoring: A dedicated view featuring a progress bar, real-time log streaming, and an expandable details box showing execution stats and the specific configuration used (with syntax highlighting).
  3. Understand the atk-interface React + Vite setup

    master

    The atk-interface package uses a React + Vite template. It provides Hot Module Replacement (HMR) and includes ESLint rules for development. The setup currently supports two official Vite plugins for React Fast Refresh:

    1. @vitejs/plugin-react: Uses Babel for Fast Refresh.
    2. @vitejs/plugin-react-swc: Uses SWC for Fast Refresh.
  4. Augmentoolkit core hypotheses and goals

    master

    Augmentoolkit is built on several key technical hypotheses and long-term goals:

    Core Hypotheses

    • Factual Recall: With proper continued pretraining and SFT, LLMs can be trained to understand and recall new factual domains.
    • Specialization over Generalization: Specialized AI (in knowledge, opinion, or tone) is more useful and controllable for specific products than generalist models.
    • Synthetic Data: High-quality synthetic data is a primary driver for making specialized models effective and is a pillar of open-source AI.
    • Abstraction-driven Generation: Dataset generation can be standardized through highly-practical abstractions and unified interfaces.

    Future Goals

    • Enhanced Fact Learning: Improving the efficacy of factual domain injection.
    • GRPO Reinforcement Learning: Implementing Group Relative Policy Optimization (GRPO) for arbitrary objectives (e.g., code or LLM-graded prompts).
    • Advanced Training Styles: Developing capabilities for writing style and agentic training.
  5. What is Augmentoolkit? (Technical Overview)

    master

    Augmentoolkit is a tool designed to create AI subject matter experts by generating high-quality datasets for Continued Pretraining and Supervised Fine Tuning (SFT). It uses LLM-powered pipelines to teach models new factual domains, including information the model has never encountered during its initial pretraining.

    The Core Methodology

    To teach a model new facts without causing it to overfit on document structure, Augmentoolkit creates many synthetic, varied representations of the target documents. The workflow typically involves:

    1. Continued Pretraining: Performed for an extended period (often around 12 epochs) to ensure the loss is low and the documents are completely memorized.
    2. Supervised Fine Tuning (SFT): Solidifies the knowledge by training on a mix of domain-specific conversational data and generic datasets (e.g., Capybara, Hermes, Bluemoon, Pippa, LMSys). This step uses a decent batch size and typically runs for 5 to 7 epochs.
    3. Hallucination Resistance: The process incorporates domain-specific data to train the model to say it "does not know" about invented facts, correct faulty assumptions, and handle follow-up questions.

    Key Capabilities

    • Knowledge Expansion: Arbitrarily expands an LLM's knowledge cutoff to any chosen area.
    • Belief/Opinion Control: Allows for the arbitrary selection of an LLM's opinions or beliefs about what is true.
    • Cost-Effectiveness: Can be run on consumer hardware. A custom-trained 7B parameter dataset generation model is available to serve as the engine, allowing domain experts to be trained for $20 or less using open-source AI.
  6. What is the Generic Data Rephrase pipeline?

    master

    The Generic Data Rephrase pipeline is a structural alignment tool used to retrofit standard instruction-following datasets (in ShareGPT JSONL format) with synthetic Chain-of-Thought (CoT) reasoning.

    Its primary purpose is to ensure that generic SFT (Supervised Fine-Tuning) data matches the format of Augmentoolkit's domain-specific SFT data. By adding a synthetic thought process before the assistant's answer in both generic and domain datasets, you prevent the model from learning superficial format cues (e.g., associating CoT only with domain knowledge) and instead force it to learn unified reasoning and knowledge patterns. This significantly improves generalization and robustness in domain-expert models.

  7. What is the RAG Data pipeline and when to use it

    master

    The RAG Data pipeline is designed to train LLMs on how to effectively utilize context provided by a Retrieval-Augmented Generation (RAG) system. It generates multi-turn conversational data where the model is presented with simulated RAG results (both relevant and deliberately irrelevant chunks) alongside a question derived from a source text chunk.

    Core Goals

    • Teach the model to synthesize answers using provided context when relevant.
    • Teach the model to rely on internal knowledge when the context is irrelevant or unhelpful.
    • Train the model to ignore misleading or noisy retrieved information.

    Use Cases

    • Improving RAG System Performance: Fine-tuning the generator component to better utilize retriever output.
    • Training Robustness to Noisy Context: Reducing susceptibility to irrelevant information.
    • Enhancing Contextual Reasoning: Teaching models to synthesize information from multiple snippets.
    • Building Advanced QA Systems: Creating models that dynamically switch between provided context and internal knowledge.
  8. What is Augmentoolkit?

    master

    Augmentoolkit is a tool designed to teach Large Language Models (LLMs) new factual domains by baking information directly into the model's weights through continued pretraining and Supervised Fine-Tuning (SFT).

    Unlike Retrieval-Augmented Generation (RAG), which retrieves relevant text from documents to show the model, Augmentoolkit aims to create 'subject-matter expert' models that have an inherent, big-picture understanding of a specific area. This allows the AI to bring up relevant information on demand without needing a massive pile of reference textbooks.

  9. Overview of the GRPO (Experimental) Pipeline

    master

    The GRPO (Generative Reward Powered Optimization) pipeline is an experimental framework for fine-tuning LLMs using Reinforcement Learning (RL). Unlike standard data generation pipelines, this performs actual model training to align a base model toward desired behaviors using custom reward functions.

    Key Characteristics

    • Purpose: Optimizes models using reward signals (programmatic or LLM-based) rather than just supervised fine-tuning (SFT).
    • Platform: Linux only. Requires a machine with a capable GPU (suitable for LoRA training) and vLLM installed in your virtual environment.
    • Complexity: This is a beta/experimental feature. It does not support auto-resume. Customization (adding reward functions) requires Python coding.
    • Workflow: Generates multiple candidate responses for prompts from input datasets $\rightarrow$ evaluates responses via reward functions $\rightarrow$ optimizes LoRA weights via GRPO.
  10. Configure Pipelines using Config files

    master

    Pipelines use configuration files to manage their arguments.

    Configuration Rules:

    • Argument Mapping: Pipeline arguments are mapped from config files as keyword arguments.
    • super_config.yaml: This file controls which pipeline is executed with which config when running in CLI mode. It also contains a path_aliases section used by the API to track existing pipelines and their primary configs.
    • Path Aliases: The path_aliases section allows the API to identify where pipelines exist and where their primary configs are located (useful for duplicating configs to create new pipelines).
    • Convention: By convention, at least one config file for a pipeline should be stored in the same folder as the pipeline itself. If listed under path_aliases, this config will appear as a template in the interface.
    • Placeholders: For fields without sensible defaults (like API keys), use the string "!!PLACEHOLDER!!". The interface recognizes this and flags the field to prevent users from forgetting to fill it in.
  11. Understand the Complete Factual Generation pipeline

    master

    The Complete Factual Generation pipeline is the primary composition pipeline in Augmentoolkit. It is designed to orchestrate multiple specialized pipelines to generate a full suite of datasets required to create a domain-expert LLM.

    By running this single pipeline, you automate the following workflow:

    1. Document Processing: Cleans input documents (including PDFs) into clean text.
    2. Pretraining Data Generation: Uses the Representation Variation pipeline to create varied representations and inferred facts.
    3. SFT Data Generation: Creates diverse Supervised Fine-Tuning (SFT) datasets, including:
      • Factual QA via the Multi-Source Recall pipeline.
      • RAG-focused training data via the RAG Data pipeline.
      • Self-correction examples via the Correction Data pipeline.
    4. Data Balancing: Combines domain-specific SFT data with generic SFT datasets, automatically balancing token counts.
    5. Training Readiness: Produces Axolotl YAML configuration files for both continued pretraining and final SFT steps.

    Essentially, you provide documents and configure API keys/models, and the pipeline outputs everything needed to train your expert model.