2015-04-25 9 views
5

Moses - это программное обеспечение для создания моделей машинного перевода. И KenLM - это программное обеспечение модели языка defacto, которое использует moses.Как настроить модель машинного перевода с использованием огромной языковой модели?

У меня есть текстовый файл с 16 Гб текста и я использую его, чтобы построить модель языка как таковые:

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

Полученный файл (text.arpa) является равен 38. Тогда я двоичная модель языка как таковые:

bin/build_binary text.arpa text.binary 

И модель двоичному языка (text.binary) растет до 71GB.

В moses, после обучения модели перевода, вы должны настроить вес модели с помощью алгоритма MERT. И это можно сделать с помощью https://github.com/moses-smt/mosesdecoder/blob/master/scripts/training/mert-moses.pl.

MERT отлично работает с небольшой языковой моделью, но с большой языковой моделью требуется довольно много дней, чтобы закончить.

Я сделал поиск Google и нашел фильтр KenLM, которая обещает фильтровать языковую модель для меньшего размера: https://kheafield.com/code/kenlm/filter/

Но я невежественный о том, как заставить его работать. Команда помощь дает:

$ ~/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 

Но когда я попытался следующий, она застревает и ничего не делает:

$ ~/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 

Что нужно сделать, чтобы языковая модель после бинаризации? Существуют ли какие-либо другие шаги для управления большими языковыми моделями для уменьшения вычислительной нагрузки при настройке?

Каков обычный способ настройки большого LM-файла?

Как использовать фильтр KenLM?

(подробнее о https://www.mail-archive.com/[email protected]/msg12089.html)

+0

Вы уверены, что это языковая модель, которая замедляет MERT? Я довольно новичок в SMT, но по какой-то причине я ожидал бы, что размер модели перевода будет более проблематичным. И это можно исправить с помощью 'training/filter-model-given-input.pl'. – scozy

+0

Да, это большая модель языка, которая замедляет MERT. Я пробовал с различными размерами LM. – alvas

ответ

0

Ответ, как использовать filter командование KenLM

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

Примечание: что single можно заменить union или copy. Подробнее читайте в справочной системе, которая печатает, если вы запустите двоичный файл filter без аргументов.