Skip to main content

Reusable Intent and Slot-filling tool

Project description

Intent and Slot-filling on the ATIS dataset task.

Model architecture

For this task, a model was trained to jointly predict a sentence's Intent and Slots (entities). Each word is embedded (using pre-defined word vectors) to capture the word's meaning while a character-level bidirection Long Short-Term Memory(LSTM) Network encodes the word's letters to capture its lexical structure.

The word vector and outputs of the character-level bi-LSTM are then fed into the word-level bi-LSTM which predicts the Intent. The second layer feeds into a Conditional Random Fields (CRF) layer to predict the individual slots (entities).

The model is stored in intents_slots/model.py

Word Vectors

The newly released Poincare word embeddings (100 dimensional) were used as they have been reported to better encode the hierarchical relationships inherent between words you can find the word vectors used in word_vectors/poincare.txt

Demo

you can run a demo of the pre-trained model by running intents_slots/demo.py

Training

The model was trained for 50 epochs and stored in the pretrained_models directory

  • pretrained_models/dataset_info contains all the vocabularies used by the model (character, word, intent, entity) and their mappings to numbers for encoding/decoding
  • pretrained_models/model.h5 are the weights to the model

The model's loss during training over the epochs are shown below:

The model's accuracy at predicting intents and entities (slots) over time are shown below:

You can retrain the model by running intents_slots/train.py

Tests

Joint:

Intents only:

Entites only:

to above results can be obtained by running intents_slots/evaluate.py

Improvements:

To improve the robustness of the model to out of vocab words, the training data was lemmatised prior to training and the model was retrained. Numbers were also masked using a placeholder (e.g. *) to avoid out-of-vocab times appearing (e.g. 9:30 may appear in training but not 9:29).

The results were slightly improved given the above tweaks. Precision, Recall and F1 scores improved across the board (for both intents, entities).

Perfect scores were achieved using the validation set!?? data/atis-2-dev.csv

Future Improvements (TO DO):

  • Balance out training data (its clear that the intent ATIS_FLIGHT dominates the training set)

(and 'O' dominates the entity tags)

(or if we discount this as an entity tag - then "to/fromloc.city_name" tags)

  • e.g. this can be achieved by subsampling or artificially perterbing data to generate more samples (e.g. increase training instance by sliding each sentences one,two,three,etc places)

  • Investigate the Intents & Entities which are scoring relatively low F1 scores

e.g. (intents such as ATIS_DAY_NAME, ATIS_MEAL, ATIS_FLIGHT_TIME, etc)

e.g. (entities such as compartment, booking_class, meal_code, etc)

  • Preprocess intent labels with #?
  • Embed unknown words too (if possible) rather than giving them (1)
  • convert word numbers (e.g. "one") into digits
  • improve slot extraction using additional pre-trained Named Entity Recognition (NER)s from various libraries

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

slize-0.0.19.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

slize-0.0.19-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file slize-0.0.19.tar.gz.

File metadata

  • Download URL: slize-0.0.19.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.3

File hashes

Hashes for slize-0.0.19.tar.gz
Algorithm Hash digest
SHA256 a0acdc6d9e84f54313f405906c2c369df6c3b41e689db1854f8a267edd615288
MD5 2271c6fb65c834326ba642e7ac8f8d6f
BLAKE2b-256 6c7aa1b5b7f6fe4ffd7d76d1ad95c3b23f7c4d3f24d2abe8ce6a552fb032d791

See more details on using hashes here.

File details

Details for the file slize-0.0.19-py3-none-any.whl.

File metadata

  • Download URL: slize-0.0.19-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.3

File hashes

Hashes for slize-0.0.19-py3-none-any.whl
Algorithm Hash digest
SHA256 2af2bd5b6a95aa0a14fecb8311b5b25f85630695ad3133f3e37e01098eb9f30a
MD5 9fd70756920f0112b98819d3ab53cb86
BLAKE2b-256 17874b11647145e1a75be4ab23a53fc21e7b0e784fbe78286b4a16c05ed8c185

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page