Skip to content

Commit

Permalink
prompt: default prompt for KG builder (#751)
Browse files Browse the repository at this point in the history
Previously, due to the fact we assumed "name" is special for
a extracted node to actually act as its vertexID, and, there
in NebulaGraph the id is actually composite 4 fields(src,dst,type,rank),
thus there is no "name" fields in extracted JSON.

In such case, the "name" field in schema of edge type will not
be handled properly in some of LLMs.

Also, previously, the JSON format was not exactly an example, but
a half example(nodes, edges) half json type schema(xxx:string, yyy:object).

This is actually not clear enough, which will cost mind-power of LLMs.

Now it's changed to a real example.
  • Loading branch information
wey-gu authored Jan 22, 2024
1 parent ef581e7 commit 9c9bda4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 18 deletions.
25 changes: 16 additions & 9 deletions server/api/studio/etc/ai-importer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,25 @@ MaxBlockSize: 0 # max request block num
GQLBatchSize: 100 # max gql batch size
PromptTemplate: |
As a knowledge graph AI importer, your task is to extract useful data from the following text:
----text
---
{text}
----
---
the knowledge graph has following schema and node name must be a real :
----graph schema
The knowledge graph should follow this schema (node name is mandatory):
---
{spaceSchema}
----
---
Please return the results in JSON format only, without any explanations or comments. The JSON should include nodes and edges with their properties, as shown below:
Return the results directly, without explain and comment. The results should be in the following JSON format:
```json
{
"nodes":[{ "name":string,"type":string,"props":object }],
"edges":[{ "src":string,"dst":string,"edgeType":string,"props":object }]
"nodes":[{ "name":"foo","type":"node_type_1","props":{"key_x":"85%"} }],
"edges":[{ "src":"foo","dst":"bar","edgeType":"edge_type_3","props":{"name":"is located in"} }]
}
the result json is:
```
Ensure the JSON is correctly formatted. Now, extract!
JSON:
28 changes: 19 additions & 9 deletions server/api/studio/etc/studio-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,27 @@ LLM:
MaxBlockSize: 0
PromptTemplate: |
As a knowledge graph AI importer, your task is to extract useful data from the following text:
```text
---
{text}
```
the knowledge graph has following schema and node name must be a real :
```graph-schema
---
The knowledge graph should follow this schema (node name is mandatory):
---
{spaceSchema}
```
---
{userPrompt}
Return the results directly, without explain and comment. The results should be in the following JSON format:
Please return the results in JSON format only, without any explanations or comments. The JSON should include nodes and edges with their properties, as shown below:
```json
{
"nodes":[{ "name":string,"type":string,"props":object }],
"edges":[{ "src":string,"dst":string,"edgeType":string,"props":object }]
"nodes":[{ "name":"foo","type":"node_type_1","props":{"key_x":"85%"} }],
"edges":[{ "src":"foo","dst":"bar","edgeType":"edge_type_3","props":{"name":"is located in"} }]
}
the result json is:
```
Ensure the JSON is correctly formatted. Now, extract!
JSON:

0 comments on commit 9c9bda4

Please sign in to comment.