Migrating to ir_axioms 1.0¶
Upgrade code written for ir_axioms < 1.0
If you have used ir_axioms < 1.0 and now want to migrate your code, please follow this guide.
Still need to support ir_axioms < 1.0?
The legacy version is still available on the legacy branch and you can still install old versions:
The Axiom Interface¶
See this example on how to define an axiom in the old (< 1.0) version and the recent version of ir_axioms.
class NewAxiom(Axiom[QueryType, ResponseType]):
def preference(self, q, d_1, d_2) -> float:
# Preference between responses d_1, d_2 for query q.
...
def preferences(self, q, D) -> PreferenceMatrix: # a square `ndarray`
# (Optional) Pairwise preference matrix for a sequence D of responses for query q.
...
Key changes are:
- There is no hard-coded dependency on the retrieval index. Instead, axioms declare the tools they need, which are injected automatically.
- You can override the batch-computation of axiomatic preferences to speed up the preference computation.
For further steps on developing new axioms, refer to our dedicated guidelines.
Usage with PyTerrier¶
To use the axioms with PyTerrier, continue to use the PyTerrier Transformer subclasses and the AxiomaticExperiment as before:
KwikSortRerankerto re-rank results based on a given axiom.AxiomaticPreferencesto return a data frame with all pairwise preferences of the given axiom(s).AggregatedAxiomaticPreferencesto return the same preferences aggregated by document (e.g., as features for LTR).AxiomaticExperimentto run an axiomatic experiment (traditional IR).
Instead of passing the index and dataset to each transformer, call inject_pyterrier() once.
The new RAG-specific axioms can be used as shown in the RAG evaluation walkthrough, which is based on the ICTIR 2025 notebook.
Other Breaking Changes¶
- There is no longer implicit disk-caching of axioms (formerly the
~operator). Instead, you now have to define the cache location explicitly, using theCachedAxiomor theAxiom.cached()instance method. - Axioms can no longer be loaded by name. The class registry was removed for simplicity.
- Some version constraints on sub-dependencies (e.g., PyTerrier) have been strictened.
- Magnitude versions of word-embeddings have been replaced by Hugging Face download and manual fastText model loading.
The separate fastText-based axiom variants (e.g.,
STMC1_f,REG_f) were removed; the term similarity is now a tool that uses fastText automatically if installed. - The Terrier- and Anserini-integration-related imports moved from
ir_axioms.backend.pyterrieretc. toir_axioms.integrations.pyterrieretc.
Quick reference
| Legacy (< 1.0) | Current (≥ 1.0) |
|---|---|
~axiom |
axiom.cached(Path("cache/axiom")) |
ir_axioms.backend.pyterrier.transformers |
ir_axioms.integrations |
ir_axioms.modules.pivot |
ir_axioms.tools |
KwikSortReranker(axiom=..., index=..., dataset=...) |
inject_pyterrier(index_location=..., dataset=...), then KwikSortReranker(axiom=...) |
VoteAxiom([...], minimum_votes=0.5) |
MajorityVoteAxiom(axioms=[...], minimum_votes=0.5) |
to_axiom("TFC1"), AutoAxiom |
TFC1() |