ArkTS-CodeSearch: A Open-Source ArkTS Dataset for Code Retrieval
Paper • 2602.05550 • Published • 1
How to use hreyulog/multilingual-e5-small-arkts with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("hreyulog/multilingual-e5-small-arkts")
sentences = [
"query: 获取mock数据的json名称 \n功能描述: 本示例介绍了@ohos.multimedia.media组件和@ohos.window接口以及使用触摸热区实现视频横竖屏切换及进度条热区拖动的功能\n\n推荐场景: 横竖屏视频等媒体播放场景\n\n核心组件:\n1. AVPlayer\n\n实现步骤:\n1. 初始化@ohos.multimedia.media的AVPlayer。\n2. 当AVPlayer初始化完毕进入initialized状态时,将XComponent和AVPlayer通过surfaceId绑定。\n3. 使用AVPlayer中的width和height属性判断是横屏视频还是竖屏视频,方便判断是否需要展示全屏观看按钮。\n4. 调用@ohos.window的 getLastWindow 方法获取当前应用内最上层的子窗口\n5. 利用获取到的窗口对象,调用 setWindowSystemBarEnable 方法设置窗口是否显示导航栏和状态栏。\n6. 调用窗口对象的 setPreferredOrientation 方法设置窗口旋转方向以及是否应用重力感应。\n7. 调用窗口对象的setWindowLayoutFullScreen方法实现沉浸式布局。\n8. 对进度条整个组件设置触摸热区。",
"passage:\npath: CommonAppDevelopment/feature/videoscreendirectionswitching/src/main/ets/view/VideoScreenDirectionSwitching.ets\nidentifier: VideoScreenDirectionSwitchingComponent\ncode: @Component\nexport struct VideoScreenDirectionSwitchingComponent {\n @State contentData: FlowItemContentsData = new FlowItemContentsData(); // 瀑布流内容\n @State selectedVideo: string = ''; // 选择的视频名称\n @State selectedIndex: number = 0; // 选择的视频index\n @State isLandscape: boolean = false; // 是否横屏状态\n @State isLandscapeStart: boolean = false; // 是否开始横屏动画\n @State statusHeight: number = 0; // 系统状态栏高度\n @State bottomHeight: number = 0; // 系统导航栏高度\n windowClass?: window.Window;\n\n async aboutToAppear() {\n // 进入沉浸式\n this.windowClass = await window.getLastWindow(getContext(this));\n let sysBarProps: window.SystemBarProperties = {\n statusBarContentColor: '#FFFFFF'\n };\n this.windowClass?.setWindowSystemBarProperties(sysBarProps);\n this.statusHeight = this.windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM).topRect.height;\n this.bottomHeight = this.windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR).bottomRect.height;\n this.windowClass.setWindowLayoutFullScreen(true);\n // 获取JSON中的列表数据\n const jsonObj: JsonObject = new JsonObject(JSON_URI);\n const array = await jsonObj.getFlowItemContentObj();\n this.contentData.pushDat",
"passage:\npath: core/designsystem/src/main/ets/component/Column.ets\nidentifier: \ncode: build(): void {\n ColumnBase({\n options: this.options,\n justifyContent: FlexAlign.SpaceEvenly,\n alignItems: HorizontalAlign.End,\n widthValue: this.widthValue,\n heightValue: this.heightValue,\n sizeValue: this.sizeValue,\n paddingValue: this.paddingValue,\n marginValue: this.marginValue,\n fillMaxSize: this.fillMaxSize,\n bgColor: this.bgColor,\n onTap: this.onTap,\n content: this.content\n });\n }",
"passage:\npath: code/Solutions/IM/Chat/features/chatlist/src/main/ets/utils/DataFactory.ets\nidentifier: \ncode: export async function getChatModelObjFromJSON(MockDataFileDir: string): Promise<Array<ChatModel>> {\n Logger.info(TAG, 'getChatModelObjFromJSON');\n let jsonObj: JsonObject = new JsonObject(MockDataFileDir);\n return await jsonObj.getChatModelObj(MockDataFileDir);\n}"
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is arkts model for Edge device.
This is a sentence-transformers model finetuned from intfloat/multilingual-e5-small. It maps sentences & paragraphs to a 384-dimensional dense vector space and can be used for retrieval. docstring <--> passage:\npath: ...\nidentifier: ...\ncode: ...
SentenceTransformer(
(0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'BertModel'})
(1): Pooling({'embedding_dimension': 384, 'pooling_mode': 'mean', 'include_prompt': True})
(2): Normalize({})
)
On arkts-code-docstring dataset split test
| Model | Params | MRR | NDCG@5 | Recall@1 | Recall@5 |
|---|---|---|---|---|---|
| multilingual-e5-small-arkts | 117.7M | 0.6849 | 0.7078 | 0.6030 | 0.7952 |
First install the Sentence Transformers library:
pip install -U sentence-transformers
Then you can load this model and run inference.
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("sentence_transformers_model_id")
# Run inference
sentences = [
'query: Persistent geographical location, re-enter to determine if the switch is turned on',
'passage:\npath: code/BasicFeature/Media/Camera/entry/src/main/ets/Dialog/SettingDialog.ets\nidentifier: getLocationBol\ncode: getLocationBol(bol: boolean) {\n this.settingDataObj.locationBol = bol;\n }',
'passage:\npath: custom_dialog/src/main/ets/model/modifier/TextAreaInputFilterModifier.ets\nidentifier: \ncode: export class TextAreaInputFilterModifier implements AttributeModifier<TextAreaAttribute> {\n inputFilter?: InputFilter;\n\n applyNormalAttribute(instance: TextAreaAttribute): void {\n if (this.inputFilter) {\n instance.inputFilter(this.inputFilter.value, this.inputFilter.error);\n }\n }\n}',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.4037, 0.0834],
# [0.4037, 1.0000, 0.0600],
# [0.0834, 0.0600, 1.0000]])
sentence_0 and sentence_1| sentence_0 | sentence_1 | |
|---|---|---|
| type | string | string |
| details |
|
|
| sentence_0 | sentence_1 |
|---|---|
query: 通过picker拉起图库并选择图片,并调用图片识码 |
passage: |
query: 启动对话流程 |
passage: |
query: 文本颜色接口 |
passage: |
{
"scale": 20.0,
"similarity_fct": "cos_sim",
"gather_across_devices": false,
"directions": [
"query_to_doc"
],
"partition_mode": "joint",
"hardness_mode": null,
"hardness_strength": 0.0
}
per_device_train_batch_size: 32num_train_epochs: 1per_device_eval_batch_size: 32multi_dataset_batch_sampler: round_robinper_device_train_batch_size: 32num_train_epochs: 1max_steps: -1learning_rate: 5e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0optim: adamw_torch_fusedoptim_args: Noneweight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08optim_target_modules: Nonegradient_accumulation_steps: 1average_tokens_across_devices: Truemax_grad_norm: 1label_smoothing_factor: 0.0bf16: Falsefp16: Falsebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Nonetorch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneuse_liger_kernel: Falseliger_kernel_config: Noneuse_cache: Falseneftune_noise_alpha: Nonetorch_empty_cache_steps: Noneauto_find_batch_size: Falselog_on_each_node: Truelogging_nan_inf_filter: Trueinclude_num_input_tokens_seen: nolog_level: passivelog_level_replica: warningdisable_tqdm: Falseproject: huggingfacetrackio_space_id: trackioper_device_eval_batch_size: 32prediction_loss_only: Trueeval_on_start: Falseeval_do_concat_batches: Trueeval_use_gather_object: Falseeval_accumulation_steps: Noneinclude_for_metrics: []batch_eval_metrics: Falsesave_only_model: Falsesave_on_each_node: Falseenable_jit_checkpoint: Falsepush_to_hub: Falsehub_private_repo: Nonehub_model_id: Nonehub_strategy: every_savehub_always_push: Falsehub_revision: Noneload_best_model_at_end: Falseignore_data_skip: Falserestore_callback_states_from_checkpoint: Falsefull_determinism: Falseseed: 42data_seed: Noneuse_cpu: Falseaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedataloader_drop_last: Falsedataloader_num_workers: 0dataloader_pin_memory: Truedataloader_persistent_workers: Falsedataloader_prefetch_factor: Noneremove_unused_columns: Truelabel_names: Nonetrain_sampling_strategy: randomlength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falseddp_backend: Noneddp_timeout: 1800fsdp: []fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}deepspeed: Nonedebug: []skip_memory_metrics: Truedo_predict: Falseresume_from_checkpoint: Nonewarmup_ratio: Nonelocal_rank: -1prompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: round_robinrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss |
|---|---|---|
| 0.8170 | 500 | 0.6130 |
@misc{he2026arktscodesearchopensourcearktsdataset,
title={ArkTS-CodeSearch: A Open-Source ArkTS Dataset for Code Retrieval},
author={Yulong He and Artem Ermakov and Sergey Kovalchuk and Artem Aliev and Dmitry Shalymov},
year={2026},
eprint={2602.05550},
archivePrefix={arXiv},
primaryClass={cs.SE},
url={https://arxiv.org/abs/2602.05550},
}
Base model
intfloat/multilingual-e5-small