-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAnswerTheQuestion.sh
executable file
·53 lines (42 loc) · 1.38 KB
/
AnswerTheQuestion.sh
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
47
48
49
50
51
52
53
#!/usr/bin/env bash
# set source
export PATH="/anaconda/envs/py36QA/bin:$PATH"
# alias pip=/anaconda/envs/py36/bin/pip
alias anaconda-navigator=/anaconda/bin/anaconda-navigator
export CLASSPATH=$CLASSPATH:data/corenlp/*
export BERT_BASE_DIR=MyBERT/fine_tuned/BERT_BASE/squad
export QES_JSON_DIR=MyRetrievedData/DocToRead
#change to args!
mkdir -p MyRetrievedData/retrieved
mkdir -p MyRetrievedData/DocToRead
mkdir -p MyAnswers
rm MyRetrievedData/retrieved/retrieved.json
echo "Enter Your Questions:"
read question
question=${question%\?*}
question="$question ?"
# echo $question
# question="latent allocation"
python retriever/RetrieverProcess.py MyRetrievedData/myTFIDF/SearchBase.npz "$question" 5 MyRetrievedData/retrieved/retrieved.json
python retriever/Pipeline.py MyCorpus MyRetrievedData/retrieved/retrieved.json MyRetrievedData/DocToRead/DocToRead.json "$question"
for d in $QES_JSON_DIR/*.json ;
do
xpath=${d%/*}
xbase=${d##*/}
xpref=${xbase%.*}
python MyBERT/run_squad.py \
--vocab_file=$BERT_BASE_DIR/vocab.txt \
--bert_config_file=$BERT_BASE_DIR/bert_config.json \
--init_checkpoint=$BERT_BASE_DIR \
--do_train=False \
--train_file= \
--do_predict=True \
--predict_file="$d" \
--train_batch_size=12 \
--learning_rate=3e-5 \
--num_train_epochs=2.0 \
--max_seq_length=384 \
--doc_stride=128 \
--output_dir=MyAnswers/
done
cat MyAnswers/predictions.json