返回模型
说明文档
QED-75M Web (ONNX)
QED-75M — 语言模型(384 隐藏层,32 层,75M 参数),专为网页部署优化。
仓库: https://huggingface.co/levossadtchi/QED-75M_web
📁 文件
| 文件 | 描述 | 大小 |
|---|---|---|
model.onnx |
模型权重 (FP32) | ~365 MB |
tokenizer.json |
分词器词表 | ~3 MB |
tokenizer_config.json |
分词器配置 | <1 KB |
config.json |
模型架构 | <1 KB |
generation_config.json |
生成参数 | <1 KB |
index.html |
演示页面 | <10 KB |
💬 提示格式
模型基于聊天格式训练。为获得最佳效果,请使用:
_inp你的问题_outp
示例:
| 提示 | 预期响应 |
|---|---|
_inpWhat is 2+2?_outp |
"The answer is 2 + 2 = 4." |
_inpExplain gravity in one sentence._outp |
"Gravity is a fundamental force..." |
_inpWrite a haiku about cats._outp |
关于猫的诗歌 |
🚀 使用方法
方式 1:Transformers.js(推荐)
npm install @xenova/transformers
import { AutoTokenizer, AutoModelForCausalLM } from '@xenova/transformers';
// 加载模型
const tokenizer = await AutoTokenizer.from_pretrained('levossadtchi/QED-75M_web');
const model = await AutoModelForCausalLM.from_pretrained('levossadtchi/QED-75M_web', {
quantized: true, // 使用 int8 量化
dtype: 'q8',
device: 'webgpu', // 或 'wasm' 使用 CPU
});
// 生成
const prompt = '_inpWhat is 2+2?_outp';
const inputs = await tokenizer(prompt, { return_tensors: 'pt' });
const outputs = await model.generate({
...inputs,
max_new_tokens: 128,
temperature: 0.7,
top_k: 40,
do_sample: true,
eos_token_id: tokenizer.eos_token_id,
pad_token_id: tokenizer.pad_token_id,
});
const text = tokenizer.decode(outputs[0], { skip_special_tokens: false });
console.log(text);
方式 2:ONNX Runtime Web(底层)
npm install onnxruntime-web
import * as ort from 'onnxruntime-web';
// 加载
const session = await ort.InferenceSession.create('model.onnx');
// 推理
const inputIds = [1, 15826, 15, 638]; // token
const tensor = new ort.Tensor('int64', BigInt64Array.from(inputIds.map(BigInt)), [1, inputIds.length]);
const { logits } = await session.run({ input_ids: tensor });
// 贪婪解码
const nextToken = logits.data.reduce((maxIdx, val, idx) => val > logits.data[maxIdx] ? idx : maxIdx, 0);
方式 3:现成 HTML
在浏览器中打开 index.html 或部署到 Vercel/Netlify。
⚙️ 生成参数
| 参数 | 默认值 | 描述 |
|---|---|---|
max_new_tokens |
128 | 最大新生成 token 数 |
temperature |
0.7 | 创造性(0 = 贪婪,>1 = 混乱) |
top_k |
40 | 从 top-k token 中采样 |
top_p |
0.9 | Nucleus sampling(top_k 的替代方案) |
repetition_penalty |
1.1 | 重复惩罚 |
建议:
- 事实性任务:
temperature=0.5, top_k=30 - 创意任务:
temperature=0.8, top_k=50 - 代码任务:
temperature=0.2, top_k=20
🏗 架构
| 参数 | 值 |
|---|---|
| Vocabulary | 49,152 token |
| Hidden dim | 384 |
| Layers | 32 |
| Attention heads | 6 |
| FFN dim | 1,024 |
| Max length | 8,192 token |
| RoPE θ | 10,000 |
| RMSNorm ε | 1e-5 |
📦 量化
为减小模型大小,可使用 int8 量化:
pip install onnxruntime-tools
python -c "
from onnxruntime.quantization import quantize_dynamic, QuantType
quantize_dynamic('model.onnx', 'model_quantized.onnx', weight_type=QuantType.QUInt8)
"
大小对比:
- 原始 (FP32):~365 MB
- 量化后 (INT8):~95 MB(−74%)
🌐 浏览器支持
| 技术 | 支持 | 大小 | 速度 |
|---|---|---|---|
| WebGPU | Chrome 113+, Edge | ~100 MB | ⚡⚡⚡ 快速 |
| WASM | 所有浏览器 | ~100 MB | ⚡⚡ 中等 |
| CPU | 后备模式 | ~365 MB | ⚡ 较慢 |
🔧 本地运行
# 克隆仓库
git lfs install
git clone https://huggingface.co/levossadtchi/QED-75M_web
# 启动本地服务器
cd QED-75M_web
python -m http.server 8000
# 在浏览器中打开
open http://localhost:8000/index.html
📝 许可证
MIT
levossadtchi/QED-75M_web
作者 levossadtchi
↓ 38
♥ 0
创建时间: 2026-03-20 19:48:15+00:00
更新时间: 2026-03-21 08:18:36+00:00
在 Hugging Face 上查看文件 (8)
.gitattributes
README.md
config.json
generation_config.json
index.html
model.onnx
ONNX
tokenizer.json
tokenizer_config.json