Fine-tuning

Updated at:

Bailian CLI command reference for creating and managing text, audio, image, and video fine-tuning jobs.

Manage the full fine-tuning lifecycle from the terminal: choose the create command for text, audio, image, or video, and manage jobs, checkpoints, and model compression.

ImportantAppend --help to any command for full parameter details, e.g. bl finetune list --help. Existing commands on this page are verified against bl 2.8.4; RL, OPD, and runtime management commands are verified against bl 2.10.4.

Choose a command by modality

ModalityCreate commandDescription
Textbl finetune text createFine-tune text models with sft, sft-lora, dpo, dpo-lora, or cpt
Audiobl finetune audio createFine-tune audio models
Imagebl finetune image createFine-tune image generation models
Videobl finetune video createFine-tune video generation models

Text fine-tuning

bl finetune text create

Create a text model fine-tune job (sft | sft-lora | dpo | dpo-lora | cpt). Requires API Key authentication.

Usage

bl finetune text create
ParameterTypeRequiredDescription
--base-model <model>stringyesBase model to fine-tune (e.g. qwen3-8b; not the output model name)
--datasets <ids|paths|oss://...>stringyesComma-separated dataset file IDs, local paths (.jsonl), or OSS mounts (oss://<bucket>/<object key>). Local paths are validated and uploaded first, then their file-ids are used; OSS mounts are read in place by the service without local validation or upload.
--validations <ids|paths|oss://...>stringnoComma-separated validation dataset file IDs, local paths, or OSS mounts (oss://<bucket>/<object key>), handled like --datasets.
--model-name <name>stringnoOutput model name (after training)
--suffix <text>stringnoOutput suffix appended by the platform (finetuned_output_suffix)
--oss-region <region>stringnoRegion ID of the OSS buckets mounted by the oss:// entries of --datasets / --validations (default: cn-beijing); forwarded as given, whether the service can mount from it is judged by the service.
--job-name <value>stringnoTraining job display name (job_name)
--priority <value>stringnoRequested scheduling priority; verify the service response
--eval-steps <value>numbernoValidation interval in training steps
--lora-alpha <value>numbernoLoRA scaling coefficient
--lora-dropout <value>numbernoLoRA dropout probability
--lora-rank <value>numbernoLoRA matrix rank
--lr-scheduler-type <value>stringnoLearning rate scheduler supported by the selected model
--save-strategy <value>stringnoCheckpoint saving strategy
--save-total-limit <value>numbernoMaximum number of saved checkpoints
--save-steps <value>numbernoCheckpoint saving interval for strategy=steps
--split <value>numbernoTraining fraction when no validation dataset is supplied
--max-split-val-dataset-sample <value>numbernoMaximum automatically split validation samples
--data-augmentation <value>stringnoMix platform preset training data into the job (true or false). Only honored for sft and sft-lora; turned on automatically by --augmentation-types.
--augmentation-types <code,...>stringnoPreset datasets to mix in, comma-separated. Codes come from bl finetune preset-datasets and are sent lowercased (e.g. mix_V2 -> mix_v2). Requires --augmentation-ratio.
--augmentation-ratio <r,...>stringnoMix ratio per preset dataset, comma-separated and positionally matching --augmentation-types; each is 0.0–2.0 of the training data volume.
--training-type <t>stringnoTraining type: sft | sft-lora | dpo | dpo-lora | cpt (default: sft-lora). Mapping to the server happens at the interface boundary (e.g. sft-lora -> efficient_sft, dpo -> dpo_full).
--n-epochs <n>numbernoNumber of epochs (default: 3)
--batch-size <n>numbernoPer-device batch size (clamped to [8, 1024]). Auto-set to 8 for small datasets (<100KB)
--learning-rate <str>stringnoLearning rate as a string to preserve precision (e.g. "1.6e-5")
--max-length <n>numbernoMax sequence length

Example: Create a text fine-tune job with base model and dataset

bl finetune text create --base-model qwen3-8b --datasets file-xxx
  • Training-type values use the <method> / <method>-lora convention: sft (full) | sft-lora (LoRA) | dpo (full) | dpo-lora (LoRA) | cpt. These map to the server's training_type at the interface boundary, so the rest of the CLI never sees the raw server strings.
  • Before submitting (non dry-run) the job, the model's training capability is checked via listFoundationModels (no console login required); an unsupported training type fails fast with the list the model actually supports.
  • The create API requires n_epochs, batch_size, and max_length: an omitted one is filled from the model's parameter defaults (query them with bl finetune params); every other omitted value uses the platform default.
  • Learning rate is forwarded as a string to avoid JSON-number precision loss.
  • Pre-submit gate: if the training dataset's sample count is not greater than batch_size, the job is rejected before upload or quota consumption (the platform would otherwise fail ~10 min in, after data processing).
  • Mixed training: --data-augmentation turns it on; --augmentation-types selects preset datasets (list them with bl finetune preset-datasets; codes are sent lowercased, e.g. mix_V2 -> mix_v2) and --augmentation-ratio gives one ratio (0.0–2.0) per type, positionally. Passing types turns data_augmentation on. These three are documented on the create API but absent from the model's parameter schema, so they are not part of the schema check; whether the selected model and training type honors them is decided by the server (documented for sft and sft-lora), and mixed data is billed as training tokens.
  • OSS mount: an oss://<bucket>/<object key> entry of --datasets / --validations is read in place, so it skips local validation, upload, and the sample-count pre-check. Upload the uncompressed dataset folder to OSS as-is (a zip cannot be mounted) and, for a multi-file dataset, point at its data.jsonl. Every oss:// entry shares --oss-region. A request with an OSS mount sends training_datasets / validation_datasets instead of training_file_ids / validation_file_ids.

Audio fine-tuning

bl finetune audio create

Create an audio TTS model fine-tune job (sft-lora). Requires API Key authentication.

Usage

bl finetune audio create
ParameterTypeRequiredDescription
--base-model <model>stringyesBase model to fine-tune (e.g. qwen3-8b; not the output model name)
--datasets <ids|paths>stringyesComma-separated dataset file IDs or local paths (.jsonl for text, .zip for audio/image/video). Local paths are uploaded (validated) first, then their file-ids are used.
--validations <ids|paths>stringnoComma-separated validation dataset file IDs or local paths (auto-uploaded like --datasets).
--model-name <name>stringnoOutput model name (after training)
--suffix <text>stringnoOutput suffix appended by the platform (finetuned_output_suffix)

Example: Create an audio TTS fine-tune job with base model and local zip dataset

bl finetune audio create --base-model cosyvoice-v3-flash --datasets ./audio.zip
  • Audio TTS training runs sft-lora (efficient_sft) with fixed CosyVoice hyper-parameter defaults; there are no training-type or hyper-parameter knobs to set.

Image fine-tuning

bl finetune image create

Create an image generation model fine-tune job (sft-lora). Requires API Key authentication.

Usage

bl finetune image create
ParameterTypeRequiredDescription
--base-model <model>stringyesBase model to fine-tune (e.g. qwen3-8b; not the output model name)
--datasets <ids|paths>stringyesComma-separated dataset file IDs or local paths (.jsonl for text, .zip for audio/image/video). Local paths are uploaded (validated) first, then their file-ids are used.
--validations <ids|paths>stringnoComma-separated validation dataset file IDs or local paths (auto-uploaded like --datasets).
--model-name <name>stringnoOutput model name (after training)
--suffix <text>stringnoOutput suffix appended by the platform (finetuned_output_suffix)
--generation-type <t2i|i2i>stringnoGeneration type: t2i (default) | i2i. Sets generation_type/max_pixels. Required to train I2I from a file-id or with --dry-run (local data auto-detects input_img).
--learning-rate <str>stringnoLearning rate as a string to preserve precision (e.g. "3e-5")

Example: Create an image generation fine-tune job with base model and local zip dataset

bl finetune image create --base-model wan2.7-image-pro --datasets ./images.zip
  • Image generation training runs sft-lora (efficient_sft) with fixed defaults; only --learning-rate is overridable. T2I vs I2I is declared with --generation-type (default t2i), which sets generation_type/max_pixels. For local data the type is auto-detected (records with input_img train I2I); pass --generation-type explicitly to train I2I from a file-id or in --dry-run.

Video fine-tuning

bl finetune video create

Create a video generation model fine-tune job (Wan i2v/kf2v, efficient_sft). Requires API Key authentication.

Usage

bl finetune video create
ParameterTypeRequiredDescription
--base-model <model>stringyesBase model to fine-tune (e.g. qwen3-8b; not the output model name)
--datasets <ids|paths>stringyesComma-separated dataset file IDs or local paths (.jsonl for text, .zip for audio/image/video). Local paths are uploaded (validated) first, then their file-ids are used.
--validations <ids|paths>stringnoComma-separated validation dataset file IDs or local paths (auto-uploaded like --datasets).
--model-name <name>stringnoOutput model name (after training)
--suffix <text>stringnoOutput suffix appended by the platform (finetuned_output_suffix)
--n-epochs <n>numbernoTraining epochs (default: 50)
--batch-size <n>numbernoBatch size (default: model-specific, 1 for wan2.7, 4 for wan2.5/2.2)
--learning-rate <str>stringnoLearning rate as a string to preserve precision (default: "2e-5")

Example: Create a video generation fine-tune job with base model and dataset ID

bl finetune video create --base-model wan2.7-i2v --datasets file-xxx
  • Video generation training (Wan i2v/kf2v) runs efficient_sft with model-specific defaults: wan2.7 (batch_size=1, max_pixels=102400), wan2.5/2.2 (batch_size=4, max_pixels per model). Override with --batch-size/--n-epochs.
  • Datasets are .zip archives with data.jsonl + frame images + videos.
  • Recommended: ≥10 training samples, 20-100 for stable results.

Fine-tuning job management

bl finetune list

List fine-tune jobs. Requires API Key authentication.

Usage

bl finetune list [--page <n>] [--page-size <n>] [--status <s>] [--base-model <model>]
ParameterTypeRequiredDescription
--page <n>numbernoPage number (default: 1)
--page-size <n>numbernoResults per page (default: 10, max 100)
--status <s>stringnoFilter by status (PENDING / RUNNING / SUCCEEDED / FAILED / CANCELED)
--base-model <model>stringnoFilter by base model ID (server-side)

Example: List fine-tune jobs filtered by status

bl finetune list --status RUNNING

bl finetune get

Get details of a single fine-tune job. Requires API Key authentication.

Usage

bl finetune get --job-id <id>
ParameterTypeRequiredDescription
--job-id <id>stringyesFine-tune job ID

Example: Get details of a specific fine-tune job by ID

bl finetune get --job-id ft-xxx

bl finetune watch

Probe a fine-tune job's status (default: single non-blocking fetch). Pass --follow to poll until terminal. Requires API Key authentication.

Usage

bl finetune watch --job-id <id> [--follow] [--interval <sec>] [--poll-timeout <sec>]
ParameterTypeRequiredDescription
--job-id <id>stringyesFine-tune job ID
--followswitchnoBlock and poll until a terminal state (the legacy behavior). Without it, a single status probe is performed and the command returns immediately.
--interval <sec>numbernoSeconds between polls with --follow (default: ${DEFAULT_INTERVAL_SEC}, min: ${MIN_INTERVAL_SEC}). Ignored without --follow.
--poll-timeout <sec>numbernoWith --follow, stop polling after this many seconds (default: no limit). Ignored without --follow.

Example: Probe a fine-tune job's status once and return immediately

bl finetune watch --job-id ft-xxx                       # single probe, returns immediately
  • Default (no --follow) is a NON-BLOCKING single status probe: one fetch, then return immediately. This is the mode meant for agents / scripts — the caller owns the polling cadence, so the CLI never holds the terminal.
  • A terminal FAILED/CANCELED status raises a normal CLI error (non-zero exit); a SUCCEEDED or still-running status returns 0. With --follow, exceeding --poll-timeout raises a timeout error.
  • Use --follow for the blocking, human-terminal-follow experience; use the default mode when driving the loop yourself (e.g. from an agent).
  • For per-step training output (not status), use finetune logs.

bl finetune logs

Fetch training logs for a fine-tune job. Requires API Key authentication.

Usage

bl finetune logs --job-id <id> [--page <n>] [--page-size <n>] [--search <keyword>] [--tail <n>]
ParameterTypeRequiredDescription
--job-id <id>stringyesFine-tune job ID
--page <n>numbernoPage number (default: 1)
--page-size <n>numbernoLines per page (default: server-defined)
--search <keyword>stringnoCase-insensitive substring filter. When set, all log pages are fetched and filtered client-side (--page is ignored).
--tail <n>numbernoKeep only the last N entries. When set, all log pages are fetched and the trailing N are kept (--page is ignored).

Example: Fetch training logs for a fine-tune job by ID

bl finetune logs --job-id ft-xxx

bl finetune metrics

Query the training metrics of a fine-tune job. Requires API Key authentication.

Usage

bl finetune metrics --job-id <id> [--page <n>] [--page-size <n>] [--workspace-id <id>]
ParameterTypeRequiredDescription
--job-id <id>stringyesFine-tune job ID
--page <n>numbernoPage number, starting at 1 (default: 1)
--page-size <n>numbernoRecords per page (default: 100)
--workspace-id <id>stringnoWorkspace ID sent as X-DashScope-WorkSpace; use the job's owning workspace. Omit when your API key is already workspace-bound.

Example: Query the training metrics of a fine-tune job

bl finetune metrics --job-id ft-xxx
  • Queries GET /api/v1/fine-tunes/{job_id}/basic_metrics. Each metrics record is returned verbatim (step plus dynamic metric fields); an empty list is a normal result.
  • Metrics are not filtered server-side; the full result is returned and callers pick the metric keys from each record. Use --page/--page-size for paging.

bl finetune checkpoints

List checkpoints produced by a fine-tune job. Requires API Key authentication.

Usage

bl finetune checkpoints --job-id <id>
ParameterTypeRequiredDescription
--job-id <id>stringyesFine-tune job ID

Example: List checkpoints from a fine-tune job by ID

bl finetune checkpoints --job-id ft-xxx
  • model_name (shown for SUCCEEDED checkpoints) is the direct input for deploy create --model-name.
  • Checkpoints expire ~15 days after creation; expire_time shows the deadline. Export or deploy before expiry.

bl finetune export

Publish a checkpoint as a deployable model. Requires API Key authentication.

Usage

bl finetune export --job-id <id> --checkpoint <name> --model-name <name>
ParameterTypeRequiredDescription
--job-id <id>stringyesFine-tune job ID
--checkpoint <name>stringyesCheckpoint identifier from finetune checkpoints
--model-name <name>stringyesDeployable model name

Example: Publish a checkpoint as a deployable model with a name

bl finetune export --job-id ft-xxx --checkpoint ckpt-3 --model-name my-qwen-sft
  • Required before deploy <modality> create can target a checkpoint. The platform may auto-export the best checkpoint when a job reaches SUCCEEDED — explicit export is the canonical path for non-best checkpoints.

bl finetune cancel

Cancel a running fine-tune job. Requires API Key authentication.

Usage

bl finetune cancel --job-id <id>
ParameterTypeRequiredDescription
--job-id <id>stringyesFine-tune job ID

Example: Cancel a fine-tune job by ID

bl finetune cancel --job-id ft-xxx
  • Only PENDING / RUNNING jobs can be cancelled. Completed / failed / already-cancelled jobs return a server-side error (passed through verbatim).

bl finetune delete

Delete a fine-tune job record. Requires API Key authentication.

Usage

bl finetune delete --job-id <id>
ParameterTypeRequiredDescription
--job-id <id>stringyesFine-tune job ID
--yesswitchnoConfirm this high-risk operation

WarningThis permanently deletes the specified fine-tune job record and cannot be undone.

Example: Delete a fine-tune job record by ID

bl finetune delete --job-id ft-xxx
  • Irreversible — the job record is permanently removed.
  • Cancel a RUNNING job first via finetune cancel — the platform refuses to delete jobs that are still in flight.

bl finetune capability

Query fine-tune training capability — by model (which training types it supports) or by training type (which models support it). No authentication required.

Usage

bl finetune capability --base-model <m> | --training-type <t>
ParameterTypeRequiredDescription
--base-model <m>stringnoList training types supported by this base model.
--training-type <t>stringnoList models supporting this training type: sft | sft-lora | dpo | dpo-lora | cpt.

Example: List training types supported by base model qwen3-8b

bl finetune capability --base-model qwen3-8b
  • Exactly one of --base-model / --training-type is required.
  • Training-type values use the <method> / <method>-lora convention: sft | sft-lora | dpo | dpo-lora | cpt. (cpt has no -lora variant server-side.)
  • Queries listFoundationModels, a public API — no console login needed.

bl finetune params

Query the training hyper-parameter configuration for a base model. Requires API Key authentication.

Usage

bl finetune params --base-model <model> [--training-type <t>] [--param-type <hyper|resource>] [--mtu-spec-code <code>] [--modality <text|vision>] [--reasoning-mode <instruct|thinking>] [--lang <locale>] [--workspace-id <id>]
ParameterTypeRequiredDescription
--base-model <model>stringyesBase model to query training parameters for (e.g. qwen3-8b)
--training-type <t>stringnoTraining type: sft | sft-lora | dpo | dpo-lora | cpt (default: sft-lora). Mapped to the server's training_type (e.g. sft-lora -> efficient_sft).
--mtu-spec-code <code>stringnoMTU spec code, required for resource-group queries (e.g. MTU2)
--param-type <hyper|resource>stringnoParameter group: hyper | resource. Omit to return all groups.
--modality <text|vision>stringnoTraining modality: text | vision. Only meaningful for models with dynamic train options; sent as modality inside hyper_parameters.
--reasoning-mode <instruct|thinking>stringnoReasoning mode: instruct (non-thinking) | thinking. Only meaningful for models with dynamic train options; sent as reasoning_mode inside hyper_parameters.
--lang <locale>stringnoLocale for server-side display text (e.g. en, zh). Omit for the server default.
--workspace-id <id>stringnoWorkspace ID sent as X-DashScope-WorkSpace; omit when your API key is already workspace-bound.

Example: Query training hyper-parameters for a base model

bl finetune params --base-model qwen3-8b

Example: Query dynamic training options

bl finetune params --base-model qwen3.7-plus-2026-05-26 --modality vision --reasoning-mode thinking
  • Queries GET /api/v1/fine-tunes/fine-tunes-params. Each hyper_params entry keeps server field names verbatim (recommend_value, defaultValue, is_advanced_parameter, ...).
  • --modality / --reasoning-mode travel as one hyper_parameters query parameter (JSON). Supported values and combinations vary per model; invalid combinations are rejected by the server and surfaced as-is. Models without dynamic train options ignore these flags.
  • resume_from_checkpoint in the output reports whether the training type supports resuming training.

bl finetune price

Estimate the training cost for a fine-tune job (token billing).

Usage

bl finetune price --base-model <model> --datasets <ids> [--training-type <type>] [--n-epochs <n>]
ParameterTypeRequiredDescription
--base-model <model>stringyesBase model to fine-tune (e.g. qwen3-8b; not the output model name)
--datasets <ids>stringyesTraining dataset file IDs, comma-separated
--training-type <type>stringnoTraining type: sft | dpo | cpt (default: sft)
--n-epochs <n>numbernoNumber of training epochs (default: 3)

Example: Estimate training cost for datasets using base model qwen3-8b

bl finetune price --base-model qwen3-8b --datasets file-ft-xxx
  • Estimate only — the server computes token usage from the datasets; final cost is subject to the bill.
  • Covers token billing for sft / dpo / cpt. Training-unit (MTU) billing is not supported by this command.
  • Hyper-parameters other than --n-epochs are fixed at representative defaults for estimation.

Model compression

Model compression quantizes supported full-parameter fine-tuned models. Run templates to find a compatible template, then create a compression job. On success, the returned quantized_output can be passed to deploy text create --model-name. Model compression APIs are currently available only in the Beijing region.

bl finetune compress templates

List quantizable models and their compression templates. Requires API Key authentication.

Usage

bl finetune compress templates [--model <model>]
ParameterTypeRequiredDescription
--model <model>stringnoFilter by custom model ID or base model name

Example: List supported models and templates

bl finetune compress templates
  • Only supported full-parameter fine-tuned models are returned. LoRA and already-quantized models are excluded.
  • Template IDs live in output.custom_models[].templates[].template_id. output.base_models only lists quantizable base model names and carries no templates.
  • An empty templates[].hyper_parameters array means the template exposes no tunable hyper-parameters; omit --hparam when creating the job.

bl finetune compress create

Create a model compression job. Requires API Key authentication.

Usage

bl finetune compress create --model <model> --template-id <id> [flags]
ParameterTypeRequiredDescription
--model <model>stringyesSource custom model ID
--template-id <id>stringyesCompression template ID
--job-name <name>stringnoUnique job name (max 50 characters)
--description <text>stringnoJob description (max 200 characters)
--hparam <key=value>arraynoHyper-parameter override; repeat for multiple values
--calibration-files <file-id,...>stringnoComma-separated calibration dataset file IDs
--suffix <suffix>stringnoOutput model suffix (1-8 lowercase letters or digits)

Example: Create a compression job with a specific template

bl finetune compress create --model qwen3.5-flash-2026-02-23-ft-xxx --template-id quant-flash-nvfp4-mlp-nomtp

bl finetune compress list

List model compression jobs. Requires API Key authentication.

Usage

bl finetune compress list [filters] [--page <n>] [--page-size <n>]
ParameterTypeRequiredDescription
--status <status>stringnoFilter by job status
--model <model>stringnoFilter by source model ID
--template-id <id>stringnoFilter by template ID
--quant-spec <spec>stringnoFilter by quantization specification
--quant-method <method>stringnoFilter by quantization method
--start-time <time>stringnoFilter jobs starting no earlier than this time
--end-time <time>stringnoFilter jobs ending no later than this time
--search <keyword>stringnoSearch job ID or name
--search-field <job_id|job_name>stringnoLimit --search to job_id or job_name
--sort-order <asc|desc>stringnoSort order by create_time (default: desc)
--page <n>numbernoPage number (default: 1)
--page-size <n>numbernoResults per page (default: 10, max: 100)

Example: List recently succeeded compression jobs

bl finetune compress list --status SUCCEEDED --page-size 20

bl finetune compress get

Get a compression job. Requires API Key authentication.

Usage

bl finetune compress get --job-id <id>
ParameterTypeRequiredDescription
--job-id <id>stringyesCompression job ID

Example: Get a specific compression job

bl finetune compress get --job-id quant-xxx

bl finetune compress watch

Probe or follow a compression job's status. Requires API Key authentication.

Usage

bl finetune compress watch --job-id <id> [--follow] [--interval <sec>] [--poll-timeout <sec>]
ParameterTypeRequiredDescription
--job-id <id>stringyesCompression job ID
--followswitchnoPoll until the job reaches a terminal state
--interval <sec>numbernoPolling interval with --follow (default: 10, min: 1)
--poll-timeout <sec>numbernoStop polling after this many seconds

Example: Follow a compression job until it finishes

bl finetune compress watch --job-id quant-xxx --follow
  • Without --follow, the command performs one non-blocking status probe.
  • On success, quantized_output can be passed to deploy text create --model-name.

bl finetune compress logs

Get compression job logs. Requires API Key authentication.

Usage

bl finetune compress logs --job-id <id> [--offset <n>] [--lines <n> | --tail <n>]
ParameterTypeRequiredDescription
--job-id <id>stringyesCompression job ID
--offset <n>numbernoSkip the first N lines (default: 0)
--lines <n>numbernoNumber of lines to read (default: 100, max: 1000)
--tail <n>numbernoRead the last N log lines

Example: Read the last 20 lines of compression logs

bl finetune compress logs --job-id quant-xxx --tail 20

bl finetune compress cancel

Cancel a compression job. Requires API Key authentication.

Usage

bl finetune compress cancel --job-id <id>
ParameterTypeRequiredDescription
--job-id <id>stringyesCompression job ID

Example: Cancel a compression job

bl finetune compress cancel --job-id quant-xxx
  • Only PENDING, QUEUING, or RUNNING jobs can be cancelled.

bl finetune compress delete

Delete a compression job record. Requires API Key authentication.

Usage

bl finetune compress delete --job-id <id>
ParameterTypeRequiredDescription
--job-id <id>stringyesCompression job ID
--yesswitchnoConfirm this high-risk operation

WarningThis permanently deletes the compression job record and cannot be undone.

Example: Preview deleting a compression job record

bl finetune compress delete --job-id quant-xxx --dry-run
  • Only terminal jobs can be deleted. Deleting a job record does not delete its quantized output model.

Reinforcement Learning Training

bl finetune rl authorize

Check and authorize reinforcement-learning access (admission allowlist, service-linked roles, service activation). Requires Console authentication.

Usage

bl finetune rl authorize [--authorize]
ParameterTypeRequiredDescription
--authorizeswitchnoPermit enabling RL once service roles are manually authorized (read-only probe without this flag)
--yesswitchnoConfirm this high-risk operation
--console-region <region>stringnoConsole gateway region (e.g. cn-beijing, ap-southeast-1)
--console-site <site>stringnoConsole site: domestic, international
--workspace-id <id>stringnoWorkspace ID (env: BAILIAN_WORKSPACE_ID)

WarningThe CLI never creates service-linked roles automatically. Missing roles return REQUIRES_USER_ACTION and abort; authorize them manually first per Environment Preparation.

Example: Read-only probe of RL admission status

bl finetune rl authorize

Example: Enable RL only after explicit confirmation

bl finetune rl authorize --authorize --yes
  • Without --authorize, this is a read-only probe. Each capability reports READY / MISSING / UNKNOWN / REQUIRES_USER_ACTION / FAILED; a failed query is UNKNOWN, never assumed enabled.
  • Only RL is enabled; OPD is never auto-enabled. In CI pass --authorize --yes to permit changes; --yes alone does not expand permissions.

bl finetune rl run

Submit a reinforcement-learning training job. Requires API Key authentication.

Usage

bl finetune rl run --model <id> [flags]
ParameterTypeRequiredDescription
--config-file <path>stringnoOptional job YAML file; explicit CLI flags take precedence
--name <name>stringnoJob name
--model <id>stringnoBase model ID
--train-file <path>arraynoLocal training file (repeatable)
--train-file-id <id>arraynoUploaded training file ID (repeatable)
--validation-file <path>arraynoLocal validation file (repeatable)
--validation-file-id <id>arraynoUploaded validation file ID (repeatable)
--code-dir <path>stringnoFunction package source directory
--requirements <path>stringnoRequirements path relative to code-dir
--rollout <classpath>stringnoRollout function classpath
--reward <name=classpath>arraynoReward function (repeatable)
--hp <key=value>arraynoHyper-parameter (repeatable, parsed by type)
--charge-type <value>stringnoResource charge type
--mtu-spec <code>stringnoMTU spec code
--mtu-count <int>numbernoMTU capacity
--watchswitchnoWait for the job to reach a terminal state
--wait-timeout <seconds>numbernoMaximum seconds to poll with --watch (default: no limit; timeout does not cancel the cloud job)
--install-runtimeswitchnoAllow first-time managed runtime preparation
--yesswitchnoConfirm this high-risk operation

WarningThis creates a billed RL training job that consumes compute resources. Runs inside an isolated sandbox; prepare the runtime first with bl finetune runtime prepare, or pass --install-runtime.

Example: Submit an RL training job and wait for completion

bl finetune rl run --model qwen3.5-9b --train-file ./data/train.jsonl --code-dir . --rollout functions.rollout.MyRollout --charge-type mtu_postpaid --mtu-spec MTU4 --mtu-count 24 --watch

Example: Submit via YAML config

bl finetune rl run --config-file job.yaml --watch

Example: Preview job specs without submission

bl finetune rl run --model qwen3.5-9b --train-file ./data/train.jsonl --dry-run
  • --watch timeout stops waiting only; it does not cancel the cloud job.

bl finetune rl get

Get reinforcement-learning training job details. Requires API Key authentication.

Usage

bl finetune rl get --job-id <id>
ParameterTypeRequiredDescription
--job-id <id>stringyesRL job ID

bl finetune rl list

List reinforcement-learning training jobs. Requires API Key authentication.

Usage

bl finetune rl list

bl finetune rl watch

Probe an RL job's status (default: single non-blocking fetch). Requires API Key authentication.

Usage

bl finetune rl watch --job-id <id> [--follow] [--interval <sec>] [--poll-timeout <sec>]
ParameterTypeRequiredDescription
--job-id <id>stringyesRL job ID
--followswitchnoBlock and poll until a terminal state; without this flag, performs a single fetch and returns immediately
--interval <sec>numbernoSeconds between polls with --follow (default: 10, min: 1)
--poll-timeout <sec>numbernoMaximum seconds to poll with --follow (default: no limit)

Example: Single status probe

bl finetune rl watch --job-id ft-xxx

Example: Poll until terminal state

bl finetune rl watch --job-id ft-xxx --follow
  • Default (no --follow) is a non-blocking single probe. Terminal FAILED/CANCELED raises a non-zero exit code; SUCCEEDED or still-running returns 0.
  • Queries the fine-tunes endpoint directly; no sandbox runtime needed. For per-step training output use bl finetune rl logs.

bl finetune rl logs

Get reinforcement-learning training job logs. Requires API Key authentication.

Usage

bl finetune rl logs --job-id <id>
ParameterTypeRequiredDescription
--job-id <id>stringyesRL job ID

bl finetune rl cancel

Cancel a reinforcement-learning training job. Requires API Key authentication.

Usage

bl finetune rl cancel --job-id <id>
ParameterTypeRequiredDescription
--job-id <id>stringyesRL job ID
--yesswitchnoConfirm this high-risk operation
  • Only PENDING, QUEUING, or RUNNING jobs can be cancelled.

bl finetune rl delete

Delete a reinforcement-learning training job record. Requires API Key authentication.

Usage

bl finetune rl delete --job-id <id>
ParameterTypeRequiredDescription
--job-id <id>stringyesRL job ID
--yesswitchnoConfirm this high-risk operation

WarningThis permanently deletes the job record and cannot be undone.

  • Only terminal jobs can be deleted.

Online Pure-Model Distillation (OPD)

bl finetune opd authorize

Check and authorize online distillation access. Requires Console authentication.

Usage

bl finetune opd authorize [--authorize]
ParameterTypeRequiredDescription
--authorizeswitchnoPermit enabling OPD once service roles are manually authorized (read-only probe without this flag)
--yesswitchnoConfirm this high-risk operation
--workspace-id <id>stringnoWorkspace ID

WarningThe CLI never creates service-linked roles automatically. Missing roles return REQUIRES_USER_ACTION and abort.

bl finetune opd run

Submit a pure-model online distillation job (pg_opd). Requires API Key authentication.

Usage

bl finetune opd run --base-model <id> --teacher-model <id> --datasets <ids|paths> [flags]
ParameterTypeRequiredDescription
--base-model <id>stringyesStudent base model ID (e.g. qwen3.5-9b)
--teacher-model <id>stringyesPlatform-registered teacher model ID (no arbitrary URLs or keys)
--datasets <ids|paths>stringyesComma-separated dataset file IDs or local .jsonl paths; local paths are validated and uploaded first
--validations <ids|paths>stringnoComma-separated validation file IDs or local paths (auto-uploaded)
--job-name <name>stringnoTraining job display name
--hyper-parameters-file <path>stringnoJSON file of training + resource hyper-parameters; --hp overrides it
--resource-config-file <path>stringnoresource_config JSON file (charge_type / mtu_spec_code / mtu_capacity); resource flags override it
--hp <key=value>arraynoHyper-parameter override (repeatable, parsed by type)
--charge-type <value>stringnoresource_config.charge_type; pg_opd only supports mtu_postpaid (default)
--mtu-spec <code>stringnoresource_config.mtu_spec_code (e.g. MTU4); required
--mtu-count <int>numbernoresource_config.mtu_capacity (student GPUs + teacher GPUs); required
--workspace-id <id>stringnoWorkspace for upload, parameter query, creation and reads
--watchswitchnoWait for the job to reach a terminal state
--wait-timeout <seconds>numbernoMaximum seconds to poll with --watch (default: no limit; timeout does not cancel the cloud job)
--yesswitchnoConfirm this high-risk operation

WarningThis creates a billed OPD training job that consumes compute resources. Forces training_type=pg_opd; no rollout/reward functions needed, no function-compute resources created. Submits directly from the host via the fine-tunes OpenAPI; no sandbox runtime required.

Example: Preview job specs without submission

bl finetune opd run --base-model qwen3.5-9b --teacher-model qwen3.8-flash --datasets file-xxx --hyper-parameters-file ./hp.json --resource-config-file ./resource.json --dry-run

Example: Submit an OPD training job and wait for completion

bl finetune opd run --base-model qwen3.5-9b --teacher-model qwen3.5-397b-a17b --datasets ./train.jsonl --hp n_epochs=1 --hp batch_size=64 --charge-type mtu_postpaid --mtu-spec MTU4 --mtu-count 24 --watch
  • Hyper-parameters are sent as provided (JSON file → --hp overrides). Omitted fields are resolved by the server and the selected teacher's defaults; the CLI never fills recommend_value.
  • mtu_capacity must equal student GPUs + teacher GPUs. Recommended configurations and model pairs: Models and Training Units.
  • --watch timeout stops waiting only; it does not cancel the cloud job.

bl finetune opd params

Query hyper-parameters supported by the student base model. Requires API Key authentication.

Usage

bl finetune opd params --base-model <id>
ParameterTypeRequiredDescription
--base-model <id>stringyesStudent base model ID

bl finetune opd get

Get online distillation job details. Requires API Key authentication.

Usage

bl finetune opd get --job-id <id>
ParameterTypeRequiredDescription
--job-id <id>stringyesOPD job ID

bl finetune opd watch

Probe an OPD job's status. Requires API Key authentication.

Usage

bl finetune opd watch --job-id <id> [--follow] [--interval <sec>] [--poll-timeout <sec>]
ParameterTypeRequiredDescription
--job-id <id>stringyesOPD job ID
--followswitchnoBlock and poll until a terminal state
--interval <sec>numbernoSeconds between polls with --follow (default: 10)
--poll-timeout <sec>numbernoMaximum seconds to poll with --follow (default: no limit)

bl finetune opd logs

Get online distillation job logs. Requires API Key authentication.

Usage

bl finetune opd logs --job-id <id>
ParameterTypeRequiredDescription
--job-id <id>stringyesOPD job ID

bl finetune opd cancel

Cancel an online distillation job. Requires API Key authentication.

Usage

bl finetune opd cancel --job-id <id>
ParameterTypeRequiredDescription
--job-id <id>stringyesOPD job ID
--yesswitchnoConfirm this high-risk operation
  • Only PENDING, QUEUING, or RUNNING jobs can be cancelled.

bl finetune opd delete

Delete an online distillation job record. Requires API Key authentication.

Usage

bl finetune opd delete --job-id <id>
ParameterTypeRequiredDescription
--job-id <id>stringyesOPD job ID
--yesswitchnoConfirm this high-risk operation

WarningThis permanently deletes the job record and cannot be undone.

  • Only terminal jobs can be deleted.

Sandbox Runtime Management

bl finetune runtime prepare

Prepare the managed Python/SDK runtime used by RL and OPD jobs. No authentication required.

Usage

bl finetune runtime prepare [--manifest <path>]
ParameterTypeRequiredDescription
--manifest <path>stringnoOptional runtime manifest file (defaults to the bundled reviewed manifest)

Example: Prepare the runtime

bl finetune runtime prepare

Example: Use a custom manifest

bl finetune runtime prepare --manifest ./runtime-manifest.json
  • Downloads and verifies the runtime locally; never creates a training job. Set BAILIAN_RL_RUNTIME to a local dashscope Python directory to reuse a development runtime.
  • CPython downloads fall back to a built-in npmmirror mirror when GitHub is unreachable; set BAILIAN_RL_PYTHON_MIRROR to a custom mirror prefix. Integrity is always verified against the reviewed SHA256.
  • When the PyPI CDN stalls, set BAILIAN_RL_PIP_INDEX_URL to a stable PyPI mirror (e.g. https://pypi.tuna.tsinghua.edu.cn/simple/); pip still verifies every package hash via --require-hashes.
  • Also reclaims orphaned run directories older than 24 hours (crash leftovers); normal invocations dispose automatically on exit.

bl finetune runtime doctor

Check the RL runtime and sandbox isolation (credential deny, home redirect, SDK import). No authentication required.

Usage

bl finetune runtime doctor

Example: Check runtime status

bl finetune runtime doctor
  • Read-only self-check; creates no cloud resources. Required checks must pass; when the runtime is missing they are skipped (not treated as passed) and the command exits non-zero.
  • Enhanced hardening (kernel network enforcement, process tree, memory) degrades with a notice when unavailable and does not fail the overall check.
  • Host network reachability (API / runtime download / PyPI hosts) is probed as an advisory check: blocked hosts degrade with guidance (agent sandboxes often block outbound network) and do not fail the overall check.

bl finetune runtime clean

Reclaim orphaned sandbox run directories and superseded runtime versions. No authentication required.

Usage

bl finetune runtime clean [--ttl-hours <hours>] [--dry-run]
ParameterTypeRequiredDescription
--ttl-hours <hours>numbernoAge threshold for orphaned run directories (default: 24 hours)
--yesswitchnoConfirm this high-risk operation

WarningThis permanently deletes orphaned run directories and superseded runtime versions; it cannot be undone.

Example: Preview cleanup plan

bl finetune runtime clean --dry-run

Example: Reclaim orphan directories older than 48 hours

bl finetune runtime clean --ttl-hours 48
  • Normal invocations dispose run directories automatically on exit; only crash leftovers (older than TTL) remain under runs/. Superseded runtime versions under runtimes/rl/ are reclaimed, keeping only the current reviewed baseline.
  • Never touches the current baseline runtime, BAILIAN_RL_RUNTIME development directories, or the content-addressed download cache. Local only: no credentials, no cloud resources.