NOVA Documentation
Python SDK
On this page
- Initialize NOVAChoose a device and seed, then create a model with the required input and output dimensions.
- Fit and evaluatePass a prepared dataset to the training loop and measure performance on held-out examples.
- Persist and predictSave and reload the checkpoint, then request predictions with optional execution traces.
Import nova in Python after installing the nova-llm distribution. The examples cover numerical training, streamed adaptation, mobile export, and StateGraph.
7.1 Installation & Environment Setup
Install directly from PyPI:
pip install nova-llmOr install using Python module syntax:
python -m pip install nova-llmInstall local development dependencies from source:
python -m pip install -r requirements.txt7.2 Training, Evaluating, and Serializing Models
import nova
import numpy as np
# 1. Initialize Engine
engine = nova.Engine(device="cpu", seed=42)
# 2. Create Model Architecture
model = engine.create_model(
name="production_brain",
architecture="nova_uac_v0",
input_dim=8,
state_dim=32,
output_dim=1,
memory_dim=16
)
# 3. Create Continuous Dataset
x = np.random.randn(500, 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
history = model.fit(dataset, epochs=5, batch_size=16)
print("Training Loss History:", history["loss"])
# 5. Evaluate and Save Checkpoint
metrics = model.evaluate(dataset)
print("Evaluation Metrics:", metrics)
model.save("./artifacts/production_brain")
# 6. Load Model Deterministically & Predict with Traces
loaded_model = nova.load("./artifacts/production_brain")
preds, trace = loaded_model.predict(x[:5], return_trace=True)
print("Predictions:", preds)
print("Novelty Score:", trace.avg_novelty)
print("Uncertainty Score:", trace.avg_uncertainty)
print("Adaptive Refinement Passes:", trace.refinement_passes)7.3 Multimodal Streaming Ingestion
Continuously ingest folders of images, videos, documents, or tabular sensor data:
import nova
from nova.sdk.multimodal_dataset import MultimodalStreamingDataset
# Ingest heterogeneous files from any folder
stream = MultimodalStreamingDataset.from_directory("./my_data_folder", embed_dim=16)
# Initialize NOVA model for streaming adaptation
engine = nova.Engine(seed=42)
model = engine.create_model(input_dim=16, state_dim=32, output_dim=1, memory_dim=16)
# Stream batches and adapt in real time
for batch_x, batch_y in stream.stream_batches(batch_size=16):
init_state = model.network.init_state(batch_x.shape[0])
loss, trace = model.executor.training_step(batch_x, batch_y[:, :1], init_state)
print(f"Stream Step Loss: {loss:.4f} | Novelty: {trace.novelty:.4f} | Uncertainty: {trace.uncertainty:.4f}")7.4 On-Device Smartphone Edge Exporter
Export trained models to compressed INT8/INT4 bundles for Android and iOS execution:
from nova.compression.mobile_export import EdgeMobileExporter
# Instantiate exporter
exporter = EdgeMobileExporter(model)
# Export compressed INT8 bundle
bundle_manifest = exporter.export_for_mobile("./artifacts/mobile_bundle", bits=8)
print("Export Succeeded:")
print(f" Target File: {bundle_manifest['bundle_path']}")
print(f" Compression Ratio: {bundle_manifest['compression_ratio']}x")
print(f" Quantized Size: {bundle_manifest['quantized_size_mb']} MB")7.5 Python Agentic StateGraph (LangGraph Alternative)
from nova.workflow import Graph
# Define agent graph
graph = Graph("adaptive_decision_flow")
# Add execution nodes
graph.add_node("preprocess", lambda s: {"x": [v * 1.5 for v in s["raw"]]})
graph.add_node("predict", lambda s: {
"novelty": 0.85 if sum(s["x"]) > 2.0 else 0.15,
"confidence": 0.92
})
graph.add_node("escalate_anomaly", lambda s: {"status": "ESCALATED_TO_DRM_MEMORY"})
graph.add_node("standard_dispatch", lambda s: {"status": "ACCEPTED_NORMAL"})
# Configure entry point and edges
graph.set_entry_point("preprocess")
graph.add_edge("preprocess", "predict")
graph.add_conditional_edge("predict", lambda s: "escalate_anomaly" if s["novelty"] > 0.5 else "standard_dispatch")
graph.add_terminal("escalate_anomaly")
graph.add_terminal("standard_dispatch")
# Execute graph
result = graph.run({"raw": [1.0, 0.5, 0.8]})
print("Workflow Execution Path:", result["_history"])
print("Final Status:", result["status"])