每天早上一封邮件,把昨天的 AI 梳理好订阅邮件

METAL LAB

Natural Language Code Retrieval for 1C:Enterprise: An Open Benchmark and Efficient Bi-Encoder

arXiv:2608.199572026-08-21

首个用俄语提问就能搜索1C企业软件代码的公开基准和专用AI模型问世

1C:Enterprise是俄语国家广泛使用的企业软件平台,但此前几乎没有公开数据集或专用模型支持用自然语言搜索其代码。研究团队构建了包含3413个真实问答对的基准数据集,并生成超过78万条合成训练数据,在此基础上训练出专用检索模型。最终模型在检索准确率上明显超过通用多语言嵌入模型。

他们做了什么

  1. 团队从论坛和FastCode网站收集了3413个俄语问题与1C/BSL代码配对,清除个人信息后发布为公开基准数据集1C-Ebench
  2. 利用公开GitHub上78万余份1C代码文件,让谷歌的gemma-4-26B-A4B-it语言模型自动生成俄语查询,构建出784057条合成训练三元组,并据此微调deepvk/USER2-base模型
  3. 采用名为Matryoshka Representation Learning的技术,让嵌入向量(将文本转化为的数字向量)可以只截取前面一部分使用而几乎不损失效果,从而将存储空间和相似度计算量削减为原来的三分之一
  4. 团队审核了训练数据与基准测试之间的重复情况,发现去掉所有被标记重复的样本后性能并未下降,说明结果并非源于数据泄漏
  5. 最终模型在检索质量指标nDCG@10上取得0.5992的均衡平均分,超过未经微调的基础架构(0.4932)和谷歌的embeddinggemma-300m(0.5404)
