Skip to content

How to establish a Docker based Qanary Question Answering system

Andreas Both edited this page Dec 8, 2022 · 6 revisions

We try to make all Qanary components available at Dockerhub. Using such components makes the integration very easy.

Requirements:

  • You already have Docker and Docker Compose installed on your system.
  • The Stardog triplestore was installed locally using the default configuration (otherwise, you need to update the values below).

A simple Question Answering system

For the sake of this simple example, we define a system consisting of two components following the tiny tutorial configuration. The used components are:

  • NED-DBpedia-Spotlight (a Named Entity Disambiguation component): The component uses the DBpedia Spotlight API to search and annotate the given question with DBpedia entities.
  • QB-SimpleRealNameOfSuperHero (a Query Builder component): If a Named Entity from DBpedia was recognized in the given question and the question starts with What is the real name of , then a SPARQL query is computed by this component that can be used to fetch the real name of a superhero from the DBpedia knowledge graph.

Use docker-compose to run your Qanary Question Answering system

It is very easy to establish a Question Answering system based on Docker images and docker-compose (cf. docker-compose documentation). Save the following content to a file called docker-compose.yml.

version: "3.7"
services:
  qanary_pipeline:
    image: qanary/qanary-pipeline:latest
    restart: unless-stopped
    environment:
      - SERVER_PORT=8080
      - STARDOG_URL=http://127.0.0.1:5820/
      - STARDOG_USERNAME=admin
      - STARDOG_PASSWORD=admin
      - QANARY_PROCESS_ALLOW-ADDITIONAL-TRIPLES=false
      - SERVER_HOST=http://localhost
    network_mode: host
  ned-dbpedia-spotlight:
    image: qanary/qanary-component-ned-dbpedia-spotlight:latest
    restart: unless-stopped
    environment:
      - SERVER_PORT=40113
      - SPRING_BOOT_ADMIN_URL=http://localhost:8080
      - SERVER_HOST=http://localhost
      - SPRING_BOOT_ADMIN_CLIENT_INSTANCE_SERVICE-BASE-URL=http://localhost:40113
    network_mode: host
    depends_on:
      - "qanary_pipeline"
  qb-simplerealnameofsuperhero:
    image: qanary/qanary-component-qb-simplerealnameofsuperhero:latest
    restart: unless-stopped
    environment:
      - SERVER_PORT=40114
      - SPRING_BOOT_ADMIN_URL=http://localhost:8080
      - SERVER_HOST=http://localhost
      - SPRING_BOOT_ADMIN_CLIENT_INSTANCE_SERVICE-BASE-URL=http://localhost:40114
    network_mode: host
    depends_on:
      - "qanary_pipeline"

Here, we assume that the system runs locally (localhost) and uses a demo installation of the Stardog triplestore. The two components ned-dbpedia-spotlight and qb-simplerealnameofsuperhero point to the Qanary pipeline component, which will be started on port 8080.

Start and Test your Qanary System

start the Qanary system

Use the following command to start your Qanary system:

docker-compose up

The Docker components will be fetched from Dockerhub automatically and started thereafter.

check if the Qanary components have started successfully

Open the following URL in your Web browser: http://localhost:8080/. You should see the two components (ned-dbpedia-spotlight and qb-simplerealnameofsuperhero) as online.

run a test question on your simple Qanary system

Open the following URL in your Web browser: http://localhost:8080/startquestionansweringwithtextquestion. There a simple Web UI should be shown, where you can input a question and select the order (drag'n drop) of the available Qanary components.

While using the "What is the real name of Batman?" and define as first component ned-dbpedia-spotlight and as second qb-simplerealnameofsuperhero. You need to activate the components (checkboxes).

Finally, you can hit the start button.

Evaluate the computed results of your Qanary process

If everything has worked, then you will see the basic information of the now executed Qanary process (see the following screenshot for exemplary values and their representation in the Web UI):

A list of the results of the Qanary process as seen below

  • Qanary triplestore endpoint
  • Qanary question analysis ingraph
  • Qanary question analysis outgraph
  • Question URI

For now, we only use the first and the third property to evaluate the results (see the following screenshot for exemplary values and their representation in the Web UI).

Qanary triplestore endpoint and Qanary question analysis outgraph

For this purpose, go to the section "SPARQL query editor" which is an integrated Yasgui interface for querying a triplestore.

Following the given configuration, the input field needs to be filled with http://localhost:8080/sparql (which earlier listed as Qanary triplestore endpoint). In the textarea, you can insert a SPARQL query. To get only the computed DBpedia SPARQL query, you might use the following query to the Qanary triplestore:

Endpoint input field and outgraph URI after FROM in SPARQL query

Important: Keep in mind to always use the Qanary question analysis outgraph (i.e., you need to replace the part of the following SPARQL query with the value shown in your UI).

###########################################################
# get computed SPARQL query
###########################################################
PREFIX oa: <http://www.w3.org/ns/openannotation/core/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX qa: <http://www.wdaqua.eu/qa#>

SELECT ?sparql
FROM <Qanary question analysis outgraph>
WHERE {
    ?annotationId rdf:type qa:AnnotationOfAnswerSPARQL.
    ?annotationId oa:hasBody ?sparql.
}

To fetch all annotations that were computed during the last process, you might use the following SPARQL query:

###########################################################
# get all annotations
###########################################################
PREFIX oa: <http://www.w3.org/ns/openannotation/core/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX qa: <http://www.wdaqua.eu/qa#>
PREFIX dbr: <http://dbpedia.org/resource/>
SELECT *
FROM <Qanary question analysis outgraph>
WHERE {
    ?annotation rdf:type ?type .
    ?annotation oa:hasTarget ?hasTarget .
    ?annotation oa:hasBody ?hasBody .
    ?annotation qa:score ?score .
    ?annotation oa:annotatedBy ?annotatedBy .
    ?annotation oa:annotatedAt ?annotatedAt .
}

You should see the properties of the annotations that were created by the two components, including the score and the creation date (annotatedAt).

Possible Next Steps

As possible next steps, you might ...

Clone this wiki locally