forked from apache/hugegraph-ai
-
Notifications
You must be signed in to change notification settings - Fork 5
Text2Gremlin Data Generation and Model Fine-Tuning System (Vertical Scenarios and General Scenarios) #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
LRriver
wants to merge
96
commits into
hugegraph:main
Choose a base branch
from
LRriver:text2gremlin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Text2Gremlin Data Generation and Model Fine-Tuning System (Vertical Scenarios and General Scenarios) #52
Changes from 16 commits
Commits
Show all changes
96 commits
Select commit
Hold shift + click to select a range
52f2e01
feat: add configuration management module with dictionary paths and gโฆ
LRriver fadaaf7
feat: add Gremlin parsing base classes with Step, Traversal core dataโฆ
LRriver b775d29
feat: add Gremlin expression processing module with predicates and coโฆ
LRriver f0588a1
feat: add graph database schema management with vertex/edge labels anโฆ
LRriver 5f3b039
feat: add Gremlin base component library with synonym replacement andโฆ
LRriver 822272f
feat: add ANTLR syntax tree visitor with Gremlin query to Recipe parsโฆ
LRriver 441b32c
feat: add recursive backtracking traversal generator for diverse querโฆ
LRriver 2de2096
feat: add main corpus generator with batch processing, global dedupliโฆ
LRriver c92f09a
config: add global configuration file with generation parameters and โฆ
LRriver 25ca990
data: add cypher2gremlin dataset with 3514 real query templates
LRriver 25a2876
docs: add project README with quick start guide and usage instructions
LRriver 541aa20
feat: add ANTLR-generated Gremlin grammar package with lexer, parser โฆ
LRriver eb7eb01
data: add schema and graph data
LRriver f0579e8
feat: add template directory with schema dictionary and synonym files
LRriver 9c13457
test: add gremlin statement generalization generation test module
LRriver b14ffb3
test: add generator unit tests for corpus generation validation
LRriver 7cd8427
Add graph2gremlin.py: Initial template-based Gremlin data generation โฆ
LRriver 4da021c
Add gremlin_checker.py: Syntax checking using Antlr4
LRriver bc10fe2
Add llm_handler.py: LLM interaction model for query generalization anโฆ
LRriver 6ea48d5
Add qa_generalize.py: Seed data generalization using gremlin_checker โฆ
LRriver 78f8c2a
Add instruct_convert.py: Instruction format conversion and train/testโฆ
LRriver b7f3f4a
Add da_data: Schema and graph data
LRriver 332b879
Add data/seed_data: Seed data directory
LRriver 8a94bad
Add data/vertical_training_sets: Vertical domain scenario generalizedโฆ
LRriver 676d28c
Add books on Gremlin syntax knowledge to process data.
LRriver 90f346f
Add a dataset of Gremlin QA pairs synthesized based on LLM.
LRriver 4120356
Add README.md
LRriver 67b523a
Compatible with OpenAI format
LRriver bccc147
Increase Gremlin syntax vocabulary that supports generalization, and โฆ
LRriver 44592b4
modify README.md
LRriver a1d614c
Add Apache-2.0 license, fix review comments
LRriver 471e141
Modify the .licenserc.yaml file to ignore license checks for .interp,โฆ
LRriver c1a7834
feat(text2gremlin): add generalize_llm.py to translate Gremlin querieโฆ
LRriver 2788dcf
chore(text2gremlin): replace config.json with config_example.json andโฆ
LRriver cbe7abb
chore(text2gremlin): stop tracking config.json
LRriver 28aa83c
fix: translate nested traversals in sideEffect/where/not/choose/unionโฆ
LRriver 9eafaa2
feat: add CRUD templates for better write operation coverage
LRriver dade70c
feat: add syntax distribution analysis script and regenerate corpus
LRriver 21c1bb2
chore: remove outdated corpus file
LRriver fceae69
Merge branch 'main' into text2gremlin
imbajin a1df93e
feat: add multi-domain schema reference data for scenario migration
LRriver faff1d9
chore: add timeout field to LLM config example
LRriver 77dd85d
refactor: move generalize_llm into llm_augment package and remove GPTโฆ
LRriver 696b3bb
feat: add scenario migration script with multi-domain CRUD generation
LRriver 6bac37d
feat: add dataset merge script with CRUD distribution stats
LRriver 897dcfb
feat: add DPO preference data generation with three task types
LRriver 8ba59be
feat: add unified LLM pipeline entry point with stage control
LRriver d7c261f
data: add LLM multi-style translated corpus output
LRriver f85c6e4
data: add extracted text2gremlin pairs for migration input
LRriver 8ac9671
data: add scenario-migrated corpus across 20 domains
LRriver 13764f9
data: add merged text2gremlin dataset with CRUD stats
LRriver ae38958
data: add DPO preference training data (Groovy vs Gremlin)
LRriver 0ebdb15
data: add Gremlin syntax distribution analysis report
LRriver a6f7740
docs: update README with LLM augmentation pipeline and project structure
LRriver 180719e
fix: slim down requirements.txt to direct dependencies only, removingโฆ
LRriver 1c967f3
style: apply ruff format to all text2gremlin Python files
LRriver eb3f51c
data:Unified Diverse Translation Tone Variable Names
LRriver 7e28c00
feat(dpo): add multi-domain DPO generation with Groovy syntax skip foโฆ
LRriver d6bcfaf
docs: update README with final DPO data stats and add English version
LRriver 2e10379
data(dpo): add merged preference data with 8920 samples across 21 domโฆ
LRriver d9da0b8
chore: remove outdated DPO data file
LRriver 8019f8a
docs:modify README
LRriver 1ff125a
Merge branch 'apache:main' into text2gremlin
LRriver b534331
Fix text2gremlin ruff checks
LRriver 5b2bf1f
Improve scenario migration operation modes
LRriver 118aaa4
Address text2gremlin review feedback
LRriver 0887abd
Address remaining text2gremlin review issues
LRriver 519ef99
Clean up text2gremlin dictionaries
LRriver e9bb59c
Document Text2Gremlin Hugging Face dataset
LRriver 6bbf946
Address text2gremlin CodeQL and review feedback
LRriver 95b5adb
Document text2gremlin pipeline subprocess output
LRriver ccb0b97
Use mtime for text2gremlin latest file lookup
LRriver ae16a5c
Merge branch 'main' into text2gremlin
imbajin b4abe6d
fix(text2gremlin): preserve schema parameter counts
LRriver da15880
feat(text2gremlin): add shared gremlin formatters
LRriver 06f21ff
fix(text2gremlin): normalize nested traversal formatting
LRriver 8f70d8e
feat(text2gremlin): model generated sample metadata
LRriver dad6814
feat(text2gremlin): select generated samples by kind and depth
LRriver b539bc0
fix(text2gremlin): preserve metadata and skip failed translations
LRriver 479710f
fix(text2gremlin): retry transient migration llm errors
LRriver 9ea3c32
fix(text2gremlin): route stage-specific pipeline args
LRriver 4850e5a
test(text2gremlin): cover generation syntax quality
LRriver 29652d5
docs(text2gremlin): document sample metadata and antlr policy
LRriver e5406d5
fix(text2gremlin): preserve nested fallback step parameters
LRriver 7bcc64c
fix(text2gremlin): preserve nested has step parameters
LRriver 763e3e9
fix(text2gremlin): preserve predicate filter and choose samples
LRriver a183eba
fix(text2gremlin): preserve choose function tokens
LRriver ee21a93
fix(text2gremlin): preserve numeric step arity
LRriver 3910a34
fix(text2gremlin): generate valid numeric fallback parameters
LRriver a7ecbea
fix(text2gremlin): preserve sample literal parameter
LRriver 8bcb369
fix(text2gremlin): mark terminal none steps complete
LRriver ab15620
fix(text2gremlin): preserve literal semantics
LRriver ed3d433
fix(text2gremlin): cover literal formatter bypasses
LRriver 9faa1ca
fix(text2gremlin): preserve edge object ids
LRriver c6c7556
fix(text2gremlin): keep object ids typed
LRriver aea50d7
Merge branch 'main' into text2gremlin
imbajin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,302 @@ | ||
| # Gremlin่ฏญๆๅบ็ๆ็ณป็ป (base_v2) | ||
|
|
||
| ## ๐ ้กน็ฎ่ๆฏ | ||
|
|
||
| ๆฌ้กน็ฎๆฏไธไธชๅบไบANTLR็Gremlinๆฅ่ฏข่ฏญๆๅบ็ๆ็ณป็ป๏ผไธไธบText-to-Gremlinไปปๅกๆไพ้ซ่ดจ้็่ฎญ็ปๆฐๆฎใ็ณป็ป่ฝๅคไปๅฐ้็Gremlinๆฅ่ฏขๆจกๆฟๅบๅ๏ผ้่ฟๆบ่ฝๆณๅๅ้ๆบๅขๅผบๆๆฏ๏ผ็ๆๅคง้่ฏญๆณๆญฃ็กฎใ่ฏญไนไธฐๅฏ็Gremlinๆฅ่ฏขๅๅ ถๅฏนๅบ็ไธญๆ่ช็ถ่ฏญ่จๆ่ฟฐใ | ||
|
|
||
| ### ๐ฏ ๆ ธๅฟไปทๅผ | ||
|
|
||
| - **ๆฐๆฎ็จ็ผบ้ฎ้ข่งฃๅณ**: ่งฃๅณText-to-Gremlinไปปๅกไธญ่ฎญ็ปๆฐๆฎไธ่ถณ็้ฎ้ข | ||
| - **้ซ่ดจ้่ฏญๆ็ๆ**: ็ๆ่ฏญๆณๆญฃ็กฎใ่ฏญไนๅ็กฎ็ๆฅ่ฏข-ๆ่ฟฐๅฏน | ||
| - **ๆบ่ฝๆณๅ่ฝๅ**: ไปๅฐ้ๆจกๆฟ็ๆๅคง้ๅคๆ ทๅ็ๆฅ่ฏขๅไฝ | ||
| - **ไธญๆๆฌๅๅ**: ๆไพๅ็กฎ็ไธญๆ่ช็ถ่ฏญ่จๆ่ฟฐ | ||
|
|
||
| ## ๐ง ๆ ธๅฟๅ็ | ||
|
|
||
| ### 1. Gremlinๆณๅๅ็ | ||
|
|
||
| ็ณป็ป้็จ**ๅบไบSchema็ๆบ่ฝๆณๅ**็ญ็ฅ๏ผ | ||
|
|
||
| ``` | ||
| ๆจกๆฟๆฅ่ฏข โ ANTLR่งฃๆ โ ็ปๆๅRecipe โ Schemaๅผๅฏผๆณๅ โ ๅคๆ ทๅๆฅ่ฏข | ||
| ``` | ||
|
|
||
| **ๆณๅ็ปดๅบฆ๏ผ** | ||
| - **ๅฎไฝๆณๅ**: `person` โ `movie`, `user`, `genre`็ญ | ||
| - **ๅฑๆงๆณๅ**: `name` โ `title`, `born`, `duration`็ญ | ||
| - **ๅ ณ็ณปๆณๅ**: `acted_in` โ `directed`, `produce`, `rate`็ญ | ||
| - **ๆฐๆฎๆณๅ**: ไปCSVๆไปถไธญ่ทๅ็ๅฎๆฐๆฎๅผ่ฟ่กๆฟๆข | ||
|
|
||
| ### 2. ็ฟป่ฏๅ็ | ||
|
|
||
| ้็จ**ๅคๅฑๆฌก็ฟป่ฏๆบๅถ**๏ผ | ||
|
|
||
| ``` | ||
| ่ฑๆๆฏ่ฏญ โ Schemaๅญๅ ธๆฅ่ฏข โ ไธญๆๆฏ่ฏญ โ ๆจกๆฟๆ ผๅผๅ โ ่ช็ถ่ฏญ่จๆ่ฟฐ | ||
| ``` | ||
|
|
||
| **็ฟป่ฏๅฑๆฌก๏ผ** | ||
| - **Schemaๆฏ่ฏญ็ฟป่ฏ**: `movie`โ`็ตๅฝฑ`, `title`โ`ๆ ้ข` | ||
| - **ๆไฝๆญฅ้ชค็ฟป่ฏ**: `.out()`โ`ๆฒฟ็...็ๅบ่พน`, `.has()`โ`ๅ ถ...ๅฑๆงไธบ` | ||
| - **ไธไธๆๆ็ฅ**: ๆ นๆฎๆฅ่ฏขไธไธๆ้ๆฉๅ้็็ฟป่ฏ | ||
|
|
||
| ### 3. ้ๆบๅขๅผบๅ็ | ||
|
|
||
| ๅบไบ**ๆฅ่ฏข็ถๆๆ็ฅ็้ๆบๅขๅผบ**๏ผ | ||
|
|
||
| ``` | ||
| ๆฅ่ฏข็ถๆๅคๆญ โ ๅขๅผบ็ฑปๅ้ๆฉ โ ๆฆ็่งฆๅ โ ่ฏญไนไฟๆๅขๅผบ | ||
| ``` | ||
|
|
||
| **ๅขๅผบ็ญ็ฅ๏ผ** | ||
| - **ๅ ็ด ๆตๅขๅผบ**: `limit()`, `sample()`, `range()`, `dedup()`, `order()` | ||
| - **ๅผๆตๅขๅผบ**: ้ๅฏน`.values()`ๅ็ๆฐๆฎๆต่ฟ่กไผๅๅขๅผบ | ||
| - **ๆบ่ฝ้ฟๅ **: ่ชๅจ่ฏๅซ็ปๆญขๆญฅ้ชค๏ผ้ฟๅ ๆ ๆๅขๅผบ | ||
|
|
||
| ## ๐ ้กน็ฎ็ปๆ | ||
|
|
||
| ``` | ||
| base/ | ||
| โโโ README.md # ้กน็ฎ่ฏดๆๆๆกฃ | ||
| โโโ generator.py # ๐ ไธปๅ ฅๅฃ่ๆฌ | ||
| โโโ Config.py # ้ ็ฝฎ็ฎก็ๆจกๅ | ||
| โโโ Schema.py # ๐ Schemaๅๆฐๆฎ็ฎก็ | ||
| โโโ GremlinBase.py # ๐ ็ฟป่ฏๅผๆ | ||
| โโโ GremlinParse.py # ๐ ๆฐๆฎ็ปๆๅฎไน | ||
| โโโ TraversalGenerator.py # โก ๆ ธๅฟ็ๆๅผๆ | ||
| โโโ GremlinTransVisitor.py # ๐ AST่ฎฟ้ฎๅจ | ||
| โโโ template/ # ๐ ็ฟป่ฏๅญๅ ธ | ||
| โ โโโ schema_dict.txt # Schemaๆฏ่ฏญ็ฟป่ฏ | ||
| โ โโโ syn_dict.txt # ๅไน่ฏๅญๅ ธ | ||
| โโโ gremlin/ # ๐ง ANTLR็ๆ็่งฃๆๅจ | ||
| โโโ GremlinLexer.py | ||
| โโโ GremlinParser.py | ||
| โโโ ... | ||
| ``` | ||
| ``` | ||
| AST_Text2Gremlin/ # ้กน็ฎๆ น็ฎๅฝ | ||
| โโโ base/ # ๆ ธๅฟ็ณป็ป็ฎๅฝ | ||
| โ โโโ generator.py # ไธป็ๆๅจๅ ฅๅฃ | ||
| โ โโโ GremlinTransVisitor.py # ANTLR่ฏญๆณๆ ่ฎฟ้ฎๅจ | ||
| โ โโโ TraversalGenerator.py # ้ๅฝๅๆบฏ็ๆๅจ | ||
| โ โโโ Schema.py # ๅพๆฐๆฎๅบSchema็ฎก็ | ||
| โ โโโ GremlinBase.py # ๅบ็ก็ปไปถๅบ | ||
| โ โโโ Config.py # ้ ็ฝฎ็ฎก็ | ||
| โ โโโ cypher2gremlin_dataset.csv # 3514ๆก็ๅฎๆฅ่ฏขๆฐๆฎ้ | ||
| โ โโโ test/ # ๆต่ฏๅฅไปถ | ||
| โโโ config.json # ๅ จๅฑ้ ็ฝฎๆไปถ | ||
| โโโ db_data/ # Schemaๅๆฐๆฎๆไปถ | ||
| โโโ README.md # ่ฏฆ็ปๆๆฏๆๆกฃ | ||
|
|
||
| ่ฟๆ ทๅฐฑๆๆๆๆไปถ้ฝๅ ๅซๅจ AST_Text2Gremlin ้กน็ฎ็ฎๅฝไธไบใ | ||
| ``` | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| ## ๐งฉ ๆ ธๅฟๆจกๅ่ฏฆ่งฃ | ||
|
|
||
| ### ๐ generator.py - ไธปๅ ฅๅฃ่ๆฌ | ||
| **ไฝ็จ**: ็ณป็ป็ไธป่ฆๅ ฅๅฃ็น๏ผๅ่ฐๆดไธช็ๆๆต็จ | ||
| **ๆ ธๅฟๅ่ฝ**: | ||
| - ๆจกๆฟๆนๅค็ๅๅ จๅฑๅป้ | ||
| - ่ฏญๆณๆฃๆฅๅ่ดจ้ไฟ่ฏ | ||
| - ็ป่ฎกๅๆๅ็ปๆๅฑ็คบ | ||
| - ๆฏๆๅฝๆฐๅ่ฐ็จๆฅๅฃ | ||
|
|
||
| **ไฝฟ็จๆนๅผ**: | ||
| ```python | ||
| # ็ดๆฅ่ฟ่ก | ||
| python generator.py | ||
|
|
||
| # ๅฝๆฐ่ฐ็จ | ||
| from generator import generate_corpus_from_templates | ||
| result = generate_corpus_from_templates(templates) | ||
| ``` | ||
|
|
||
| ### ๐ Schema.py - Schemaๅๆฐๆฎ็ฎก็ | ||
| **ไฝ็จ**: ็ฎก็ๅพๆฐๆฎๅบ็Schemaไฟกๆฏๅๅฎไพๆฐๆฎ | ||
| **ๆ ธๅฟๅ่ฝ**: | ||
| - ๅ ่ฝฝๅ่งฃๆJSONๆ ผๅผ็Schemaๅฎไน | ||
| - ไปCSVๆไปถไธญ่ฏปๅ็ๅฎๆฐๆฎๅฎไพ | ||
| - ๆไพSchemaๆฅ่ฏขๆฅๅฃ๏ผๆ ็ญพใๅฑๆงใๅ ณ็ณป็ญ๏ผ | ||
| - ๆฏๆๅคๅฎไพๆฐๆฎ่ทๅ๏ผๅขๅ ๆณๅๅคๆ ทๆง | ||
|
|
||
| **ๅ ณ้ฎๆนๆณ**: | ||
| ```python | ||
| schema.get_vertex_labels() # ่ทๅๆๆ้กถ็นๆ ็ญพ | ||
| schema.get_properties_with_type() # ่ทๅๅฑๆงๅ็ฑปๅไฟกๆฏ | ||
| schema.get_instances() # ่ทๅๅคไธชๆฐๆฎๅฎไพ | ||
| schema.get_valid_steps() # ่ทๅๆๆ็้ๅๆญฅ้ชค | ||
| ``` | ||
|
|
||
| ### โก TraversalGenerator.py - ๆ ธๅฟ็ๆๅผๆ | ||
| **ไฝ็จ**: ็ณป็ป็ๆ ธๅฟ๏ผ่ด่ดฃไปRecipe็ๆๅคง้ๆฅ่ฏขๅไฝ | ||
| **ๆ ธๅฟๅ่ฝ**: | ||
| - ้ๅฝๆทฑๅบฆไผๅ ๆ็ดข็ๆๆๆๅฏ่ฝ็ๆฅ่ฏข่ทฏๅพ | ||
| - ๅบไบSchema็ๆบ่ฝๆณๅ๏ผๅฎไฝใๅฑๆงใๅ ณ็ณปใๆฐๆฎ๏ผ | ||
| - ้ๆบๅขๅผบๅ่ฝ๏ผ20%ๆซ็ซฏ + 10%ไธญ้ดๆฆ็่งฆๅ๏ผ | ||
| - ไธญ้ด็ปๆไฟๅญ๏ผ็ๆไธๅๅคๆๅบฆ็ๆฅ่ฏข | ||
|
|
||
| **็ๆ็ญ็ฅ**: | ||
| ```python | ||
| # ๆณๅ็ปดๅบฆ | ||
| - ๆ ็ญพๆณๅ: person โ movie, user, genre | ||
| - ๅฑๆงๆณๅ: name โ title, born, duration | ||
| - ๅ ณ็ณปๆณๅ: acted_in โ directed, produce | ||
| - ๆฐๆฎๆณๅ: ็ๅฎCSVๆฐๆฎๆฟๆข | ||
|
|
||
| # ้ๆบๅขๅผบ | ||
| - ๅ ็ด ๆต: limit(), sample(), range(), dedup(), order() | ||
| - ๅผๆต: ้ๅฏนvalues()ไผๅ็ๅขๅผบ | ||
| - ๆบ่ฝๅคๆญ: ้ฟๅ ๅจ็ปๆญขๆญฅ้ชคๅๅขๅผบ | ||
| ``` | ||
|
|
||
| ### ๐ GremlinTransVisitor.py - AST่ฎฟ้ฎๅจ | ||
| **ไฝ็จ**: ๅฐANTLR่งฃๆ็AST่ฝฌๆขไธบ็ปๆๅ็Recipeๅฏน่ฑก | ||
| **ๆ ธๅฟๅ่ฝ**: | ||
| - ๅฎ็ฐANTLR Visitorๆจกๅผ | ||
| - ๅค็ๅ็งGremlin่ฏญๆณ็ปๆ | ||
| - ๆๅๆฅ่ฏข็ๆ ธๅฟๆญฅ้ชคๅๅๆฐ | ||
| - ็ๆๅฏ็จไบๆณๅ็Recipe | ||
|
|
||
| **ๆฏๆ็่ฏญๆณ**: | ||
| - ้ๅๆญฅ้ชค: `.V()`, `.out()`, `.in()`, `.both()` | ||
| - ่ฟๆปคๆญฅ้ชค: `.has()`, `.hasLabel()`, `.limit()` | ||
| - ไฟฎๆนๆญฅ้ชค: `.addV()`, `.property()`, `.drop()` | ||
| - ๅคๆ็ปๆ: ๅตๅฅ้ๅใ่ฐ่ฏ่กจ่พพๅผ็ญ | ||
|
|
||
| ### ๐ GremlinBase.py - ็ฟป่ฏๅผๆ | ||
| **ไฝ็จ**: ๆไพGremlinๆฏ่ฏญๅฐไธญๆ็ๆบ่ฝ็ฟป่ฏ | ||
| **ๆ ธๅฟๅ่ฝ**: | ||
| - ๅ ่ฝฝSchema็ฟป่ฏๅญๅ ธๅๅไน่ฏๅญๅ ธ | ||
| - ๆไพไธไธๆๆ็ฅ็ๆฏ่ฏญ็ฟป่ฏ | ||
| - ๆฏๆ้ๆบๅไน่ฏ้ๆฉ๏ผๅขๅ ๆ่ฟฐๅคๆ ทๆง | ||
| - ๆ ผๅผๅ็ๆ่ช็ถๆต็ ็ไธญๆๆ่ฟฐ | ||
|
|
||
| **็ฟป่ฏๆบๅถ**: | ||
| ```python | ||
| # ๆฏ่ฏญ็ฟป่ฏ | ||
| movie โ ็ตๅฝฑ | ||
| title โ ๆ ้ข | ||
| acted_in โ ๅๆผ | ||
|
|
||
| # ๆไฝ็ฟป่ฏ | ||
| .out('acted_in') โ "ๆฒฟ็'ๅๆผ'็ๅบ่พน" | ||
| .has('title', 'Matrix') โ "ๅ ถ'ๆ ้ข'ๅฑๆงไธบ'Matrix'" | ||
| .limit(10) โ "ๅนถๅชๅๅ10ไธช็ปๆ" | ||
| ``` | ||
|
|
||
| ### ๐ ๅ ถไปๆฏๆๆจกๅ | ||
|
|
||
| **Config.py**: ้ ็ฝฎๆไปถ็ฎก็๏ผๆฏๆJSONๆ ผๅผ้ ็ฝฎ | ||
| **GremlinParse.py**: ๅฎไนStepๅTraversalๆฐๆฎ็ปๆ | ||
| **template/**: ็ฟป่ฏๅญๅ ธๆไปถ๏ผๆฏๆSchemaๆฏ่ฏญๅๅไน่ฏ็ฟป่ฏ | ||
|
|
||
| ## ๐ฏ ไฝฟ็จ็คบไพ | ||
|
|
||
| ### ๅบๆฌไฝฟ็จ | ||
| ```python | ||
| # ๅฎไนๆจกๆฟ | ||
| templates = [ | ||
| "g.V().has('name', 'John')", | ||
| "g.V().hasLabel('movie').out('acted_in')", | ||
| "g.addV('person').property('name', 'Test')", | ||
| "g.V().has('title', 'Matrix').drop()" | ||
| ] | ||
|
|
||
| # ็ๆ่ฏญๆๅบ | ||
| from generator import generate_corpus_from_templates | ||
| result = generate_corpus_from_templates(templates) | ||
|
|
||
| print(f"็ๆไบ {result['total_unique_queries']} ไธช็ฌ็นๆฅ่ฏข") | ||
| ``` | ||
|
|
||
| ### ็ๆ็ปๆ็คบไพ | ||
| ```json | ||
| { | ||
| "query": "g.V().hasLabel('person').out('acted_in').limit(10)", | ||
| "description": "ไปๅพไธญๅผๅงๆฅๆพๆๆ้กถ็น๏ผ่ฟๆปคๅบ'ไบบ'็ฑปๅ็้กถ็น๏ผ็ถๅๆฒฟ็'ๅๆผ'็ๅบ่พนๆพๅฐ'็ตๅฝฑ'้กถ็น๏ผๅนถๅชๅๅ10ไธช็ปๆ" | ||
| } | ||
| ``` | ||
|
|
||
| ## ๐ ็ณป็ป็นๆง | ||
|
|
||
| ### ๐ฅ ้ซ่ดจ้ไฟ่ฏ | ||
| - **่ฏญๆณๆฃๆฅ**: ไฝฟ็จANTLR็กฎไฟ100%่ฏญๆณๆญฃ็กฎ | ||
| - **ๅป้ๆบๅถ**: ๅ จๅฑๅป้้ฟๅ ้ๅคๆฅ่ฏข | ||
| - **็ฑปๅๅฎๅ จ**: ๅบไบSchema็็ฑปๅๆฃๆฅ | ||
|
|
||
| ### โก ้ซๆ็ๆ | ||
| - **ๆบ่ฝๆณๅ**: ไป32ไธชๆจกๆฟ็ๆ940+็ฌ็นๆฅ่ฏข | ||
| - **ๆน้ๅค็**: ๆฏๆๅคง่งๆจกๆจกๆฟๆนๅค็ | ||
| - **ๅข้็ๆ**: ๆฏๆๅข้ๆทปๅ ๆฐๆจกๆฟ | ||
|
|
||
| ### ๐ ไธฐๅฏๅคๆ ทๆง | ||
| - **ๆไฝ็ฑปๅๅ่กก**: ๆฅ่ฏข62.6% + ๆดๆฐ28.3% + ๅๅปบ6.6% + ๅ ้ค2.6% | ||
| - **ๅคๆๅบฆๅๅธ**: 1-8ๆญฅๆฅ่ฏขๅ จ่ฆ็ | ||
| - **้ๆบๅขๅผบ**: 20%ๆซ็ซฏ + 10%ไธญ้ดๅขๅผบๆฆ็ | ||
|
|
||
| ### ๐ ๆฌๅๅๆฏๆ | ||
| - **ไธญๆ็ฟป่ฏ**: ๅ็กฎ็Schemaๆฏ่ฏญ็ฟป่ฏ | ||
| - **่ช็ถๆ่ฟฐ**: ็ฌฆๅไธญๆ่กจ่พพไน ๆฏ็่ช็ถ่ฏญ่จ | ||
| - **ๅฏๆฉๅฑๅญๅ ธ**: ๆฏๆ่ชๅฎไน็ฟป่ฏๅญๅ ธ | ||
|
|
||
| ## ๐ ๅฟซ้ๅผๅง | ||
|
|
||
| ### 1. ็ฏๅขๅๅค | ||
| ```bash | ||
| # ็กฎไฟPython็ฏๅขๅไพ่ต | ||
| pip install antlr4-python3-runtime | ||
| ``` | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| ### 2. ่ฟ่ก็ๆ | ||
| ```bash | ||
| cd base_v2 | ||
| python generator.py | ||
| ``` | ||
|
|
||
| ### 3. ๆฅ็็ปๆ | ||
| ็ๆ็่ฏญๆๅบไฟๅญๅจ `generated_corpus.json` ๆไปถไธญ๏ผๅ ๅซ๏ผ | ||
| - ๅ ๆฐๆฎไฟกๆฏ๏ผๆจกๆฟๆฐ้ใๆฅ่ฏขๆฐ้็ญ๏ผ | ||
| - ๆฅ่ฏข-ๆ่ฟฐๅฏนๅ่กจ | ||
| - ๅฎๆด็JSONๆ ผๅผ๏ผไพฟไบๅ็ปญๅค็ | ||
|
|
||
| ## ๐ง ่ชๅฎไน้ ็ฝฎ | ||
|
|
||
| ### ๆทปๅ ๆฐ็Schemaๆฏ่ฏญ็ฟป่ฏ | ||
| ็ผ่พ `template/schema_dict.txt`: | ||
| ``` | ||
| new_entity ๆฐๅฎไฝ | ||
| new_property ๆฐๅฑๆง | ||
| new_relation ๆฐๅ ณ็ณป | ||
| ``` | ||
|
|
||
| ### ่ฐๆด้ๆบๅขๅผบๆฆ็ | ||
| ไฟฎๆน `TraversalGenerator.py` ไธญ็ๆฆ็ๅๆฐ๏ผ | ||
| ```python | ||
| if random.random() < 0.2: # ๆซ็ซฏๅขๅผบๆฆ็ | ||
| if random.random() < 0.1: # ไธญ้ดๅขๅผบๆฆ็ | ||
| ``` | ||
|
|
||
| ### ๆฉๅฑๆฏๆ็Gremlin่ฏญๆณ | ||
| ๅจ `GremlinTransVisitor.py` ไธญๆทปๅ ๆฐ็visitๆนๆณใ | ||
|
|
||
| ## ๐ ๆง่ฝๆๆ | ||
|
|
||
| - **็ๆๆ็**: 32ไธชๆจกๆฟ โ 940ไธชๆฅ่ฏข (29.4ๅๆพๅคง) | ||
| - **่ฏญๆณๆญฃ็กฎ็**: 100% (็ปANTLR้ช่ฏ) | ||
| - **็ฟป่ฏๅ็กฎ็**: ๅบไบไบบๅทฅๆ ๆณจ็Schemaๅญๅ ธ | ||
| - **ๅคๆ ทๆงๆๆ **: 8็งๅคๆๅบฆ็บงๅซ๏ผ4็งๆไฝ็ฑปๅๅ่กกๅๅธ | ||
|
|
||
| ## ๐ค ่ดก็ฎๆๅ | ||
|
|
||
| ๆฌข่ฟ่ดก็ฎไปฃ็ ๅๆน่ฟๅปบ่ฎฎ๏ผไธป่ฆ่ดก็ฎๆนๅ๏ผ | ||
| - ๆฉๅฑGremlin่ฏญๆณๆฏๆ | ||
| - ๆน่ฟ็ฟป่ฏ่ดจ้ๅๅคๆ ทๆง | ||
| - ไผๅ็ๆ็ฎๆณๆ็ | ||
| - ๆทปๅ ๆฐ็้ๆบๅขๅผบ็ญ็ฅ | ||
|
|
||
| ## ๐ ่ฎธๅฏ่ฏ | ||
|
|
||
| ๆฌ้กน็ฎ้็จๅผๆบ่ฎธๅฏ่ฏ๏ผ่ฏฆ่งLICENSEๆไปถใ | ||
|
|
||
| --- | ||
|
|
||
| **้กน็ฎ็ปดๆค**: ๆฌ้กน็ฎไธๆณจไบไธบText-to-Gremlinไปปๅกๆไพ้ซ่ดจ้็่ฎญ็ปๆฐๆฎ๏ผๆ็ปญๆน่ฟๅไผๅไธญใ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
|
|
||
| """ | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| ้กน็ฎ้ ็ฝฎ็ฎก็ๆจกๅใ | ||
|
|
||
| ่ด่ดฃๅ ่ฝฝๅ็ฎก็้กน็ฎ้ ็ฝฎๆไปถ๏ผๆไพๅๆจกๅๆ้็้ ็ฝฎๅๆฐใ | ||
| """ | ||
|
|
||
| import json | ||
| import os | ||
| import sys | ||
|
|
||
|
|
||
| class Config: | ||
| def __init__(self, file_path): | ||
| self.file_path = file_path | ||
| self.config_data = self.load_config() | ||
| self.gen_query = self.config_data.get( | ||
| "genQuery" | ||
| ) # default genQuery๏ผcan be set as translate | ||
| self.db_id = self.config_data.get("db_id") | ||
|
|
||
| def load_config(self): | ||
| with open(self.file_path, "r") as file: | ||
| return json.load(file) | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| def get_input_query_path(self): | ||
| return self.config_data.get("input_query_path") | ||
|
|
||
| def get_input_query_template_path(self): | ||
| return self.config_data.get("input_query_template_path") | ||
|
|
||
| def get_input_corpus_dir_or_file(self): | ||
| return self.config_data.get("input_corpus_dir_or_path") | ||
|
|
||
| def set_input_corpus_dir_or_file(self, dir_or_file): | ||
| self.config_data["input_corpus_dir_or_path"] = dir_or_file | ||
|
|
||
| def get_output_path(self): | ||
| if self.gen_query: | ||
| dir_or_file = self.config_data.get("output_query_dir_or_file") | ||
| if os.path.isdir(dir_or_file): | ||
| output_path = os.path.join(dir_or_file, self.db_id + ".txt") | ||
| return output_path | ||
| else: | ||
| return dir_or_file | ||
| else: | ||
| return self.config_data.get("output_prompt_path") | ||
|
|
||
| def get_output_corpus(self): | ||
| return self.config_data.get("output_corpus_path") | ||
|
|
||
| def get_schema_dict_path(self): | ||
| return self.config_data.get("schema_dict_path") | ||
|
|
||
| def get_syn_dict_path(self): | ||
| return self.config_data.get("syn_dict_path") | ||
|
|
||
| def get_db_id(self): | ||
| return self.db_id | ||
|
|
||
| def get_schema_path(self, db_id): | ||
| schema_dict = self.config_data.get("db_schema_path") | ||
| return schema_dict[db_id] # todo error check | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| def get_config(self, module_name): | ||
| return self.config_data.get(module_name) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.