Using Claude to Generate RDF Triples

Written by on April 11, 2025 in Homeopathy, Knowledge Representation with 0 Comments

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:

Lycopodium TTL Format

Lycopodium TTL Format

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:

Arg Nit TTL Format

Arg Nit TTL Format

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”.

Importing TTL Data

Importing TTL Data

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:

Executing Sparql Query

Executing Sparql Query

Next query: “What are the modalities of the remedies?”

Here is the answer:

Query on Modalities

Query on Modalities

Third and final question: “What are the Mental, Emotional and Digestive symptoms of the remedies?”

Another Query

Another Query

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!

Tags: , ,

About the Author

About the Author: .

Subscribe

If you enjoyed this article, subscribe now to receive more just like it.

Subscribe via RSS Feed

Leave a Reply

Your email address will not be published. Required fields are marked *

Top