Question: Q 2 . Slot Filling Algorithm: Code [ 2 0 ] In this question, you will learn to implement the slot - filling algorithm using

Q2. Slot Filling Algorithm: Code [20]
In this question, you will learn to implement the slot-filling algorithm using LSTM. You can use Keras, PyTorch, or TensorFlow to build the model. You are provided with 3 files: atis.train.csv, atis.test.csv, atis.val.csv for this task.
1. Load atis.train.csv provided for training your model and atis.test.csv provided for testing the model in a DataFrame. Load atis.val.csv as validation data for your model. You need to use tokens and slots columns only.
2. Tokenize both columns and create a vocabulary of all words in tokens column and count the number of slots in slots column (including slot '0').
3. Create a dictionary with the word as a key and a unique index for the word as a value (index starting with 1). Create another dictionary with the given index as a key and the word as the value. Create a dictionary with a slot label as the key and index as the value (index starting with 0).
4. Convert the words in all the sentences of the corpus to their respective index. Find the maximum sequence length of the corpus and pad each sentence with 0 such that the length of each input vector is the same as the maximum sequence length. Execute the same data preprocessing tasks for test and validation sets.
5. Build a model using layers: Embedding, LSTM, Dense layers, TimeDistributed layer, and softmax activation function.
6. Train the model with input of the index vector generated in step 4 and hyper-parameters of your choice. Tune the model on the validation set. To calculate the loss, use the index vector of the labels and the Softmax output of the model. You may use cross-entropy loss for this purpose. Report the F-score, precision, and recall on the test set.
Q 2 . Slot Filling Algorithm: Code [ 2 0 ] In

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!