Download scripts/r5_linedet/lm_build.sh from treoa/turkic-ocr-code: direct link, hf CLI and curl.
- Browser
- Download file 704 Bytes
-
https://huggingface.co/treoa/turkic-ocr-code/resolve/main/scripts/r5_linedet/lm_build.sh
- Command line
-
hf download hf://treoa/turkic-ocr-code/scripts/r5_linedet/lm_build.sh
-
curl -L -o lm_build.sh https://huggingface.co/treoa/turkic-ocr-code/resolve/main/scripts/r5_linedet/lm_build.sh
704 Bytes
| # Character 6-gram, modified Kneser-Ney, built with kenlm lmplz (kenlm 0.3.0 PyPI source, sha256 c4628bb9...; static-boost build on the login node). | |
| # Usage: lm_build.sh [folder with train_text.txt] (default DATA/outputs/r5/linedet/lm) | |
| set -eu | |
| DATA=/path/to/TURKIC_OCR_DATA | |
| LM=${1:-$DATA/outputs/r5/linedet/lm} | |
| BIN=$DATA/tmp/kenlm_build/build_static/bin | |
| TMP=$DATA/tmp/lmplz_tmp_$$ | |
| mkdir -p $LM $TMP | |
| cd $LM | |
| ls -la train_text.txt | |
| nice -n 5 $BIN/lmplz -o 6 -S 16G -T $TMP --discount_fallback < train_text.txt > char6.arpa | |
| ls -la char6.arpa | |
| $BIN/build_binary -q 8 -b 8 trie char6.arpa char6.klm | |
| ls -la char6.klm | |
| sha256sum char6.klm train_text.txt > char6.sha256 | |
| head -12 char6.arpa | |
| rm -rf $TMP | |