Figure 1: Construction of the public PruhaNLP/1C-Ebench benchmark and the dense-retrieval evaluation pipeline implemented in PruhaNLP/1C-RB.
Figure 1: Construction of the public PruhaNLP/1C-Ebench benchmark and the dense-retrieval evaluation pipeline implemented in PruhaNLP/1C-RB.
Table 1: Public resource stack.
ComponentContentScale
PruhaNLP/1C-EbenchTest pairs: question → code, subsets forum/fastcode3,413 pairs
PruhaNLP/1C-RBEvaluation harness: dense, BM25, metricsCLI/Python
PruhaNLP/1C-Code-TrainTriplets (q,d+,d−) with PII scrubbing784,057 triplets
PruhaNLP/USER2-1C-codeDomain-adapted reference bi-encoder768d, MRL
Figure 2: Construction of PruhaNLP/1C-Code-Train: from filtered public 1C code to synthetic queries, hard-negative triplets, PII scrubbing, and fine-tuning of PruhaNLP/USER2-1C-code.
Figure 2: Construction of PruhaNLP/1C-Code-Train: from filtered public 1C code to synthetic queries, hard-negative triplets, PII scrubbing, and fine-tuning of PruhaNLP/USER2-1C-code.
Table 2: PruhaNLP/1C-Ebench subsets.
SubsetQueriesShareSourceCharacterization
forum2,88384.5%Forum discussionsLong questions, context, errors, inline code
fastcode53015.5%Snippet catalogShort queries, long ready-to-use snippets
Total3,413100%Closed-set, single-gold qrels
Figure 3: nDCG@10 leaderboard on PruhaNLP/1C-Ebench (balanced-subset macro).
Figure 3: nDCG@10 leaderboard on PruhaNLP/1C-Ebench (balanced-subset macro).
Table 3: Train–benchmark overlap audit.
Metricforumfastcodeall
Exact match: code0.10%0.00%0.09%
Exact match: question0.03%8.68%1.38%
Exact match: pair0.00%0.00%0.00%
13-gram overlap: code6.24%16.23%7.79%
13-gram overlap: question0.03%8.68%1.38%
Input-only0.03%6.60%1.05%
Label-only6.24%14.15%7.47%
Input-and-label0.00%2.08%0.32%
Any 13-gram dirty flag6.28%22.83%8.85%
Figure 4: Matryoshka truncation: balanced-subset macro nDCG@10 by embedding dimension.
Figure 4: Matryoshka truncation: balanced-subset macro nDCG@10 by embedding dimension.
Table 4: PruhaNLP/USER2-1C-code configuration.
ParameterValue
Base modeldeepvk/USER2-base
ArchitectureModernBERT/RuModernBERT sentence-transformers encoder
Embedding dimension768
Maximum sequence length8,192
PoolingMean pooling
SimilarityCosine over L2-normalized embeddings
MRL dimensions768, 512, 384, 256, 128, 64, 32
Table 5: LLM-as-a-judge scores for 300 synthetic query–code pairs.
CriterionMeanMedianShare ≥4
Relevance4.33582.0%
Naturalness4.17576.3%
Clarity4.37582.0%
Table 6: Training hyperparameters.
ParameterValue
Training samples784,057 triplets
Batch size / MNRL mini-batch256 / 32
Epochs / steps3 / 9,189
Learning rate2×10−5
LR schedule5% cosine warmup + decay
Max sequence length / precision8,192 / FP16
Seed / hardware / runtime42 / A100 / ≈7.5 h
Table 7: Dense baselines and prompts. Empty means no prompt prefix.
ModelQuery promptDocument prompt
PruhaNLP/USER2-1C-codesearch_querysearch_document
deepvk/USER2-basesearch_querysearch_document
google/embeddinggemma-300mquerydocument
deepvk/USER-bge-m3emptyempty
ibm-granite/granite-embedding-311m-multilingual-r2querydocument
microsoft/harrier-oss-v1-270mweb_search_queryempty
intfloat/multilingual-e5-basequery:passage:
ai-forever/sbert_large_nlu_ruemptyempty
Table 8: nDCG@10 leaderboard on PruhaNLP/1C-Ebench.
RankModelforumfastcodemacromicro
1PruhaNLP/USER2-1C-code0.46170.73660.59920.5044
2google/embeddinggemma-300m0.37200.70800.54040.4242
3deepvk/USER2-base0.36700.61900.49320.4061
4deepvk/USER-bge-m30.34300.63900.49100.3890
5ibm-granite/granite-embedding-311m-multilingual-r20.31900.65100.48460.3706
6microsoft/harrier-oss-v1-270m0.32300.63600.47960.3716
7intfloat/multilingual-e5-base0.30700.55100.42900.3449
8ai-forever/sbert_large_nlu_ru0.09400.07900.08620.0917
BM25Okapi0.28650.33340.30990.2938
RRF(BM25 + PruhaNLP/USER2-1C-code)0.40000.46000.43000.4093
RRF(BM25 + deepvk/USER2-base)0.36200.41950.39080.3709
Table 9: Full @10 metrics for the reference dense model and BM25.
SystemSubsetnDCG@10Recall@10MRR@10
PruhaNLP/USER2-1C-codeforum0.46170.60080.4178
PruhaNLP/USER2-1C-codefastcode0.73660.92080.6774
BM25Okapiforum0.28650.34790.2670
BM25Okapifastcode0.33340.41890.3067
Table 10: Paired-bootstrap nDCG@10 comparisons.
ComparisonΔ95% CI / P
Macro: Ours vs. USER2-base+0.106[0.087, 0.125], P<0.001
Macro: Ours vs. EmbeddingGemma+0.0588[0.042, 0.075], P<0.001
RRF vs. dense (Ours), forum−0.062[−0.075,−0.049], P<0.05
RRF vs. dense (Ours), fastcode−0.277[−0.319,−0.234], P<0.05
RRF vs. dense (Base), forum−0.005[−0.016, 0.006], n.s.
RRF vs. dense (Base), fastcode−0.200[−0.237,−0.164], P<0.05
Table 11: Qualitative wins and failures (original Russian query/code). Gold rank: 1 = best; >10 = outside top-10.
Type / ranksQuery, gold, interpretation
Win (forum) Ours 1; others >10Q: Как обойти ограничения ФО на реквизит в динамическом списке, не трогая константу ФО? Gold: ОтключенныеПоля = Новый Массив; … FO×dynamic-list pattern; little lexical overlap with gold.
Win (fastcode) Ours 1; others >10Q: Описание строки в таблице значений Gold: ст90 = новый ОписаниеТипов("строка",,Новый КвалификаторыСтроки(90)); Colloquial «описание строки» → type API; lexical baselines miss it.
Fail (fastcode) Ours >10; base 1Q: Произношение текста голосом Gold: Voice = Новый COMObject("SAPI.SpVoice"); Voice.Speak("Привет!"); Rare COM API; general models recover Speak/SAPI.
Fail (fastcode) Ours 32; base 1Q: Сжатие длинной Строки Gold: СжатиеДанных = Новый СжатиеДанных(9); …Base64. Short generic title; surface «сжатие»+«строка» wins.
Table 12: MRL truncation on PruhaNLP/1C-Ebench.
Dimension mmacro nDCG@10RetentionRelative index size
7680.599100.0%1.00×
5120.600100.0%0.67×
3840.600100.0%0.50×
2560.59899.9%0.33×
1280.58497.5%0.17×
640.56093.5%0.08×
320.50383.9%0.04×

