NOVA Documentation
Examples
On this page
Follow the examples in order or jump to the task you need. See the Python SDK for related APIs, and the JavaScript SDK for client and workflow examples.
Installation
Install the package and its declared dependencies from PyPI.
pip install nova-llmFrom the NOVA source checkout, install the dependencies listed in its requirements file. Run the examples from the checkout root when working with source.
python -m pip install -r requirements.txtDeveloper Model API
- Prepare arraysBuild input rows with eight features and one target per example. Convert them into a NOVA dataset.
- Train and evaluateFit the model on batches and inspect the evaluation result. Use held-out data to assess generalization.
- Save and reloadWrite the checkpoint, load it, and pass new feature rows to the prediction call.
- Inspect the traceRead novelty and uncertainty alongside the returned predictions.
Train a model on 200 samples with eight features and one numeric target. This example evaluates on its training data and saves a checkpoint under ./artifacts/my_model. Use a separate validation dataset to measure generalization. Seed NumPy separately if you need to reproduce the generated input.
import nova
import numpy as np
# 1. Initialize NOVA Engine
engine = nova.Engine(device="cpu", seed=42)
# 2. Instantiate Model
model = engine.create_model(
name="my_intelligence",
architecture="nova_uac_v0",
input_dim=8,
state_dim=32,
output_dim=1,
memory_dim=16
)
# 3. Create Dataset from real numeric dynamics
x = np.random.randn(200, 8).astype(np.float32)
y = (np.sin(x[:, :1]) + 0.5 * np.cos(x[:, 1:2])).astype(np.float32)
dataset = nova.Dataset.from_numpy(x, y)
# 4. Train with ECAL and DRM
model.fit(dataset, epochs=5, batch_size=16)
# 5. Evaluate and Save
metrics = model.evaluate(dataset)
model.save("./artifacts/my_model")
# 6. Load & Predict Deterministically
loaded = nova.load("./artifacts/my_model")
pred, trace = loaded.predict(x[:5], return_trace=True)
print(pred, trace.avg_novelty, trace.avg_uncertainty)Streaming Multimodal Ingestion & Mobile Edge Export
- Prepare inputsPut supported inputs in the example folder and choose an embedding dimension that matches the model.
- Adapt per batchStream feature and target batches, initialize batch state as the example does, and call the training step.
- Export the trained bundleChoose INT8 or INT4, then record the exported size and compression ratio.
- Validate on target hardwareCheck that the runtime can load the bundle and compare prediction error and latency against the original model.
Place input files in ./my_uploads. The encoder uses 16 features to match the model input dimension. The export writes a quantized bundle under ./artifacts/mobile_bundle.
import nova
from nova.sdk.multimodal_dataset import MultimodalStreamingDataset
from nova.compression.mobile_export import EdgeMobileExporter
# 1. Ingest any folder of images, videos, documents, or data
dataset = MultimodalStreamingDataset.from_directory("./my_uploads", embed_dim=16)
# 2. Train and adapt in real time on the stream
engine = nova.Engine(seed=42)
model = engine.create_model(input_dim=16, state_dim=32, output_dim=1, memory_dim=16)
for batch_x, batch_y in dataset.stream_batches(batch_size=16):
model.executor.training_step(batch_x, batch_y[:, :1], model.network.init_state(batch_x.shape[0]))
# 3. Export compressed INT8 bundle for smartphones (Android / iOS)
exporter = EdgeMobileExporter(model)
manifest = exporter.export_for_mobile("./artifacts/mobile_bundle", bits=8)
print(f"Compressed {manifest['compression_ratio']}x -> {manifest['quantized_size_mb']} MB")Native Agentic StateGraph (LangGraph Alternative)
This template expects you to supply the four named callbacks. The graph routes on novelty alone. A standalone routing example follows the template.
from nova.workflow import Graph
graph = Graph("adaptive_pipeline")
graph.add_node("ingest", ingest_fn)
graph.add_node("assess", model_predict_fn)
graph.add_node("memory_node", consult_drm_fn)
graph.add_node("decision", finalize_fn)
graph.set_entry_point("ingest")
graph.add_edge("ingest", "assess")
# Dynamic conditional routing based on NOVA internal novelty & uncertainty
graph.add_conditional_edge("assess", lambda state: "memory_node" if state["novelty"] > 0.6 else "decision")
graph.add_edge("memory_node", "decision")
graph.add_terminal("decision")
result = graph.run({"raw_input": [0.5, 0.2, -0.9, 0.4]})Try the StateGraph with sample data
- Ingest and assessConvert the inputs and calculate or assign a novelty score.
- Evaluate noveltyUse the example’s threshold of 0.6.
- Novelty above 0.6Visit the memory callback, then proceed to the decision node.
- Novelty at or below 0.6Proceed directly to the decision node.
- Return the decision stateThe final callback writes the status and terminates the graph.
The README version uses application callbacks. The standalone example below defines all four callbacks and uses a fixed novelty score to illustrate routing. It visits the memory node when novelty exceeds 0.6, then moves to the decision node. Replace the sample assessment and memory callbacks when integrating a model.
from nova.workflow import Graph
def ingest_fn(state):
return {"features": [float(value) for value in state["raw_input"]]}
def model_predict_fn(state):
# Fixture for the routing example
return {"novelty": 0.75}
def consult_drm_fn(state):
return {"memory_consulted": True}
def finalize_fn(state):
return {
"status": "review" if state.get("memory_consulted") else "standard"
}
graph = Graph("adaptive_pipeline")
graph.add_node("ingest", ingest_fn)
graph.add_node("assess", model_predict_fn)
graph.add_node("memory_node", consult_drm_fn)
graph.add_node("decision", finalize_fn)
graph.set_entry_point("ingest")
graph.add_edge("ingest", "assess")
graph.add_conditional_edge(
"assess",
lambda state: "memory_node" if state["novelty"] > 0.6 else "decision",
)
graph.add_edge("memory_node", "decision")
graph.add_terminal("decision")
result = graph.run({"raw_input": [0.5, 0.2, -0.9, 0.4]})
print(result["status"])Set the sample novelty to 0.6 or lower to try the standard branch.
Local Model Serving API
python -m nova.serving.appThe README lists these HTTP routes. Open http://127.0.0.1:8000/docs to confirm the paths and schemas for your installed server. See the REST reference for the master specification paths and a prediction request example.
GET /healthGET /v1/model/infoPOST /v1/predictGET /v1/memory/inspectPOST /v1/memory/writeDELETE /v1/memory/{id}
Running Benchmarks & Tests
Run these commands from the NOVA source checkout after installing its development dependencies.
# Run the 22 automated unit and integration tests
python -m pytest tests/ -v
# Run the live multimodal streaming test
python examples/06_realtime_multimodal_live_test.py
# Run empirical benchmark suite (continual learning, memory, ARA)
python -m benchmarks.run_all_benchmarks