How predibase/llm_distillation_playbook works
Main Components
• Application Layer:
– The “app” directory contains the core application logic. Notice that there are submodules for initialization (app/init) and two variants of S3 logging (app/s3_logging vs. app/s3_logging_threaded). These indicate that the playbook supports synchronous and asynchronous logging of requests/results.
• Configuration Module:
– The “configs” directory holds YAML configuration files that likely parameterize the behavior of the different application modules.
• Data Layer:
– The “data” directory is organized to support different parts of the distillation workflow. It has:
▪ “data_pools” – raw CSV files (with variants such as test and train datasets).
▪ “dataset_subsets” – multiple subsets, including examples processed for different LLM versions (gpt-3.5-turbo, gpt-4-1106-preview, etc.), along with associated prompts, metrics, and parsed outputs.
▪ “original_data” – the source CSV files for training and evaluation.
• Data Preparation Pipeline:
– The “jigsaw_data_prep” folder includes scripts and notebooks that are used to preprocess and evaluate data (e.g., for toxic comment classification via evaluation, label parsing, and subset generation). This module demonstrates how to transform raw data into a form that is ready for training or evaluation.
• Notebooks and Documentation:
– Jupyter Notebooks like “profile_jigsaw.ipynb” are used for exploratory analysis and model profiling.
• Ancillary Resources:
– “requirements.txt” for dependency management and “.vscode” configuration files indicate development environment support.
Relationships and Interactions
• Data Flow:
– The logging apps (app/s3_logging and app/s3_logging_threaded) will capture requests and responses from the teacher models (used for distillation) and send these logs to external storage (presumably S3 or a similar service).
– Configurations (from YAML files) drive the behavior of these logging and initialization scripts.
– The raw data (both training and testing CSV files) is processed by the “jigsaw_data_prep” scripts – feeding into the distillation experiments as described in the README.
• Modular Communication:
– The separation between “app/init” and “app/s3_logging” shows a clear modular design. One module initializes and maybe serves model requests, while another handles logging asynchronously.
– The processed data stored in “data/dataset_subsets” (including the multiple examples with different prompt versions) informs the evaluation metrics and comparisons (teacher vs. student performance) discussed in the README.
• Deployment/Monitoring:
– The README also contains guidelines for deployment and monitoring, tying these modules together as part of a complete production pipeline.
Architectural Patterns and Technologies
• Separation of Concerns:
– Each folder (app, configs, data, jigsaw_data_prep) represents a different concern: application logic, configuration management, data storage/processing, and data preparation.
• Asynchronous Logging Pattern:
• Configuration Driven Behavior:
– Using YAML configurations shows the reliance on external settings which can be modified without changing the code base.
• Data Pipeline Management:
– The structure of datasets (with variants tailored for different LLM versions and evaluation criteria) is central to the distillation process, as described in the playbook. This corresponds to a multi-stage data processing pipeline.
• Technologies:
– Python is the core language (as seen by .py scripts), with Jupyter notebooks for experiments.
– YAML (for configs) and CSV files (for datasets) are also key technologies.
– External services such as Amazon S3 are implied in the logging modules for production-level logging.