Downloads · 30 days
16
31% of all-time downloads
LoganResearch/ARC-Cognitive-Qwen-7B
ARC-Cognitive-Qwen-7B is a text generation model from LoganResearch. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as cc-by-4.0.
Downloads · 30 days
16
31% of all-time downloads
All-time downloads
51
Public
Repo size
3.6 MB
Likes
0
Public
Click a slice to open those files.
.pt3.6 MB · 99%
From the Hugging Face model README
Decode-Time Behavioral Control via Hidden State Probing
Logan Matthew Napolitano
Research into cognitive behavioral control in language models
Quick Start • Architecture • Probes • Evaluation • Citation
</div>This repository contains a cognitive enhancement adapter for Qwen2.5-7B-Instruct. The adapter consists of five lightweight probes that analyze hidden states during generation and apply targeted interventions to improve response quality.
The adapter detects cognitive failure modes (shallow reasoning, vagueness, overconfidence, topic drift, logical inconsistency) by monitoring the model's internal representations at decode time. When a probe fires, the system adjusts token probabilities to steer generation toward more desirable behaviors.
git clone https://huggingface.co/LoganResearch/qwen2.5-7b-cognitive-enhanced
cd qwen2.5-7b-cognitive-enhanced
pip install torch transformers accelerate bitsandbytes
python inference.py
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
# Load base model
model = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen2.5-7B-Instruct",
quantization_config=BitsAndBytesConfig(load_in_4bit=True),
device_map="auto",
output_hidden_states=True,
)
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-7B-Instruct")
# Load adapter
adapter = torch.load("cognitive_adapter.pt", map_location="cuda")
print(f"Probes loaded: {list(adapter['probes'].keys())}")
┌─────────────────────────────────────────────────────────────────────────────┐
│ COGNITIVE ENHANCEMENT ARCHITECTURE │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ INPUT PROCESSING │ │
│ │ User Prompt → Tokenization → Model Forward Pass │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ HIDDEN STATE EXTRACTION │ │
│ │ Layer 7, 14, 21 → Last Token Position → [batch, 3584] │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ FIBER PROJECTION │ │
│ │ Per-layer linear projection: 3584 → 16 dimensions │ │
│ │ Learned layer weights: softmax([w₇, w₁₄, w₂₁]) │ │
│ │ Weighted sum → 16-dimensional behavioral embedding │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ PROBE HEADS (×5) │ │
│ │ ┌───────────┐ ┌───────────┐ ┌───────────┐ ┌───────────┐ ┌───────┐ │ │
│ │ │ Depth │ │Specificity│ │Calibration│ │ Focus │ │Cohere.│ │ │
│ │ │ 366× │ │ 215× │ │ 165× │ │ 227× │ │ 191× │ │ │
│ │ └─────┬─────┘ └─────┬─────┘ └─────┬─────┘ └─────┬─────┘ └───┬───┘ │ │
│ │ │ │ │ │ │ │ │
│ │ └─────────────┴──────┬──────┴─────────────┴───────────┘ │ │
│ │ │ │ │
│ │ Probe Scores: P(behavior) ∈ [0,1] │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ INTERVENTION ENGINE │ │
│ │ For each probe where score > threshold (0.5): │ │
│ │ • Boost tokens: logits[token_id] += strength × boost_factor │ │
│ │ • Suppress tokens: logits[token_id] -= strength × suppress_factor│ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ OUTPUT SAMPLING │ │
│ │ Modified logits → Softmax → Token sampling → Next token │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘
Each probe consists of two components:
1. Fiber Projection (shared structure, independent weights)
Input: Hidden states from layers [7, 14, 21]
Shape: [batch, hidden_dim] × 3
Layer weights: learnable [3] → softmax
Per-layer projection: Linear(3584 → 16, bias=False)
Output: Weighted sum → [batch, 16]
2. Classification Head
Input: [batch, 16]
Linear(16 → 64) → GELU → Linear(64 → 64) → GELU → Linear(64 → 1) → Sigmoid
Output: P(cognitive_failure_mode) ∈ [0, 1]
| Probe | Separation | Detection Target | Training Steps |
|---|---|---|---|
| Depth | 366× | Shallow reasoning patterns | 2000 |
| Specificity | 215× | Vague or generic language | 2500 |
| Calibration | 165× | Overconfident assertions | 2500 |
| Focus | 227× | Topic drift indicators | 2500 |
| Coherence | 191× | Logical inconsistencies | 2500 |
Separation Ratio = mean(P(positive_class)) / mean(P(negative_class))
Higher separation indicates cleaner discrimination between behavioral states.
Purpose: Detects when the model is about to produce shallow, unsupported conclusions without intermediate reasoning steps.
Positive class indicators:
Intervention tokens:
Purpose: Detects when the model is about to produce vague, non-committal language lacking concrete details.
Positive class indicators:
Intervention tokens:
Purpose: Detects when the model is about to make overconfident claims on inherently uncertain topics.
Positive class indicators:
Intervention tokens:
Purpose: Detects when the model is about to drift away from the user's question or introduce tangential content.
Positive class indicators:
Intervention tokens:
Purpose: Detects when the model is about to produce logically inconsistent or poorly structured content.
Positive class indicators:
Intervention tokens:
def apply_intervention(logits, probe_scores, config):
"""
Modify logits based on probe activations.
Args:
logits: [vocab_size] tensor of next-token logits
probe_scores: dict mapping probe_name → score ∈ [0,1]
config: intervention parameters
Returns:
Modified logits tensor
"""
for probe_name, score in probe_scores.items():
if score > config.threshold: # Default: 0.5
strength = (score - config.threshold) * 2 # Scale to [0, 1]
# Boost beneficial tokens
for token_id in config.boost_tokens[probe_name]:
logits[token_id] += strength * config.boost_strength
# Suppress harmful tokens
for token_id in config.suppress_tokens[probe_name]:
logits[token_id] -= strength * config.suppress_strength
return logits
| Parameter | Default | Description |
|---|---|---|
threshold | 0.5 | Minimum probe score to trigger intervention |
boost_strength | 3.0 | Multiplier for token boosting |
suppress_strength | 4.0 | Multiplier for token suppression |
pip install torch>=2.0.0
pip install transformers>=4.35.0
pip install accelerate>=0.24.0
pip install bitsandbytes>=0.41.0 # For 4-bit quantization
git clone https://huggingface.co/LoganResearch/qwen2.5-7b-cognitive-enhanced
cd qwen2.5-7b-cognitive-enhanced
pip install -r requirements.txt
See inference.py for the full CognitiveEnhancedQwen class implementation.
from inference import CognitiveEnhancedQwen
# Initialize
qwen = CognitiveEnhancedQwen("cognitive_adapter.pt")
# Generate with enhancement
response = qwen.generate(
prompt="Explain why the sky is blue.",
enhanced=True,
max_tokens=300,
temperature=0.7
)
print(response)
# Compare vanilla vs enhanced
vanilla = qwen.generate("Explain the Monty Hall problem.", enhanced=False)
enhanced = qwen.generate("Explain the Monty Hall problem.", enhanced=True)
# Enable only specific probes
qwen.active_probes = ["depth", "calibration"]
# Disable a probe
qwen.active_probes = [p for p in qwen.probes.keys() if p != "focus"]
| Prompt | Vanilla Qwen | Enhanced Qwen |
|---|---|---|
| "Explain the Monty Hall problem" | Begins explanation without structure | "Here's a step-by-step explanation..." with labeled sections |
| "Will AI replace most jobs?" | "It's unlikely that AI will replace..." (leads with conclusion) | "The question is complex and multifaceted..." (acknowledges uncertainty) |
| "How can I improve productivity?" | Lists techniques by name | Explains techniques with specific details (e.g., "SMART criteria: Specific, Measurable...") |
| Dimension | Vanilla | Enhanced | Change |
|---|---|---|---|
| Step-by-step reasoning | Occasional | Consistent | Improved |
| Concrete examples | Sometimes present | More frequent | Improved |
| Epistemic hedging | Inconsistent | Appropriate | Improved |
| Topic adherence | Generally good | Slightly improved | Marginal |
| Logical transitions | Present | More explicit | Improved |
Note: These are qualitative observations from limited testing. Independent benchmark evaluation is recommended before deployment.
{
"model_type": "cognitive_enhancement_adapter",
"version": "1.0.0",
"base_model": "Qwen/Qwen2.5-7B-Instruct",
"architecture": {
"hidden_dim": 3584,
"fiber_dim": 16,
"head_hidden_dim": 64,
"probe_layers": [7, 14, 21]
},
"usage": {
"boost_strength": 3.0,
"suppress_strength": 4.0,
"threshold": 0.5
}
}
| Component | Minimum | Recommended |
|---|---|---|
| GPU VRAM | 8 GB (4-bit) | 16+ GB |
| System RAM | 16 GB | 32 GB |
| Storage | 20 GB | 50 GB |
Tested Configuration:
Performance:
| Limitation | Description |
|---|---|
| Base model dependency | Inherits all limitations of Qwen2.5-7B-Instruct |
| Language | English only (training data was English) |
| Evaluation | No formal benchmark results; qualitative assessment only |
| Intervention scope | Token-level intervention cannot fix deep reasoning errors |
| Training data | Synthetic training examples may not cover all edge cases |
| Generalization | Probe behavior on out-of-distribution inputs is unknown |
Each probe was trained on ~3000 synthetic examples:
qwen2.5-7b-cognitive-enhanced/
├── cognitive_adapter.pt # Merged probe weights (3.57 MB)
├── config.json # Architecture and intervention config
├── inference.py # Ready-to-use inference class
└── README.md # This file
@software{napolitano2026cognitive,
author = {Napolitano, Logan Matthew},
title = {Cognitive Enhancement Adapter for {Qwen2.5-7B}},
year = {2026},
publisher = {Hugging Face},
url = {https://huggingface.co/LoganResearch/qwen2.5-7b-cognitive-enhanced},
license = {CC BY 4.0}
}
This work is licensed under CC BY 4.0 (Creative Commons Attribution 4.0 International).
You are free to:
Under the following terms:
Contact: Hugging Face Discussions
Version: 1.0.0 | Released: February 2026
Logan Napolitano / Fiber AI
</div>