Auto-KGQA, an autonomous domain-independent framework based on LLMs for text-to-SPARQL. Given a KG K, the framework selects fragments of the T-Box and A-Box of K, which the LLM uses to translate the user's original NL question Q to a SPARQL query on K.
Auto-KGQA generates n SPARQL queries that translate Q and selects the best one, based on the query results on K. Finally, Auto-KGQA generates an NL response to the user, based on Q, the selected SPARQL query S, and the result of the execution of S over K. The main goal of Auto-KGQA is the selection of smaller KG fragments thereby reducing the number of tokens passed as input to the LLM, which decreases the possibility of hallucinations with irrelevant elements in the input and increases the ability to support large KGs.
OPENAI_API_KEY = OPENAI_TOKEN
./install.sh
./server.sh or python server.py
npm install
npm start
python create_indexes.py
Demo
The file "Demo/ontology_example.ttl" can be used with a demo KG to test the framework's functionalities. To use it, upload it to a triplestore and configure your SPARQL endpoint in the file "API/configs.py".