This project provides a web service for generating natural-language representations for SPARQL queries over the Wikidata or DBpedia knowledge graphs.
The corresponding web-based frontend — LoRiS - LLM-generated natural-language representations of SPARQL queries over Wikidata and DBpedia — is provided here.
The API is available at https://wse-research.org/api/sparql2nl
Sample SPARQL2NL API request:
curl -X 'GET' \
'https://wse-research.org/api/sparql2nl?query_text=QUERYTEXT&language=LANG&shots=SHOTS&model=MODELID' \
-H 'accept: application/json'
-
query_text
: a SPARQL query over Wikidata or DBpedia -
language
: English (en), German (de), or Russian (ru) -
shots
: zero-shot (0), one-shot (1) -
model
: model id (any text model from OpenAI https://platform.openai.com/docs/models)
Feedback API request:
curl -X 'POST' 'https://wse-research.org/api/sparql2nl-feedback' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"query_text": "SELECT * WHERE { ?s ?p ?o }",
"verbalization": "select everything",
"rating": 5,
"comment": "cool"
}'
-
query_text
: a SPARQL query over Wikidata or DBpedia -
verbalization
: a result of our model -
rating
: a grade from 1 (bad) to 5 (good) -
comment
: optional, additional notes to the result
The application is available at Dockerhub for free use in your environment.
.env
file
OPENAI_API_KEY=
PORT=
MONGO_HOST=
MONGO_PORT=
MONGO_USERNAME=
MONGO_PASSWORD=
We are happy to receive your contributions. Please create a pull request or an issue. As this tool is published under the MIT license, feel free to fork it and use it in your own projects.