NTU ADL2022-HW1
客观的
实现基于LSTM和基于GRU的方法来实现意图分类和插槽标记。
有关更多详细信息,请查看我的报告https://www.*dro*p*box.com/s/55vsj8k60jdbwqj/report.pdf?dl = 1。
环境
# If you have conda, we recommend you to build a conda environment called \"adl-hw1\" make # otherwise pip install -r requirements.in
预处理
# To preprocess intent detection and slot tagging datasets
bash preprocess.sh
意图检测
火车
python train_intent.py --data_dir < data_dir > --cache_dir < chche_dir > --ckpt_dir < ckpt_dir > --max_len < max_len > --hidden_size < hidden_size > --num_layers < num_layers > --dropout < dropout > --bidirectional < bidirectional > --lr < lr > --batch_size < batch_size > --device < device > --seed < seed >
- data_dir :数据集的目录。
- CACHE_DIR :预处理缓存的目录。
- CKPT_DIR :保存模型文件的目录。
- max_len :最大长度的数量。
- hidden_size :rnn隐藏状态昏暗。
- num_layers :图层数。
- 辍学:型号辍学率。
- 双向:模型是否为双向
- LR :优化器学习率。
- batch_size :批次大小的数量。
- 设备:选择您的设备(CUDA,CPU,CUDA:0或…)。
- 种子:种子数。它做出预测可以复制。
输出CSV
python test_intent.py --test_file < test_file > --cache_dir < chche_dir > --ckpt_path < ckpt_path > --pred_file < pred_file > --max_len < max_len > --hidden_size < hidden_size > --num_layers < num_layers > --dropout < dropout > --bidirectional < bidirectional > --lr < lr > --batch_size < batch_size > --device < device >
- test_file :测试文件的路径。
- CACHE_DIR :预处理缓存的目录。
- ckpt_path :模型检查点的路径。
- pred_file :perdict文件路径。
- max_len :最大长度的数量。
- hidden_size :rnn隐藏状态昏暗。
- num_layers :图层数。
- 辍学:型号辍学率。
- 双向:模型是否为双向
- batch_size :批次大小的数量。
- 设备:选择您的设备(CUDA,CPU,CUDA:0或…)。
重现我的结果(在Kaggle上公开:0.91466)
bash download.sh bash intent_cls.sh /path/to/test.json /path/to/pred.csv
插槽标记
火车
python train_slot.py --data_dir < data_dir > --cache_dir < chche_dir > --ckpt_dir < ckpt_dir > --max_len < max_len > --hidden_size < hidden_size > --num_layers < num_layers > --dropout < dropout > --bidirectional < bidirectional > --lr < lr > --batch_size < batch_size > --device < device > --seed < seed >
- data_dir :数据集的目录。
- CACHE_DIR :预处理缓存的目录。
- CKPT_DIR :保存模型文件的目录。
- max_len :最大长度的数量。
- hidden_size :rnn隐藏状态昏暗。
- num_layers :图层数。
- 辍学:型号辍学率。
- 双向:模型是否为双向
- LR :优化器学习率。
- batch_size :批次大小的数量。
- 设备:选择您的设备(CUDA,CPU,CUDA:0或…)。
- 种子:种子数。它做出预测可以复制。
输出CSV
python test_slot.py --test_file < test_file > --cache_dir < chche_dir > --ckpt_path < ckpt_path > --pred_file < pred_file > --max_len < max_len > --hidden_size < hidden_size > --num_layers < num_layers > --dropout < dropout > --bidirectional < bidirectional > --lr < lr > --batch_size < batch_size > --device < device >
- test_file :测试文件的路径。
- CACHE_DIR :预处理缓存的目录。
- ckpt_path :模型检查点的路径。
- pred_file :perdict文件路径。
- max_len :最大长度的数量。
- hidden_size :rnn隐藏状态昏暗。
- num_layers :图层数。
- 辍学:型号辍学率。
- 双向:模型是否为双向
- batch_size :批次大小的数量。
- 设备:选择您的设备(CUDA,CPU,CUDA:0或…)。
复制我的结果(Kaggle上的公共:0.82252)
bash download.sh bash slot_tag.sh /path/to/test.json /path/to/pred.csv
参考
NTU-ADL-TA/ADL21-HW1
