text-generation · bilingual chat LLM · WebGPU · ~1 GB
GLM-Edge-1.5B-Chat is the browser-runnable member of Zhipu AI's GLM family — the
same glm architecture as GLM-4, shrunk to 1.5 billion parameters for on-device use.
It's genuinely bilingual: ask in English or Chinese (中文) and it answers in kind,
or translates between them. It streams tokens on your own GPU with sampling controls, and you can
open the hood on the real next-token probability distribution. No server, no API key, nothing
uploaded.
| Model | onnx-community/glm-edge-1.5b-chat-ONNX (ONNX of THUDM/GLM-Edge-1.5B-Chat) |
|---|---|
| Task | text-generation (causal LM, chat-tuned) |
| Architecture | GLM (model_type glm → GlmForCausalLM) — the GLM-4 architecture family, 1.5B params |
| Family | Zhipu AI / Z.ai GLM. Bilingual English + Chinese. GLM-4-9B and larger have no browser-feasible ONNX (9B q4 ≈ 5 GB); GLM-Edge-1.5B is the member that runs in a tab. |
| Params / dtype | 1.5B · q4f16 on WebGPU (4-bit weights, fp16 compute) |
| Backend | WebGPU (gates on a real GPU adapter; a slow WASM q4 opt-in exists) |
| Download | ~1 GB (q4f16), cached after first load — WASM q4 is ~1.3 GB |
| License | GLM-4 model license |
| Web APIs | WebGPU, Web Workers, ES module imports |
How it differs from the other chat pages: it's a GLM (Zhipu) architecture, distinct from the Qwen (Qwen2.5 0.5B), Llama (Llama 3.2 1B) and SmolLM (SmolLM2) models here — and it's built for bilingual EN/ZH work out of one small model.
Heads up: loading transfers ~1 GB the first time (then it's cached). WebGPU with ≥2 GB of GPU memory is the practical path.
An LLM never "chooses a word" — every step it produces a probability over its entire vocabulary, and the sampler picks one. Below is the exact templated prompt the model receives (GLM's chat markup with role tokens), and — from one real forward pass over the current conversation — the actual top candidates for the very next token, with their probabilities. Prompt it in Chinese and the top candidates become Chinese tokens; raise the temperature and the tail fattens. This is the real distribution, computed on-device, not a mock-up.
Load the model and click "Show next-token distribution".
A bilingual instruct model that fits in a browser tab turns cross-language work into a client-side primitive: private, offline-capable, and free to run. GLM-Edge is Zhipu's answer to on-device GLM — the same family that powers GLM-4, sized down to reach real hardware. No inference bill, no data leaving the device, no per-language service.
Ask a question in English or Chinese, watch the answer stream — the core chat loop.
Bilingual structured extraction: turn EN/ZH free text into schema-shaped JSON.
A live bilingual translator & language tutor that explains as it translates.
Cross-lingual RAG: multilingual E5 retrieves from an EN+ZH corpus → GLM answers grounded in it.
GLM-Edge uses the standard text-generation pipeline. Pass a messages array (the
pipeline applies GLM's chat template for you), a TextStreamer for token-by-token
output, and your sampling settings:
import { pipeline, TextStreamer } from "@huggingface/transformers";
const generator = await pipeline(
"text-generation",
"onnx-community/glm-edge-1.5b-chat-ONNX",
{ dtype: "q4f16", device: "webgpu" }, // WebGPU path (~1 GB); WASM q4 is a slow opt-in
);
const messages = [
{ role: "system", content: "You are a helpful bilingual assistant." },
{ role: "user", content: "用一句话解释什么是 WebGPU。" }, // ask in Chinese…
];
const streamer = new TextStreamer(generator.tokenizer,
{ skip_prompt: true, skip_special_tokens: true, callback_function: (t) => append(t) });
await generator(messages, {
max_new_tokens: 256, do_sample: true, temperature: 0.7, top_p: 0.9, streamer,
}); // …and it answers in Chinese
The "see inside" panel runs one raw forward pass —
generator.model(generator.tokenizer(prompt)) — reads the last position's
logits, softmaxes them, and shows the real top-k. Everything runs in a Web Worker and
gates on a real WebGPU adapter first; with none, it shows a labelled needs-WebGPU state (plus an
opt-in WASM path) instead of faking tokens.