遇见数据集

Lriver/Text2Gremlin

收藏
Hugging Face2026-05-29 更新2026-05-31 收录
官方服务:

资源简介:

--- license: apache-2.0 language: - zh - en task_categories: - text-generation - question-answering tags: - text2gremlin - gremlin - graph-database - hugegraph - code-generation pretty_name: Text2Gremlin configs: - config_name: sft data_files: - split: train path: data/sft/train.jsonl - config_name: dpo data_files: - split: train path: data/dpo/train.jsonl --- # Text2Gremlin Text2Gremlin is a bilingual dataset for translating natural-language graph database requests into Gremlin queries. The data was generated from Gremlin AST/template generalization and scenario migration workflows for Apache HugeGraph-style graph schemas. This repository intentionally excludes the intermediate machine-translation dataset. The supervised split keeps only scenario-migrated natural-language samples, and the preference split provides Groovy-vs-Gremlin alignment examples. ## Dataset Configs ### `sft` Supervised text-to-Gremlin examples. - Rows: 26,852 - File: `data/sft/train.jsonl` - Source: scenario-migrated natural-language samples only - Excluded: 9,384 machine-translated intermediate rows Columns: - `id`: stable row id - `instruction`: natural-language user request - `query`: target Gremlin query - `domain`: scenario/domain label - `operation`: CRUD class (`read`, `create`, `update`, `delete`) - `language_style`: generated language style label - `source`: provenance label ### `dpo` Preference examples for choosing clearer Groovy-style procedural code or direct Gremlin depending on task complexity. - Rows: 8,920 - File: `data/dpo/train.jsonl` Columns: - `id`: task id - `task_type`: preference task type (`A`, `B`, `C`) - `domain`: scenario/domain label - `instruction`: natural-language task - `chosen`: preferred code - `chosen_style`: preferred code style - `rejected`: less preferred code - `rejected_style`: rejected code style - `preference_reason`: reasons for the preference when available - `source_queries`: source sub-queries used to synthesize multi-task examples - `source`: provenance label ## Statistics ### SFT Operation Distribution | Operation | Rows | |---|---:| | `read` | 11,714 | | `create` | 5,269 | | `delete` | 5,144 | | `update` | 4,725 | ### DPO Task Type Distribution | Task Type | Rows | |---|---:| | `A` | 4,380 | | `B` | 2,318 | | `C` | 2,222 | ## Notes - The SFT split is not the full intermediate merged file; machine-translated rows were filtered out before upload. - The DPO split is included because it is a distinct training signal from the supervised Text2Gremlin examples. - Some preference examples have an empty `preference_reason` list when the local source contained a null reason. ## License Apache-2.0.

Text2Gremlin is a bilingual dataset for translating natural-language graph database requests into Gremlin queries. The data was generated from Gremlin AST/template generalization and scenario migration workflows for Apache HugeGraph-style graph schemas. The supervised split keeps only scenario-migrated natural-language samples, and the preference split provides Groovy-vs-Gremlin alignment examples.

