2015-04-25 13 views
5

Moses là một phần mềm để xây dựng các mô hình dịch máy. Và KenLM là phần mềm mô hình ngôn ngữ defacto sử dụng.Làm thế nào để điều chỉnh một mô hình dịch máy với mô hình ngôn ngữ rất lớn?

Tôi có một textfile với 16GB bộ văn bản và tôi sử dụng nó để xây dựng một mô hình ngôn ngữ như vậy:

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

Các tập tin kết quả (text.arpa) là 38GB. Sau đó, tôi binarized mô hình ngôn ngữ như vậy:

bin/build_binary text.arpa text.binary 

Và mô hình ngôn ngữ binarized (text.binary) phát triển đến 71GB.

Trong moses, sau khi đào tạo mô hình dịch, bạn nên điều chỉnh trọng số của mô hình bằng cách sử dụng thuật toán MERT. Và điều này có thể được thực hiện đơn giản với https://github.com/moses-smt/mosesdecoder/blob/master/scripts/training/mert-moses.pl.

MERT hoạt động tốt với mô hình ngôn ngữ nhỏ nhưng với mô hình ngôn ngữ lớn, phải mất một vài ngày để hoàn thành.

Tôi đã làm một tìm kiếm google và tìm thấy bộ lọc KenLM, mà hứa hẹn sẽ lọc các mô hình ngôn ngữ đến một kích thước nhỏ hơn: https://kheafield.com/code/kenlm/filter/

Nhưng tôi tránh khỏi thất bại như thế nào để làm cho nó làm việc. Lệnh giúp đỡ cho:

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

Nhưng khi tôi cố gắng sau, nó bị mắc kẹt và không làm gì:

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

ta nên làm gì để mô hình ngôn ngữ sau binarization? Có các bước khác để thao tác các mô hình ngôn ngữ lớn để giảm tải tính toán khi điều chỉnh không? theo cách thông thường để điều chỉnh trên một tập tin LM lớn là

gì?

Làm thế nào để sử dụng bộ lọc KenLM không?

(thêm chi tiết về https://www.mail-archive.com/[email protected]/msg12089.html)

+0

Bạn có chắc đó là mô hình ngôn ngữ khiến MERT chậm? Tôi khá mới với SMT, nhưng vì một lý do nào đó tôi mong đợi kích thước của mô hình dịch sẽ trở nên khó khăn hơn. Và điều này có thể được sửa với 'đào tạo/lọc-mô-đun-đầu vào.pl'. – scozy

+0

Vâng, đó là mô hình ngôn ngữ lớn làm cho MERT chậm. Tôi đã thử với các kích cỡ khác nhau của LM. – alvas

Trả lời

0

trả lời làm thế nào để sử dụng filter lệnh của KenLM

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

Lưu ý: đó single có thể được thay thế với union hoặc copy. Đọc thêm trong trợ giúp đang in nếu bạn chạy mã nhị phân filter không có đối số.

Các vấn đề liên quan