This project is made by undergraduate students from the WIDM Lab. (Web Intelligence and Data Mining Laboratory), and is the result of NCU (National Central University) CSIE dept. (Computer Science and Information Engineering department) 2023 project competition.
It has won the Outstanding Performance Award (4th place) in the department-level project competition and the Excellent Award (2nd place) in the college-level project competition.
Due to the size of data, model and checkpoints files are too large, you need to download those files and put them into the correct paths manually, and the program can execute correctly.
- data: put all files into
./legal_judgment_prediction/data
- pytorch_model.bin: put file into
./legal_judgment_prediction/bert/
- checkpoints: download the checkpoint you want and put the file into
./legal_judgment_prediction/results/Bert
Run pip install -r requirements.txt
to install all required modules.
This program has three mode: train, eval, serve.
All execution messages are saved in legal_judgment_prediction/log/Bert.log
.
python main.py --config [config_file_path] --gpu [gpu IDs] --mode [mode] \
[--checkpoint] [checkpoint_file_path] [--do_test] [--open_server]
- --config, -c [config_file_path]: The path of config file. You can use default config
./config.ini
- --gpu, -g [gpu_IDs]: The list of gpu ID. The first gpu ID starts from 0.
- --mode, -m [mode]: There are three mode: train, eval or serve.
- --checkpoint: The path of checkpoint. (eval, serve mode required)
- --do_test: If you want to do test when training, add this parameter into instruction.
- --open_server: If you want to run this service on Line-Bot, Add this parameter into instruction.
python main.py --config [config_file_path] --gpu [gpu_IDs] --mode train \
[--checkpoint] [checkpoint_file_path] [--do_test]
In this mode, program will train new checkpoints.
If you add --checkpoint [checkpoint_file_path]
into instruction, program will train new checkpoints based [checkpoint_file_path].
If you want to do test when training, add --do_test
into instruction.
python main.py --config [config_file_path] --gpu [gpu_IDs] --mode eval \
--checkpoint [checkpoint_file_path]
In this mode, program will evalute test data.
python main.py --config [config_file_path] --gpu [gpu_IDs] --mode serve \
--checkpoint [checkpoint_file_path] [--open_server]
In this mode, program can predict the accuse, article and article_source of inputting string.
If you add --open_server
into instruction, program will open Flask web server. You can use this mode with Line-Bot.
- Move to root directory
Taiwan-Criminal-Law-Interactive-Chatbot
- Revise below settings in ./config.ini
- [server]
- server_socket_IP: This can be found with command
ifconfig
. - LINE_CHANNEL_ACCESS_TOKEN: This can be found in your channel on LINE Developers.
- CHANNEL_SECRET: This can be found in your channel on LINE Developers.
- server_socket_IP: This can be found with command
- [server]
- Run ngrok with instruction
ngrok http 5000
- Edit
Webhook URL
in your channel on LINE Developers with the link generated by ngrok - Run
main.py
withserve
mode and add--open_server
parameter into instruction
Enter
shutdown
in chatroom to close whole system safely.
Enter
shutdown
in chatroom to close whole system safely (Same as Serve (simple_IO)).