Talk to Your Graph examples

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:

  1. First, create a repository with a name of your choice (for example, starwars).

  2. Then, download the starwars.trig dataset 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 Lab ‣ Talk to Your Graph.

First, you need to create an agent:

  1. Click on the icon-fa-message-bot Create your first agent button. If you already have one or more agents, click on the Create a new agent icon-gdb-plus icon on the top right of the Talk to Your Graph interface. The create agent dialog will open.

  2. Enter a name for the agent, for example, “Star Wars demo”.

  3. Choose the repository you just created (if not already selected).

  4. Enable the SPARQL query method.

  5. 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 the starwars.trig file you downloaded that has the ontology.

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

  7. Click on the Create Agent button.

_images/ttyg-create-star-wars.png

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-fa-pen-to-square 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.

_images/ttyg-select-agent-star-wars.png

Try asking questions about characters in the Star Wars universe:

_images/ttyg-star-wars-chat.png

If you are curious how a particular question was answered, you can click the Explain response icon-fa-wand-magic-sparkles icon under any response.

_images/ttyg-star-wars-explain.png

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:

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

    _images/ttyg-acme-fts-index-repo.png
  2. Then, download the acme.trig dataset 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 Lab ‣ Talk to Your Graph.

First, you need to create an agent:

  1. Click on the icon-fa-message-bot Create your first agent button. If you already have one or more agents, click on the Create a new agent icon-gdb-plus icon on the top right of the Talk to Your Graph interface. The create agent dialog will open.

  2. Enter a name for the agent, for example, “Acme demo”.

  3. Choose the repository you just created if it’s not already selected.

  4. Enable the SPARQL query method.

  5. Click on Fetch ontology from a named graph and enter http://example.com/acme in the named graph field because that is the named graph in the acme.trig file you downloaded that has the ontology.

  6. Enable the Full-text search query method, because we will execute a query that takes advantage of that.

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

  8. Click on the Create Agent button.

_images/ttyg-create-acme.png

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-fa-pen-to-square 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.

_images/ttyg-select-agent-acme.png

Try asking questions about employees, departments and products of Acme:

_images/ttyg-acme-chat1.png _images/ttyg-acme-chat2.png _images/ttyg-acme-chat3.png _images/ttyg-acme-chat4.png

The model answered these questions by using the ontology and writing SPARQL queries. Let’s try a more open-ended question:

_images/ttyg-acme-chat5.png

If you click the Explain response icon-fa-wand-magic-sparkles icon under that response you will see the model used the Full-text search query method to answer that question.

_images/ttyg-acme-explain.png

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.