Skip to content

Data Model

API of ir_axioms.model

See the quickstart for how to create queries, documents, requests, and responses.

ir_axioms.model.retrieval

Query dataclass

Query(id: str, text: str | None = None)

id instance-attribute

id: str

Unique identifier for the query.

text class-attribute instance-attribute

text: str | None = None

Query text content.

Document dataclass

Document(
    id: str,
    text: str | None = None,
    score: float | None = None,
    rank: int | None = None,
    relevance: float | None = None,
)

id instance-attribute

id: str

Unique identifier for the document.

text class-attribute instance-attribute

text: str | None = None

Document text content.

score class-attribute instance-attribute

score: float | None = None

The document's retrieval score.

rank class-attribute instance-attribute

rank: int | None = None

The document's ranking position.

relevance class-attribute instance-attribute

relevance: float | None = None

The true relevance label of the document.

TextQuery

TextQuery(*args, **kwargs)

Bases: Query

Source code in ir_axioms/model/retrieval.py
def __init__(self, *args, **kwargs) -> None:
    super().__init__(*args, **kwargs)
    if self.text is None:
        raise ValueError(f"{type(self).__name__} must have a non-empty text field.")

text instance-attribute

text: str

TextDocument

TextDocument(*args, **kwargs)

Bases: Document

Source code in ir_axioms/model/retrieval.py
def __init__(self, *args, **kwargs) -> None:
    super().__init__(*args, **kwargs)
    if self.text is None:
        raise ValueError(f"{type(self).__name__} must have a non-empty text field.")

text instance-attribute

text: str

ScoredDocument

ScoredDocument(*args, **kwargs)

Bases: Document

Source code in ir_axioms/model/retrieval.py
def __init__(self, *args, **kwargs) -> None:
    super().__init__(*args, **kwargs)
    if self.score is None:
        raise ValueError(
            f"{type(self).__name__} must have a non-empty score field."
        )

score instance-attribute

score: float

RankedDocument

RankedDocument(*args, **kwargs)

Bases: Document

Source code in ir_axioms/model/retrieval.py
def __init__(self, *args, **kwargs) -> None:
    super().__init__(*args, **kwargs)
    if self.rank is None:
        raise ValueError(f"{type(self).__name__} must have a non-empty rank field.")

rank instance-attribute

rank: int

ScoredTextDocument dataclass

ScoredTextDocument(*args, **kwargs)

Bases: ScoredDocument, TextDocument

Source code in ir_axioms/model/retrieval.py
def __init__(self, *args, **kwargs) -> None:
    super().__init__(*args, **kwargs)
    if self.score is None:
        raise ValueError(
            f"{type(self).__name__} must have a non-empty score field."
        )

RankedTextDocument dataclass

RankedTextDocument(*args, **kwargs)

Bases: RankedDocument, TextDocument

Source code in ir_axioms/model/retrieval.py
def __init__(self, *args, **kwargs) -> None:
    super().__init__(*args, **kwargs)
    if self.rank is None:
        raise ValueError(f"{type(self).__name__} must have a non-empty rank field.")

RankedScoredDocument dataclass

RankedScoredDocument(*args, **kwargs)

Bases: ScoredDocument, RankedDocument

Source code in ir_axioms/model/retrieval.py
def __init__(self, *args, **kwargs) -> None:
    super().__init__(*args, **kwargs)
    if self.score is None:
        raise ValueError(
            f"{type(self).__name__} must have a non-empty score field."
        )

RankedScoredTextDocument dataclass

RankedScoredTextDocument(*args, **kwargs)

Bases: RankedScoredDocument, ScoredTextDocument, RankedTextDocument

Source code in ir_axioms/model/retrieval.py
def __init__(self, *args, **kwargs) -> None:
    super().__init__(*args, **kwargs)
    if self.score is None:
        raise ValueError(
            f"{type(self).__name__} must have a non-empty score field."
        )

JudgedDocument

JudgedDocument(*args, **kwargs)

Bases: Document

Source code in ir_axioms/model/retrieval.py
def __init__(self, *args, **kwargs) -> None:
    super().__init__(*args, **kwargs)
    if self.relevance is None:
        raise ValueError(
            f"{type(self).__name__} must have a non-empty relevance field."
        )

relevance instance-attribute

relevance: float

JudgedTextDocument dataclass

JudgedTextDocument(*args, **kwargs)

Bases: TextDocument, JudgedDocument

Source code in ir_axioms/model/retrieval.py
def __init__(self, *args, **kwargs) -> None:
    super().__init__(*args, **kwargs)
    if self.text is None:
        raise ValueError(f"{type(self).__name__} must have a non-empty text field.")

JudgedScoredDocument dataclass

JudgedScoredDocument(*args, **kwargs)

Bases: ScoredDocument, JudgedDocument

Source code in ir_axioms/model/retrieval.py
def __init__(self, *args, **kwargs) -> None:
    super().__init__(*args, **kwargs)
    if self.score is None:
        raise ValueError(
            f"{type(self).__name__} must have a non-empty score field."
        )

JudgedScoredTextDocument dataclass

JudgedScoredTextDocument(*args, **kwargs)

Bases: ScoredTextDocument, JudgedDocument

Source code in ir_axioms/model/retrieval.py
def __init__(self, *args, **kwargs) -> None:
    super().__init__(*args, **kwargs)
    if self.score is None:
        raise ValueError(
            f"{type(self).__name__} must have a non-empty score field."
        )

JudgedRankedDocument dataclass

JudgedRankedDocument(*args, **kwargs)

Bases: RankedDocument, JudgedDocument

Source code in ir_axioms/model/retrieval.py
def __init__(self, *args, **kwargs) -> None:
    super().__init__(*args, **kwargs)
    if self.rank is None:
        raise ValueError(f"{type(self).__name__} must have a non-empty rank field.")

JudgedRankedTextDocument dataclass

JudgedRankedTextDocument(*args, **kwargs)

Bases: RankedTextDocument, JudgedDocument

Source code in ir_axioms/model/retrieval.py
def __init__(self, *args, **kwargs) -> None:
    super().__init__(*args, **kwargs)
    if self.rank is None:
        raise ValueError(f"{type(self).__name__} must have a non-empty rank field.")

JudgedRankedScoredDocument dataclass

JudgedRankedScoredDocument(*args, **kwargs)

Bases: RankedScoredDocument, JudgedScoredDocument, JudgedRankedDocument

Source code in ir_axioms/model/retrieval.py
def __init__(self, *args, **kwargs) -> None:
    super().__init__(*args, **kwargs)
    if self.score is None:
        raise ValueError(
            f"{type(self).__name__} must have a non-empty score field."
        )

JudgedRankedScoredTextDocument dataclass

JudgedRankedScoredTextDocument(*args, **kwargs)

Bases: JudgedRankedScoredDocument, JudgedScoredTextDocument, JudgedRankedTextDocument

Source code in ir_axioms/model/retrieval.py
def __init__(self, *args, **kwargs) -> None:
    super().__init__(*args, **kwargs)
    if self.score is None:
        raise ValueError(
            f"{type(self).__name__} must have a non-empty score field."
        )

ir_axioms.model.generation

GenerationRequest dataclass

GenerationRequest(
    *,
    id: str | None = None,
    text: str,
    context: Sequence[str] | None = None,
    reference_output: Optional[GenerationResponse] = None,
)

id class-attribute instance-attribute

id: str | None = None

Unique identifier for the generation input.

text instance-attribute

text: str

Request text, e.g., a question or query.

context class-attribute instance-attribute

context: Sequence[str] | None = None

Optional retrieved context (e.g., when evaluating RAG).

reference_output class-attribute instance-attribute

reference_output: Optional[GenerationResponse] = None

Optional ground-truth refeerence response.

GenerationInput dataclass

GenerationInput(
    *,
    id: str | None = None,
    text: str,
    context: Sequence[str] | None = None,
    reference_output: Optional[GenerationResponse] = None,
)

GenerationResponse dataclass

GenerationResponse(
    *,
    id: str | None = None,
    text: str,
    context: Sequence[str] | None = None,
)

id class-attribute instance-attribute

id: str | None = None

Unique identifier for the generation output.

text instance-attribute

text: str

Text response generated.

context class-attribute instance-attribute

context: Sequence[str] | None = None

Override context from input if necessary.

GenerationOutput dataclass

GenerationOutput(
    *,
    id: str | None = None,
    text: str,
    context: Sequence[str] | None = None,
)

ir_axioms.model.base

Input module-attribute

Input = TypeVar('Input', contravariant=True)

Output module-attribute

Output = TypeVar('Output', contravariant=True)

Preference module-attribute

Preference: TypeAlias = float

PreferenceMatrix module-attribute

PreferenceMatrix: TypeAlias = NDArray[floating]

PreferenceMatrices module-attribute

PreferenceMatrices: TypeAlias = NDArray[floating]

Mask module-attribute

Mask: TypeAlias = bool

MaskMatrix module-attribute

MaskMatrix: TypeAlias = NDArray[bool_]