为什么重要

混合了俄语语法与行业专用术语的1C代码此前连衡量搜索质量的公开标准都没有,这限制了相关工具的开发。该基准、模型与训练数据均已公开发布,任何研究非英语或特定领域代码搜索的人都可以直接使用。

本文术语

  • 双编码器(bi-encoder) · 分别将查询和文档独立编码成向量、再比较相似度的检索模型结构
  • nDCG@10 · 衡量搜索结果前10项中正确答案排名高低的检索质量指标
  • Matryoshka Representation Learning(MRL) · 一种让嵌入向量可以只截取前面部分而基本不损失效果的训练方法
  • BM25 · 基于关键词匹配程度的经典检索算法
  • 个人信息脱敏(PII scrubbing) · 自动识别并遮蔽邮箱、电话等个人身份信息的处理过程

论文原文摘要(英文)

Natural language code retrieval is a rapidly evolving task in computer science. However, the 1C:Enterprise ecosystem combines Russian syntax with highly domain-specific terminology, for which open datasets and specialized models have been virtually non-existent. We present a comprehensive pipeline for 1C code retrieval: an open benchmark of 3,413 real-world, PII-scrubbed query-code pairs, a reproducible evaluation harness, and a specialized bi-encoder. To overcome scarce labeled data, we fine-tune on 784,057 synthetic triplets generated by google/gemma-4-26B-A4B-it from public code repositories, using Matryoshka Representation Learning (MRL) and a privacy-aware tokenizer. Because the benchmark subsets differ in size, we report balanced-subset macro, query-weighted micro, and forum-only results. Our model reaches 0.5992 balanced macro nDCG@10, 0.5044 micro, and 0.4617 on forum, versus 0.4932 macro for the baseline architecture and 0.5404 for google/embeddinggemma-300m. Removing every benchmark example flagged by the conservative exact/13-gram overlap audit leaves 0.6011 balanced macro (0.5010 micro), indicating that detected train-benchmark overlap does not explain the headline result. MRL truncation to 256 dimensions preserves 99.9% of retrieval quality while reducing dense-index storage and exact similarity arithmetic by a factor of three.

作者 · Konstantin Chesnokov, Chingiz Mingazov

在 arXiv 阅读

最新论文

全部论文 →

METAL LAB 最新报道

图片来源: Konstantin Chesnokov et al., arXiv:2608.19957, arxiv-nonexclusive