Fabryka · Research guidesAPI verified · 05 Sep 2026
Full-vocabulary log probabilities

More than an answer.
A distribution
to learn from.

Ask Bielik for every possible next token and its probability. Qwen provides generated-token probabilities and top alternatives. Use that richer signal to train a student model, inspect uncertainty, and measure changes in model behavior.

32,128Bielik vocabulary tokens
248,320Qwen vocabulary tokens
JSON + SSEFull coverage, checked by token ID

Bielik full-vocabulary mode is available through the authenticated chat API: logprobs: true and top_logprobs: -1.

01 / The useful difference

The alternatives carry information.

A text response tells you which token was generated. A probability distribution also tells you which alternatives the model considered plausible. A student can learn from the teacher’s relative preferences instead of receiving only one selected token as its target.

TEXT-ONLY TEACHER

One continuation

Train on the generated answer with ordinary supervised learning. Useful across different tokenizers, after filtering the data.

FULL-DISTRIBUTION TEACHER

Every alternative

Train against a probability target at each available position. Direct token-level distillation requires matching vocabulary meanings and IDs.

A logprob is a natural logarithm: p = exp(logprob). For example, −0.693 is approximately 50%. Full mode includes the tail that a top-5 or top-20 response omits.

02 / Interactive explanation

See what the student can learn.

In this tiny, fictional vocabulary, the teacher prefers A but leaves room for B and C. Increase the distillation temperature to give the alternatives more weight.

ILLUSTRATIVE · THREE-TOKEN VOCABULARYNo API call
TokenHard targetSoft teacher target
A
100%
70%
B
0%
20%
C
0%
10%

A: 70.0% · B: 20.0% · C: 10.0%. Entropy: 0.802 nats.

This is a teaching example, not a Qwen or Bielik measurement. The control reweights a saved distribution with softmax(logp / T); it does not change the API’s generation temperature.

03 / Applications

What you can build with it.

01

Distill a smaller model

Use a served model as a teacher for a student with a compatible vocabulary. Combine soft targets with task data, then measure quality, latency and memory against your original student.

02

Choose examples to review

Compute entropy or the gap between leading tokens to flag ambiguous next-token predictions. Validate any review threshold on your own labeled data: token confidence is not factual correctness.

03

Measure behavior drift

Compare distributions from aligned models or checkpoint variants on identical token contexts. This can reveal changes hidden by identical generated text, including shifts after quantization.

04

Study your training data

Inspect probability mass, rare alternatives and disagreement with a student. Use these signals to prioritize experiments; entropy alone does not establish that an example is useful or correct.

04 / Start with one position

Request every next-token probability.

Generate an API key and put it in FABRYKA_API_KEY. Save the following as request.json. Use bielik-11b-v3 instead of qwen3.8-27b to query Bielik.

REQUEST.JSON
{
  "model": "bielik-11b-v3",
  "messages": [{"role": "user", "content": "Stolica Polski to"}],
  "max_tokens": 1,
  "temperature": 0,
  "logprobs": true,
  "top_logprobs": -1
}
SHELL · SAVE THE RESPONSE
curl --fail-with-body --silent --show-error \
  https://fabryka.ai/v1/chat/completions \
  -H "Authorization: Bearer $FABRYKA_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @request.json \
  -o teacher.json

max_tokens: 1 returns a distribution for the next generated position after the server’s chat-formatted prompt. For up to 8 positions, each later row is conditioned on the tokens the teacher actually generated before it.

OptionWhat you get
logprobs: trueLog probabilities for generated tokens.
top_logprobs: 5Five alternatives per position; values 0–20 are supported.
top_logprobs: -1The full vocabulary, including special tokens. Requires max_tokens from 1 to 8.
stream: trueRead distributions from SSE chunks, including chunks without a text delta.

In JSON, read choices[0].logprobs.content. Each position contains a generated id, token, bytes, logprob, and a top_logprobs list. In full mode that list contains every vocabulary token. The enclosing object reports full_vocabulary: true and vocab_size.

Alternatives are in backend probability order. Always index by id, not by list position or decoded text. The API rejects incomplete vocabularies, duplicate IDs and invalid values. Open the API reference →

05 / A reusable teacher artifact

Turn the response into a tensor.

The downloadable exporter validates full coverage and saves a float32 array with shape [generated_positions, vocabulary_size]. Column j always refers to teacher token ID j. It also saves the request, generated token IDs and response metadata in a separate JSON file.