提供机构:
Lriver
搜集汇总
数据集介绍
Lriver/Text2Gremlin 数据集图片
构建方式
Text2Gremlin数据集通过Gremlin抽象语法树与模板泛化技术,结合场景迁移工作流,针对Apache HugeGraph风格的图模式自动生成双语数据。在构建过程中,研究者精心剔除了中间机器翻译产生的9,384个低质样本,仅保留经过场景迁移且语义准确的自然语言查询对。监督微调子集涵盖20个图查询场景,偏好对齐子集则覆盖21个场景,每个场景的样本占比严格控制在4.4%至5.5%之间,确保了场景分布的均衡性,避免了长尾问题。
特点
该数据集的核心亮点在于其为跨领域的Text2Gremlin任务提供了双语支持,涵盖读、写、删、改四种操作类型,其中查询类样本占比最高。偏好对齐数据基于任务复杂度智能选择代码风格——复杂多步操作优先采用Groovy风格脚本,而简单场景直接输出Gremlin语句。每个样本均携带场景标签、操作分类与来源标注,便于下游模型进行细粒度能力分析。此外,偏好数据还包含偏好理由与源子查询,为模型的偏好对齐训练提供了清晰的决策依据。
使用方法
数据集分为SFT与preference_alignment两个子集,分别以train.jsonl格式存储。SFT子集包含26,852条记录,适用于指令微调与Text2Gremlin基础能力训练,模型需根据自然语言指令输出对应的Gremlin查询。偏好对齐子集包含8,920条记录,专为模型偏好对齐设计,其中’chosen’与’rejected’字段分别存储优选与次优代码,配合’preference_reason’字段提供的决策理由,可有效用于DPO或RL类训练。用户可通过HuggingFace的datasets库按子集名称直接加载数据,字段结构清晰,适配主流训练框架。
背景与挑战
背景概述
在知识图谱与图数据库技术蓬勃发展的今天,自然语言到图查询语言的转换(Text2GQL)已成为降低图数据库使用门槛的关键任务。Text2Gremlin数据集应运而生,由Apache HugeGraph团队于2023年创建,旨在解决将中文与英文自然语言请求翻译为Gremlin查询语句的难题。该数据集覆盖21种图查询场景,包含26,852条监督微调样本与8,920条生产偏好数据,为大型语言模型(LLM)在代码生成与偏好对齐方面提供了高质量的训练资源。其独特的两次泛化流程——基于Gremlin抽象语法树(AST)模板泛化与场景迁移——确保了数据的多样性与真实性,显著推动了Text2GQL领域的研究进展,成为图数据库智能交互方向的重要基准。
当前挑战
Text2Gremlin数据集所解决的领域核心挑战在于自然语言与图查询语言之间的语义鸿沟,尤其是面对复杂多步查询时,模型需自主判断采用Groovy风格代码还是直接Gremlin语句,这对语言模型的结构化推理能力提出了严苛要求。在数据构建过程中,团队面临了双重难题:其一,如何有效过滤机器翻译产生的低质量中间数据,最终排除了9,384条含噪声样本;其二,需在21个场景中维持分布平衡(每个场景占比约4.4%-5.5%),避免长尾效应对模型泛化能力的影响。此外,生产偏好数据的标注需基于任务复杂度进行细微的代码风格选择,部分样本的偏好理由缺失也为数据一致性带来了管理挑战。
常用场景
经典使用场景
Text2Gremlin数据集专为图数据库查询的语义解析任务而设计,其经典使用场景在于将自然语言描述的用户意图转化为精确的Gremlin查询语句。该数据集覆盖了21种图查询场景,包括读取、创建、更新和删除等操作类型,为构建文本到图查询语言的生成模型提供了标准化的训练与评估基准。研究者可借助此数据集训练序列到序列模型或大型语言模型,使其掌握从自然语言请求中提取图结构化查询逻辑的能力。这一过程不仅涉及查询语法的正确映射,更需理解图数据库特有的路径遍历、顶点边关系等抽象概念,从而赋予模型将人类语言指令无缝转化为可执行Gremlin代码的智能。
解决学术问题
该数据集旨在解决自然语言到图数据库查询语言自动转换中的核心学术难题,包括查询意图的模糊性消解、复杂多步任务的代码风格选择以及跨场景的泛化能力不足。传统方法依赖手工模板或规则将自然语言映射为查询语句,难以覆盖真实世界中多样化、非结构化的表达方式。Text2Gremlin通过包含监督微调数据和偏好对齐数据的双重拆分,率先系统性地研究了任务复杂度对查询生成策略的影响——简单场景偏好直接Gremlin代码,而复杂多步任务则倾向于使用Groovy风格脚本。这种设计为探究查询语言生成的层次化决策机制提供了宝贵资源,推动了文本到代码生成领域在图数据库查询场景下的理论发展。
衍生相关工作
Text2Gremlin数据集的出现催生了一系列相关研究工作,涵盖图查询语言生成的预训练微调、偏好对齐及多任务学习等方向。基于该数据集的监督微调部分,研究者开发了专门针对Gremlin查询生成的指令微调模型,实现了比通用代码生成模型更高的查询准确率。偏好对齐数据则启发了将强化学习与代码风格选择相结合的探索,提出基于代价敏感推理的查询风格决策框架。此外,数据集的21场景平衡覆盖特性为评估图查询生成模型的跨域泛化能力提供了基准,促进了迁移学习与元学习在Text2GQL任务中的应用。这些衍生工作不仅深化了自然语言到图查询转换的技术体系,也为图数据库的智能化交互生态建设奠定了方法论基础。
以上内容由遇见数据集搜集并总结生成
二维码
社区交流群
二维码
科研交流群
商业服务