embed

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package embed es la capa OPCIONAL de embeddings de nem (apagada por default). La base de la búsqueda es estructura + BM25 + razonamiento del agente; los embeddings agregan una señal semántica (para paráfrasis/idioma) que se fusiona por RRF. Backends pluggables Ollama (local) y API (OpenAI-compatible), solo net/http: nem sigue Go puro. Se embeben los resúmenes de los nodos del índice (baratos: decenas), no los 97k mensajes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cosine

func Cosine(a, b []float32) float64

Cosine devuelve la similitud coseno de dos vectores (0 si dimensiones != ).

func Decode

func Decode(b []byte) []float32

Decode deserializa un BLOB de Encode a un vector float32.

func Encode

func Encode(v []float32) []byte

Encode serializa un vector float32 a bytes (little-endian) para guardar en BLOB.

Types

type Embedder

type Embedder interface {
	Embed(ctx context.Context, texts []string) ([][]float32, error)
}

Embedder convierte textos en vectores. Embed procesa un lote.

func FromConfig

func FromConfig() (Embedder, error)

FromConfig construye un Embedder según ~/.nem/config.toml embed. Devuelve (nil, nil) si el backend está vacío (= embeddings apagados).

func New

func New(backend string, options ...Option) (Embedder, error)

New crea un Embedder para "ollama" | "api".

type Option

type Option func(*config) error

Option configura el Embedder.

func WithAPIKey

func WithAPIKey(k string) Option

WithAPIKey fija la API key (backend "api"; si no, OPENAI_API_KEY).

func WithEndpoint

func WithEndpoint(e string) Option

WithEndpoint fija el endpoint base.

func WithModel

func WithModel(m string) Option

WithModel fija el modelo de embeddings.

Jump to

Keyboard shortcuts

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