Talk to Your Graph examples¶
What’s in this document?
Once you have configured Talk to Your Graph, you can create an agent and use it to query your data using natural language. The examples below use two different datasets to demonstrate how to achieve that.
Star Wars example¶
This example uses data describing Star Wars movies, characters, planets and vehicles, and an agent configured to use SPARQL for querying the database and answering questions.
Creating a repository and importing the data¶
Before you start with Talk to Your Graph, you need to create a repository and import the dataset:
First, create a repository with a name of your choice (for example, starwars).
Then, download the
starwars.trigdataset and import it into your new repository.
Talking to your graph¶
At this point you’re set to use the Talk to Your Graph feature. On the Workbench go to .
First, you need to create an agent:
Click on the
Create your first agent button. If you already have one or more agents, click on the Create a new agent
icon on the top right of the Talk to Your Graph interface. The create agent dialog will open.
Enter a name for the agent, for example, “Star Wars demo”.
Choose the repository you just created (if not already selected).
Enable the SPARQL query method.
Click on Fetch ontology from a named graph and enter
https://swapi.co/ontology/in the named graph field, because that is the ontology named graph in thestarwars.trigfile you downloaded that has the ontology.If needed, scroll down to the Additional instructions and enter “The data uses the SWAPI dataset and describes characters, space vessels and planets from the Star Wars universe.”
Click on the Create Agent button.
Once the agent has been created, you will see the chat interface. Locate the dropdown field at the top of the screen where it says Select an agent and choose the agent you just created. If you already have other agents and chats, the interface will continue showing the last chat and you need to click the Start a new chat icon at the top of the chat list. This will initiate a new chat, and then you need to select the agent you created from the dropdown.
Try asking questions about characters in the Star Wars universe:
If you are curious how a particular question was answered, you can click the Explain response icon under any response.
Acme employees and products example¶
Another dataset and corresponding agent configuration lets you explore the Talk to Your Graph feature with more business-oriented data. It contains data about the employees and products of Acme, an IT company that makes software for the animation industry.
Unlike the Star Wars example, this one will use both SPARQL and full-text search for querying the database.
Creating a repository and importing the data¶
Before you start with Talk to Your Graph, you need to create a repository and import the dataset:
First, create a repository with a name of your choice (for example, acme). Unlike the previous example, you need to enable the Simple full-text search index for this repository by clicking the Enable full-text search (FTS) index checkbox in the repository creation form.
Then, download the
acme.trigdataset and import it into your new repository.
Talking to your graph¶
At this point you’re set to use the Talk to Your Graph feature. On the Workbench go to .
First, you need to create an agent:
Click on the
Create your first agent button. If you already have one or more agents, click on the Create a new agent
icon on the top right of the Talk to Your Graph interface. The create agent dialog will open.
Enter a name for the agent, for example, “Acme demo”.
Choose the repository you just created if it’s not already selected.
Enable the SPARQL query method.
Click on Fetch ontology from a named graph and enter
http://example.com/acmein the named graph field because that is the named graph in theacme.trigfile you downloaded that has the ontology.Enable the Full-text search query method, because we will execute a query that takes advantage of that.
If needed, scroll down to the Additional instructions and enter “The data describes employees, roles, job titles and products of Acme, a company that makes software for the animation industry.”
Click on the Create Agent button.
Once the agent has been created, you will see the chat interface. Locate the dropdown field at the top of the screen where it says Select an agent and choose the agent you just created. If you already have other agents and chats, the interface will continue showing the last chat and you need to click the Start a new chat icon at the top of the chat list. This will initiate a new chat, and then you need to select the agent you created from the dropdown.
Try asking questions about employees, departments and products of Acme:
The model answered these questions by using the ontology and writing SPARQL queries. Let’s try a more open-ended question:
If you click the Explain response icon under that response you will see the model used the Full-text search query method to answer that question.
Note
Whether the model uses SPARQL or another enabled query method like Full-text search is not strictly predictable. In fact, the question about employees liking hiking and photography could be answered by a SPARQL query that searches the employees’ biographies for keywords.
