2015-04-25 5 views
5

Moses ist eine Software zum Erstellen von Maschinenübersetzungsmodellen. Und ist die defacto Sprachmodell-Software, die moses verwendet.Wie wird ein maschinelles Übersetzungsmodell mit einem großen Sprachmodell optimiert?

Ich habe eine Text-Datei mit 16 GB Text und ich verwende es ein Sprachmodell als solches zu bauen:

bin/lmplz -o 5 <text > text.arpa 

Die resultierende Datei (text.arpa) ist 38GB. Dann binarisiert ich das Sprachmodell als solche:

bin/build_binary text.arpa text.binary 

Und das digitalisierte Sprachmodell (text.binary) wächst zu 71GB.

In moses, nach dem Training des Übersetzungsmodells, sollten Sie die Gewichte des Modells mithilfe von MERT Algorithmus abstimmen. Und das kann einfach mit https://github.com/moses-smt/mosesdecoder/blob/master/scripts/training/mert-moses.pl getan werden.

MERT funktioniert gut mit kleinen Sprachmodell, aber mit dem großen Sprachmodell dauert es einige Tage bis zum Ende.

habe ich eine Google-Suche und KenLM des Filters gefunden, die das Sprachmodell auf eine kleinere Größe zu filtern verspricht: https://kheafield.com/code/kenlm/filter/

aber ich bin ratlos, wie es funktioniert. Der Befehl help gibt:

$ ~/moses/bin/filter 
Usage: /home/alvas/moses/bin/filter mode [context] [phrase] [raw|arpa] [threads:m] [batch_size:m] (vocab|model):input_file output_file 

copy mode just copies, but makes the format nicer for e.g. irstlm's broken 
    parser. 
single mode treats the entire input as a single sentence. 
multiple mode filters to multiple sentences in parallel. Each sentence is on 
    a separate line. A separate file is created for each sentence by appending 
    the 0-indexed line number to the output file name. 
union mode produces one filtered model that is the union of models created by 
    multiple mode. 

context means only the context (all but last word) has to pass the filter, but 
    the entire n-gram is output. 

phrase means that the vocabulary is actually tab-delimited phrases and that the 
    phrases can generate the n-gram when assembled in arbitrary order and 
    clipped. Currently works with multiple or union mode. 

The file format is set by [raw|arpa] with default arpa: 
raw means space-separated tokens, optionally followed by a tab and arbitrary 
    text. This is useful for ngram count files. 
arpa means the ARPA file format for n-gram language models. 

threads:m sets m threads (default: conccurrency detected by boost) 
batch_size:m sets the batch size for threading. Expect memory usage from this 
    of 2*threads*batch_size n-grams. 

There are two inputs: vocabulary and model. Either may be given as a file 
    while the other is on stdin. Specify the type given as a file using 
    vocab: or model: before the file name. 

For ARPA format, the output must be seekable. For raw format, it can be a 
    stream i.e. /dev/stdout 

Aber wenn ich folgendes versucht, wird es fest und tut nichts:

$ ~/moses/bin/filter union lm.en.binary lm.filter.binary 
Assuming that lm.en.binary is a model file 
Reading lm.en.binary 
----5---10---15---20---25---30---35---40---45---50---55---60---65---70---75---80---85---90---95--100 

Was soll man nach Digitalisierungs auf das Sprachmodell tun? Gibt es noch andere Schritte, um große Sprachmodelle zu manipulieren, um die Rechenlast beim Abstimmen zu reduzieren?

Was ist der übliche Weg, um eine große LM-Datei abzustimmen?

Wie benutzt man den KenLM Filter?

(weitere Details über https://www.mail-archive.com/[email protected]/msg12089.html)

+0

Sind Sie sicher, dass es das Sprachmodell ist, das MERT langsam macht? Ich bin ziemlich neu in SMT, aber aus irgendeinem Grund würde ich erwarten, dass die Größe des Übersetzungsmodells problematischer ist. Und dies kann mit 'training/filter-model-given-input.pl' behoben werden. – scozy

+0

Ja, es ist das große Sprachmodell, das MERT langsam macht. Ich habe es mit verschiedenen Größen von LM versucht. – alvas

Antwort

0

Answering wie filter Verwendung des Befehls von KenLM

cat small_vocabulary_one_word_per_line.txt \ 
    | filter single \ 
     "model:LM_large_vocab.arpa" \ 
      output_LM_small_vocab. 

Hinweis: dass single mit union oder copy ersetzen werden. Lesen Sie mehr in der Hilfe, die gedruckt wird, wenn Sie die filter-Binärdatei ohne Argumente ausführen.

Verwandte Themen