mosesdecoder/lm
2012-05-31 12:55:05 +01:00
..
bhiksha.cc eclipse project 2012-05-28 17:29:46 +01:00
bhiksha.hh KenLM b1daeaf for clang 2012-05-05 00:55:46 -04:00
binary_format.cc KenLM 98814b2 including faster malloc-backed building and portability improvements 2012-02-28 13:58:00 -05:00
binary_format.hh KenLM 98814b2 including faster malloc-backed building and portability improvements 2012-02-28 13:58:00 -05:00
blank.hh Move kenlm up one level, simplify compilation 2011-11-17 12:49:55 +00:00
build_binary.cc KenLM 98814b2 including faster malloc-backed building and portability improvements 2012-02-28 13:58:00 -05:00
clean.sh Move kenlm up one level, simplify compilation 2011-11-17 12:49:55 +00:00
compile.sh Move kenlm up one level, simplify compilation 2011-11-17 12:49:55 +00:00
config.cc KenLM 98814b2 including faster malloc-backed building and portability improvements 2012-02-28 13:58:00 -05:00
config.hh KenLM 98814b2 including faster malloc-backed building and portability improvements 2012-02-28 13:58:00 -05:00
COPYING Move kenlm up one level, simplify compilation 2011-11-17 12:49:55 +00:00
COPYING.LESSER Move kenlm up one level, simplify compilation 2011-11-17 12:49:55 +00:00
enumerate_vocab.hh Move kenlm up one level, simplify compilation 2011-11-17 12:49:55 +00:00
facade.hh Move kenlm up one level, simplify compilation 2011-11-17 12:49:55 +00:00
Jamfile move all executables into bin 2012-05-31 12:55:05 +01:00
left_test.cc Updated kenlm 96ef3f2c11. 2011-11-17 19:12:19 +00:00
left.hh KenLM b1daeaf for clang 2012-05-05 00:55:46 -04:00
LICENSE Move kenlm up one level, simplify compilation 2011-11-17 12:49:55 +00:00
lm_exception.cc Move kenlm up one level, simplify compilation 2011-11-17 12:49:55 +00:00
lm_exception.hh Move kenlm up one level, simplify compilation 2011-11-17 12:49:55 +00:00
max_order.hh Move kenlm up one level, simplify compilation 2011-11-17 12:49:55 +00:00
model_test.cc Updated kenlm 96ef3f2c11. 2011-11-17 19:12:19 +00:00
model_type.hh Move kenlm up one level, simplify compilation 2011-11-17 12:49:55 +00:00
model.cc KenLM 98814b2 including faster malloc-backed building and portability improvements 2012-02-28 13:58:00 -05:00
model.hh Make lm constructor explicit 2012-01-14 17:07:31 +00:00
ngram_query.cc Make lm constructor explicit 2012-01-14 17:07:31 +00:00
ngram_query.hh Make lm constructor explicit 2012-01-14 17:07:31 +00:00
quantize.cc KenLM 98814b2 including faster malloc-backed building and portability improvements 2012-02-28 13:58:00 -05:00
quantize.hh KenLM b1daeaf for clang 2012-05-05 00:55:46 -04:00
read_arpa.cc KenLM c1dba12 2012-03-11 13:47:38 -04:00
read_arpa.hh KenLM c1dba12 2012-03-11 13:47:38 -04:00
README KenLM b1daeaf for clang 2012-05-05 00:55:46 -04:00
return.hh Move kenlm up one level, simplify compilation 2011-11-17 12:49:55 +00:00
search_hashed.cc KenLM 98814b2 including faster malloc-backed building and portability improvements 2012-02-28 13:58:00 -05:00
search_hashed.hh KenLM 98814b2 including faster malloc-backed building and portability improvements 2012-02-28 13:58:00 -05:00
search_trie.cc KenLM 98814b2 including faster malloc-backed building and portability improvements 2012-02-28 13:58:00 -05:00
search_trie.hh KenLM 98814b2 including faster malloc-backed building and portability improvements 2012-02-28 13:58:00 -05:00
test_nounk.arpa Move kenlm up one level, simplify compilation 2011-11-17 12:49:55 +00:00
test.arpa Move kenlm up one level, simplify compilation 2011-11-17 12:49:55 +00:00
test.sh Move kenlm up one level, simplify compilation 2011-11-17 12:49:55 +00:00
trie_sort.cc KenLM 98814b2 including faster malloc-backed building and portability improvements 2012-02-28 13:58:00 -05:00
trie_sort.hh KenLM b1daeaf for clang 2012-05-05 00:55:46 -04:00
trie.cc Move kenlm up one level, simplify compilation 2011-11-17 12:49:55 +00:00
trie.hh KenLM b1daeaf for clang 2012-05-05 00:55:46 -04:00
virtual_interface.cc Move kenlm up one level, simplify compilation 2011-11-17 12:49:55 +00:00
virtual_interface.hh Move kenlm up one level, simplify compilation 2011-11-17 12:49:55 +00:00
vocab.cc KenLM 98814b2 including faster malloc-backed building and portability improvements 2012-02-28 13:58:00 -05:00
vocab.hh KenLM b1daeaf for clang 2012-05-05 00:55:46 -04:00
weights.hh Move kenlm up one level, simplify compilation 2011-11-17 12:49:55 +00:00
word_index.hh Move kenlm up one level, simplify compilation 2011-11-17 12:49:55 +00:00

Language model inference code by Kenneth Heafield <kenlm at kheafield.com>

THE GIT REPOSITORY https://github.com/kpu/kenlm IS WHERE ACTIVE DEVELOPMENT HAPPENS.  IT MAY RETURN SILENTLY WRONG ANSWERS OR BE SILENTLY BINARY-INCOMPATIBLE WITH STABLE RELEASES.  

The website http://kheafield.com/code/kenlm/ has more documentation.  If you're a decoder developer, please download the latest version from there instead of copying from another decoder.  

Two data structures are supported: probing and trie.  Probing is a probing hash table with keys that ere 64-bit hashes of n-grams and floats as values.  Trie is a fairly standard trie but with bit-level packing so it uses the minimum number of bits to store word indices and pointers.  The trie node entries are sorted by word index.  Probing is the fastest and uses the most memory.  Trie uses the least memory and a bit slower.  

With trie, resident memory is 58% of IRST's smallest version and 21% of SRI's compact version.  Simultaneously, trie CPU's use is 81% of IRST's fastest version and 84% of SRI's fast version.  KenLM's probing hash table implementation goes even faster at the expense of using more memory.  See http://kheafield.com/code/kenlm/benchmark/.  

Binary format via mmap is supported.  Run ./build_binary to make one then pass the binary file name to the appropriate Model constructor.   


PLATFORMS
murmur_hash.cc and bit_packing.hh perform unaligned reads and writes that make the code architecture-dependent.  
It has been sucessfully tested on x86_64, x86, and PPC64.  
ARM support is reportedly working, at least on the iphone, but I cannot test this. 

Runs on Linux, OS X, Cygwin, and MinGW.  

Hideo Okuma and Tomoyuki Yoshimura from NICT contributed ports to ARM and MinGW.  Hieu Hoang is working on a native Windows port.  


DECODER DEVELOPERS
- I recommend copying the code and distributing it with your decoder.  However, please send improvements upstream as indicated in CONTRIBUTORS.  

- It does not depend on Boost or ICU.  If you use ICU, define HAVE_ICU in util/have.hh (uncomment the line) to avoid a name conflict.  Defining HAVE_BOOST will let you hash StringPiece.  

- Most people have zlib.  If you don't want to depend on that, comment out #define HAVE_ZLIB in util/have.hh.  This will disable loading gzipped ARPA files.  

- There are two build systems: compile.sh and Jamroot+Jamfile.  They're pretty simple and are intended to be reimplemented in your build system.  

- Use either the interface in lm/model.hh or lm/virtual_interface.hh.  Interface documentation is in comments of lm/virtual_interface.hh and lm/model.hh.  

- There are several possible data structures in model.hh.  Use RecognizeBinary in binary_format.hh to determine which one a user has provided.  You probably already implement feature functions as an abstract virtual base class with several children.  I suggest you co-opt this existing virtual dispatch by templatizing the language model feature implementation on the KenLM model identified by RecognizeBinary.  This is the strategy used in Moses and cdec.

- See lm/config.hh for tuning options.  


CONTRIBUTORS
Contributions to KenLM are welcome.  Please base your contributions on https://github.com/kpu/kenlm and send pull requests (or I might give you commit access).  Downstream copies in Moses and cdec are maintained by overwriting them so do not make changes there.  


The name was Hieu Hoang's idea, not mine.