<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rspamd.git/src/lua/lua_static_embed.cxx, branch master</title>
<subtitle>rspamd</subtitle>
<id>http://dangofactory.net/cgit/cgit.cgi/Server/rspamd.git/atom/src/lua/lua_static_embed.cxx?h=master</id>
<link rel='self' href='http://dangofactory.net/cgit/cgit.cgi/Server/rspamd.git/atom/src/lua/lua_static_embed.cxx?h=master'/>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/rspamd.git/'/>
<updated>2026-07-02T08:18:51Z</updated>
<entry>
<title>[Feature] static_embed: per-token sequence access</title>
<updated>2026-07-02T08:18:51Z</updated>
<author>
<name>Vsevolod Stakhov</name>
<email>vsevolod@rspamd.com</email>
</author>
<published>2026-07-02T08:12:44Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/rspamd.git/commit/?id=655a436ca8601c4719fcf7b899e790901ed8d8dd'/>
<id>urn:sha1:655a436ca8601c4719fcf7b899e790901ed8d8dd</id>
<content type='text'>
Add model:get_token_vectors(input[, opts]) for offline consumers
(external trainers exporting order-aware text features): the token
embedding sequence in token order instead of only the pooled mean.

- Accepts exactly what get_sentence_vector accepts (word list or whole
  text) and tokenizes through the same shared code path; unk rows are
  included the same way the pooled path includes them.
- opts.max_tokens truncates after tokenization to the first N tokens
  (the returned count is post-truncation); opts.raw returns an
  rspamd_text with ntokens*dim little-endian float32s packed row-major
  instead of a table of tables. Invalid opts raise errors, no silent
  coercions. Empty input yields an empty table/text and 0, never nil.
- The provider path is unchanged: fusion vectors stay fixed-dim, so the
  neural provider keeps using only the pooled get_sentence_vector.
- Tests: id/row alignment, pooled-mean consistency (incl. unk-heavy
  input), word-list/text equivalence, max_tokens, raw packing and
  strict opts validation.
</content>
</entry>
<entry>
<title>[Feature] neural: static_embed provider (WordPiece + static matrix)</title>
<updated>2026-07-01T21:31:01Z</updated>
<author>
<name>Vsevolod Stakhov</name>
<email>vsevolod@rspamd.com</email>
</author>
<published>2026-07-01T20:24:09Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/rspamd.git/commit/?id=8c28072867c7b0cffb6b804ca0906cbab27404ad'/>
<id>urn:sha1:8c28072867c7b0cffb6b804ca0906cbab27404ad</id>
<content type='text'>
Add a static token-embedding provider (Model2Vec style), the cheap
multilingual successor to fasttext_embed: words from rspamd's regular
tokenization pipeline are re-tokenized into WordPiece subword tokens and
embedded by mean-pooling rows of a precomputed float32 matrix, with no
neural forward pass and no new dependencies.

- rspamd_static_embed: a Lua-C module combining a WordPiece tokenizer
  (BertNormalizer via ICU + Bert pre-tokenizer + greedy WordPiece) with
  an mmap-ed embedding matrix shared between workers. The model spec is
  read from the model directory (config.json + vocab.txt + matrix +
  optional HF tokenizer.json) and validated strictly, fail-fast: any
  unsupported normalizer/pre-tokenizer/model type, pooling other than
  mean, non-float32 matrix or size mismatch fails the load instead of
  degrading silently. get_sentence_vector() accepts a word list (the
  provider path) or a whole text; both produce identical vectors.
- The WordPiece tokenizer is internal to the vectorizer: the global
  word-breaking / statistics tokenization path is untouched, so Bayes
  tokens and fuzzy hashes are unaffected.
- static_embed provider: extracts words like fasttext_embed and feeds
  them to the model; the Lua side holds no matrix data and uses no FFI.
- unit tests with a generated fixture covering normalization, subword
  splitting, greedy matching, CJK padding, unk handling, mean pooling,
  word-list/text equivalence and strict rejection of unsupported
  configs (BPE model type, vocab/matrix size mismatches, pooling).

Verified against the reference tokenizer oracle: token ids match
exactly, pooled vectors match within 2.4e-05 max abs diff, and the
word-list path is bit-identical to raw-text tokenization on the corpus.
</content>
</entry>
</feed>
