Skip to content

Models

UNaIVERSE puts no constraint on what an agent is made of. Its processor can be a neural network, a language model, a symbolic planner or a plain function (see Agents). You can pass your own torch.nn.Module or callable as proc. The SDK wraps it in a ModuleWrapper that checks the inputs and outputs against the streams of the agent and runs the calls in a worker thread (see Agents).

The module unaiverse.modules.networks (API reference) also offers ready-made processors. Each one is a ModuleWrapper that already declares its inputs and outputs. Agent(proc=TinyLLama()) therefore needs no proc_inputs or proc_outputs.

from unaiverse.agent import Agent
from unaiverse.modules.networks import SmolVLM
from unaiverse.networking.node.node import Node

agent = Agent(proc=SmolVLM(), proc_inputs=["img", "text"], proc_outputs=["text"])
Node(agent, node_name="SmolVLM", hidden=True).run()

Language and vision models that run locally

The weights are downloaded from Hugging Face the first time.

Class Model Reads and writes
TinyLLama(device=None) TinyLlama/TinyLlama-1.1B-Chat-v1.0 text to text
LLama(device=None) meta-llama/Llama-3.2-3B-Instruct (gated: accept its license on Hugging Face first) text to text
Phi(device=None) microsoft/Phi-3.5-mini-instruct text to text
SmolVLM(device=None) HuggingFaceTB/SmolVLM2-500M-Video-Instruct a picture and a text to text
LangSegmentAnything(device=None) segmentation guided by a text prompt (needs the lang_sam package) a picture and a text to a picture
SiteRAG(site_url, site_folder="rag/downloaded_site", db_folder="rag/chroma_db") answers from the pages of one web site, which it downloads and indexes text to text

Hosted language models

Two clients call language models that run on a provider. They take a prompt, return the text of the answer and accept the usual sampling options (max_tokens, temperature, top_p, top_k, frequency_penalty, presence_penalty, repetition_penalty, min_p and a sampler dictionary for anything else). A negative or None option is left out of the request and the provider uses its own default.

FeatherlessAPI(model=None, cost=1, system_prompt="", api_key=None, key_units=None, ...) calls Featherless. All the agents of one machine share one local gateway. The first client starts it by itself and it stops when the last client closes. The gateway shares the budget of the account among the callers and serves them in turn. cost is the number of units that each call takes (one of 1, 2 and 4 by default, as defined by GW_VALID_COSTS). The key comes from api_key or FEATHERLESS_API_KEY. The budget of the account comes from key_units or FEATHERLESS_KEY_UNITS.

OpenRouterAPI(model=None, system_prompt="", api_key=None, timeout=120.0, max_retries=3, ...) calls OpenRouter directly. model is an OpenRouter slug such as openai/gpt-4o (default from OPENROUTER_MODEL_ID) and the key comes from api_key or OPENROUTER_API_KEY. The client makes at most max_retries attempts with growing pauses for a call that fails, is rate limited or returns nothing. The client needs the openai Python package.

from unaiverse.agent import Agent
from unaiverse.modules.networks import OpenRouterAPI

agent = Agent(proc=OpenRouterAPI(model="meta-llama/llama-3.3-70b-instruct",
                                 system_prompt="You are the concierge of a small hotel."),
              proc_inputs=["text"], proc_outputs=["text"])

Like any language model, both clients can answer the forms of interactive messages and the agent checks each answer against its form.

Vision models

Class Model
ResNet(d_dim=-1, freeze_backbone=True) A ResNet-50 with ImageNet weights. With d_dim > 0 a linear layer of that size followed by a sigmoid replaces the last layer. With freeze_backbone=True only the last layer learns.
ViT(d_dim=-1), DenseNet(d_dim=-1), EfficientNet(d_dim=-1) The same for other backbones.
FasterRCNN() Object detection.
CNN, CNNMNIST Small convolutional networks for tests.

A torchvision model works just as well when you pass it as proc with the right streams (see Data streams).

Networks that learn over time

The SDK also ships the networks that the research behind UNaIVERSE designed for learning from a stream of data (see Learning over time).

Classes Module What they are
RNN, RNNTokenLM modules.networks Recurrent networks, the second one over tokens.
CSSM, CDiagR, CDiagC, CTE, CTB, CTBE and their variants modules.networks Continuous-time state-space networks that process a signal sample by sample.
SingleLayerCNU, CNNCNU, ResNetCNU modules.networks, modules.cnu Networks with Continual Neural Units, layers that keep a memory of keys and update it while they learn.
Hamiltonian Learning helpers modules.hl Integration steps for models whose parameters evolve in time under a Hamiltonian formulation of learning.