embedmodel

package
v0.31.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package embedmodel bundles a sentence-embedding model so agentic memory works with zero external dependencies — no API key, no network call (after the one-time model download), no separate model server required.

The model is thenlper/gte-small (384-dimensional embeddings), run via Hugot's pure-Go (GoMLX simplego) backend. Because Hugot loads models from filesystem paths, the small tokenizer/config assets are embedded in the binary and lazily materialized to a cache directory on first use, while the large ONNX weight file (~133 MB) is downloaded on first use from Hugging Face rather than bloating the binary, which keeps the distributable binary small while preserving the single-command, no-API-key experience.

gte-small was chosen over the previous all-MiniLM-L6-v2 because it scores higher on the MTEB benchmark (~61.4 vs ~56.3), requires no query/passage prefixing (unlike bge-small or e5-small), and is a drop-in 384-dim replacement.

Index

Constants

View Source
const EmbeddingDim = 384

EmbeddingDim is the dimensionality of the vectors produced by the model.

View Source
const ModelFileName = "model.onnx"

ModelFileName is the name of the ONNX weight file in the cache directory.

View Source
const ModelName = "thenlper/gte-small"

ModelName is the human-readable identifier of the bundled model.

View Source
const ModelSHA256 = "0b01312b59bec0a2558a626f2937be4cbe4bb16d1511560153f598cec488f1f8"

ModelSHA256 is the expected SHA-256 of the downloaded ONNX file, used to verify integrity and detect partial/corrupt downloads.

View Source
const ModelURL = "https://huggingface.co/thenlper/gte-small/resolve/main/onnx/model.onnx"

ModelURL is the canonical download URL for the ONNX weights. The file is fetched on first use when it is not already present in the cache directory.

Variables

View Source
var AssetNames = []string{
	"tokenizer.json",
	"tokenizer_config.json",
	"special_tokens_map.json",
	"config.json",
	"vocab.txt",
}

AssetNames is the ordered list of small files bundled in the binary, relative to the assets/ directory. Each is written verbatim to the cache dir. The large ONNX model file is NOT in this list — it is downloaded on first use (see ModelURL / ModelSHA256).

Functions

func ReadAsset

func ReadAsset(name string) []byte

ReadAsset returns the raw bytes of a bundled asset file. name must be one of AssetNames. It panics if the asset is missing (a build-time packaging bug).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL