We all know that LLMs are now capable of generating structured data. I have used OpenAI models earlier to generate Tables and JSON data, but this time I wanted to try a more complex example.
As someone interested in Homeopathy, I wanted to generate remedy descriptions as RDF triples, in particular, Turtle (TTL) format. That would allow me to model homeo remedies using Knowledge Graph.
I decided to use Anthropic Claude for this experiment.
I launched Claude (Sonnet 3.7) and gave it the following prompt:
“You are an experienced software developer with a deep understanding of semantic web standards. As a student of homeopathy, I want to represent the key symptoms (including modalities) of Lycopodium in Turtle format. Apply your extensive knowledge and do this for me.”
It immediately generated a TTL representation of some interesting symptoms of Lycopodium. Here is a partial representation:
Then I asked it to do the same for Argentum Nitricum:
“Thanks! Please do the same for Arg Nit remedy.”
As earlier, it generated a TTL representation corresponding to Argentum Nitricum:
The next challenge was to confirm that the generated information was a valid TTL representation. I used the “Turtle Validator” to test this. Fortunately, both representations were correct and I was relieved!
How to use the generated TTL data of the two remedies? As a user of Allegro Common Lisp, I am familiar with their other excellent product “AllegroGraph”. I have written an article earlier on this.
This time I decided to use their Cloud Hosted service (Free tier) and created a new account. I then used their “WebView” to connect to the server and created a new Repository called “Homeopathy”. Next, I imported data corresponding to the 2 remedies by copy pasting into the Input area. By default “Auto-detect” option is enabled in “Import Options”.
The Knowledge Graph repository now contains information about two homeopathy remedies. How can we use this? “Sparql” immediately comes to our mind.
Here is a query for: “What are the Mental/Emotional symptoms of Argentum Nitricum?”
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX homo: <http://example.org/homeopathy/ontology#>
PREFIX remedy: <http://example.org/homeopathy/remedy#>
PREFIX argnit: <http://example.org/homeopathy/remedy/argentumnitricum#>SELECT ?symptomName ?symptomDescription
WHERE {
?symptom homo:characteristicOf remedy:argentumnitricum ;
rdfs:label ?symptomName ;
homo:description ?symptomDescription ;
homo:belongsTo argnit:MentalEmotional .
}
ORDER BY ?symptomName
It is quite easy to run this in AllegroGraph:
Next query: “What are the modalities of the remedies?”
Here is the answer:
Third and final question: “What are the Mental, Emotional and Digestive symptoms of the remedies?”
AllegroGraph even supports OpenAI LLM Integration, but I did not get into that mode.
What I wanted to convey in this article is that LLMs are capable of generating highly structured data. This particular example is to show that unstructured data can be converted into a Knowledge Graph and then used appropriately depending on the requirements.
You can download the TTL representations of Lycopodium and Argentum Nitricum used in this article.
Have a great Weekend!
Recent Comments