models/wolfDefender/src/wolf_defender_engine library

Classes

WolfDefenderEngine
WolfDefenderOnnxBackend
Runs the Wolf Defender graph.

Constants

wolfDefenderWindowOverlap → const int
Adjacent windows share this many tokens.
wolfDefenderWindowPositions → const int
The positions of one model input, with <bos> and <eos>.

Functions

wolfDefenderPool(List<Float32List> logits) → double
The injection probability of the windows' logits: per class, a smooth maximum over the windows (temperature 1 for one window, 0.1 for more), normalized by the window count; then softmax. One window is the softmax of its logits. Patronus's inference.py defines it.
wolfDefenderWindows(int tokens) → List<(int, int)>
The token ranges of the windows of tokens tokens. Each has at most 2046 tokens; each after the first starts 64 tokens before the end of the one before it. No tokens is one empty window.