Skip to main content
POST
POST /v1/training/jobs/{job_id}/forward-backward Computes the loss of a batch of token-level datums and accumulates its gradients. The next optimizer step applies them. The response is a future; read the loss and per-token log probabilities from GET /v1/training/jobs/{job_id}/futures/{future_id}. POST /v1/training/jobs/{job_id}/forward takes the same body and computes the loss without gradients. A GLiDE (fastino/GLiDE) job takes decisions instead of datums. See Train GLiDE below.

Request

string
required
Your Fastino API key.
string
required
Interactive job ID.
object[]
One or more training examples for a decoder job. Tokenize them yourself with the base model’s tokenizer. Send exactly one of datums and decisions.
object[]
GLiDE jobs only: decision rows instead of datums, at most 512. On this route every row needs gold, soft_target, or both.
string
default:"cross_entropy"
cross_entropy, importance_sampling, ppo, cispo, or dro for a decoder job. A GLiDE job uses glide_decision, its default.
object
Loss settings. ppo and cispo take clip_low_threshold and clip_high_threshold; dro takes beta; glide_decision takes ce_weight (default 0.3) and kl_weight (default 0.7). Unknown keys are rejected.
The numeric token arrays below are illustrative placeholders. Tokenize your actual text with the tokenizer for the job’s base_model.

Response

string
The queued future.
string
The job.
string
forward_backward.

Train GLiDE

For a GLiDE job, ce_weight sets how much each row’s loss counts gold, and kl_weight how much it counts matching soft_target. A row with only gold puts both weights on gold. The loss is summed over the rows, each scaled by its weight. Each row can be at most 16,384 tokens.
cURL
The completed future’s result.loss_fn_outputs holds each row’s option probabilities as probs, in the question’s option order (true, false for noul), and result.metrics["loss:sum"] holds the summed loss. Rows that fail the schema, such as a gold that isn’t one of the question’s options, a soft_target key that isn’t an option or with no positive mass, or an image state, return 422. A row without gold or soft_target, a loss_fn other than glide_decision, an unknown loss_fn_config key, decisions on a decoder job, or datums on a GLiDE job return 400.

Errors

Before queuing the batch, the route also refuses with 400 what the model would refuse: an unknown loss_fn_config key, an unknown loss_fn_inputs key, a datum without loss_fn_inputs.target_tokens (or, for a reward loss, without logprobs or advantages, or with target_tokens that isn’t 1-D), and a datum longer than the model’s limit. Problems found only while the batch runs, such as tensor lengths that don’t match across a datum’s inputs, fail the future. Its error.category is user.