【机器翻译】【mRASP】跑通mRASP代码(一):preprocess

以作者使用的toy en-de数据集微调工作为示例,该数据集作者已经放在了experiments/example/data/raw,这里直接用

  • 首先下载代码,配置环境不再赘述,按照开源代码进行
  • 接着从linzehui/mRASP (github.com)中下载一些公开资源:Vocab; BPE Code; mRASP-PC32
  • 【机器翻译】【mRASP】跑通mRASP代码(一):preprocess_第1张图片数据集
  • 【机器翻译】【mRASP】跑通mRASP代码(一):preprocess_第2张图片模型

 能看到词表大小为32000

 【机器翻译】【mRASP】跑通mRASP代码(一):preprocess_第3张图片

 vocab和codes放在experiments/example/vocab下,需要手动新建,删掉.txt后缀

【机器翻译】【mRASP】跑通mRASP代码(一):preprocess_第4张图片

  •  之后开始改配置文件
    ${PROJECT_ROOT}/experiments/example/configs/preprocess/train_en2de.yml和${PROJECT_ROOT}/experiments/example/configs/preprocess/test_en2de.yml

 前四行的path改为:自己的项目路径/experiments/example/相应目录

subword_bpe_merge_ops改为32000

raw_data_path: /home/bit/data/ymz/mRASP-master/experiments/example/data/raw/train
merged_output_path: /home/bit/data/ymz/mRASP-master/experiments/example/merged_data/en2de
output_main_path: /home/bit/data/ymz/mRASP-master/experiments/example/data/prep/en2de/train
final_vocab_path: /home/bit/data/ymz/mRASP-master/experiments/example/vocab
configs_subdir: configs
cleaned_subdir: cleaned
logs_subdir: logs
vocab_subdir: vocab
output_subdir: output
preprocess_steps_list: clean:subword
file_prefix: train
learn: false
subword_bpe_merge_ops: 32000
pairs: en_de
directions: en2de
languages: en;de
default_pairs:
  deduplicate: false
  keep_lines_percent: '1.0'
  shuffle: false
default_langs:
  do_normalize_punctuations: true
  tokenizer: MosesTokenizer
src: en
trg: de

此时,按照作者给出的命令执行依然会报错,错误内容具体看生成的log文件

bash ${PROJECT_ROOT}/preprocess/multilingual_preprocess_main.sh ${PROJECT_ROOT}/experiments/example/configs/preprocess/train_en2de.yml

【机器翻译】【mRASP】跑通mRASP代码(一):preprocess_第5张图片

 我的问题主要出现在第二个log:提示split: 无效的块数: “

INPUT DIR: /home/bit/data/ymz/mRASP-master//experiments/example/data/prep/en2de/train/cleaned
OUTPUT DIR: /home/bit/data/ymz/mRASP-master//experiments/example/data/prep/en2de/train/output
Now have read all input data
split all data to different process
split: 无效的块数: “”
Wait all process end
All process ended
Write the output to the standard output
cat: '/mp/out/in_file*': 没有那个文件或目录
Now have read all input data
split all data to different process
split: 无效的块数: “”
Wait all process end
All process ended
Write the output to the standard output
cat: '/mp/out/in_file*': 没有那个文件或目录
SUBDIR: en_de done

问题出在mRASP-master/preprocess/tools/subword/multilingual_apply_subword_vocab.sh脚本缺少num_cpus参数,修改:

在mutiprocess_pipeline命令前加入num_cpus=2;代表两个线程执行(?) 

之后,还是这个log提示:multilingual_apply_subword_vocab.sh脚本的codes_file路径有问题

【机器翻译】【mRASP】跑通mRASP代码(一):preprocess_第6张图片

 codes_file定义如下:表明两个参数传递出了问题,我也没系统学过shell命令不太清楚原理

codes_file=${final_vocab_path}/codes.bpe.${subword_bpe_merge_ops}

但是直接简单点,把codes_file作为参数传进来好了

首先,把multilingual_apply_subword_vocab.sh脚本的codes_file定义注释,把codes_file改为第3个参数:

#!/usr/bin/env bash

input_path=$1
output_path=$2
codes_file=$3


[[ ! -d ${output_path} ]] && mkdir -p ${output_path}
# codes_file=${final_vocab_path}/codes.bpe.${subword_bpe_merge_ops}

同时,修改mRASP-master/preprocess/multilingual_preprocess_main.sh,调用multilingual_apply_subword_vocab.sh时加入第三个参数

echo "******** Only Apply BEGIN ********"
        echo "${repo_dir}/tools/subword/multilingual_apply_subword_vocab.sh"
        bash ${repo_dir}/tools/subword/multilingual_apply_subword_vocab.sh ${cleaned_path} ${output_path} ${final_vocab_path}/codes.bpe.${subword_bpe_merge_ops}  &>${logs_path}/2_preprocess_apply.log
echo "******** Only Apply ALL DONE ********"
  • 最后log提示一切正常,处理后的训练文件正常就OK了
  • 处理好的数据会出现在${merged_output_path}所指定的位置mRASP-master/experiments/example/merged_data/en2de
  • LANG_TOK_DE Un@@ s als Pol@@ itik@@ ern war jedoch klar , daß es zun@@ eh@@ men@@ de Unter@@ stüt@@ zung da@@ für ga@@ b , diese In@@ iti@@ ative bis ins Jahr 2000 fort@@ zus@@ et@@ zen .
    LANG_TOK_DE Die Probl@@ eme best@@ ehen noch immer , und dann kommen Z@@ we@@ if@@ el auf .
    LANG_TOK_DE N@@ ach Ar@@ tikel 2@@ 80 des Ver@@ tra@@ gs kann der Rat ge@@ eig@@ nete M@@ itt@@ el zur B@@ ek@@ ämp@@ f@@ ung von Bet@@ r@@ ü@@ ger@@ ei@@ en besch@@ lie@@ ßen .
    LANG_TOK_DE Herr Präsident , Herr Kom@@ miss@@ ar , wer@@ te Kol@@ leg@@ innen und Kol@@ legen ! Ich er@@ gre@@ if@@ e das W@@ ort im N@@ amen me@@ ines Kol@@ legen Robert Go@@ eb@@ bel@@ s , der w@@ egen einer polit@@ ischen Ver@@ p@@ fli@@ cht@@ ung lei@@ der nicht an@@ w@@ es@@ end sein kann .
    LANG_TOK_DE D@@ ah@@ er sind unserer M@@ ein@@ ung nach alle Ang@@ ab@@ en , die das Gener@@ al@@ sek@@ retar@@ i@@ at des R@@ ates gegen@@ w@@ är@@ tig der Ö@@ ff@@ ent@@ lich@@ keit zur Ver@@ füg@@ ung stell@@ t , die w@@ es@@ ent@@ lichen Ang@@ ab@@ en über die Arbe@@ its@@ weise des R@@ ates als Leg@@ isl@@ ativ@@ organ .
    LANG_TOK_DE Der Vor@@ sit@@ z@@ ende der Fre@@ i@@ heit@@ lichen Par@@ tei Ö@@ ster@@ reich@@ s , J@@ ör@@ g H@@ ai@@ der , hat me@@ hr@@ fa@@ ch seine Mi@@ ß@@ a@@ cht@@ ung dieser W@@ erte zum Aus@@ dru@@ ck gebracht .
    

你可能感兴趣的:(机器翻译,人工智能,自然语言处理)