Closed jacobkahn closed 1 year ago
no KenLM symbols are bundled into
libflashlight-text-kenlm
.
In KenLM.cpp
, I see lm::ngram::State
and lm::ngram::State
are used, so don't they show up as undefined symbols?
@jacobkahn has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
@jacobkahn has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
This pull request was exported from Phabricator. Differential Revision: D43294535
This pull request was exported from Phabricator. Differential Revision: D43294535
This pull request was exported from Phabricator. Differential Revision: D43294535
@jacobkahn merged this pull request in flashlight/text@dcfc637d03ab30b053fcf99fc664f43eff8cb3f4.
Separates KenLM-related components of Flashlight Text into a separate library:
libflashlight-text-kenlm
. This library is built whenFL_TEXT_USE_KENLM
is enabled. In particular, with a shared lib configuration, no KenLM symbols are bundled intolibflashlight-text-kenlm
.When building Python bindings, Flashlight Text tries to find
kenlm
installed via pip (vis-a-vispip install git@https://github.com/kpu/kenlm
). This PR adds machinery to download KenLM headers when building wheels from source but still links to the kenlm installed via pip. This enables dynamically loading a KenLM built from pip by a consuming C++ library from FL Text.Some other details/changes:
flashlight_lib_text_decoder_kenlm
pybind extension.decoder.py
intodecoder/__init__.py
KenLM
class in Python bindings now lives inflashlight.lib.text.decoder.kenlm
rather than just indecoder
.libkenlm_utils
(which doesn't exist in thepip
installed version),KENLM_DISABLE_UTILS_SEARCH
disables searching inFindkenlm
forlibkenlm_utils
since those symbols are all bundled intolibkenlm
.NB: as above, the import path for KenLM support has changed. It's now:
In order for this to work fully on macOS, https://github.com/kpu/kenlm/pull/413 needs to be merged in because FL Text needs to link at build time with a KenLM
dylib
and at runtime with the samedylib
per portable rpath. Linking with a macOSso
bundle at runtime sadly won't work because of howflashlight-text-kenlm
was linked.Test plan: CI, cibuildwheel and local wheel tests across macOS and Linux.
Checklist