SHELL · EXPORT LOCALLY
python -m pip install numpy
curl --fail --silent --show-error \
  https://fabryka.ai/examples/export_logprobs.py -o export_logprobs.py
python export_logprobs.py teacher.json --request request.json --out teacher
01 · CollectPrompt + teacher distribution
02 · AlignToken IDs + identical context
03 · TrainStudent loss + task data
04 · EvaluateHeld-out quality + serving cost

A single dense float32 vector takes about 0.12 MiB for Bielik or 0.95 MiB for Qwen. The API’s JSON is substantially larger because it includes token strings, bytes and IDs. A million Qwen positions would require about 926 GiB for the float32 values alone. Pilot your collection and storage budget before scaling.

Record the exact teacher checkpoint, tokenizer revision, chat template, quantization and generation settings with the experiment. The public model ID and system_fingerprint are useful labels, but are not an immutable checkpoint pin. Ask for the exact serving configuration before a reproducibility-sensitive collection.

06 / Distillation recipe

Train on the teacher’s preferences.

For a student with the same vocabulary semantics and token IDs, minimize KL(p_teacher || p_student) at matched positions. You can soften both distributions with temperature T and mix the distillation objective with supervised cross-entropy on task targets. Tune the mixture on a held-out validation set.

The function below takes two tensors of shape [valid_positions, vocabulary_size]. Remove padding and unscored prompt positions before calling it. It normalizes the stored teacher logprobs and keeps gradients only on the student.

PYTORCH · DISTILLATION LOSS
import torch
import torch.nn.functional as F


def distillation_loss(student_logits, teacher_logprobs, temperature=2.0):
    if temperature <= 0:
        raise ValueError('temperature must be positive')
    if student_logits.ndim != 2 or student_logits.shape != teacher_logprobs.shape:
        raise ValueError('Inputs must have matching [valid_positions, vocabulary] shapes')
    if student_logits.shape[0] == 0:
        raise ValueError('At least one valid position is required')
    teacher = teacher_logprobs.detach().to(device=student_logits.device, dtype=torch.float32)
    log_p_teacher = F.log_softmax(teacher / temperature, dim=-1)
    log_p_student = F.log_softmax(student_logits.float() / temperature, dim=-1)
    return F.kl_div(
        log_p_student, log_p_teacher,
        reduction='batchmean', log_target=True,
    ) * temperature ** 2

Download the loss function → This is the training objective, not a complete trainer. For the first generated position, use the student’s last-position logits on the identical teacher input prefix. For later positions, condition the student on the teacher’s preceding token IDs and select the corresponding next-token logits.

Full logprobs are enough to change distillation temperature offline: log_softmax(logp_teacher / T) cancels the original normalization constant. The API’s temperature controls generation; it is separate from this training-time T. Native floating-point precision still applies.

If the student uses a different tokenizer, start with filtered teacher-generated text and supervised sequence training, or implement and validate an explicit cross-tokenizer alignment method. Do not apply elementwise KL directly between Qwen and Bielik vectors.

Measure the student against its own baseline on held-out tasks. Distillation can transfer teacher behavior, including errors; access to the full distribution does not guarantee a smaller model will match or outperform its teacher. The soft-target method follows Hinton, Vinyals & Dean; the loss implementation uses PyTorch’s documented KL convention.

07 / Know what you are collecting

Full vocabulary. Defined scope.

Generated positions only
This endpoint does not return prompt logprobs, arbitrary reference-text likelihoods or teacher-forced scores for a supplied continuation. Appending text as another chat message changes the context; it is not an exact continuation-scoring API.
Up to 8 positions per full request
The explicit limit bounds very large responses. Higher values are rejected before billing. Start with one position per prompt; full JSON and SSE are supported.
Probabilities, not raw logits
The API returns natural-log probabilities before sampling filters in full mode. It does not expose hidden states, gradients or raw pre-softmax scores. Re-normalize native-precision values for training.
Pin Qwen or Bielik
Use qwen3.8-27b or bielik-11b-v3. Auto Router, the hybrid route and PLLuM do not support this option. The distribution belongs to the served model configuration, not necessarily the original full-precision weights.
Plan collection and evaluation
Normal authentication and token billing apply. Save responses locally; the guide does not train or store a dataset for you. Keep provenance and use data and model outputs under their applicable terms.
08 / Read further

Method and reference.

Full-vocabulary coverage verified through fabryka.ai for both models in JSON and SSE on 5 September 2026. This verifies API behavior, not a distillation quality benchmark.