Skip to content
BENIBIX Learn

Open Neural Network Exchange (ONNX)

AI⚙️ MLOps & DeploymentModel Deployment

Also known as ONNX, ONNX Format, .onnx File

An open file type for AI models. A model made in one tool runs in others.

Think of it like

It is like saving a story as a PDF. It opens the same way on almost any device.

Example

Emma trains a photo model in PyTorch and saves it as ONNX. She runs that same file in her web app and her phone app.

Why it matters

The tool that trains best is often not the one that runs best. ONNX lets you pick each one apart.

Definition

ONNX is an open file format for machine learning models. You train a model in one tool, such as PyTorch, and save it as a single .onnx file. Many other tools and chips can then run that file, from servers to phones and web pages. This frees the model from the tool it was made in. It is a graduated project of the LF AI & Data Foundation.

Example code

python
torch.onnx.export(model, sample_input, "model.onnx")
One line turns a PyTorch model into one .onnx file. Other tools can then run it.
The first panel is ONNX. One saved file runs on a phone, a browser and a server.

Common mistake

Thinking every model carries over cleanly. Some parts may not, so check the new file gives the same answers.

Key takeaways

  1. 1
    One file. The whole model in a single .onnx file.
  2. 2
    Runs anywhere. Servers, phones, browsers and many chips.
  3. 3
    Open standard. Not owned by one company.