Download scripts/10_gate.lua from TigreGotico/rawi-ensemble-loom: direct link, hf CLI and curl.
- Browser
- Download file 861 Bytes
-
https://huggingface.co/TigreGotico/rawi-ensemble-loom/resolve/main/scripts/10_gate.lua
- Command line
-
hf download hf://TigreGotico/rawi-ensemble-loom/scripts/10_gate.lua
-
curl -L -o 10_gate.lua https://huggingface.co/TigreGotico/rawi-ensemble-loom/resolve/main/scripts/10_gate.lua
861 Bytes
| -- Ensemble gate (arbtok tools/build_ensemble_logits_onnx.py): where argmax(v2_logits) == 0, | |
| -- lift class 0 of the v3 value logits to v0 + relu(max - v0 + 1). ArgMax keeps the first maximum. | |
| local gated_logits = v3_value | |
| local n_cls = 75 | |
| for t = 0, #tokens - 1 do | |
| local base = t * n_cls | |
| local g_best, g_arg = v2_logits[base + 1], 0 | |
| local v_max = v3_value[base + 1] | |
| for c = 2, n_cls do | |
| local g = v2_logits[base + c] | |
| if g > g_best then g_best, g_arg = g, c - 1 end | |
| local v = v3_value[base + c] | |
| if v > v_max then v_max = v end | |
| end | |
| if g_arg == 0 then | |
| local v0 = v3_value[base + 1] | |
| local boost = v_max - v0 + 1.0 | |
| if boost < 0 then boost = 0 end | |
| gated_logits[base + 1] = v0 + boost | |
| end | |
| end | |