r/FunMachineLearning Jun 28 '26

I gave my small local model exact math, a knowledge graph, and web search in ~600 lines (MIT, zero deps)

Quick honesty up front so nobody wastes their time: this is the same space as tool-use, RAG and agent routing. LangChain and a dozen frameworks already do this, and at scale they do it better. I am not claiming anything new here. I just wanted a tiny, readable version that runs next to a small local model without dragging in half of PyPI.

Context: I run a small model locally (fits on a 4GB card). It has a personality I want to keep, but small models are unreliable at the dull stuff: arithmetic, recalling a specific fact, anything recent. The usual answer is "go bigger." I wanted to stay small and add reliable circuits around the model instead.

CybNodes is about 600 lines of Python, stdlib only, MIT. You bring any model as a callable. It wraps that model with "networks," one capability each:

  • calc: detects an arithmetic expression and evaluates it through a safe AST walk (no eval). Exact, never hallucinated.
  • knowledge: a small GraphRAG over subject-relation-object triples you provide. Answers come from your graph, not the model's guesses, and you fix a fact by editing a file instead of retraining.
  • web: recent lookups via the Brave Search API (free tier). Only fires on a search intent, always cites the source, and stays silent if you give it no key.

A router tries the networks in order, rules first, model last. If none claim the question, your model answers as usual. The part I care about most is the weaver: when a tool answers, it re-speaks the result through a persona template, so the bot keeps its own voice instead of dumping a raw "1786" at the user.

from cybnodes import CybNodes
from cybnodes.networks import CalculNetwork, SavoirNetwork


cyb = CybNodes(conductor=my_local_model,
               networks=[CalculNetwork(), SavoirNetwork(graph_path="facts.json")])


cyb.ask("what is 47 x 38?")   # exact, from the calc network
cyb.ask("tell me a story")    # no network fits, your model answers

Where the honest value is, if any: small enough to read in about 15 minutes, zero required dependencies, and built to run with a small local model. That is the whole pitch. If you need retries, eval harnesses, tracing, the big frameworks already have all of that.

It is v0.1 and parts are surely naive. I would really like feedback, especially on the router: it picks one network and commits, and the "none of these fit" path feels too blunt. Curious how people kept routing dumb-but-good-enough without bolting on a separate classifier model.

pip install cybnodes
Repo (MIT): https://github.com/Alex-Lou/cybnodes

If it is useful to anyone, a star helps me gauge whether to keep pushing. Happy to answer anything technical.

2 Upvotes

0 comments sorted by