rawi ensemble for loom
The rawi v2 + v3 Arabic diacritization ensemble as one loom GGUF. The file holds 16 graphs and a Lua driver. Each network has an embedding, two BiLSTM layers (an input projection and one cell per direction for each) and a head. The driver applies the ensemble gate. infer(tokens) returns T 脳 75 gated_logits, row-major.
Each BiLSTM layer computes its input half (W_ih x + b) for the whole sequence in one product. A per-step sweep then adds only W_hh h (loom.cpp ADR-137, ADR-144). The calls it uses are in loom-py-rt 1.0.0, so the file runs on the released engine.
| File | Weights | sha256 |
|---|---|---|
rawi_ensemble.f16.gguf |
F16 | 06be2203d163215b871c08237c49c8440d585baf93a80ac9f4204a35d406ed24 |
rawi_ensemble.f32.gguf |
F32 | 6ef01d1d19b80f65c44ea0b42a1a4debd1d97cf3d1d600b624d1d6ebfe967041 |
Input
NFD, drop symbols (category So), drop combining marks (category Mn). Map each character to an id with char_to_idx in TigreGotico/rawi-v2 rawi_v2.vocab.json (unknown characters take <UNK>). test/ids.txt holds 934 sentences in this form, one per line.
Run it
pip install loom-py-rt
import loom
model = loom.Model.from_file("rawi_ensemble.f32.gguf")
logits = model.call("infer", {"tokens": ids}) # len(ids) * 75 floats
Check parity and speed
test/onnx_fp32_logits.f32 is the fp32 ONNX ensemble output for test/ids.txt (24,477 characters 脳 75 logits).
# L = a loom.cpp checkout (1.0.0 or later), built in $L/build
D=$L/build/_deps
c++ -O2 -std=c++17 scripts/rawi_run.cpp -I$L/include -I$L/tests/support \
-I$D/nlohmann_json-src/single_include -I$D/ggml-src/include \
-L$L/build -lloom_engine -L$D/ggml-build/src -lggml -lggml-base -o rawi_run
LD_LIBRARY_PATH=$L/build:$D/ggml-build/src ./rawi_run rawi_ensemble.f32.gguf test/ids.txt f32.f32 f32_times.txt
python scripts/check_parity.py f32.f32 test/onnx_fp32_logits.f32 f32_times.txt
On an AMD Ryzen 3 3250U (CPU, one thread for the sweep), the median per sentence is 23.3 ms at F32 and 31.8 ms at F16. The per-step sweep without the projection takes 27.4 ms and 43.0 ms.
Argmax differences against fp32 ONNX:
- F32: 0 (max |d| 1.3e-5).
- F16: 2 of 24,477 characters, from the F16 weights (max |d| 0.015).
check_parity.pyexits 1 on any difference.
Rebuild the GGUF
pip install "loom-exporter @ git+https://github.com/loom-ai-org/loom-exporter" torch==2.8.0 coremltools==9.0 gguf==0.17.1 huggingface_hub
cd scripts
python export_rawi_ensemble.py rawi_ensemble.f16.gguf F16
python export_rawi_ensemble.py rawi_ensemble.f32.gguf
export_rawi_ensemble.py downloads the two .pth checkpoints from the Hub. The projected layers need loom-exporter with loom-ai-org/loom-exporter#99 (BiRecurrentCall(input_topology=...)); until it is merged, install @feat/projected-bi-recurrent-call. These steps give the files above byte for byte.
- Downloads last month
- -
16-bit
32-bit
Model tree for TigreGotico/rawi-ensemble-loom
Base model
TigreGotico/rawi-v2