# `vllm_mlx.rerank`

Reranker engine for cross-encoder models.

[View the complete module source at #L1-L398](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L1-L398).

## API details

Each callable below includes its exact signature, type annotations, inputs, defaults, return contract, documented exceptions, implementation source, and parsed docstring sections when the source provides them.

::: vllm_mlx.rerank
    options:
      members:
        - logger
        - RerankAdapter
        - SigmoidAdapter
        - _ADAPTER_REGISTRY
        - get_adapter
        - RerankEngine
        - _build_classifier_model
        - _MLXClassifierWrapper
        - _ClassifierOutput
      filters: []
      show_if_no_docstring: true

## Complete contract reference

Expand any definition for its exact inputs, annotations, defaults, return contract, directly raised exceptions, source-grounded behavior, and immutable line link. This section includes private and nested definitions that ordinary API generators omit.

<details class="api-contract" id="contract-vllm_mlx.rerank.RerankAdapter" markdown="1">
<summary><code>vllm_mlx.rerank.RerankAdapter</code> · class</summary>

```python
vllm_mlx.rerank.RerankAdapter()
```

Per-family adapter for reranker models.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Constructs: `vllm_mlx.rerank.RerankAdapter`

**Exceptions and behavior**

Class `RerankAdapter` derives from `ABC` and declares 3 direct member(s).
No direct `raise` statement appears in this definition.

[View source #L29-L80](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L29-L80).

</details>

<details class="api-contract" id="contract-vllm_mlx.rerank.RerankAdapter.tokenize_pair" markdown="1">
<summary><code>vllm_mlx.rerank.RerankAdapter.tokenize_pair</code> · method</summary>

```python
vllm_mlx.rerank.RerankAdapter.tokenize_pair(tokenizer, query: str, document: str, max_length: int) -> dict
```

Tokenize a (query, document) pair for the cross-encoder.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `tokenizer` | `not annotated` | `yes` | `none` | The HuggingFace tokenizer instance. |
| `query` | `str` | `yes` | `none` | The query string. |
| `document` | `str` | `yes` | `none` | The document string. |
| `max_length` | `int` | `yes` | `none` | Truncation length (from the model's context window). |

**Returns**

- Type: `dict`

**Exceptions and behavior**

Method `RerankAdapter.tokenize_pair` contains no state mutation, call, raise, return, await, or yield.
No direct `raise` statement appears in this definition.

[View source #L39-L54](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L39-L54).

</details>

<details class="api-contract" id="contract-vllm_mlx.rerank.RerankAdapter.extract_score" markdown="1">
<summary><code>vllm_mlx.rerank.RerankAdapter.extract_score</code> · method</summary>

```python
vllm_mlx.rerank.RerankAdapter.extract_score(logits) -> float
```

Extract a raw relevance score from model output logits.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `logits` | `not annotated` | `yes` | `none` | Model output logits (list or array), shape varies by model. |

**Returns**

- Type: `float`

**Exceptions and behavior**

Method `RerankAdapter.extract_score` contains no state mutation, call, raise, return, await, or yield.
No direct `raise` statement appears in this definition.

[View source #L57-L67](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L57-L67).

</details>

<details class="api-contract" id="contract-vllm_mlx.rerank.RerankAdapter.normalize" markdown="1">
<summary><code>vllm_mlx.rerank.RerankAdapter.normalize</code> · method</summary>

```python
vllm_mlx.rerank.RerankAdapter.normalize(raw_score: float) -> float
```

Normalize a raw score to [0, 1] range.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `raw_score` | `float` | `yes` | `none` | The raw score from extract_score(). |

**Returns**

- Type: `float`

**Exceptions and behavior**

Method `RerankAdapter.normalize` contains no state mutation, call, raise, return, await, or yield.
No direct `raise` statement appears in this definition.

[View source #L70-L80](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L70-L80).

</details>

<details class="api-contract" id="contract-vllm_mlx.rerank.SigmoidAdapter" markdown="1">
<summary><code>vllm_mlx.rerank.SigmoidAdapter</code> · class</summary>

```python
vllm_mlx.rerank.SigmoidAdapter()
```

Default adapter for single-logit sigmoid rerankers.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Constructs: `vllm_mlx.rerank.SigmoidAdapter`

**Exceptions and behavior**

Class `SigmoidAdapter` derives from `RerankAdapter` and declares 3 direct member(s).
No direct `raise` statement appears in this definition.

[View source #L83-L111](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L83-L111).

</details>

<details class="api-contract" id="contract-vllm_mlx.rerank.SigmoidAdapter.tokenize_pair" markdown="1">
<summary><code>vllm_mlx.rerank.SigmoidAdapter.tokenize_pair</code> · method</summary>

```python
vllm_mlx.rerank.SigmoidAdapter.tokenize_pair(tokenizer, query: str, document: str, max_length: int) -> dict
```

Tokenize as a sentence pair (query, document).

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `tokenizer` | `not annotated` | `yes` | `none` | Required positional or keyword input. |
| `query` | `str` | `yes` | `none` | Required positional or keyword input. |
| `document` | `str` | `yes` | `none` | Required positional or keyword input. |
| `max_length` | `int` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `dict`
- Direct return expressions: `tokenizer(query, document, padding=True, truncation=True, max_length=max_length, return_tensors='np')`

**Exceptions and behavior**

Method `SigmoidAdapter.tokenize_pair` calls `tokenizer`; returns `tokenizer(query, document, padding=True, truncation=True, max_length=max_length, return_tensors='np')`.
No direct `raise` statement appears in this definition.

[View source #L92-L103](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L92-L103).

</details>

<details class="api-contract" id="contract-vllm_mlx.rerank.SigmoidAdapter.extract_score" markdown="1">
<summary><code>vllm_mlx.rerank.SigmoidAdapter.extract_score</code> · method</summary>

```python
vllm_mlx.rerank.SigmoidAdapter.extract_score(logits) -> float
```

Extract the first logit as the relevance score.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `logits` | `not annotated` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `float`
- Direct return expressions: `float(logits[0])`

**Exceptions and behavior**

Method `SigmoidAdapter.extract_score` calls `float`; returns `float(logits[0])`.
No direct `raise` statement appears in this definition.

[View source #L105-L107](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L105-L107).

</details>

<details class="api-contract" id="contract-vllm_mlx.rerank.SigmoidAdapter.normalize" markdown="1">
<summary><code>vllm_mlx.rerank.SigmoidAdapter.normalize</code> · method</summary>

```python
vllm_mlx.rerank.SigmoidAdapter.normalize(raw_score: float) -> float
```

Apply sigmoid normalization.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `raw_score` | `float` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `float`
- Direct return expressions: `1.0 / (1.0 + math.exp(-raw_score))`

**Exceptions and behavior**

Method `SigmoidAdapter.normalize` calls `math.exp`; returns `1.0 / (1.0 + math.exp(-raw_score))`.
No direct `raise` statement appears in this definition.

[View source #L109-L111](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L109-L111).

</details>

<details class="api-contract" id="contract-vllm_mlx.rerank.get_adapter" markdown="1">
<summary><code>vllm_mlx.rerank.get_adapter</code> · function</summary>

```python
vllm_mlx.rerank.get_adapter(model_name: str) -> RerankAdapter
```

Return the appropriate adapter for a model.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `model_name` | `str` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `RerankAdapter`
- Direct return expressions: `_ADAPTER_REGISTRY['default']()`

**Exceptions and behavior**

Function `get_adapter` calls `_ADAPTER_REGISTRY['default']`; returns `_ADAPTER_REGISTRY['default']()`.
No direct `raise` statement appears in this definition.

[View source #L124-L133](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L124-L133).

</details>

<details class="api-contract" id="contract-vllm_mlx.rerank.RerankEngine" markdown="1">
<summary><code>vllm_mlx.rerank.RerankEngine</code> · class</summary>

```python
vllm_mlx.rerank.RerankEngine(model_name: str, token_budget: int = 4096, max_concurrency: int = 1)
```

Reranker engine for cross-encoder sequence classification models.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `model_name` | `str` | `yes` | `none` | Required positional or keyword input. |
| `token_budget` | `int` | `no` | `4096` | Optional positional or keyword input; defaults to `4096`. |
| `max_concurrency` | `int` | `no` | `1` | Optional positional or keyword input; defaults to `1`. |

**Returns**

- Constructs: `vllm_mlx.rerank.RerankEngine`

**Exceptions and behavior**

Class `RerankEngine` declares 6 direct member(s).
No direct `raise` statement appears in this definition.

[View source #L136-L338](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L136-L338).

</details>

<details class="api-contract" id="contract-vllm_mlx.rerank.RerankEngine.__init__" markdown="1">
<summary><code>vllm_mlx.rerank.RerankEngine.__init__</code> · method</summary>

```python
vllm_mlx.rerank.RerankEngine.__init__(model_name: str, token_budget: int = 4096, max_concurrency: int = 1) -> not annotated
```

Method `RerankEngine.__init__` updates `self.model_name`, `self.token_budget`, `self.max_concurrency`, `self._semaphore`; calls `asyncio.Semaphore`.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `model_name` | `str` | `yes` | `none` | Required positional or keyword input. |
| `token_budget` | `int` | `no` | `4096` | Optional positional or keyword input; defaults to `4096`. |
| `max_concurrency` | `int` | `no` | `1` | Optional positional or keyword input; defaults to `1`. |

**Returns**

- Type: `not annotated`

**Exceptions and behavior**

Method `RerankEngine.__init__` updates `self.model_name`, `self.token_budget`, `self.max_concurrency`, `self._semaphore`; calls `asyncio.Semaphore`.
No direct `raise` statement appears in this definition.

[View source #L147-L159](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L147-L159).

</details>

<details class="api-contract" id="contract-vllm_mlx.rerank.RerankEngine.is_loaded" markdown="1">
<summary><code>vllm_mlx.rerank.RerankEngine.is_loaded</code> · method</summary>

```python
vllm_mlx.rerank.RerankEngine.is_loaded() -> bool
```

Return whether the reranking model has been loaded.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `bool`
- Direct return expressions: `self._model is not None`

**Exceptions and behavior**

Method `RerankEngine.is_loaded` returns `self._model is not None`.
No direct `raise` statement appears in this definition.

[View source #L162-L165](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L162-L165).

</details>

<details class="api-contract" id="contract-vllm_mlx.rerank.RerankEngine.load" markdown="1">
<summary><code>vllm_mlx.rerank.RerankEngine.load</code> · method</summary>

```python
vllm_mlx.rerank.RerankEngine.load() -> None
```

Load the cross-encoder model and tokenizer.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `None`

**Exceptions and behavior**

Method `RerankEngine.load` updates `self._tokenizer`, `self._model`, `self._adapter`; calls `logger.info`, `time.perf_counter`, `AutoTokenizer.from_pretrained`, `self._load_mlx_model`.
No direct `raise` statement appears in this definition.

[View source #L167-L184](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L167-L184).

</details>

<details class="api-contract" id="contract-vllm_mlx.rerank.RerankEngine._load_mlx_model" markdown="1">
<summary><code>vllm_mlx.rerank.RerankEngine._load_mlx_model</code> · method</summary>

```python
vllm_mlx.rerank.RerankEngine._load_mlx_model(model_name: str) -> not annotated
```

Load an MLX cross-encoder model from HuggingFace Hub.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `model_name` | `str` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `not annotated`
- Direct return expressions: `model`

**Exceptions and behavior**

Method `RerankEngine._load_mlx_model` calls `snapshot_download`, `os.path.join`, `open`, `json.load`; can raise `FileNotFoundError`; returns `model`.
Directly raised exceptions: `FileNotFoundError`.

[View source #L187-L230](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L187-L230).

</details>

<details class="api-contract" id="contract-vllm_mlx.rerank.RerankEngine._ensure_loaded" markdown="1">
<summary><code>vllm_mlx.rerank.RerankEngine._ensure_loaded</code> · method</summary>

```python
vllm_mlx.rerank.RerankEngine._ensure_loaded() -> None
```

Method `RerankEngine._ensure_loaded` calls `self.load`.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `None`

**Exceptions and behavior**

Method `RerankEngine._ensure_loaded` calls `self.load`.
No direct `raise` statement appears in this definition.

[View source #L232-L234](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L232-L234).

</details>

<details class="api-contract" id="contract-vllm_mlx.rerank.RerankEngine.score_pairs" markdown="1">
<summary><code>vllm_mlx.rerank.RerankEngine.score_pairs</code> · method</summary>

```python
vllm_mlx.rerank.RerankEngine.score_pairs(query: str, documents: list[str]) -> tuple[list[float], int]
```

Score each (query, document) pair and return normalized relevance scores.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `query` | `str` | `yes` | `none` | The query string. |
| `documents` | `list[str]` | `yes` | `none` | List of document strings. |

**Returns**

- Type: `tuple[list[float], int]`
- Direct return expressions: `([score for _, score in all_scores], total_tokens)`

**Exceptions and behavior**

Method `RerankEngine.score_pairs` calls `self._ensure_loaded`, `resolve_max_length`, `getattr`, `self._adapter.tokenize_pair`; returns `([score for _, score in all_scores], total_tokens)`.
No direct `raise` statement appears in this definition.

[View source #L236-L338](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L236-L338).

</details>

<details class="api-contract" id="contract-vllm_mlx.rerank._build_classifier_model" markdown="1">
<summary><code>vllm_mlx.rerank._build_classifier_model</code> · function</summary>

```python
vllm_mlx.rerank._build_classifier_model(model_type, config, weights, num_labels) -> not annotated
```

Build an MLX sequence classification model from config and weights.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `model_type` | `not annotated` | `yes` | `none` | Required positional or keyword input. |
| `config` | `not annotated` | `yes` | `none` | Required positional or keyword input. |
| `weights` | `not annotated` | `yes` | `none` | Required positional or keyword input. |
| `num_labels` | `not annotated` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `not annotated`
- Direct return expressions: `_MLXClassifierWrapper(config, weights, num_labels)`

**Exceptions and behavior**

Function `_build_classifier_model` calls `_MLXClassifierWrapper`; returns `_MLXClassifierWrapper(config, weights, num_labels)`.
No direct `raise` statement appears in this definition.

[View source #L341-L349](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L341-L349).

</details>

<details class="api-contract" id="contract-vllm_mlx.rerank._MLXClassifierWrapper" markdown="1">
<summary><code>vllm_mlx.rerank._MLXClassifierWrapper</code> · class</summary>

```python
vllm_mlx.rerank._MLXClassifierWrapper(config: dict, weights: dict, num_labels: int)
```

Minimal MLX wrapper for sequence classification models.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `config` | `dict` | `yes` | `none` | Required positional or keyword input. |
| `weights` | `dict` | `yes` | `none` | Required positional or keyword input. |
| `num_labels` | `int` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Constructs: `vllm_mlx.rerank._MLXClassifierWrapper`

**Exceptions and behavior**

Class `_MLXClassifierWrapper` declares 3 direct member(s).
No direct `raise` statement appears in this definition.

[View source #L352-L391](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L352-L391).

</details>

<details class="api-contract" id="contract-vllm_mlx.rerank._MLXClassifierWrapper.__init__" markdown="1">
<summary><code>vllm_mlx.rerank._MLXClassifierWrapper.__init__</code> · method</summary>

```python
vllm_mlx.rerank._MLXClassifierWrapper.__init__(config: dict, weights: dict, num_labels: int) -> not annotated
```

Method `_MLXClassifierWrapper.__init__` updates `self.config`, `self.weights`, `self.num_labels`, `self._params`; calls `list`, `weights.values`.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `config` | `dict` | `yes` | `none` | Required positional or keyword input. |
| `weights` | `dict` | `yes` | `none` | Required positional or keyword input. |
| `num_labels` | `int` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `not annotated`

**Exceptions and behavior**

Method `_MLXClassifierWrapper.__init__` updates `self.config`, `self.weights`, `self.num_labels`, `self._params`; calls `list`, `weights.values`.
No direct `raise` statement appears in this definition.

[View source #L361-L365](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L361-L365).

</details>

<details class="api-contract" id="contract-vllm_mlx.rerank._MLXClassifierWrapper.parameters" markdown="1">
<summary><code>vllm_mlx.rerank._MLXClassifierWrapper.parameters</code> · method</summary>

```python
vllm_mlx.rerank._MLXClassifierWrapper.parameters() -> not annotated
```

Return model parameters for mx.eval.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `not annotated`
- Direct return expressions: `self._params`

**Exceptions and behavior**

Method `_MLXClassifierWrapper.parameters` returns `self._params`.
No direct `raise` statement appears in this definition.

[View source #L367-L369](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L367-L369).

</details>

<details class="api-contract" id="contract-vllm_mlx.rerank._MLXClassifierWrapper.__call__" markdown="1">
<summary><code>vllm_mlx.rerank._MLXClassifierWrapper.__call__</code> · method</summary>

```python
vllm_mlx.rerank._MLXClassifierWrapper.__call__(input_ids: mx.array, attention_mask: mx.array = None) -> not annotated
```

Forward pass through the classifier.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `input_ids` | `mx.array` | `yes` | `none` | Required positional or keyword input. |
| `attention_mask` | `mx.array` | `no` | `None` | Optional positional or keyword input; defaults to `None`. |

**Returns**

- Type: `not annotated`
- Direct return expressions: `_ClassifierOutput(logits=logits)`

**Exceptions and behavior**

Method `_MLXClassifierWrapper.__call__` calls `classifier_forward`, `_ClassifierOutput`; returns `_ClassifierOutput(logits=logits)`.
No direct `raise` statement appears in this definition.

[View source #L371-L391](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L371-L391).

</details>

<details class="api-contract" id="contract-vllm_mlx.rerank._ClassifierOutput" markdown="1">
<summary><code>vllm_mlx.rerank._ClassifierOutput</code> · class</summary>

```python
vllm_mlx.rerank._ClassifierOutput(logits: mx.array)
```

Simple container for classifier output logits.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `logits` | `mx.array` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Constructs: `vllm_mlx.rerank._ClassifierOutput`

**Exceptions and behavior**

Class `_ClassifierOutput` declares 1 direct member(s).
No direct `raise` statement appears in this definition.

[View source #L394-L398](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L394-L398).

</details>

<details class="api-contract" id="contract-vllm_mlx.rerank._ClassifierOutput.__init__" markdown="1">
<summary><code>vllm_mlx.rerank._ClassifierOutput.__init__</code> · method</summary>

```python
vllm_mlx.rerank._ClassifierOutput.__init__(logits: mx.array) -> not annotated
```

Method `_ClassifierOutput.__init__` updates `self.logits`.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `logits` | `mx.array` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `not annotated`

**Exceptions and behavior**

Method `_ClassifierOutput.__init__` updates `self.logits`.
No direct `raise` statement appears in this definition.

[View source #L397-L398](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L397-L398).

</details>

## Complete symbol map

This map also includes private definitions and nested helpers. The signature column exposes every explicit input even when an internal helper has no dedicated parameter prose.

| Symbol | Kind | Signature and inputs | What it does | Source |
| --- | --- | --- | --- | --- |
| [`RerankAdapter`](#contract-vllm_mlx.rerank.RerankAdapter) | class | `RerankAdapter()` | Per-family adapter for reranker models. | [#L29-L80](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L29-L80) |
| [`RerankAdapter.tokenize_pair`](#contract-vllm_mlx.rerank.RerankAdapter.tokenize_pair) | method | `RerankAdapter.tokenize_pair(tokenizer, query: str, document: str, max_length: int) -> dict` | Tokenize a (query, document) pair for the cross-encoder. | [#L39-L54](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L39-L54) |
| [`RerankAdapter.extract_score`](#contract-vllm_mlx.rerank.RerankAdapter.extract_score) | method | `RerankAdapter.extract_score(logits) -> float` | Extract a raw relevance score from model output logits. | [#L57-L67](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L57-L67) |
| [`RerankAdapter.normalize`](#contract-vllm_mlx.rerank.RerankAdapter.normalize) | method | `RerankAdapter.normalize(raw_score: float) -> float` | Normalize a raw score to [0, 1] range. | [#L70-L80](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L70-L80) |
| [`SigmoidAdapter`](#contract-vllm_mlx.rerank.SigmoidAdapter) | class | `SigmoidAdapter()` | Default adapter for single-logit sigmoid rerankers. | [#L83-L111](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L83-L111) |
| [`SigmoidAdapter.tokenize_pair`](#contract-vllm_mlx.rerank.SigmoidAdapter.tokenize_pair) | method | `SigmoidAdapter.tokenize_pair(tokenizer, query: str, document: str, max_length: int) -> dict` | Tokenize as a sentence pair (query, document). | [#L92-L103](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L92-L103) |
| [`SigmoidAdapter.extract_score`](#contract-vllm_mlx.rerank.SigmoidAdapter.extract_score) | method | `SigmoidAdapter.extract_score(logits) -> float` | Extract the first logit as the relevance score. | [#L105-L107](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L105-L107) |
| [`SigmoidAdapter.normalize`](#contract-vllm_mlx.rerank.SigmoidAdapter.normalize) | method | `SigmoidAdapter.normalize(raw_score: float) -> float` | Apply sigmoid normalization. | [#L109-L111](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L109-L111) |
| [`get_adapter`](#contract-vllm_mlx.rerank.get_adapter) | function | `get_adapter(model_name: str) -> RerankAdapter` | Return the appropriate adapter for a model. | [#L124-L133](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L124-L133) |
| [`RerankEngine`](#contract-vllm_mlx.rerank.RerankEngine) | class | `RerankEngine(model_name: str, token_budget: int = 4096, max_concurrency: int = 1)` | Reranker engine for cross-encoder sequence classification models. | [#L136-L338](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L136-L338) |
| [`RerankEngine.__init__`](#contract-vllm_mlx.rerank.RerankEngine.__init__) | method | `RerankEngine.__init__(model_name: str, token_budget: int = 4096, max_concurrency: int = 1) -> not annotated` | Method `RerankEngine.__init__` updates `self.model_name`, `self.token_budget`, `self.max_concurrency`, `self._semaphore`; calls `asyncio.Semaphore`. | [#L147-L159](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L147-L159) |
| [`RerankEngine.is_loaded`](#contract-vllm_mlx.rerank.RerankEngine.is_loaded) | method | `RerankEngine.is_loaded() -> bool` | Return whether the reranking model has been loaded. | [#L162-L165](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L162-L165) |
| [`RerankEngine.load`](#contract-vllm_mlx.rerank.RerankEngine.load) | method | `RerankEngine.load() -> None` | Load the cross-encoder model and tokenizer. | [#L167-L184](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L167-L184) |
| [`RerankEngine._load_mlx_model`](#contract-vllm_mlx.rerank.RerankEngine._load_mlx_model) | method | `RerankEngine._load_mlx_model(model_name: str) -> not annotated` | Load an MLX cross-encoder model from HuggingFace Hub. | [#L187-L230](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L187-L230) |
| [`RerankEngine._ensure_loaded`](#contract-vllm_mlx.rerank.RerankEngine._ensure_loaded) | method | `RerankEngine._ensure_loaded() -> None` | Method `RerankEngine._ensure_loaded` calls `self.load`. | [#L232-L234](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L232-L234) |
| [`RerankEngine.score_pairs`](#contract-vllm_mlx.rerank.RerankEngine.score_pairs) | method | `RerankEngine.score_pairs(query: str, documents: list[str]) -> tuple[list[float], int]` | Score each (query, document) pair and return normalized relevance scores. | [#L236-L338](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L236-L338) |
| [`_build_classifier_model`](#contract-vllm_mlx.rerank._build_classifier_model) | function | `_build_classifier_model(model_type, config, weights, num_labels) -> not annotated` | Build an MLX sequence classification model from config and weights. | [#L341-L349](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L341-L349) |
| [`_MLXClassifierWrapper`](#contract-vllm_mlx.rerank._MLXClassifierWrapper) | class | `_MLXClassifierWrapper(config: dict, weights: dict, num_labels: int)` | Minimal MLX wrapper for sequence classification models. | [#L352-L391](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L352-L391) |
| [`_MLXClassifierWrapper.__init__`](#contract-vllm_mlx.rerank._MLXClassifierWrapper.__init__) | method | `_MLXClassifierWrapper.__init__(config: dict, weights: dict, num_labels: int) -> not annotated` | Method `_MLXClassifierWrapper.__init__` updates `self.config`, `self.weights`, `self.num_labels`, `self._params`; calls `list`, `weights.values`. | [#L361-L365](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L361-L365) |
| [`_MLXClassifierWrapper.parameters`](#contract-vllm_mlx.rerank._MLXClassifierWrapper.parameters) | method | `_MLXClassifierWrapper.parameters() -> not annotated` | Return model parameters for mx.eval. | [#L367-L369](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L367-L369) |
| [`_MLXClassifierWrapper.__call__`](#contract-vllm_mlx.rerank._MLXClassifierWrapper.__call__) | method | `_MLXClassifierWrapper.__call__(input_ids: mx.array, attention_mask: mx.array = None) -> not annotated` | Forward pass through the classifier. | [#L371-L391](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L371-L391) |
| [`_ClassifierOutput`](#contract-vllm_mlx.rerank._ClassifierOutput) | class | `_ClassifierOutput(logits: mx.array)` | Simple container for classifier output logits. | [#L394-L398](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L394-L398) |
| [`_ClassifierOutput.__init__`](#contract-vllm_mlx.rerank._ClassifierOutput.__init__) | method | `_ClassifierOutput.__init__(logits: mx.array) -> not annotated` | Method `_ClassifierOutput.__init__` updates `self.logits`. | [#L397-L398](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/rerank.py#L397-L398) |
