This repository provides a unique attention-gain signal for LLM agents, emulating the dynamic modulation of noradrenaline in the brain. By incorporating both phasic and tonic signals, it allows agents to adapt to environmental changes, enhancing decision-making based on recent experiences and prediction uncertainties.
Introduction
The @mneva/lc-attention module introduces a novel attention-gain signal inspired by the locus coeruleus for large language model (LLM) agents. This implementation utilizes dual modes of noradrenaline-like modulation—phasic and tonic—to dynamically adjust attention based on contextual signals derived from a Postgres database.
Value Proposition
Most conventional agent frameworks treat attention as a static parameter, either as a prompt or a sampling temperature. However, human cognitive processes, particularly involving the locus coeruleus, operate differently. This module replicates the brain’s approach by employing two distinct modes:
- Tonic Mode: Provides a consistent baseline that tracks volatility over a longer duration (30-60 minutes).
- Phasic Mode: Reacts to significant prediction errors with brief pulses that decay within minutes.
These modes work together to effectively modulate cortical gain—determining what information gets prioritized and how aggressively updates to prior knowledge occur. The lcCurrent() function acts as a focal point for agents, guiding decision-making based on attentional state:
- With high phasic readings, attention windows can be broadened.
- When tonic levels rise, indicating environmental noise, action can be tempered.
Literature Foundation
The concepts underlying @mneva/lc-attention draw from various pivotal studies:
- Aston-Jones & Cohen 2005: Adaptive gain theory.
- Yu & Dayan 2005: Representation of unexpected uncertainty in neural encoding.
- Bouret & Sara 2005: Mechanistic insights into neurophysiological network resets.
Functionality Overview
This library is designed to track gain signals based on activity descriptions without serving as a baseline-computing tool or learning-rate scheduler. Instead, it allows for flexibility as users define the conditions under which gain signals are pulsed and foundational metrics are recalibrated, customized to the needs of individual agents.
Usage Example
To implement @mneva/lc-attention:
import { Pool } from 'pg';
import { lcPulse, lcTonicUpdate, lcCurrent } from '@mneva/lc-attention';
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
// Trigger a phasic response for a prediction miss.
await lcPulse(pool, {
gain: 1.7,
trigger_source: 'prediction_miss',
reason: 'expected file to exist, got ENOENT',
inputs: { prior_confidence: 0.9, tool: 'Read' },
});
// Update tonic gain based on recent performance.
await lcTonicUpdate(pool, {
gain: 1.25,
reason: 'miss rate 0.4 over last 60 min',
inputs: { window_minutes: 60, miss_rate: 0.4 },
});
// Acquire the current gain state.
const state = await lcCurrent(pool);
if (state.gain > 1.3) {
// Broaden attention parameters based on the current high gain.
}
Behavioral Insights
The lcCurrent() function determines gain states based on:
- The presence of active phasic or tonic samples.
- Exponential decay tied to the sample's half-life.
- Prioritization rules where phasic samples take precedence over tonic ones.
The interpretation of gain values provides insights that can guide further actions without imposing strict policies. As agents interact with the system, they can weigh responses based on their specific contexts and conditions.
Schema
A single table, lc_samples, captures each gain sample with a distinct mode to differentiate between phasic and tonic entries. The structure is optimized for efficiency in accessing the most recent active samples.
This module serves as a powerful tool for enhancing decision-making processes in LLM agents, informed by neurophysiological principles.
No comments yet.
Sign in to be the first to comment.