-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtranslate.sh
64 lines (45 loc) · 1.66 KB
/
translate.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
54
55
56
57
58
59
60
61
62
63
64
export CUDA_VISIBLE_DEVICES=0
export SEED=0
#You can find all supported languages abbreviation in languages_abbreviation2fullname.txt
export SRC_LANG= #SOURCE_LANGUAGE_ABBREVIATION (e.g., "en")
export TGT_LANG= #TARGET_LANGUAGE_ABBREVIATION (e.g., "zh")
export PROMPT_FILE= #PROMPT_FILE_PATH (supported file type: txt or json, e.g., "./example/en.txt")
export SAVE_PATH= #SAVE_FILE_PATH
LOG_FILE="translate_bigtrans.example.log"
export INSTRUCT="True"
export VERBOSE="True" #Whether to print the details in translation.
export CHECKPOINT_PATH= #CHECKPOINT_PATH (e.g., /PATH2BigTrans or decapoda-research/llama-7b-hf)
export TOKENIZER_PATH= #TOKENIZER_PATH (e.g., /PATH2BigTrans or decapoda-research/llama-7b-hf)
# export MODEL_TYPE="bf16"
export MODEL_TYPE="fp16" #The type of model parameters to load (e.g., ["fp16", "bf16", "fp32"])
export NUM_BEAMS=5
export MAX_TOKENS=1024
export NO_REPEAT_NGRAM_SIZE=6
export LOW_TEMPERATURE=0.01
export ADD_PARAMETERS=""
if [ "${INSTRUCT}" != "False" ];
then
ADD_PARAMETERS="--with-instruct "
fi
if [ "${VERBOSE}" != "False" ];
then
ADD_PARAMETERS="${ADD_PARAMETERS} --verbose "
fi
# beam search is deterministic
export OUT_TIME=1
python -u model/translate.py \
--model ${CHECKPOINT_PATH} \
--tokenizer-path ${TOKENIZER_PATH} \
--prompt-file ${PROMPT_FILE} \
${ADD_PARAMETERS} \
--out-file ${SAVE_PATH} \
--source-language ${SRC_LANG} \
--target-language ${TGT_LANG} \
--seed ${SEED} \
--beam-search \
--parameter-type ${MODEL_TYPE} \
--num-beams ${NUM_BEAMS} \
--times ${OUT_TIME} \
--max-tokens ${MAX_TOKENS} \
--no-repeat-ngram-size ${NO_REPEAT_NGRAM_SIZE} \
--temperature ${LOW_TEMPERATURE} 2>&1 >>${LOG_FILE}