ONNX 模型库
返回模型

说明文档

UniXcoder ONNX 代码搜索模型

VibeAtlas 转换 - 面向开发者的 AI 上下文优化工具

这是 微软的 UniXcoder 转换为 ONNX 格式的版本,可用于 Transformers.js 在浏览器和 Node.js 环境中运行。

为什么选择 UniXcoder?

UniXcoder 能够语义化理解代码,而不仅仅是将其视为文本:

  • 在 6 种编程语言上训练(Python、Java、JavaScript、PHP、Ruby、Go)
  • 理解 AST 结构和数据流
  • 代码搜索准确率比通用嵌入模型高 20-30%

快速开始

Transformers.js(浏览器/Node.js)

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

const embedder = await pipeline(
  'feature-extraction',
  'sailesh27/unixcoder-base-onnx'
);

const code = `function authenticate(user) {
  return user.isValid && user.hasPermission;
}`;

const embedding = await embedder(code, {
  pooling: 'mean',
  normalize: true
});

console.log(embedding.dims); // [1, 768]

语义代码搜索

import { pipeline, cos_sim } from '@huggingface/transformers';

const embedder = await pipeline('feature-extraction', 'sailesh27/unixcoder-base-onnx');

// 索引你的代码
const codeSnippets = [
  'function login(user, pass) { ... }',
  'function formatDate(date) { ... }',
  'function validateEmail(email) { ... }'
];

const codeEmbeddings = await embedder(codeSnippets, { pooling: 'mean', normalize: true });

// 使用自然语言搜索
const query = 'user authentication';
const queryEmbedding = await embedder(query, { pooling: 'mean', normalize: true });

// 找出最相似的代码
const similarities = codeEmbeddings.tolist().map((emb, i) => ({
  code: codeSnippets[i],
  score: cos_sim(queryEmbedding.tolist()[0], emb)
}));

技术细节

  • 架构:基于 RoBERTa 的编码器
  • 隐藏层大小:768
  • 最大序列长度:512 个 token
  • 输出维度:768
  • ONNX Opset:14

关于 VibeAtlas

VibeAtlas 是 AI 编程的可靠性基础设施:

  • 降低 40-60% 的 AI token 成本
  • 通过语义理解提升代码搜索准确率
  • 为 AI 工作流添加治理护栏

链接

引用

@misc{unixcoder-onnx-2025,
  title={UniXcoder ONNX: Code Embeddings for JavaScript},
  author={VibeAtlas Team},
  year={2025},
  publisher={Hugging Face},
  url={https://huggingface.co/sailesh27/unixcoder-base-onnx}
}

原 UniXcoder 论文

@inproceedings{guo2022unixcoder,
  title={UniXcoder: Unified Cross-Modal Pre-training for Code Representation},
  author={Guo, Daya and Lu, Shuai and Duan, Nan and Wang, Yanlin and Zhou, Ming and Yin, Jian},
  booktitle={ACL},
  year={2022}
}

许可证

Apache 2.0(与原版 UniXcoder 相同)

sailesh27/unixcoder-base-onnx

作者 sailesh27

feature-extraction transformers.js
↓ 1 ♥ 0

创建时间: 2025-12-07 10:36:54+00:00

更新时间: 2025-12-07 10:44:54+00:00

在 Hugging Face 上查看

文件 (9)

.gitattributes
README.md
config.json
merges.txt
model.onnx ONNX
special_tokens_map.json
tokenizer.json
tokenizer_config.json
vocab.json