Download engine/klm_shim.cc from Reza2kn/Shenava-Rizeh-v1.5: direct link, hf CLI and curl.
- Browser
- Download file 857 Bytes
-
https://huggingface.co/Reza2kn/Shenava-Rizeh-v1.5/resolve/main/engine/klm_shim.cc
- Command line
-
hf download hf://Reza2kn/Shenava-Rizeh-v1.5/engine/klm_shim.cc
-
curl -L -o klm_shim.cc https://huggingface.co/Reza2kn/Shenava-Rizeh-v1.5/resolve/main/engine/klm_shim.cc
857 Bytes
| extern "C" { | |
| void* klm_load(const char* path) { | |
| lm::ngram::Config c; c.load_method = util::POPULATE_OR_READ; | |
| try { return lm::ngram::LoadVirtual(path, c); } catch (...) { return nullptr; } | |
| } | |
| int klm_state_size(void* m) { return (int)static_cast<lm::base::Model*>(m)->StateSize(); } | |
| void klm_begin(void* m, void* st) { static_cast<lm::base::Model*>(m)->BeginSentenceWrite(st); } | |
| float klm_score(void* m, const void* in, const char* w, int len, void* out) { | |
| auto* M = static_cast<lm::base::Model*>(m); | |
| lm::WordIndex i = M->BaseVocabulary().Index(StringPiece(w, len)); | |
| return M->BaseScore(in, i, out); | |
| } | |
| float klm_end(void* m, const void* in, void* out) { | |
| auto* M = static_cast<lm::base::Model*>(m); | |
| return M->BaseScore(in, M->BaseVocabulary().EndSentence(), out); | |
| } | |
| } | |