翻篇收录说明
翻篇网页快照

The cookbook - Fireworks AI Docs

https://docs.fireworks.ai/fine-tuning/training-api/cookbook/overview

最近抓取:2026-12-03 16:57:33(北京时间)

最近内容变化:2026-12-03 16:57:33(北京时间)

这是最近一次有效抓取的文本快照,不含网页脚本、图片和动态交互内容。实际网页可能已更新。

访问原网页

页面简介

Overview of the Training API cookbook: ready-to-run recipes for supervised fine-tuning, DPO, GRPO reinforcement learning, and distillation on Fireworks.

正文摘录

What is the cookbook? The Fireworks Cookbook is a collection of training recipes and utilities built on top of the Training API. It provides config-driven training loops that handle trainer provisioning, data loading, tokenization, gradient accumulation, checkpointing, and cleanup automatically. The cookbook is optional — everything it does can be done with the API directly. Use the cookbook when you want a working training loop quickly; use the API when you need full control. New to training on Fireworks? Cookbook: Muse Glimmer First Fine-Tune runs a free LoRA SFT job on preloaded example data and compares base versus tuned. Installation Use Python 3.11 or newer. Install the published cookbook to import its recipes and utilities: python -m pip install --upgrade fireworks-training-cookbook The distribution is fireworks-training-cookbook; Python imports remain training.*, such as from training.recipes.sft_loop import Config, main. It installs the Fireworks SDK and the cookbook’s runtime dependencies. The cookbook and SDK have separate release versions. Cookbook 2026.11.5.1 uses calendar versioning; SDK 1.2.31 is published as fireworks-ai. To reproduce those releases: python -m pip install "fireworks-ai[training]==1.2.31" "fireworks-training-cookbook==2026.11.5.1" Edit recipes or run source examples Clone the public repository when you want to modify a recipe or follow an example that runs from the checkout: git clone https://github.com/fw-ai-external/cookbook.git cd cookbook python -m pip install -e ./training An editable install uses your checkout, which can include changes newer than the published PyPI release. For a reproducible source checkout, check out the matching release tag before installing. Verify the installation python -c "from importlib.metadata import version; import training; print(version('fireworks-training-cookbook'))" This prints the installed cookbook version. With the pinned release above, it prints 2026.11.5.1. Authentication Before running a training job, set your credentials: export FIREWORKS_API_KEY="your-api-key" Update an existing checkout The cookbook’s canonical repository is now fw-ai-external/cookbook. In an existing cookbook clone, update the remote: cd cookbook git remote set-url origin https://github.com/fw-ai-external/cookbook.git To use PyPI releases instead of a local checkout, install the package in a fresh Python environment. To update coding-agent skills, use the current installation commands. Skills are installed from GitHub separately from the Python package. Available recipes RecipeModuleUse caseRL (primary, experimental)training.recipes.async_rl_loopReinforcement learning — you write a rollout function, and the recipe owns completion-driven rollout production, bounded off-policy admission, ready-group training submission, and weight publication. See Cookbook RL. No backward-compatibility guarantee.Serverless async RL (experimental)training.recipes.experiment.async_rl_loop_serverlessThe same rollout and scheduling contract on the shared serverless training and sampling pool. See Serverless Training. No backward-compatibility guarantee.Agentic RL integrationEither async loop plus your rollout adapterMulti-turn rollouts. The structured Cookbook path uses Pi, OpenCode, or Mini-SWE-Agent with Harbor and an environment-local TITO sidecar in Docker or E2B. See Cookbook Agentic RL.HUD RL traininghud-python/cookbooks/fireworks-rl-trainingTrain a Serverless Training LoRA from one-turn HUD environment rewards. See Fireworks x HUD RL Training.RL (simpler, synchronous)training.recipes.rl_loopSynchronous on-policy GRPO scaffold — reach for it when you don’t need rollout/train overlapIGPOrl_loop with igpo.prepare_batchTurn-level information-gain advantages for multi-turn trajectories; see the multi-hop example.DPOtraining.recipes.dpo_loopDirect preference optimization from chosen/rejected pairs. serverless=True uses the shared pool.SFTtraining.recipes.sft_loopSupervised fine-tuning with cross-entropy loss. serverless=True uses the shared pool.Distillationtraining.recipes.distillation_loopOn-policy distillation from a frozen teacher’s sampled-token scoresSDFTExternal SDFT cookbookTop-K self-distillation on serverless. Maintained outside this cookbook; see the SDFT guide.ORPOtraining.recipes.orpo_loopOdds ratio preference optimization. The recipe runs on dedicated trainers only. Each recipe follows the same pattern: import Config and main, set your config, and call main(cfg). Dedicated recipes attach or create trainer and deployment resources from TrainerConfig / DeployConfig. Serverless recipes attach to the shared pool and publish session-scoped sampler snapshots instead of provisioning a deployment. All launch examples below use trainer=TrainerConfig(training_shape_id=...) for explicit shape selection. Cookbook recipes can also auto-select validated shapes when training_shape_id is unset. The main run-level trainer knob you may set alongside a shape is replica_count for replicated HSDP launches; reference shapes can usually be left unset because the cookbook auto-selects or uses a shared-session reference when appropriate. If you want field-level details about what a training shape controls and what stays configurable, see Training shapes and the Cookbook Reference. InfraConfig and the standalone setup_infra / ResourceCleanup helpers are deprecated and removed from the recipe surface. Recipes now take trainer=TrainerConfig(...) (and deployment=DeployConfig(...) for RL). See Migrating from the deprecated managed infra. Quick example: SFT from training.recipes.sft_loop import Config, main from training.utils import TrainerConfig cfg = Config( log_path="./sft_quickstart", base_model="accounts/fireworks/models/qwen3-8b", dataset="/path/to/training_data.jsonl", tokenizer_model="Qwen/Qwen3-8B", max_seq_len=4096, epochs=1, batch_size=4, trainer=TrainerConfig( training_shape_id="accounts/fireworks/trainingShapes/qwen3-8b-128k", ), ) main(cfg) Quick example: GRPO from training.recipes.rl_loop import Config, main from training.utils import DeployConfig, TrainerConfig cfg = Config( log_path="./grpo_quickstart", base_model="accounts/fireworks/models/qwen3-8b", dataset="/path/to/prompts.jsonl", max_rows=100, trainer=TrainerConfig( training_shape_id="accounts/fireworks/trainingShapes/qwen3-8b-128k", ), deployment=DeployConfig( deployment_id="grpo-serving", tokenizer_model="Qwen/Qwen3-8B", ), ) main(cfg) W&B logging All cookbook recipes accept a WandBConfig to stream metrics to Weights & Biases: from training.utils import WandBConfig cfg = Config( # ... same config as above ... wandb=WandBConfig( entity="my-team", project="grpo-experiment", run_name="qwen3-8b-sft-v1", # optional, auto-generated if omitted ), ) main(cfg) Vision-language model support For vision-language training, choose a supported VLM recipe, training shape, and matching tokenizer, and provide multimodal datasets with image_url content. See Vision Inputs for dataset format and examples. Embedding loop The embedding_loop recipe trains embedding models with contrastive or supervised embedding objectives. Use it when your base model is an embedding endpoint rather than a chat completion model. Next steps Cookbook SFT — supervised fine-tuning Cookbook DPO — preference optimization with pairwise data Cookbook RL (GRPO) — full GRPO walkthrough with reward functions Cookbook Agentic RL — multi-turn trajectory, token ancestry, and session design Fireworks x HUD RL Training — train a LoRA adapter from HUD environment rewards Cookbook Distillation — on-policy distillation (OPD) and where to find top-K SDFT Vision Inputs — train VLMs with image and text data Cookbook Reference — all config classes and parameters Was this page helpful?YesNo⌘I