Best Practices To Help GPT Understand the Ontology of JSON files

I have some data in JSON format. And I want to prompt GPT to answer questions given the data in the JSON file as context.

For example:
The file

{ 
"0" : {
"userid": "123",  "age": 33, "gender": "male", "book": "the outsiders", "comment":"i like sodapop!"
},
 "1": {...},
...
}

Prompt

Given the data.json what are millennial men commenting about?

This of course is a dummy example, but illustrates the idea. The real data would be more nested than this.

Wondering if there is a best practice or method that I should use to help GPT understand the meaning of the ontology of the JSON file. So that it could better understand the meaning of each field and the relationship of between fields.

I had same task with sales data before. The best approach that I found it was about giving “typed structure” of JSON beforehand and then push the real data. let say

{
"Month name" : 
  {
  "days": "amount of days in that month", 
  "value": "amount of sales in EUR", 
  "count": "amount of sold items per period"
  }
}

It gave more context and the most detailed answer.

1 Like

I haven’t tested as much on GPT4, but my experience dealing with the structured data is that GPT-3.5 does a good job of picking up intent based on field names, although you may need to tweak the field names if its getting something wrong.

In regards to nested structures, its generally ok on reading them but not so great if you need to generate nested structures, as the AI can get creative on more complicated structures. Also I do notice an additional latency in requests dealing with more complicated structures.

So my general advice is the flatter the structure the less problems you will have out-of-the-box. More complicated structures may require more explanation in the prompts and are generally slower.

In the title you noted Ontology but in the question only gave example of JSON. When you note Ontology is the meaning the same as noted in this Wikipedia article?

If so then as we know Ontologies carry much more semantic information than just JSON. As such would it not be in your interest to use a Ontology store that can make use of LLM APIs?

Perhaps

1 Like

I haven’t tested this format yet but it should work.

Use the following data.json to answer the given questions.

```json
// data.json
{ 
"0" : {
"userid": "123",  "age": 33, "gender": "male", "book": "the outsiders", "comment":"i like sodapop!"
},
 "1": {...},
...
}```

Questions:

1- what are millennial men commenting about?

Provide examples in your prompt my friend. Make it easy on the machine :slight_smile: