How the Feedback Loop Adapts AutoTune Parameters in G0DM0D3
The feedback loop adapts AutoTune parameters by maintaining exponential moving averages (EMA) of user-rated parameter sets, computing weighted deltas between positive and negative feedback, and blending these adjustments into the base generation profile to continuously optimize LLM output quality.
The G0DM0D3 repository implements a self-optimizing parameter selection system that refines generation settings based on real-world usage. The feedback loop works alongside the core AutoTune engine to learn which temperature, top-p, and top-k values produce the best results for specific conversation contexts.
Core Components of the Feedback System
The feedback architecture centers on persistent storage of generation outcomes paired with quality signals. Every interaction generates a data point that influences future parameter selection.
Recording User Feedback
Each response cycle creates a FeedbackRecord that captures the complete context of generation. According to the source code in src/lib/autotune-feedback.ts, this structure stores the parameters used, the user rating (thumbs-up/down), and automatically computed quality heuristics at lines 23-32.
The processFeedback function ingests these records and maintains the system's learning state. When a user provides explicit feedback or the system generates automatic quality metrics, the record enters the processing pipeline to update the learned profiles.
Bounded History Management
To prevent unbounded memory growth, the system maintains a sliding window of recent feedback. The MAX_HISTORY constant limits the retention to the last 500 records, as implemented in the history truncation logic at lines 65-69 of autotune-feedback.ts. This ensures the feedback loop remains performant while still capturing recent usage patterns.
EMA-Based Parameter Learning
The system tracks performance using exponential moving averages that weight recent feedback more heavily than older data. This approach allows the engine to adapt to changing user preferences or conversation dynamics without overfitting to isolated incidents.
Dual EMA Tracking per Context
For each ContextType (such as code generation, creative writing, or factual queries), the engine maintains two distinct EMA parameter sets:
positiveParams– Tracks parameter configurations from up-voted responsesnegativeParams– Tracks configurations from down-voted responses
The emaUpdate function at lines 78-86 refreshes these averages whenever new feedback arrives. This separation allows the system to learn not just what works well, but also which parameter ranges consistently produce poor results.
Calculating and Applying Adjustments
The transformation from raw feedback into actionable parameter changes involves differential analysis and confidence weighting.
Delta Calculation Between EMAs
The computeAdjustments function derives parameter modifications by comparing the positive and negative EMAs. When both data sets exist, the system calculates each parameter delta as half the distance between the two averages (lines 42-48 in autotune-feedback.ts).
If only positive feedback exists for a context, the fallback computeDeltaFromNeutral applies a milder shift from a neutral baseline instead (lines 30-33). This prevents aggressive adjustments when the sample size is small or exclusively positive.
Confidence-Based Weighting
The influence of learned adjustments scales with data volume. The applyLearnedAdjustments function calculates a weight based on the number of feedback samples available, capping the learned component at 50% of the final parameter set (lines 98-102). This safeguard ensures that base context profiles always retain significant influence while learned patterns gradually increase their impact as evidence accumulates.
Blending with Base Profiles
The actual parameter synthesis occurs in the blend loop at lines 107-113, where weighted deltas merge with the parameters originally selected by the context detector. This produces the final generation settings that balance predefined heuristics with empirical performance data.
Integration with the AutoTune Engine
The public API surface exposes this learning mechanism through the computeAutoTuneParams function in src/lib/autotune.ts. This entry point accepts an optional learnedProfiles map containing the feedback state, invokes applyLearnedAdjustments, and records the resulting modifications in the transparent paramDeltas array (lines 66-71 and 76-88).
This integration ensures that every parameter computation considers historical performance while maintaining full auditability of how feedback influenced the specific values chosen.
Practical Implementation
The following patterns demonstrate how to initialize the feedback system, process ratings, and apply learned optimizations:
// 1️⃣ Initialise the feedback store (once per client)
import { createInitialFeedbackState } from './lib/autotune-feedback';
const feedbackState = createInitialFeedbackState();
// 2️⃣ After generating a response, store the rating + heuristics
import { computeHeuristics, processFeedback } from './lib/autotune-feedback';
import type { AutoTuneParams, ContextType } from './lib/autotune';
const response = /* LLM output */;
const rating: 1 | -1 = /* user thumbs‑up/down */;
const heuristics = computeHeuristics(response);
const record = {
messageId: 'msg-123',
timestamp: Date.now(),
contextType: 'code' as ContextType,
model: 'gpt-4',
persona: 'assistant',
params: currentParams, // the params used for this generation
rating,
heuristics,
};
feedbackState = processFeedback(feedbackState, record);
// 3️⃣ Use the learned profile when computing the next set of parameters
import { computeAutoTuneParams } from './lib/autotune';
const result = computeAutoTuneParams({
strategy: 'adaptive',
message: nextUserMessage,
conversationHistory,
learnedProfiles: feedbackState.learnedProfiles, // <- plug the learned data in
});
console.log('Adjusted params:', result.params);
console.log('Reasoning:', result.reasoning);
// 4️⃣ Inspect statistics (optional, for UI or debugging)
import { getFeedbackStats } from './lib/autotune-feedback';
const stats = getFeedbackStats(feedbackState);
console.table(stats.contextBreakdown);
Summary
- Dual EMA tracking maintains separate running averages for positive and negative feedback per context type in
autotune-feedback.ts - Bounded history limits memory usage to 500 records while preserving recent learning signals
- Differential adjustment computes parameter deltas as half the distance between positive and negative EMAs, or falls back to neutral baseline calculations when data is one-sided
- Confidence weighting scales adjustment influence by sample count, capping learned contributions at 50% of final parameters
- Seamless integration via
computeAutoTuneParamsblends learned profiles with base context detection, exposing full transparency throughparamDeltas
Frequently Asked Questions
How does the system handle conflicting user feedback?
The exponential moving average (EMA) mechanism naturally smooths conflicting signals by weighting recent feedback more heavily than older entries. When positive and negative ratings exist for similar contexts, computeAdjustments calculates the midpoint between the two EMAs, effectively finding a compromise position. If the conflict persists over many interactions, the EMAs will stabilize at values that statistically minimize poor outcomes across the user base.
What happens when there is not enough feedback data for a specific context?
When feedback samples are scarce or exclusively positive, the system invokes computeDeltaFromNeutral to generate conservative adjustments from a baseline rather than computing EMA differentials. Additionally, the weight calculation in applyLearnedAdjustments ensures that low-sample contexts receive minimal learned influence (approaching 0%), relying primarily on the base context profile until sufficient data accumulates.
Can the feedback loop override the base AutoTune profiles completely?
No, the architecture enforces a hard limit where learned adjustments can contribute at most 50% of the final parameter value according to lines 98-102 in autotune-feedback.ts. This design guarantees that the base heuristic profiles—derived from domain expertise—always retain veto power over fully automated optimization, preventing degenerate feedback loops or manipulation.
Where is the feedback data stored between sessions?
The provided code implements an in-memory feedback state via createInitialFeedbackState() that returns a JavaScript object structure. For persistence across sessions, applications using this library must serialize the feedbackState object (particularly the learnedProfiles map) to external storage such as a database or local filesystem, then rehydrate it when initializing the client on subsequent loads.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →