factlogic's picture
Release the evaluated checkpoint, inference example and research paper
52bccbd verified
|
Raw History Blame Contribute Delete
2.52 kB
# Inference with a compatible classifier
Run commands from a local copy of this repository with the packages listed in requirements.txt. The demo uses synthetic tensors and a deterministic seed. The research numbers in the paper were computed separately on held-out datasets.
The target is a BGE-small, BGE-base or DINOv2-small encoder followed by the study's normalized CLS readout and an affine classifier. Use features.static(backbone, key) to construct the fixed projection and selected channels. Run the shared frozen backbone in evaluation mode and call features.capture(backbone, key, inputs, static_state) to obtain a triple (k, a, s) for each batch. Here k is the projected block input, a holds selected preactivations, and s is the residual stream before final normalization. Keep class IDs aligned between versions.
Each endpoint is expressed relative to that same base in six tensors: inc [r,m], inbias [m], out [m,d], outbias [d], head [C,d], and bias [C]. The reference implementation uses r=48 and m=128. Generic updates outside this family require an adapter. target.init(static_state,C) creates zero residuals and an empty head. target.logits(triple,patch,static_state) evaluates a patch. target.physical(base,key,patch,static_state) writes both internal affine maps into a copy of the base. Keep patch['head'] and patch['bias'] as the classifier, and apply the normalized CLS readout in target.full_logits. Applying the patch to an already edited base would double-count the changes.
~~~python
from inference import Predictor
from fixture import example
o,u,st,s,y,f,fy,g,q = example()
model = Predictor()
cal = model.calibrate(s,o,st)
record = model.cache(q,o,st,cal)
estimated_logits = model.forecast(record,cal,o,u,st)
~~~
The candidate may come from the companion editor or any other supported update. The candidate is supplied at forecast time. A calibrated record can be reused across proposals. True labels are needed to measure error detection.
The CSV records balanced accuracy and decision agreement as fractions. The paper first averages within each held dataset and then gives all four datasets equal weight. Seeds share test examples. Data sources: [MASSIVE](https://huggingface.co/datasets/AmazonScience/massive), [Banking77](https://huggingface.co/datasets/PolyAI/banking77), [CLINC150](https://github.com/clinc/oos-eval), [Flowers102](https://www.robots.ox.ac.uk/~vgg/data/flowers/102/) and [FGVC-Aircraft](https://www.robots.ox.ac.uk/~vgg/data/fgvc-aircraft/).