Haruka Tagger, compressed

This is Haruka Tagger (EVA02-B/14 at 448 px, 98,782 tags) compressed from 809 MB to 187 MB for downloading into a browser. foidfinder runs it in the browser with WebGPU, at 52 ms per image on an M4 Pro in Chrome, and with MLX on Apple Silicon (foidfinder --model-dir <local copy> serve).

Accuracy

Agreement with the fp32 model on 400 recent safebooru.org posts, at the recommended thresholds (character, copyright and general 0.35, artist 0.25). The counts are changed decisions.

size KL per image max |ฮ”p| character copyright artist general top-1 character
fp16 386 MB 0.0007 0.008 2 1 0 33 100%
bf16, the training precision 386 MB 0.046 0.079 9 5 10 242 99.7%
this checkpoint 187 MB 0.023 0.031 5 6 2 175 100%

KL is summed over all tags.

Method

The backbone linears, the pool's key/value projection and the tag classifier hold 99.6% of the weights. GPTQ, calibrated on 1,536 other safebooru posts, rounds each of them to integer multiples of one fp16 step per output row. The step is the row's RMS divided by 40 in the backbone and by 32 in the classifier. The integer codes are zigzag-mapped, split into byte planes and gzipped. They average 7.4 bits per weight. Everything else is fp16.

foidfinder quantize-haruka KaraKaraWitch/haruka-tagger <dir> --calib <images> reproduces it.

Format

model.safetensors holds the weights in the layout that foidfinder's runtimes read. The input normalization is folded into the patch embedding and the attention scales into the query and key projections. QKV is one matrix, and so are the two SwiGLU input projections. Linear weights are [out, in].

For each compressed matrix name with config.json["quantization"]["layers"][name] = {"shape": [rows, cols], "planes": n}:

  • name.step, f16 [rows]
  • name.plane0 โ€ฆ name.plane{n-1}, u8, each a gzip stream of rows ร— cols bytes. Byte i of z is in plane i.
z      = plane0[j] | plane1[j] << 8 | ...
code   = (z >> 1) ^ -(z & 1)
weight = code * step[row]          # row = j / cols

config.json also holds the architecture, the tag names and categories in output order, and the recommended thresholds.

Downloads last month
-
Safetensors
Model size
0.2B params
Tensor type
F16
ยท
U8
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for alpindale/haruka-compressed