Skip to main content

Neurotransmitter-inspired adaptive learning layer for LLMs

Project description

Limbiq

Neurotransmitter-inspired adaptive learning layer for LLMs.

Limbiq makes any LLM appear to learn and adapt across conversations — without touching a single weight. It sits between the user and the LLM, modifying what the model sees through five discrete signal types inspired by human brain chemistry.

User → Limbiq → Modified Context → Any LLM → Response → Limbiq observes → Loop

Installation

pip install limbiq                    # Core — text-based signals + knowledge graph
pip install limbiq[steering-mlx]      # + MLX activation steering (Apple Silicon)

Quick Start

As a library

from limbiq import Limbiq

lq = Limbiq(
    store_path="./neuro_data",
    user_id="dimuthu",
)

# Before sending to LLM — get enriched context
result = lq.process(
    message="What's my wife's name?",
    conversation_history=[
        {"role": "user", "content": "Hi there"},
        {"role": "assistant", "content": "Hello! How can I help?"},
    ],
)

# Inject result.context into your system prompt
messages = [
    {"role": "system", "content": f"You are a helpful assistant.\n\n{result.context}"},
    {"role": "user", "content": "What's my wife's name?"},
]
response = my_llm(messages)  # Any LLM

# After getting response — let Limbiq observe and learn
lq.observe("What's my wife's name?", response)

# End session — triggers memory compression + graph inference
lq.end_session()

With the built-in LLM client

Limbiq includes a generic LLM client that works with any OpenAI-compatible API — Ollama, OpenAI, Claude (via proxy), vLLM, LM Studio, etc.

from limbiq import Limbiq, LLMClient

# Connect to Ollama
llm = LLMClient(base_url="http://localhost:11434/v1", model="llama3.1")

# Connect to OpenAI
llm = LLMClient(base_url="https://api.openai.com/v1", model="gpt-4o", api_key="sk-...")

# Pass to Limbiq — enables LLM-powered compression, entity extraction, and pattern detection
lq = Limbiq(store_path="./data", user_id="dimuthu", llm_fn=llm)

Playground

Limbiq ships with an interactive web dashboard for exploring the knowledge graph, chatting, and inspecting signals.

# Basic — heuristic mode (no LLM needed)
python -m limbiq.playground

# With Ollama
python -m limbiq.playground --llm-url http://localhost:11434/v1 --llm-model llama3.1

# With OpenAI
python -m limbiq.playground --llm-url https://api.openai.com/v1 --llm-model gpt-4o --llm-api-key sk-...

# With any OpenAI-compatible API (vLLM, LM Studio, etc.)
python -m limbiq.playground --llm-url http://localhost:8000/v1 --llm-model my-model

The playground includes:

  • Chat — talk to limbiq and watch it learn in real time (uses LLM if connected)
  • Knowledge Graph — interactive D3 visualization of entities and relations
  • Entity Explorer — browse entities and their relationships
  • Query Builder — test graph queries, memory retrieval, and the reasoner side by side
  • Traces — OpenTelemetry trace viewer for debugging

Open http://localhost:8765 after starting.

The Five Signals

Dopamine — "This matters, remember it"

Fires when the user shares personal info, corrects the model, or gives positive feedback. Tagged memories are always included in context.

lq.dopamine("User's wife is named Prabhashi")

GABA — "Suppress this, let it fade"

Fires when memories are denied, contradicted, or go stale. Suppression is soft — memories can be restored.

lq.gaba(memory_id="abc123")
lq.restore_memory("abc123")  # Undo suppression

Serotonin — "This pattern is stable, make it a rule"

Watches for recurring patterns across sessions. After 3+ observations across 2+ sessions, crystallizes into a permanent behavioral rule injected into every future context.

# Automatic — fires when patterns like "user always writes short messages" repeat
rules = lq.get_active_rules()
lq.deactivate_rule(rule_id)   # Turn off a wrong rule
lq.reactivate_rule(rule_id)   # Turn it back on

