Skip to content

How To Use Information From Existing Graphs

Andreas Both edited this page Oct 3, 2023 · 1 revision

The Qanary methodology is typically implemented while using a new graph (in the Qanary triplestore) to represent the information about the current question of a user. Sometimes (e.g., while implementing chat-like interactions) one needs to access the information from the previous graph to get the full context. For example, imagine a chat interaction where a user asks:

  • Input 1: "What is the birthday of Albert Einstein?"

    • answer of the system where all information is stored in a graph X

  • Input 2: "What was his birthplace?"

To provide an answer to the second input of the user, the systems needs access to the previous input and its annotations stored in graph X (i.e., to all the information Qanary components have retrieved from the textual input and stored in the graph X of the Qanary triplestore).

Currently, there are three methods supported to access information on an existing graph:

  • Re-use the existing graph

  • Reference an existing graph

  • Copy values from an existing graph into the current graph

In the following, each method is explained in more detail.

Re-use an Existing Graph

With this straightforward approach, new information is added to the existing graph. This makes all data easily available in only one named graph.

However, this also means that it may be more difficult to distinguish new data entries from existing data.

How to use this approach

Start the question answering process by making a POST request to the /questionanswering endpoint provided by the Qanary pipeline template implementation. Specify the parameter graph (together with other necessary parameters) to point to the existing process graph.

Note, that in this case, you cannot provide a new value for the question parameter, as only the existing text question is used. As such, this is only suitable for adding newly computed information to the existing graph, not for following up with a new question.

Reference an Existing Graph

This approach offers a clear differentiation between existing and new data. However, it might be required to adjust individual component implementations to make use of the provided reference, reducing their reusability and removing, one of the core strengths of Qanary components.

This approach may be viable if information from an existing graph is only used in very few components, that are specifically designed with this functionality in mind.

How to use this approach

Specify the parameter priorConversation as part of the POST request to start a Qanary pipeline process. This reference to a graph URI is then available as an annotation to the current question qa:Question under the attribute qa:priorConversation. In the following, a corresponding exemplary request is shown:

$ curl http://localhost:8080/startquestionansweringwithtextquestion \
           -d "question=<question>" \
           -d "componentlist[]=<components>" \
           -d "priorConversation=<existingGraph>"

Copy Values from an Existing Graph

This approach is especially useful, if some components need a direct reference to data that was previously computed and that is highly relevant for context-awareness.

For example, in the case of a chatbot that needs to answer a follow-up question that relates to a resource that was only specifically mentioned in a prior question.

However, note that copying all data over to the current graph will result in more than one question actively being held in the context of the current graph, which need to be properly distinguished in order to avoid processing errors.

How to use this approach

There are two ways to implement this approach, using the provided Qanary component.

Option 1: Copy data independently of the Qanary Pipeline

Once started, the Qanary component qanary-component-CopyValuesOfPriorGraph will provide the endpoint /copyvaluestograph, requiring the following parameters:

  • sourceGraph - The existing graph with information that should be copied

  • targetGraph - The process graph that should be updated with the existing data

You may directly formulate a POST request, or use the provided minimal web UI under the same endpoint. In the following, a corresponding exemplary request is shown:

$ curl http://localhost:5566/copyvaluestograph \
           -d "sourceGraph=<sourceGraph>" \
           -d "targetGraph=<targetGraph>"

Option 2: Copy data as a processing step of the Qanary Pipeline

Alternatively, you can specify the priorConversation parameter when starting a Qanary question answering process, as mentioned above.

The component will then copy data from this existing graph into the current graph of the Qanary process. For this, it is highly recommended to call this component – responsible for copying the data – as the first in the component list!

Clone this wiki locally