Skip to content

refactor(llm): improve graph extraction default prompt#187

Merged
imbajin merged 2 commits intoapache:mainfrom
Kryst4lDem0ni4s:promptrefactor
Mar 3, 2025
Merged

refactor(llm): improve graph extraction default prompt#187
imbajin merged 2 commits intoapache:mainfrom
Kryst4lDem0ni4s:promptrefactor

Conversation

@Kryst4lDem0ni4s
Copy link
Copy Markdown
Contributor

@Kryst4lDem0ni4s Kryst4lDem0ni4s commented Mar 2, 2025

fix #185

After modifying the prompt configuration file (incubator-hugegraph-ai\hugegraph-llm\src\hugegraph_llm\config\prompt_config.py), the output has significantly improved.

For the generic input and schema example, the output being generated now is:

{
  "vertices": [
    {
      "id": "1:Sarah",
      "label": "person",
      "type": "vertex",
      "properties": {
        "name": "Sarah",
        "age": 30,
        "occupation": "attorney"
      }
    },
    {
      "id": "1:James",
      "label": "person",
      "type": "vertex",
      "properties": {
        "name": "James",
        "occupation": "journalist"
      }
    },
    {
      "id": "2:SarahsPlace",
      "label": "webpage",
      "type": "vertex",
      "properties": {
        "name": "SarahsPlace",
        "url": "www.sarahsplace.com"
      }
    }
  ],
  "edges": [
    {
      "id": 1,
      "label": "roommate",
      "type": "edge",
      "outV": "1:Sarah",
      "outVLabel": "person",
      "inV": "1:James",
      "inVLabel": "person",
      "properties": {
        "date": "2010"
      }
    },
    {
      "id": 2,
      "label": "link",
      "type": "edge",
      "outV": "2:SarahsPlace",
      "outVLabel": "webpage",
      "inV": "1:Sarah",
      "inVLabel": "person",
      "properties": {}
    }
  ]
}

from the previous errenous output:

"vertices": [
   {
     "id": "1:person",
     "label": "person",
     "type": "vertex",
     "properties": {
       "name": "Sarah",
       "age": "30",
       "occupation": "attorney"
     }
   },
   {
     "id": "1:webpage",
     "label": "webpage",
     "type": "vertex",
     "properties": {
       "name": "www.sarahsplace.com",
       "url": "None"
     }
   }
 ],
 "edges": [
   {
     "label": "roommate",
     "type": "edge",
     "outV": "1:person",
     "outVLabel": "person",
     "inV": "1:webpage",
     "inVLabel": "webpage",
     "properties": {
       "date": "2010"
     }
   }
 ]
}

This significant improvement is possible by clearly outlining the data type and conditional requirements.
Tested locally and through API.

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 2, 2025
@github-actions github-actions bot added the llm label Mar 2, 2025
@dosubot dosubot bot added the enhancement New feature or request label Mar 2, 2025
@imbajin imbajin changed the title [Feature] Improvement of Prompt Configuration for rag_demo Graph Index generation #185 refactor(llm): improve graph extraction default prompt Mar 2, 2025
@imbajin
Copy link
Copy Markdown
Member

imbajin commented Mar 2, 2025

THX, the context is clearly~ (we'll review/test it soon)

Copy link
Copy Markdown
Member

@imbajin imbajin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THX

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 3, 2025
@imbajin imbajin merged commit 8c1ffbb into apache:main Mar 3, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer llm size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Improvement of Prompt Configuration for rag_demo Graph Index generation

2 participants