Improving entity extraction from text using the lookup table feature in rasa_nlu
Switch branches/tags
Nothing to show
Clone or download
Latest commit de615df Sep 18, 2018
Failed to load latest commit information.
configs clean commit Sep 13, 2018
data clean commit Sep 13, 2018
img clean commit Sep 13, 2018
ngrams added liscence, updated readmes Sep 13, 2018
speed_test got rid of old notebook (for real) Sep 13, 2018
.gitignore clean commit Sep 13, 2018 update version number Sep 13, 2018
LICENSE.txt added liscence, updated readmes Sep 13, 2018 Update Sep 18, 2018 clean commit Sep 13, 2018 clean commit Sep 13, 2018 clean commit Sep 13, 2018

Phrase Matcher Demo

This is a simple demo of the new lookup table feature in rasa_nlu. See the blog post accompanying this repository here

The goal is to show how lookup tables may improve entity extraction under certain conditions and also give some advice on using this feature effectively.

This repo contains two demos:

  1. A simple restaurant example with very few training examples and only one entity.
  2. A medium-sized company name extraction example with a few thousand examples and several entities.

Running the demo.

No installation is necessary although you must have rasa_nlu installed and version > 0.13.3 or above.

To run one or both of the demos:

python <demo_key>

where <demo_key> is one of {food, company}. If <demo_key> is ommitted, it will run both of the demos.

Code Structure

data/ holds the training data and lookup tables for each of the demos.

models/ is where the models are persisted.

configs/ holds the rasa_nlu configs to do the baseline evaluation and the lookup table evaluation.

img/ stores plots and outputs from the runs.

Cleaning lookup tables

The script may be used to clean up lookup tables by removing any elements that match with a cross-list.

You can call this scripy by running

python <lookup_in> <cross_list> <lookup_out>

<lookup_in> is a lookup table with newline-separated elements.

<cross_list> is either a comma or newline-separated list of elements that you'd like to remove from <lookup_in>

<lookup_out> is the name of the file that you'd like to write the filtered list to.

Speed Testing

We include the directory speed_test/ for testing the speed of training as a function of the lookup table size.

This generates random lookup tables and times each component of the training and evaluation process. We use the company dataset data/company/

cd speed_test

See speed_test/ for more details.


A simple ngrams tester is included and can be run by


This loads two lookup tables, data/company/pos_ngrams.txt & data/company/neg_ngrams.txt, each containing ngrams that were found to be influential to classifying phrases as company names. We then compute the f1 score as a function of random noise injected into the entities. The 'noise' value is the probability of a character flip in each character of each company entity in the test set.

This gives the following plot