Metadata-Version: 2.4
Name: polyprobe
Version: 1.0.1
Summary: A research library for training and evaluating probes of information processed by transformer attention heads.
Author-email: Richard Paul Hudson <info@richardpaulhudson.com>
License-Expression: Apache-2.0
Project-URL: Repository, https://github.com/richardpaulhudson/polyprobe
Project-URL: Issues, https://github.com/richardpaulhudson/polyprobe/issues
Keywords: transformers,probing,linear-probes,interpretability,mechanistic-interpretability,attention,attention-heads,representation-analysis,model-analysis,machine-learning,pytorch,linguistics,nlp
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Text Processing :: Linguistic
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: !=3.14.1,<3.15,>=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: LICENSE-CC-BY-4.0
Requires-Dist: transformers<6.0.0,>=5.17.0
Requires-Dist: torch<3.0.0,>=2.14.0
Requires-Dist: transformer-lens>=4.2.0
Requires-Dist: tqdm<5.0.0,>=4.70.1
Requires-Dist: conllu<7.0.0,>=6.0.0
Requires-Dist: psutil<8.0.0,>=7.2.2
Provides-Extra: plot
Requires-Dist: matplotlib<4.0.0,>=3.11.2; extra == "plot"
Dynamic: license-file

Polyprobe is a research library for training and evaluating lightweight binary-classification probes over representations within language-model attention heads. While many prior probing studies have been implemented as task-specific experiments, Polyprobe provides reusable infrastructure for:

- efficient training of independent probes across hundreds of attention heads;
- memory-mapped activation storage and GPU-aware batching;
- head ranking and model selection; 
- evaluation and interactive inference.

The details of individual experiments, on the other hand, are specified via a number of swappable abstractions that can either be selected from what the library already has to offer or registered at runtime:

- the architecture of the language model being investigated; 
- the features to learn;
- the source of the training data;
- the definition of positive and negative examples;
- the vector representations to probe; 
- the type of probe to use; 
- the metric to use to select probe results; 
- optionally, how probe results are pooled.

I am currently using Polyprobe to investigate how grammatical dependencies are represented and processed by language models. On held-out English Web Treebank data, pooled Qwen3-4B probes reached 82.28% average precision for subject-before-head dependencies and 83.57% for head-before-object dependencies against positive prevalences of 0.49% and 0.29% respectively. The probes can be tested against user-entered sentences via a simple analysis console:

```text
The dog saw the cat

nsubj:  dog (3: 7) ->  saw (7: 11) (strictest met threshold: 25%)
obj:  cat (15: 19) ->  saw (7: 11) (strictest met threshold: 15%)
```

For more information, please see the [main documentation on GitHub](https://github.com/richardpaulhudson/polyprobe).