Acetylcholine — "Go deep here, build expertise"

Detects sustained interest in a topic and creates knowledge clusters — grouped collections of memories loaded as a unit when the topic returns.

clusters = lq.get_clusters()
memories = lq.get_cluster_memories(cluster_id)

Norepinephrine — "Something changed, be careful"

Fires on topic shifts, user frustration, or contradictions. Temporarily widens memory retrieval and adds caution flags. Effects reset after each process() call.

Knowledge Graph

Limbiq automatically builds a knowledge graph from conversations. Entities and relationships are extracted, inferred, and used to answer questions with zero LLM cost.

lq.query_graph("Who is Prabhashi?")    # Direct graph lookup
lq.get_world_summary()                  # Compact summary of everything known
lq.get_entities()                        # All known entities
lq.get_relations()                       # All relationships (including inferred)

Activation Steering (Experimental)

Beyond text injection, limbiq can modify the model's internal representations at inference time using learned direction vectors.

from limbiq import Limbiq
from limbiq.steering import enable_steering

lq = Limbiq(store_path="./data", user_id="test")
steered = enable_steering(lq, model_path="mlx-community/Meta-Llama-3.1-8B-Instruct-4bit")

# Signals now operate at the activation level
result = steered.generate("What's my wife's name?")
# Dopamine fires → memory_attention vector injected → model attends to memory

8 steering dimensions: conciseness, formality, technical depth, creativity, confidence, helpfulness, honesty, memory attention.

Corrections

Combines Dopamine + GABA — stores new info as priority, suppresses the old.

lq.correct("User works at Bitsmedia, not Google")

Inspection

lq.get_stats()              # Memory counts per tier
lq.get_signal_log()         # Full history of signals fired
lq.get_priority_memories()  # All dopamine-tagged memories
lq.get_suppressed()         # All GABA-suppressed memories
lq.get_full_profile()       # Complete user profile across all signals
lq.export_state()           # Full JSON export for debugging

How It Works

  • LLM-agnostic — works with any LLM via a unified OpenAI-compatible client (Ollama, OpenAI, Claude, vLLM, LM Studio)
  • Zero weight modification — all adaptation through context manipulation and activation steering
  • Knowledge graph — entities and relations extracted automatically, inferred transitively
  • Interactive playground — web dashboard with chat, graph visualization, and trace viewer
  • SQLite persistence — memories, graph, and rules survive across sessions
  • Semantic search — sentence-transformers for embedding-based retrieval (TF-IDF fallback)
  • Transparent — every signal is logged with trigger, timestamp, and effect
  • Reversible — suppressed memories can be restored, rules deactivated, nothing permanently destructive
  • Thread-safe — per-thread SQLite connections for Gradio, FastAPI, etc.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

limbiq-0.4.0.tar.gz (124.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

limbiq-0.4.0-py3-none-any.whl (125.7 kB view details)

Uploaded Python 3

File details

Details for the file limbiq-0.4.0.tar.gz.

File metadata

  • Download URL: limbiq-0.4.0.tar.gz
  • Upload date:
  • Size: 124.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for limbiq-0.4.0.tar.gz
Algorithm Hash digest
SHA256 10b6336167b977566847117be63e579c36b3c78a49d22c4e1e479b887d41a368
MD5 414000ad20c7c050986412c5d9a51c5d
BLAKE2b-256 074ef264f44b70f24d1cfa8fdf9109d4008b186a6cbdc75ef2db0219e58d6a48

See more details on using hashes here.

File details

Details for the file limbiq-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: limbiq-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 125.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for limbiq-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a2f201c4c9e71394bbe7a9851526996f627de6f4bd19c6bd3a83a1ffc2d0fab5
MD5 ddebe802160dbde670f700cd6f17413d
BLAKE2b-256 88ea64c369f5099cb9b9426feb5ad2388d4ed2def7b9f761cb98da1675747b7a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page