Views
No views yet
1import * as webllm from "@mlc-ai/web-llm";
2
3const MODEL_ID = "ReaderLM-v2-q4f16_1-MLC";
4const MODEL_URL = "https://huggingface.co/YOUR_USERNAME/ReaderLM-v2-q4f16_1-MLC/resolve/main";
5
6const engine = await webllm.CreateMLCEngine(MODEL_ID, {
7 appConfig: {
8 model_list: [
9 {
10 model_id: MODEL_ID,
11 model: MODEL_URL,
12 model_lib: `${MODEL_URL}/model.wasm`,
13 },
14 ],
15 },
16});
17
18const response = await engine.chat.completions.create({
19 messages: [{ role: "user", content: "Your prompt here" }],
20 temperature: 0.3,
21});
22
23console.log(response.choices[0].message.content);model.wasm - Compiled WebGPU modelparams_shard_*.bin - Quantized model weights (30 shards)mlc-chat-config.json - Model configurationtokenizer.json, vocab.json, merges.txt - Tokenizer files1# Convert weights
2python -m mlc_llm convert_weight ./ReaderLM-v2 --quantization q4f16_1 --output ./dist
3
4# Generate config
5python -m mlc_llm gen_config ./ReaderLM-v2 --quantization q4f16_1 --conv-template chatml --context-window-size 8192 --output ./dist
6
7# Compile for WebGPU
8python -m mlc_llm compile ./dist --device webgpu --output ./dist/model.wasm