AD Research Wiki:

Everything about the Broccoli project. To restart the latest instance, only the very first section is relevant.

Note that (re-)building a (fresh) Wikipedia+FBEasy index is different from setting up an index for different data. This is because our UIMA chain contains steps that use data specific to that input and that would have to be emulated for other collections. For different collections, it's usually better to bypass the whole UIMA chain and produce a words- and docs-file by hand. Both approaches are described below.

Current Broccoli deployment on filicudi

The current deployment is a clone of https://ad-git.informatik.uni-freiburg.de/ad/broccoli-deployment.git It is started using gantry and has restart: unless-stopped set.

filicudi:/local/data/broccoli$ gantry

To create a new deployment run the following command:

git clone --recursive https://ad-git.informatik.uni-freiburg.de/ad/broccoli-deployment.git
cd broccoli-deployment

# These two require that freebase is build first
gantry build -i yago -i freebase-easy
gantry build

#Copy the relevant data from {{{filicudi

# Copy www-data scp -r filicudi:/local/data/broccoli/proxy/www/broccoli/repro-cikm2013 ./proxy/www/broccoli scp -r filicudi:/local/data/broccoli/proxy/www/broccoli/repro-corr ./proxy/www/broccoli scp -r filicudi:/local/data/broccoli/proxy/www/broccoli/repro-ecir2014 ./proxy/www/broccoli scp -r filicudi:/local/data/broccoli/proxy/www/broccoli/repro-ki2018 ./proxy/www/broccoli scp -r filicudi:/local/data/broccoli/proxy/www/broccoli/repro-ki2018-qlever ./proxy/www/broccoli scp -r filicudi:/local/data/broccoli/proxy/www/broccoli/repro-vldb2013 ./proxy/www/broccoli scp -r filicudi:/local/data/broccoli/proxy/www/broccoli/repro-wsdm-cup-2017 ./proxy/www/broccoli

# Copy indices scp -r filicudi:/local/data/broccoli/yago-backend/index ./freebase-backend/index scp -r filicudi:/local/data/broccoli/yago-backend/index ./yago-backend/index

# Start deployment gantry }}}

Current Broccoli version (OLD!)

Built by Björn beginning of August 2016, Wikipedia version from August 2016 (2.8B postings), latest Freebase dump (freebase-rdf-latest, 372M statements extracted a la Freebase Easy).

Start the service on elba (via docker, NEW 13.11.2018)

ssh <user>@elba
cd /local/data1/broccoli-docker/build
[sudo] docker build -f Dockerfile.backend -t broccoli-backend .
[sudo] docker run -d --restart=unless-stopped -p 6002:6002 \
  -v /local/data2/broccoli/wikipedia+freebase.26-09-2016/:/data/ \
  --name broccoli-backend broccoli-backend \
  ./server/ServerMain \
    -p 6002 \
    -o /data/semantic-wikipedia-full-jul16-ontology \
    -m /data/semantic-wikipedia-full-jul16-ontology.url-mapping \
    -t /data/triple-scores.14oct \
    -s /data/semantic-wikipedia.stop-words \
    -c /data/custom-scores.txt \
    /data/semantic-wikipedia-full-jul16

Note: this is just a clone of https://ad-git.informatik.uni-freiburg.de/ad/broccoli-docker

TODO: The Dockerfile.backend already has an entry point CMD ["sh", "-c", "make start PORT=6001 DATA_DIRECTORY=/data DBTAIL=$DBTAIL"], this can probably made to work by renaming a few files.

TODO: Currently no permanent log, we couldn't get the "> /data/server-log.date +%Y-%m-%d" to work "inside" the container (escaping the > didn't work either).

TODO: Docker has a health check feature (that checks, via an arbitrary command, whether a service is still functioning) and the ability to restart the service if the health check fails.

Start the service on elba (via start.sh)

Accessible under http://broccoli.informatik.uni-freiburg.de

ssh bast@elba
tmux attach -t broccoli || tmux new -s broccoli
Ctrl+B :setw -g mode-mouse on
cd /local/data2/broccoli/wikipedia+freebase.26-09-2016
./start.sh
Ctrl+B+D

The script contains all files as variables. Changing something (e.g. other custom scores or triple scores should be self explanatory).

