Question: Q 2 . Slot Filling Algorithm: Code [ 2 0 ] In this question, you will learn to implement the slot - filling algorithm using
Q Slot Filling Algorithm: Code
In this question, you will learn to implement the slotfilling algorithm using LSTM You can use Keras, PyTorch, or TensorFlow to build the model. You are provided with files: atis.train.csv atis.test.csv atis.val.csv for this task.
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.
Tokenize both columns and create a vocabulary of all words in tokens column and count the number of slots in slots column including slot
Create a dictionary with the word as a key and a unique index for the word as a value index starting with 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
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 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.
Build a model using layers: Embedding, LSTM Dense layers, TimeDistributed layer, and softmax activation function.
Train the model with input of the index vector generated in step and hyperparameters 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 crossentropy loss for this purpose. Report the Fscore, precision, and recall on the test set.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
