<!-- Source: https://docs.squirro.com/en/latest/api/squirro.lib.nlp.steps.runtimes.ONNXRuntime.html -->
# ONNXRuntime

**`class ONNXRuntime(config)`**

Bases: [`Runtime`](squirro.lib.nlp.steps.runtimes.Runtime.md#squirro.lib.nlp.steps.runtimes.Runtime)

Step that process data using models in the ONNX format ([https://onnx.ai/](https://onnx.ai/)).

**Input** - the input fields need to be of type that is expected by the provided model.

**Output** - the output fields depend on the provided model and the data it returns.

Parameters

- `type` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – onnx
- `model` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – Model location
- `input_mapping` ([`dict`](https://docs.python.org/3.11/library/stdtypes.html#dict)) – dictionary of input fields mapping: name of the model
  input to the document input field
- `output_mapping` ([`dict`](https://docs.python.org/3.11/library/stdtypes.html#dict)) – dictionary of output fields mapping: name of the model
  output to the document output field

**Example**

```json
{
    "step": "runtime",
    "type": "onnx",
    "model": "/models/test-model.onnx",
    "input_mapping": {
        "input": "query"
    },
    "output_mapping": {
        "output_label": "query_class",
        "output_probability": "query_probability"
    }
}
```

Methods SummaryMethods Documentation

**`pre_session_hook()`**

Pre-session hook that is executed before creating an inference session.

It can be overwritten by subclasses to perform custom operations e.g.
downloading model.

Return type

[`None`](https://docs.python.org/3.11/library/constants.html#None)

**`process_batch(batch)`**

Process a batch of documents. If not defined will default to using
self.process_doc for each document in the batch.

Parameters

`batch` ([`list`](https://docs.python.org/3.11/library/stdtypes.html#list)`(`[`Document`](../technical/libnlp/base.md#squirro.lib.nlp.document.Document)`)`) – List of documents

Returns

List of processed documents

Return type

[list](https://docs.python.org/3.11/library/stdtypes.html#list)([Document](../technical/libnlp/base.md#squirro.lib.nlp.document.Document))
