marian-nmt / marian

Fast Neural Machine Translation in C++
https://marian-nmt.github.io
Other
1.25k stars 233 forks source link

How to use marian to load wmt_17 mandarin to english translations (zh-en)? #202

Closed lordzuko closed 6 years ago

lordzuko commented 6 years ago

I am trying to use the wmt_17 zh-en model. I am currently able to do translation using nematus but it's slow, now I am trying to do the same with marian, but I am unable to figure out the values of various parameters.

I am using following :


 ~/virtualenv/translation/translation$ marian/build/marian-decoder     
--type nematus   \
--models wmt17_systems/zh-en/model.l2r.ens1.npz \     
--vocabs wmt17_systems/zh-en/vocab.zh.json wmt17_systems/zh-en/vocab.en.json   \
--dim-vocabs 74791 64163    \ 
--enc-depth 1     \
--enc-cell-depth 4   \
--enc-type bidirectional    \
--dec-depth 1    \ 
--dec-cell-base-depth 8    \
 --dec-cell-high-depth 1     \
--dec-cell gru-nematus \
--enc-cell gru-nematus    \
--tied-embeddings true    \
--layer-normalization true \
-n 1 \
-b 12 \ 
-d 0 

[2018-08-07 14:21:01] [config] No model configuration found in model file
[2018-08-07 14:21:01] [config] allow-unk: false
[2018-08-07 14:21:01] [config] beam-size: 12
[2018-08-07 14:21:01] [config] best-deep: false
[2018-08-07 14:21:01] [config] clip-gemm: 0
[2018-08-07 14:21:01] [config] cpu-threads: 0
[2018-08-07 14:21:01] [config] dec-cell: gru-nematus
[2018-08-07 14:21:01] [config] dec-cell-base-depth: 8
[2018-08-07 14:21:01] [config] dec-cell-high-depth: 1
[2018-08-07 14:21:01] [config] dec-depth: 1
[2018-08-07 14:21:01] [config] devices:
[2018-08-07 14:21:01] [config]   - 0
[2018-08-07 14:21:01] [config] dim-emb: 512
[2018-08-07 14:21:01] [config] dim-rnn: 1024
[2018-08-07 14:21:01] [config] dim-vocabs:
[2018-08-07 14:21:01] [config]   - 74791
[2018-08-07 14:21:01] [config]   - 64163
[2018-08-07 14:21:01] [config] enc-cell: gru-nematus
[2018-08-07 14:21:01] [config] enc-cell-depth: 4
[2018-08-07 14:21:01] [config] enc-depth: 1
[2018-08-07 14:21:01] [config] enc-type: bidirectional
[2018-08-07 14:21:01] [config] ignore-model-config: false
[2018-08-07 14:21:01] [config] input:
[2018-08-07 14:21:01] [config]   - stdin
[2018-08-07 14:21:01] [config] interpolate-env-vars: false
[2018-08-07 14:21:01] [config] layer-normalization: true
[2018-08-07 14:21:01] [config] log-level: info
[2018-08-07 14:21:01] [config] max-length: 1000
[2018-08-07 14:21:01] [config] max-length-crop: false
[2018-08-07 14:21:01] [config] max-length-factor: 3
[2018-08-07 14:21:01] [config] maxi-batch: 1
[2018-08-07 14:21:01] [config] maxi-batch-sort: none
[2018-08-07 14:21:01] [config] mini-batch: 1
[2018-08-07 14:21:01] [config] mini-batch-words: 0
[2018-08-07 14:21:01] [config] models:
[2018-08-07 14:21:01] [config]   - wmt17_systems/zh-en/model.l2r.ens1.npz
[2018-08-07 14:21:01] [config] n-best: false
[2018-08-07 14:21:01] [config] normalize: 1
[2018-08-07 14:21:01] [config] optimize: false
[2018-08-07 14:21:01] [config] port: 8080
[2018-08-07 14:21:01] [config] quiet: false
[2018-08-07 14:21:01] [config] quiet-translation: false
[2018-08-07 14:21:01] [config] relative-paths: false
[2018-08-07 14:21:01] [config] right-left: false
[2018-08-07 14:21:01] [config] seed: 0
[2018-08-07 14:21:01] [config] skip: false
[2018-08-07 14:21:01] [config] skip-cost: false
[2018-08-07 14:21:01] [config] tied-embeddings: true
[2018-08-07 14:21:01] [config] tied-embeddings-all: false
[2018-08-07 14:21:01] [config] tied-embeddings-src: false
[2018-08-07 14:21:01] [config] transformer-aan-activation: swish
[2018-08-07 14:21:01] [config] transformer-aan-depth: 2
[2018-08-07 14:21:01] [config] transformer-aan-nogate: false
[2018-08-07 14:21:01] [config] transformer-decoder-autoreg: self-attention
[2018-08-07 14:21:01] [config] transformer-dim-aan: 2048
[2018-08-07 14:21:01] [config] transformer-dim-ffn: 2048
[2018-08-07 14:21:01] [config] transformer-ffn-activation: swish
[2018-08-07 14:21:01] [config] transformer-ffn-depth: 2
[2018-08-07 14:21:01] [config] transformer-heads: 8
[2018-08-07 14:21:01] [config] transformer-no-projection: false
[2018-08-07 14:21:01] [config] transformer-postprocess: dan
[2018-08-07 14:21:01] [config] transformer-postprocess-emb: d
[2018-08-07 14:21:01] [config] transformer-preprocess: ""
[2018-08-07 14:21:01] [config] type: nematus
[2018-08-07 14:21:01] [config] vocabs:
[2018-08-07 14:21:01] [config]   - wmt17_systems/zh-en/vocab.zh.json
[2018-08-07 14:21:01] [config]   - wmt17_systems/zh-en/vocab.en.json
[2018-08-07 14:21:01] [config] word-penalty: 0
[2018-08-07 14:21:01] [config] workspace: 512
[2018-08-07 14:21:01] [data] Loading vocabulary from Yaml/JSON file wmt17_systems/zh-en/vocab.zh.json
[2018-08-07 14:21:01] [data] Setting vocabulary size for input 0 to 74791
[2018-08-07 14:21:01] [data] Loading vocabulary from Yaml/JSON file wmt17_systems/zh-en/vocab.en.json
[2018-08-07 14:21:02] [memory] Extending reserved space to 512 MB (device gpu0)
[2018-08-07 14:21:02] No model settings found in model file
[2018-08-07 14:21:02] Loading scorer of type nematus as feature F0
[2018-08-07 14:21:02] Loading model from wmt17_systems/zh-en/model.l2r.ens1.npz
[2018-08-07 14:21:02] [memory] Reserving 1615 MB, device gpu0
贸易@@ 战 如何 影响 中国 人 的 餐桌 、 学费 和 房产

[2018-08-07 14:21:14] Requested shape shape=74791x512 size=38292992 for existing parameter 'F0::encoder_Wemb' does not match original shape shape=74791x500 size=37395500
Aborted from marian::Expr marian::ExpressionGraph::param(const string&, const marian::Shape&, const NodeInitializer&, bool) in /home/himanshu/virtualenv/translation/translation/marian/src/marian/src/graph/expression_graph.h: 325
Aborted (core dumped)

I am not sure what this error means. I have seen marian-examples and found the german to english example there, I have tried to use the same for mandarin to english also, where I am going wrong and what am I missing here ?

Best Regards, Himanshu

snukky commented 6 years ago

Please try --dim-emb 500.

For further reference:

lordzuko commented 6 years ago

@snukky Thanks it worked.