Using SPARQL Query Templates to Fine-Tune ChatGPT's Large Language Model (LLM)

SPARQL INSERTs based Fine-Tuning

Here’s how the goal outlined above is achieved, using a template based on the following generic INSERT statement.

INSERT DATA {
  GRAPH <http://example.com/graphURI> {
    <S> <P> <O> .
  }
}

Template

Using relative hyperlinks for subject and object denotation, add data expressed in the RDF triple: <S> <P> <O> to the knowledge graph <G>;PREFIX : <urn:records:test#> INSERT DATA { GRAPH <G> { :<S> :<P> :<O> .}} ;

Here’s a usage example using a ChatGPT session transcript.

Transcript

Q:
Using the following template.

Using relative hyperlinks for subject and object denotation, add data expressed in the RDF triple: <S> <P> <O> to the knowledge graph <G>;PREFIX : <urn:records:test#> INSERT DATA { GRAPH <G> { :<S> :<P> :<O> .}} ;

Create a clickable SPARQL link for inserting the following into the knowledge graph denoted by urn:records:test: this4 relatedTo this . Using the endpoint https://linkeddata.uriburner.com/sparql

A:
Sure, to insert the RDF triple this4 relatedTo this into the graph urn:records:test , the SPARQL command would be:

PREFIX : <urn:records:test#> 
INSERT DATA { GRAPH <urn:records:test> { :this4 :relatedTo :this .}} 

Here’s the clickable SPARQL link for the given endpoint: SPARQL Insert Link

Screenshot 1

Screenshot 2 (Multi-Protocol Authentication Challenge)

chatgpt-uriburner-sparql-7

Note:

  1. The URIBurner Service implements a Data Access Policy informed by an attribute-based access control (ABAC) that allows authenticated users perform read-write operations against public knowledge graphs (i.e., those that aren’t protected by more constraining data access policies).
  2. Data Access policies are created via RDF statements too!

Screenshot 3 (Successful Insert)

chatgpt-sparql-rww-demo-3

Screenshot 4 SPARQL URL (via the OpenLink Structured Data Sniffer Browser Extension)

Screenshot 5 (SPARQL SELECT Query Displaying Effects of INSERT)

Screenshot 6 (Single-Page Read-Write Application View)

Here’s alternative view showing SPARQL INSERT operation effects.

Related