For reference (btw: I have no idea how to write proper shellscrips, don't judge :-) ) NOTE: The snippet below is simply for references w.r.t. how to change some files. The most up-to-date version is the one on elba.

 #!/bin/bash

dir='/local/data2/broccoli/16-09-26/'
binary='ServerMain.2017-02-13'

index='semantic-wikipedia-full-jul16'
kbsuffix='-ontology'
kb=$index$kbsuffix
port='6002'

stopwords='semantic-wikipedia.stop-words'
triplescores='triple-scores.14oct'
mapping='semantic-wikipedia-full-jul16-ontology.url-mapping'
customscores='custom-scores.txt'

date=`date +%Y-%m-%d`
log="server-log.$date"

call=$dir$binary
args=(-p $port -o $dir$kb -m $dir$mapping -t $dir$triplescores -s $dir$stopwords -c $dir$customscores $dir$index)

echo "Starting broccoli instance and writing output into $dir$log"
echo "Starting now will be available within the minute."
$call "${args[@]}" > $dir$log &

Start Broccoli YAGO on elba

Similar to the "normal" Broccoli version, just start like:

cd /local/data1/broccoli/broccoli-yago
./start.sh

Building a new version is complicated. Best go back to svn revision r1438.

Deploy a user interface

You need a tomcat installed on the server where the UI should be running. On the machine from where you want to compile and deploy the UI, you need several jar files and their paths set correctly. This can be done by hand but is easiest if ant and also tomcat are installed. Also /nfs/raid5 has to be mounted there. Filicudi always works well for me.

Then go to

<broccoli-code-dir>/userinterface

Edit two files: build.properties and war/server_properties.xml

In build.properties, adjust the proeprties "warfile.name=" (Name of the UI instance) and "manager.url=" (adjust the server on which it should be deployed) In server_properties.xml just set the correct backend host and port.

Then run

  ant war deploy

  ant war redeploy

To deploy a UI for Broccoli Yago, go back to svn revision 1438 and do the same.

Data

The intermediate files of the August 2016 version can be found in /nfs/raid5/buchholb/semantic-wikipedia-data

Code

Code is in https://ad-websvn.informatik.uni-freiburg.de/broccoli/. The Code for CSD is in the subfolder: https://ad-websvn.informatik.uni-freiburg.de/broccoli/nlp/

Preparation

Install required dependencies. On a Ubuntu system, this should be all that is required:

    sudo apt install libboost-dev libboost-regex-dev libstxxl-dev libsparsehash-dev

Compilation

make all -j

Ignore possible lint problems.

Known functionality issues

Known installation issues

STXXL: Currently broccoli depends on STXXL version <= 1.3.1. You can get version 1.3.1 via

git clone --branch 1.3.1 https://github.com/stxxl/stxxl.git

To make STXXL compile in UNIX systems edit /utils/mlock.cpp in the STXXL root and add

#include <ctime>
#include <cerrno>

and replace sleep(864000); in /utils/mlock.cpp:34 by

nanosleep((const struct timespec[]){{0, 864000L}}, NULL);

Now run

make config_gnu

eventually adjust the generated make.settings.local file. Now you can compile STXXL with

make library_g++

Adjust the path to the stxxl.mk file in broccoli/paths.mak

STXXL_CONFIG   = <path to your local stxxl root>/stxxl.mk

Docker setup

Axel has started working on a Docker setup. There are three parts: (1) use Broccoli to build an index from given words and docs and knowledge base files; (2) start a Broccoli backend using such an index and deploy a Broccoli UI via Tomcat; (3) run the extensive pipeline to produce the various files needed to build an index.

Axel has managed to enable a Docker setup for (1) and (2). This required the idenfitication and change of many hard-coded paths in the files from the Broccoli SVN.

Usage

The current version of Axels files are available under vulcano:/local/raid/ad/broccoli-docker. There you find the following files and sub-directories

docker-compose.yml                  # For building and running everything easily
build                               # The various Dockerfiles and the Broccoli code
data                                # The input files for the index builder and the built index files

Use the following commands for building and running:

docker-compose build                # Builds broccoli:index-builder, broccoli:backend, broccoli:frontend
docker-compose up                   # Creates the containers for all three images and starts them in concert
docker-compose up index-builder     # Same, for only the index builder.
docker-compose up backend           # Same, for only the backend.
docker-compose up frontent          # Same, for only the frontend.
docker-compose up -d                # Same, but running in the background (as a "demon")
docker-compose down                 # The opposite of docker-compose up
docker-compose [start|stop]         # Start or stop the containers

The containers can also be run explicitly with docker run, for example:

docker run -v /local/raid/ad/broccoli-docker/data:/data -e DBTAIL=example broccoli:index-builder

Build a Wikipedia+FBEasy Index from scratch

First, obtain a Wikipedia XML and a Freebase dump (usually stored in /nfs/raid5/broccoli/...) and make sure the correct files are referenced in broccoli/Makefile and broccoli/freebase/Makefile. Give a proper name to your index using the variable DBTAIL in broccoli/Makefile

Create ontology.txt

If you use an existing RDF3X DB (as usually the case), make sure it is referenced correctly in broccoli/freebase/Makefile and only run (inside the broccoli folder):

    make get-freebase-ontology

Otherwise run:

    make -C freebase/ build-db
    make get-freebase-ontology

Create cas0.zip

This is the first of two parts of our UIMA Chain. For an explanation see Broccoli Uima. In this first step, the Wikipedia XML is parsed (from XML to a UIMA model), text is tokenized and parse trees are constructed. Since running an off-the-shelf parser is computationally expensive, this part uses the asynchronous scale-out and is run on many of our machines.

Make sure all paths are set correctly in paths.mak

on FILICUDI!! (if you want to start the broker elsewhere, the Makefile has to be adjusted), run in the broccoli/ folder:

    make deploy-broker

Then, on the server you want to have the reader and writer (the "main" part), run

    make deploy-reader

To get things going run the following on as many PC's (and servers) as possible

    make deploy-senna

Create a broccoli index

Make sure to copy/move or reference the cas0.zip you built in broccoli/Makefile then run

    make build-txt build-index

The first target calls the second part of our UIMA chain. It performs entity recognition and our NLP (CSD) and then writes a words- and a docs-file. The second target builds all necessary binary indices (and files like vocabularies) from that words- and docs-file.

Start the server

    make start PORT=<PORT>

Set up a Broccoli instance for different data

With parts of our chain

Understand the process above and the UIMA framework (see official documentation) and modify accordingly.

From scratch

There is a special folder broccoli/example-data now that has files that can be used as a blue-print for your own data. Produce the following files:

1. A Knowledge Base file, name: $(DBTAIL)-ontology.txt

Tab-separated, one line per triple: subject<TAB>predicate<TAB>object<TAB>. For example broccoli/example-data/example-ontology.txt:

Björn Buchhold  is-a    PhD Student     .
Björn Buchhold  is-a    Person  .
Björn Buchhold  Country of nationality  Germany .

Values use XML Schema notation, e.g.:

Some Song    Length    "19.0"^^<http://www.w3.org/2001/XMLSchema#float>    .

IMPORTANT: The name has to end with -ontology.txt and there has to be at least one triple with a relation is-a and one triple with some other relation (for historical, technical reasons).

2. A file with text postings, named: $(DBTAIL).words-by-contexts.txt

Tab-separated, one line per posting. word<TAB>contextId<TAB>score<TAB>position, entities use underscores for spaces and are prefixed with :e:, e.g.:

this                    1       1       0
is                      1       1       1
just                    1       1       2
an                      1       1       3
example                 1       1       4
I                       2       5       0
:e:Björn_Buchhold       2       5       0
hope                    2       1       1
it                      2       1       2
helps                   2       1       3

3. A file with with info to display for hits, named: $(DBTAIL).docs-by-contexts.txt

Tab-separated, one line per context. contextId<TAB>URL<TAB>Title<TAB>Text to display (positions from wordsfile are separated by @@)<TAB>Which positions belong to the context (used for grey vs black highlighting in the UI)<TAB>context-range (in terms of position for grey/black highlighting in the UI)<TAB>parse-tree<TAB>all-context-boundaries-in-sentence.

The last three columns can be filled with dummy/empty information (contexts 0-maxpos, empty parse tree). The number of tabs must remain the same, though. Maybe the UI needs to be adjusted with an empty parse tree.

See the example.docs-by-contexts.txt for somethind that is rather easy to understand (context 1 has positions 0-5, context 2 has positions 0-3):

1       Example_Document        http://example.com      This@@ is@@ just@@ an@@ example@@.      0-5     NoParseTree     0-5
1       Example_Document        http://example.com      I@@ hope@@ it@@ helps@@.        0-3     NoParseTree     0-3

For real-world data with parse-tree information, this can get quite complex (see first sentence in the normal Broccoli data):

1       http://en.wikipedia.org/wiki/Alain_Connes       Alain Connes    Alain Connes@@ (@@;@@ born@@ 1@@ April@@ 1947@@)@@ is@@ a@@ French@@ mathematician@@,@@ currently@@ Professor@@ at@@ the@@ Collège de France@@,@@ IHÉS@@,@@ The Ohio State University@@ and@@ Vanderbilt University@@.  0-1,7-11,13-17  0_Alain_NNP_*_(S1,(S,(NP_(ENUM,(C,(CH 0_Connes_NNP_*_)_) 1_(_*_*_*_* 2_;_:_*_(S1,(NP_(C* 3_born_VBN_*_(NP_* 4_1_CD_*_*_* 5_April_NNP_*_*_* 6_1947_NN_*_),),)_) 7_)_*_*_*_* 8_is_VBZ_*_(VP_* 9_a_DT_*_(NP,(NP_* 10_French_JJ_*_*_* 11_mathematician_NN_*_)_* 12_,_,_*_*_* 13_currently_RB_*_(ADVP,)_* 14_Professor_NNP_*_(NP,(NP,)_* 15_at_IN_*_(PP_* 16_the_DT_*_(NP,(NP_(ENUM,(C 17_Collège_NNP_*_*_* 17_de_IN_*_*_* 17_France_NNP_*_)_) 18_,_,_*_*_* 19_IHÉS_NNP_*_(NP,)_(C,) 20_,_,_*_*_* 21_The_DT_*_(NP_(C 21_Ohio_NNP_*_*_* 21_State_NNP_*_*_* 21_University_NNP_*_)_) 22_and_CC_*_*_* 23_Vanderbilt_NNP_*_(NP_(C 23_University_NNP_*_),),),),),)_),) 24_._._*_),)_),)    0-1,7-11,13-17;0-1,7-11,13-15,19-19;0-1,7-11,13-15,21-21;0-1,7-11,13-15,23-23;0-0,3-6

4. Create the following empty files

Fill them with actual data if you have it available. It works with empty files (see example-data)

touch $(DBTAIL)-ontology.entity-scores.noabs
touch $(DBTAIL)-ontology.name-mapping
touch $(DBTAIL)-ontology.reverse-relations

Build an index

Call make build-index and set the variables DATA_DIRECTORY and DBTAIL:

make build-index DATA_DIRECTORY=/home/buchholb/broccoli/example-data DBTAIL=example

Start a server instance

Call make start and set the variables PORT, DATA_DIRECTORY and DBTAIL:

make start PORT=6001 DATA_DIRECTORY=/home/buchholb/broccoli/example-data DBTAIL=example

Deploy a user interface (to a tomcat webserver)

Go to

cd broccoli/userinterface

edit the files with your data (adjust: instance name, Tomcat location, maybe username+password, server, port)

vim build.properties
vim war/server_properties.xml

compile and deploy

ant build war deploy

Testing if everything works

If you used the files in example-data, a query for PhD-Student occurs-with helps should yield a result.

Image Service

Basic procedure

In a nutshell, the Broccoli image service works as follows:

1. For each hitgroup (= entity), the JavaScript code of the frontent sends a POST request with the following URL and payload (the format of the payload is something GWT does).

http://<hostname>:8080/Broccoli/broccoli/wikipediaImage

7|0|7|http://vulcano.informatik.privat:8080/Broccoli/broccoli/|4CF27DDA2D936B5A841B0681EFD6AC13|de.uni.freiburg.broccoli.client.service.WikipediaImageService|getImageURL|java.lang.String/2004016611|Björn_Buchhold|m/0hkxq|1|2|3|4|2|5|5|6|7|

2. Note the Freebase ID m/0hkxq in the payload next to the entity name Björn_Buchhold. This is simple generated from the URL of the hit group in lines 906+ of the file userinterface/src/de/uni/freiburg/broccoli/client/ui/HitsPanel.java. The current functionality is simply to look whether there is a suffix starting with /m/ and then take the suffix m/... as image id.

String freebaseMId = null;
int mIdIndex = hitGroup.getUrl().lastIndexOf("/m/");
if (mIdIndex > 0) {
   freebaseMId = hitGroup.getUrl().substring(mIdIndex + 1); 
   if (freebaseMId.length() <= 2) { freebaseMId = null; }
}

Note: if there is no file <basename>-ontology.url-mapping, then the URLs are simply of the form https://en.wikipedia.org/wiki/Björn_Buchhold. TODO: find out where these URLs are constructed in Broccoli.

2. The answer (from the Java Code of the GWT frontend) looks as follows. The respective code is in line 69 of the file userinterface/src/de/uni/freiburg/broccoli/server/WikipediaImageServiceImpl.java (again, the format is something GWT does).

//OK[1,["../wpthumbsvc.php?id\x3Dm/0hkxq"],0,7]

3. Now the JavaScript code inserts the following element into the DOM tree (which is then shown as the respective image on the right side of the respective hit group).

<img src="../wpthumbsvc.php?id=m/0hkxq" class="gwt-Image">

Image Cache

The image cache service of the current instance (on elba) runs on filicudi. It is located under /var/www/freebase-imgsvc. It is simply a checkout of http://ad-svn.informatik.uni-freiburg.de/broccoli/freebase-imgsvc/.

The actually directory where the images are cached is located at /nfs/raid5/broccoli/freebase-thumb-cache.

NEW 22-03-2017: Robin Krahl has written a new version of the script wpthumbsvc.php that asks the Mediawiki API of the English Wikipedia. The script greps the file /nfs/raid5/broccoli/freebase-thumb-cache.mid-to-wikipedia.unique-mids, which contains the last mid from the file freebase-thumb-cache.mid-to-wikipedia and the corresponding Wikipedia name (this is usally the canonical Wikipedia name of the entity).

To add individual images (for demos, needs access to raid so it can write to cache folder, and img has to have a file extension for convert to work, tested on filicudi, does not work on stromboli because code requires Python version >= 3.3):

python3 ~/broccoli/img-hack/image_to_cache.py --mid <MID> --img 'http://...'

Image Service

Florians code has a mechanism for removing outdated images, which also removes images in the cache which now return a 404 not found (which effectively removes all images from the cache after the shutdown of the Freebase API). This should be corrected. Here is the guilty piece of code from https://ad-websvn.informatik.uni-freiburg.de/broccoli/freebase-imgsvc/fbthumbsvc.php:

// If no image could be found (404 error) create a 404 cache file for the
// current id, return a 404 error and end the script.
if ($return_status_code == 404)
{
  // If there still was an expired cache file then remove it now!
  if ($cachefile_exists)
  {
      unlink($cachefile_path);
  }

  // Create a 404 cache file for the current id.
  touch($cachefile_path . '_404');
 
  returnMissingError();
}

Mediator Only Index (CIKM)

An index that contains mediators (used for the CIKM presentation) is available in /nfs/raid5/haussmae/demos/broccoli_mediators_no_text

to start (on filicudi, port 7099, should work as any user that can read the files):

/home/haussmae/demos/broccoli_mediators_no_text/ServerMain -p 7099 -o /home/haussmae/demos/broccoli_mediators_no_text/semantic-wikipedia-scientists-ontology -s /home/haussmae/demos/broccoli_mediators_no_text/semantic-wikipedia.stop-words /home/haussmae/demos/broccoli_mediators_no_text/semantic-wikipedia-scientists -m /home/haussmae/demos/broccoli_mediators_no_text/semantic-wikipedia-scientists-ontology.url-mapping

The user interface for backend filicudi:7099 is available at http://filicudi.informatik.uni-freiburg.de:6222/BroccoliCIKM (no UI hack) and http://filicudi.informatik.uni-freiburg.de:6222/BroccoliCIKM2 (UI hack). The UI hack makes specific mediator names readable in the query graph (and only there). The hack adjusts the nameLabel variable in the File src/de/uni/freiburg/broccoli/client/ui/BreadcrumbLabel.java of userinterface (in the broccoli respository).

AD Research Wiki: Projects/Broccoli (last edited 2019-09-05 13:56:28 by Axel Lehmann)