This includes two different implementations to solve the Airline Travel Information System(ATIS) Named-Entity-Recognition (NER) challenge.
One implementation uses (linear chain) conditional random fields (CRF), and, more specifically, the python-crfsuite library as its basis.
The other implementation uses a single-layer LSTM leveraging Keras and Tensorflow.
The LSTM approach resulted in better performance in terms of precision and recall.
Here is an example sentence and its labels from the dataset:
Show (O) | flights (O) | from (O) | Boston (B-dept) | to (O) | New (B-arr) | York (I-arr) | today (B-depart_date.today_relative)
Download ATIS Dataset here! split 0 split 1 split 2 split 3 split 4
- Python 3.5
- virtualenv venv && source venv/bin/activate
- pip install -r requirements.txt
- Execute
python download_data.py - Execute
python -m spacy download en - Specify tensorflow as a backend of Keras in file
~/.keras/keras.json
- The python file
crf.training.pyperforms Random Grid search (optimizing F1 score) to find the best possible values for parametersc1andc2of CRF. It saves the model in a file namedbest_crf_model.pkl. If you run it again, it will overwrite thebest_crf_model.pklfile. It takes ~7 hours in ` MacBook Pro i7 16GB. - The python file
crf.evaluation.pyevaluates the latter model in terms of Precision, Recall and Sequence Accuracy Score.
- The python file
lstm.training.pytrains/evaluates a single-layer LSTM network. The weights for each epoch are stored underlstm/keras_checkpoints/. It takes a few hours in CPU at most.
Weighted Precision Score = 0.958208628893Weighted Recall Score = 0.96260056534Sequence Accuracy Score = 0.7928331466965286crf_results.txthas thorough details about the performance of CRF in this task
Weighted Precision Score = 0.972639507033Weighted Recall Score = 0.97347249402Sequence Accuracy Score = 0.8286674132138858lstm_results.txthas thorough details about the performance of LSTM in this task
Try more complicated LSTM architectures and/or use pre-trained word embeddings.