mixle.represent.api module¶
fit_embedder – point it at raw heterogeneous data, get back vectors and retrieval.
The one-call product surface over the representation layer: text or records (dicts / tuples of mixed
fields) featurize through the task layer’s deterministic hashers, and a generatively-trained autoencoder
(mixle.represent.generative.fit_autoencoder()) compresses them into a learned dim-space. The
returned Embedder transforms new items into that space and retrieves nearest neighbours over the
fitted corpus – model-based retrieval over raw data, no upstream tokenizer or external embedding API:
emb = fit_embedder(tickets, dim=16) # dict/tuple records or strings
emb.transform(new_items) # (N, dim)
emb.retrieve(query, k=5) # [(corpus index, similarity), ...]
emb.save(path); Embedder.load(path) # durable artifact
Deterministic given seed. Needs torch only to FIT; a saved Embedder reloads and transforms anywhere.
- class Embedder(featurizer, result, kind, corpus_vectors)[source]
Bases:
objectA fitted embedding of raw heterogeneous items:
transformto vectors,retrieveneighbours.- Parameters:
featurizer (Any)
result (AutoencoderResult)
kind (str)
corpus_vectors (np.ndarray)
- property dim: int
- transform(items)[source]
Embed items into the learned space, unit-normalized (so dot = cosine similarity).
- retrieve(query, k=5)[source]
Top-
kfitted-corpus neighbours ofqueryas(corpus index, cosine similarity).
- fit_embedder(data, dim=32, *, kind=None, feature_dim=256, hidden=(64,), epochs=200, lr=1e-2, seed=0)[source]
Fit a learned embedding of raw text or record items and return an
Embedder.Items featurize deterministically (hashing trick; no fitted vocabulary), then an autoencoder learns a
dim-dimensional generative representation of the corpus.retrieveworks out of the box over the fitted data;transformembeds anything of the same kind.