{"id":45214,"library":"kenlm","title":"KenLM","description":"KenLM is a Python bindings package for the KenLM language model toolkit. It provides efficient querying of n-gram language models (ARPA format) for tasks like speech recognition, machine translation, and text generation. The current version is 0.3.0, with irregular release cadence.","status":"active","version":"0.3.0","language":"python","source_language":"en","source_url":"https://github.com/kpu/kenlm","tags":["language model","n-gram","ARPA","KenLM","NLP","speech recognition"],"install":[{"cmd":"pip install kenlm","lang":"bash","label":"Install from PyPI (pre-built wheels limited; may need compilation)"}],"dependencies":[{"reason":"Required to build from source if precompiled wheels are unavailable.","package":"cython","optional":true}],"imports":[{"note":"Model class is not directly importable from kenlm; use kenlm.Model.","wrong":"from kenlm import Model","symbol":"Model","correct":"import kenlm\nmodel = kenlm.Model('model.arpa')"}],"quickstart":{"code":"import kenlm\n\nmodel = kenlm.Model('test.arpa')\nscore = model.score('hello world', bos=True, eos=True)\nprint(f'Score: {score}')\nfull_scores = list(model.full_scores('hello world', bos=True, eos=True))\nprint(f'Full scores: {full_scores}')","lang":"python","description":"Load an ARPA format language model and score a sentence."},"warnings":[{"fix":"Always use `import kenlm; model = kenlm.Model('path')`.","message":"The Model class is not directly importable; use `import kenlm` then `kenlm.Model`.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `list(model.full_scores(...))` to access individual n-gram scores.","message":"Full scores are returned as a generator; must be converted to list for indexing.","severity":"gotcha","affected_versions":"all"},{"fix":"Install Cython and build from source on arm64/aarch64: `pip install cython; pip install kenlm --no-binary kenlm`.","message":"Precompiled wheels on PyPI do not support arm64 (Apple Silicon) or manyLinux aarch64. Users must compile from source.","severity":"breaking","affected_versions":"<=0.3.0"}],"env_vars":null,"search_vec":"'0.3.0':40 'arpa':24,50 'bind':6 'cadenc':44 'current':37 'effici':16 'format':25 'generat':35 'gram':21,49 'irregular':42 'kenlm':1,2,10,51 'languag':11,22,45 'like':28 'machin':31 'model':12,23,46 'n':20,48 'n-gram':19,47 'nlp':52 'packag':7 'provid':15 'python':5 'queri':17 'recognit':30,54 'releas':43 'speech':29,53 'task':27 'text':34 'toolkit':13 'translat':32 'version':38","created_at":"2026-06-07T12:53:54.595636+00:00","updated_at":"2026-06-07T12:53:54.595636+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"kenlm.pyx\", line 139, in kenlm.Model.__init__\nRuntimeError: util/file.cc:76 in int util::OpenReadOrThrow(const char*) threw ErrnoException because `-1 == (ret = open(name, 00))'.\nNo such file or directory while opening /home/xor/Documents/code/ray-tracer/mo"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"skip","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-08-01","install_tag":null}}