Skip to content
@gonnx-models

gonnx-models

Hi there 👋

gonnx

gonnx is a thin packaging wrapper on the onnxruntime-purego package. A library which loads libonnx using purego.

While there are other non-cgo options for ONNX inference, I found inference to be orders of magnitudes slower than libonnx. Of course, there are also cgo options for libonnx, but they evidently come with the downsides of cgo. Thus for me (and I wager for many) libonnx with purego is the best option.

Along with helpers for embedding batteries-included ONNX models directly in your go binary, gonnx has helpers for embedding libonnx (required by purego).

The available libonnx runtime packages follow:

github.com/mackross/gonnx/runtimes/linuxamd64
github.com/mackross/gonnx/runtimes/linuxarm64
github.com/mackross/gonnx/runtimes/darwinamd64
github.com/mackross/gonnx/runtimes/darwinarm64
github.com/mackross/gonnx/runtimes/windowsamd64
github.com/mackross/gonnx/runtimes/windowsarm64

Simply _ import these packages for architectures where you wish to use libonnx with purego.

gonnx-models

gonnx-models contain ONNX models that have already been prepared with gonnx. They are ready to run without download at runtime. The ONNX model data has been embedded into the go packages using go embed. While this increases the size of your binary, the ease of running a model that "just works" is often worth it.

Quick start with NER (named entity extraction) model

import (
    "context"

    "github.com/gonnx-models/bertuncased"
    "github.com/mackross/gonnx"
    _ "github.com/mackross/gonnx/runtimes/linuxamd64"
)

recognizer, err := bertuncased.Open(gonnx.WithThreads(1))
if err != nil {
    return err
}
defer recognizer.Close()

entities, err := recognizer.Recognize(context.Background(), "Bill Gates worked at Microsoft in Seattle.")
// entities = Bill Gates, Microsoft, Seattle.

Models

The models repository contains a list of the ready to drop in gonnx (go module) models.

Popular repositories Loading

  1. models models Public

  2. nerutils nerutils Public

    Go

  3. silero silero Public

    Go

  4. smartturn smartturn Public

    Go

  5. neurobert neurobert Public

    Go

  6. bertcased bertcased Public

    Go

Repositories

Showing 10 of 11 repositories

People

This organization has no public members. You must be a member to see who’s a part of this organization.

Top languages

Loading…

Most used topics

Loading…