liveBook · Manning

Optimum

As explained in Domain-Specific Small Language Models

A Hugging Face extension library for optimizing transformer models for training and inference on target hardware, including ONNX workflows.

Optimum is a Hugging Face Transformers extension for optimizing model training and inference on target hardware. Its ONNX Runtime integration supports model export, graph optimization, and quantization while keeping common workflows at a high level. section 6.3

An ONNX Runtime workflow typically includes:

  • Load a task-specific `ORTModelForXxx` class and export a Transformers model to ONNX. section 6.3

Optimizing a sequence classifier

Load a pretrained sequence-classification model with `ORTModelForSequenceClassification.from_pretrained(..., export=True)`, save the ONNX artifact, quantize it with an AVX512-VNNI configuration, and run the result through a Transformers pipeline. Compare its accuracy on Banking77 with the unoptimized pipeline and measure repeated inference latency.

How Domain-Specific Small Language Models covers it

How deep it goes
Explains high-level export and quantization workflows, but defers custom ONNX configurations for unsupported architectures.
Examples
Uses BERT and DistilBERT sequence classifiers plus CodeGen causal-language-model conversion, quantization, pipelines, and CPU benchmarks.
What it assumes
Assumes a pretrained Transformers model and tokenizer, while teaching the high-level path from model loading through ONNX export and quantization.
What you can do after
Operate/configure ONNX Runtime exports and quantization, then evaluate accuracy, latency, and throughput against an unoptimized model.
How it connects
Connects Transformers, ONNX, ONNX Runtime, quantization, model export, and inference benchmarking.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Domain-Specific Small Language Models. The section links point to the parts of the book it draws on.