Recursive AI

OneModel guide

All onemodel docs

How to use the library, with examples that are built and run in CI (tests/GuideSamples). The notes one level up in docs are the normative specifications; this guide is for people who want to run a model, or train one, today.

If you want toRead
Run an ONNX model in a few lines, then with options, named tensors and limitsgetting-started.md
Work with tensors: creation, views, arithmetic, who owns the memory, scopestensors.md
Know what can go wrong and what to catcherrors.md
Save a model in the OneModel format, or tell what a file isformat.md
Train a model, checkpoint it and resumetraining.md
Turn a model written in C# into a graph that runs and saves like an imported onetracing.md
Move code over from Microsoft.ML.OnnxRuntimemigrating-from-onnxruntime.md
Move code over from TorchSharpmigrating-from-torchsharp.md

The three layers

You use the lowest one that does the job.

LayerTypesNamespace
Happy path: load a file, pass arrays, get an arrayModelRecursiveAI.OneModel
Graph layer: sessions, options, named tensors, the imported graphSession, ModelOptions, ModelLoadOptions, SessionOutputs, IrModel, OnnxImporter, ModelFormat, TracerRecursiveAI.OneModel.Graph, .Onnx, .Format, .Tracing
Tensor layer: tensors, differentiable operations, scopes (and, in RecursiveAI.OneModel.Training, modules, optimizers, losses, checkpoints)Tensor, Ops, ActivationScope, TensorComputeRecursiveAI.OneModel.Tensors

ArithmeticMode, ModelLoadOptions and the base exception OneModelException live in the root namespace RecursiveAI.OneModel, which is also the one Model is in. The examples assume using lines for the namespaces they use.

Install

dotnet add package RecursiveAI.OneModel
dotnet add package RecursiveAI.OneModel.Training      # only to train

Both packages reference nothing but the .NET shared framework (net10.0). They run unchanged on Linux, macOS and Windows, x64 and arm64, and in a browser (WebAssembly). Under NativeAOT see the note in the README.