-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile.run_classifier
46 lines (33 loc) · 1.73 KB
/
Makefile.run_classifier
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
TARGET_QUESTIONS_FILE := data/localgovfaq/qas/questions_in_Amagasaki.txt
TARGET_ANSWERS_FILE := data/localgovfaq/qas/answers_in_Amagasaki.txt
# Specify these
PYTHON_GPU := python
PYTHON_CPU := python
BERT_DIR := data/bert
# Japanese Pre-trained model
BERT_MODEL_DIR := data/Japanese_L-12_H-768_A-12_E-30_BPE
VOCAB_FILE := $(BERT_MODEL_DIR)/vocab.txt
BERT_CONFIG_FILE := $(BERT_MODEL_DIR)/bert_config.json
BERT_DATA_DIR :=
OUTPUT_DIR :=
TEST_TSV := $(BERT_DATA_DIR)/test.tsv
TEST_RESULT := $(OUTPUT_DIR)/test_results.tsv
TEST_ARRANGED := $(OUTPUT_DIR)/test_arranged.txt
TEST_W_EVAL := $(OUTPUT_DIR)/test_w_eval.txt
TEST_SET_FILE := data/localgovfaq/testset_segmentation.txt
JAPANESE := false
BERT_ARGS := --task_name=CQA --do_train=true --do_predict=true --data_dir=$(BERT_DATA_DIR) --vocab_file=$(VOCAB_FILE) --bert_config_file=$(BERT_CONFIG_FILE) --init_checkpoint=$(BERT_MODEL_DIR)/bert_model.ckpt --max_seq_length=128 --train_batch_size=32 --learning_rate=2e-5 --num_train_epochs=3.0 --output_dir=$(OUTPUT_DIR)
ifeq ($(JAPANESE),true)
BERT_ARGS += --japanese=true --do_lower_case=false
endif
all: $(TEST_W_EVAL)
# fine tuneing
$(TEST_RESULT):
mkdir -p $(OUTPUT_DIR) && \
ln -s $(BERT_CONFIG_FILE) $(OUTPUT_DIR)/bert_config.json && \
ln -s $(VOCAB_FILE) $(OUTPUT_DIR)/vocab.txt &&\
$(PYTHON_GPU) $(BERT_DIR)/run_classifier.py $(BERT_ARGS) 2>&1 | tee $(OUTPUT_DIR)/log.txt
$(TEST_ARRANGED): $(TEST_RESULT)
paste $(TEST_RESULT) $(TEST_TSV) | $(PYTHON_CPU) scripts/generate_evaluation_file.py --question_file $(TARGET_QUESTIONS_FILE) > $@
$(TEST_W_EVAL): $(TEST_ARRANGED)
$(PYTHON_CPU) scripts/calculate_score.py --testset $(TEST_SET_FILE) --search_result $< --target_qs $(TARGET_QUESTIONS_FILE) --target_as $(TARGET_ANSWERS_FILE) > $@ && tail -n 4 $@