Skip to content

Language models, retrieval, prompting, and language adaptation · Autoregressive and open-weight model families · LNG038 · Model

Qwen language-model family

Documents a multilingual open-weight language-model family, with the Qwen3 report describing dense and mixture-of-experts configurations and thinking/non-thinking behavior.

Explained here Component demo, not a trained model CodeSplash's own run

In CodeSplash

Documented in the Academy only. There's no Set up button.

Availability
Explained here
Code example
Component demo, not a trained model
Who ran it
CodeSplash's own run
CodeSplash's run
The reference's example ran in Python and R here, and they agree.
The reference's record
Python: The chapter's authors report running it; there is no record for this entry alone. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

Documents a multilingual open-weight language-model family, with the Qwen3 report describing dense and mixture-of-experts configurations and thinking/non-thinking behavior. Those configurations are grouped as a family, not counted by parameter size.

Question / objective

How does a particular dense or sparse Qwen checkpoint handle multilingual and reasoning tasks?

Architecture / computational structure

The family includes dense and MoE decoders with release-specific attention, routing, and post-training choices. Learned weights depend on the exact checkpoint; thinking mode, template, generation budget, and deployment precision are user/configuration controls.

Assumptions

Family branding does not ensure identical licensing, modality support, architecture, or prompting conventions.

Formula / computational definition

Lcausal=−∑tlog⁡pθ(xt∣x<t),yMoE=∑i∈S(x)gi(x)Ei(x).\mathcal L_{\mathrm{causal}}=-\sum_t\log p_\theta(x_t\mid x_{<t}),\qquad y_{\mathrm{MoE}}=\sum_{i\in\mathcal S(x)}g_i(x)E_i(x).

Base language modeling uses autoregressive cross-entropy; post-training introduces task and reasoning-related objectives. For an MoE configuration, token-conditioned expert routing changes feed-forward computation, whereas dense configurations use all feed-forward parameters.

Parameters and notation

Learned parameters: identified in the architecture subsection. Hyperparameters, design and inference choices: Exact release, dense versus MoE configuration, chat template, reasoning-mode controls, context budget, precision, and generation settings.

Fitting, fine-tuning, and adaptation

Use the released template and documented mode controls. Adapt through compatible SFT/LoRA tooling or full updates, specifying whether reasoning traces and final answers are both supervised. Validate task correctness, language coverage, token cost, and retention; do not generalize one checkpoint's results to all family members.

How to use and calibrate

Assess the exact checkpoint and mode on multilingual tasks, reasoning correctness, token cost, latency, and robustness; separate quality improvements from longer output budgets. Use development data for settings and an independent test set for the final estimate. Report uncertainty across examples or seeds when the evaluation design supports it; model scores and self-assessments are not automatically calibrated probabilities of correctness.

Example application

Compare reasoning-enabled and ordinary response modes on multilingual technical questions at equal budgets.

Interpretation / pitfalls

Watch out

Reasoning text is an output artifact and need not faithfully expose the causal computation producing an answer. The code below isolates one stated component; successful execution does not validate model quality or reproduce the cited experiment.

Python and R code examples

Full implementation route: Follow the checkpoint's supported Transformers version and chat-template documentation. R uses reticulate to run the same implementation. A toy MoE mixing example illustrates one disclosed design component without claiming to reproduce the family.

Example scope: Toy sparse expert mixing relevant to Qwen MoE configurations; not a family-wide specification.

Dependencies: Python 3 standard library; base R; shared setup above. No model downloads or external services.

Validation: Python component executed in the combined example script; R counterpart supplied but not runtime-tested here. All numbers are synthetic.

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Component demo, not a trained model — Toy sparse expert mixing relevant to Qwen MoE configurations; not a family-wide specification.

Shared setup for this chapter
import math

def softmax(xs):
    m = max(xs)
    es = [math.exp(x-m) for x in xs]
    return [e/sum(es) for e in es]

def dot(a, b):
    return sum(x*y for x, y in zip(a, b))

def matvec(matrix, vector):
    return [dot(row, vector) for row in matrix]

def meanvec(rows):
    return [sum(row[j] for row in rows)/len(rows) for j in range(len(rows[0]))]

def sigmoid(x):
    return 1/(1+math.exp(-x))

def nll(probabilities):
    return -sum(math.log(p) for p in probabilities)
selected_scores = softmax([0.7,0.2])
expert_outputs = [[0.5,0.1],[-0.2,0.8]]
y = [sum(w*h[j] for w,h in zip(selected_scores,expert_outputs)) for j in range(2)]
print(y)
R

Component demo, not a trained model — Toy sparse expert mixing relevant to Qwen MoE configurations; not a family-wide specification.

Shared setup for this chapter
softmax <- function(x) {
  shifted <- exp(x-max(x))
  shifted/sum(shifted)
}
selected_scores <- softmax(c(0.7,0.2))
expert_outputs <- rbind(c(0.5,0.1),c(-0.2,0.8))
y <- colSums(expert_outputs*selected_scores)
print(y)

Sources

From the CodeSplash reference, entry LNG038.