ONNX 模型库
返回模型

说明文档

Qwen3-Embedding-4B-ONNX

这是 Qwen/Qwen3-Embedding-4B 的 ONNX 转换版本,用于在浏览器中使用 Transformers.js

模型详情

  • 模型类型: 文本嵌入
  • 基础模型: Qwen3-Embedding-4B
  • 参数量: 4B
  • 嵌入维度: 2560
  • 上下文长度: 32K
  • MTEB v2 得分: 74.60
  • 支持语言: 100+

使用方法 (Transformers.js v3)

import { pipeline } from "@huggingface/transformers";

// Create a feature extraction pipeline
const extractor = await pipeline(
  "feature-extraction",
  "dssjon/Qwen3-Embedding-4B-ONNX",
  {
    dtype: "fp32",
    device: "webgpu", // Use WebGPU for acceleration
  }
);

// Format query with instruction
const taskDescription = "Given a web search query, retrieve relevant passages that answer the query";
const query = `Instruct: ${taskDescription}\nQuery:What is the capital of China?`;

// Generate embedding
const output = await extractor(query, {
  pooling: "last_token",
  normalize: true
});

console.log(output.data); // 2560-dimensional embedding

使用方法 (Python - 原始模型)

from sentence_transformers import SentenceTransformer

model = SentenceTransformer("Qwen/Qwen3-Embedding-4B")

# For queries
query = "What is the capital of China?"
query_embedding = model.encode(query, prompt_name="query")

# For documents (no prompt needed)
document = "The capital of China is Beijing."
doc_embedding = model.encode(document)

转换详情

  • ONNX Opset: 14
  • 精度: FP32
  • 优化: 无 (ONNX Runtime 优化器尚未支持 Qwen3)
  • 文件大小: ~15.3 GB

性能

MTEB v2 基准测试得分:

任务 得分
分类 89.84
聚类 57.51
成对分类 87.01
重排序 50.76
检索 68.46
语义文本相似度 88.72
摘要 34.39
平均 74.60

许可证

Apache 2.0 (与基础模型相同)

引用

@article{qwen3embedding2025,
  title={Qwen3 Embedding},
  author={Qwen Team},
  year={2025},
  url={https://huggingface.co/Qwen/Qwen3-Embedding-4B}
}

致谢

dssjon/Qwen3-Embedding-4B-ONNX

作者 dssjon

feature-extraction transformers.js
↓ 0 ♥ 0

创建时间: 2025-10-07 20:35:54+00:00

更新时间: 2025-10-07 20:39:20+00:00

在 Hugging Face 上查看

文件 (14)

.gitattributes
README.md
added_tokens.json
chat_template.jinja
config.json
merges.txt
model.onnx ONNX
model.onnx_data
onnx/model.onnx ONNX
onnx/model.onnx_data
special_tokens_map.json
tokenizer.json
tokenizer_config.json
vocab.json