agent-o-rama
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseagent-o-rama
agent-o-rama
Layer 4: Learning and Pattern Extraction for Cognitive Surrogate Systems
Version: 1.0.0
Trit: +1 (Generator - produces learned patterns)
Bundle: learning
Trit: +1 (Generator - produces learned patterns)
Bundle: learning
第4层:认知代理系统的学习与模式提取
版本: 1.0.0
Trit: +1(生成器 - 生成学习到的模式)
** Bundle**: learning
Trit: +1(生成器 - 生成学习到的模式)
** Bundle**: learning
Overview
概述
Agent-o-rama trains learning agents on interaction sequences to discover behavioral patterns. It extracts temporal, topic, and network patterns from raw interaction data, producing models compatible with the cognitive-surrogate skill.
NEW (Langevin/Unworld Integration): Agent-o-rama now supports both:
- Temporal Learning (traditional): Train interaction predictor via epochs
- Derivational Generation (unworld): Generate equivalent patterns via seed chaining (100x faster, deterministic)
Agent-o-rama 通过在交互序列上训练学习型Agent,发现行为模式。它从原始交互数据中提取时间、主题和网络模式,生成与cognitive-surrogate skill兼容的模型。
新增(Langevin/Unworld集成):Agent-o-rama现在同时支持两种方式:
- 时间学习(传统方式):通过轮次训练交互预测器
- 派生生成(unworld方式):通过种子链生成等效模式(速度提升100倍,确定性)
Capabilities
功能特性
1. train-interaction-predictor
1. train-interaction-predictor
Train a model to predict next interactions given history.
python
from agent_o_rama import InteractionPredictor
predictor = InteractionPredictor(
learning_rate=0.01,
epochs=100,
batch_size=32,
seed=0xf061ebbc2ca74d78 # SPI seed for reproducibility
)训练模型以根据历史记录预测下一次交互。
python
from agent_o_rama import InteractionPredictor
predictor = InteractionPredictor(
learning_rate=0.01,
epochs=100,
batch_size=32,
seed=0xf061ebbc2ca74d78 # SPI种子,确保可复现
)Train on DuckDB interaction sequences
在DuckDB交互序列上训练
predictor.fit(
db_path="interactions.duckdb",
table="interaction_sequences",
validation_split=0.2
)
predictor.fit(
db_path="interactions.duckdb",
table="interaction_sequences",
validation_split=0.2
)
Predict next interaction
预测下一次交互
next_pred = predictor.predict(recent_history)
undefinednext_pred = predictor.predict(recent_history)
undefined2. extract-temporal-patterns
2. extract-temporal-patterns
Discover time-based behavioral patterns.
sql
-- Pattern query for DuckDB
SELECT
EXTRACT(HOUR FROM created_at) as hour,
EXTRACT(DOW FROM created_at) as day_of_week,
COUNT(*) as post_count,
AVG(response_time_minutes) as avg_response_time
FROM interactions
GROUP BY hour, day_of_week
ORDER BY post_count DESC;Output Schema:
TemporalPattern:
- peak_hours: [9, 14, 21]
- peak_days: [1, 3, 5] # Mon, Wed, Fri
- avg_response_time: 12.5 minutes
- posting_frequency: 4.2 posts/day
- engagement_cycles: [{start: 9, end: 11, intensity: 0.8}]发现基于时间的行为模式。
sql
-- DuckDB模式查询
SELECT
EXTRACT(HOUR FROM created_at) as hour,
EXTRACT(DOW FROM created_at) as day_of_week,
COUNT(*) as post_count,
AVG(response_time_minutes) as avg_response_time
FROM interactions
GROUP BY hour, day_of_week
ORDER BY post_count DESC;输出 Schema:
TemporalPattern:
- peak_hours: [9, 14, 21]
- peak_days: [1, 3, 5] # 周一、周三、周五
- avg_response_time: 12.5 minutes
- posting_frequency: 4.2 posts/day
- engagement_cycles: [{start: 9, end: 11, intensity: 0.8}]3. extract-topic-patterns
3. extract-topic-patterns
Analyze topic dynamics and correlations.
python
patterns = extract_topic_patterns(
posts=all_posts,
embedding_model="all-MiniLM-L6-v2",
n_topics=20
)分析主题动态与相关性。
python
patterns = extract_topic_patterns(
posts=all_posts,
embedding_model="all-MiniLM-L6-v2",
n_topics=20
)Returns:
返回结果:
- topic_distribution: {topic_id: frequency}
- topic_distribution: {topic_id: frequency}
- topic_transitions: Markov chain P(topic_j | topic_i)
- topic_transitions: 马尔可夫链 P(topic_j | topic_i)
- topic_entropy: Shannon entropy of topic usage
- topic_entropy: 主题使用的香农熵
- topic_clusters: Hierarchical clustering of related topics
- topic_clusters: 相关主题的层次聚类
undefinedundefined4. skill-discovery
4. skill-discovery
Identify latent skills from behavioral patterns.
python
skills = discover_skills(
interactions=interaction_log,
min_frequency=5,
coherence_threshold=0.7
)从行为模式中识别潜在技能。
python
skills = discover_skills(
interactions=interaction_log,
min_frequency=5,
coherence_threshold=0.7
)Example output:
示例输出:
[
[
{skill: "category-theory-explanation", frequency: 23, coherence: 0.89},
{skill: "category-theory-explanation", frequency: 23, coherence: 0.89},
{skill: "code-review-feedback", frequency: 45, coherence: 0.92},
{skill: "code-review-feedback", frequency: 45, coherence: 0.92},
{skill: "community-bridge-building", frequency: 18, coherence: 0.85}
{skill: "community-bridge-building", frequency: 18, coherence: 0.85}
]
]
undefinedundefined5. derive-patterns-via-unworld
5. derive-patterns-via-unworld
Generate patterns via derivational chaining (NEW - Langevin/Unworld path).
python
from agent_o_rama import UnworldPatternDeriver通过派生链生成模式(新增 - Langevin/Unworld路径)。
python
from agent_o_rama import UnworldPatternDeriverInstead of train_interaction_predictor(epochs=100)
替代 train_interaction_predictor(epochs=100)
Now also support:
现在还支持:
deriver = UnworldPatternDeriver(
genesis_seed=0xDEADBEEF,
interaction_schema=schema
)
deriver = UnworldPatternDeriver(
genesis_seed=0xDEADBEEF,
interaction_schema=schema
)
Generate learned patterns deterministically
确定性生成学习到的模式
patterns = deriver.derive_patterns(
depth=100, # Derivation depth instead of epochs
verify_gf3=True # Verify GF(3) conservation
)
patterns = deriver.derive_patterns(
depth=100, # 派生深度,替代轮次
verify_gf3=True # 验证GF(3)守恒
)
Cost comparison
成本对比
cost_analysis = {
"temporal_training": {
"time": "5-10 minutes",
"cost": "high (compute)",
"determinism": "stochastic"
},
"derivational_generation": {
"time": "5-10 seconds",
"cost": "low",
"determinism": "deterministic ✓"
}
}
undefinedcost_analysis = {
"temporal_training": {
"time": "5-10 minutes",
"cost": "high (compute)",
"determinism": "stochastic"
},
"derivational_generation": {
"time": "5-10 seconds",
"cost": "low",
"determinism": "deterministic ✓"
}
}
undefined6. verify-equivalence-via-bisimulation
6. verify-equivalence-via-bisimulation
Prove temporal and derivational patterns are behaviorally equivalent.
python
from bisimulation_game import BisimulationGame证明时间模式与派生模式在行为上等效。
python
from bisimulation_game import BisimulationGameVerify that temporal and derivational patterns are equivalent
验证时间模式与派生模式是否等效
are_equivalent = BisimulationGame(
system1=learned_patterns, # from temporal training
system2=derived_patterns, # from unworld derivation
seed=0xDEADBEEF
).play()
if are_equivalent:
print("✓ Patterns are behaviorally equivalent")
print("✓ Can safely switch from temporal to derivational")
undefinedare_equivalent = BisimulationGame(
system1=learned_patterns, # 来自时间训练
system2=derived_patterns, # 来自unworld派生
seed=0xDEADBEEF
).play()
if are_equivalent:
print("✓ 模式在行为上等效")
print("✓ 可安全从时间方式切换为派生方式")
undefined7. validate-held-out
7. validate-held-out
Cross-validate models on held-out test sets.
python
validation = validate_held_out(
predictor=trained_model,
test_set=held_out_interactions,
metrics=["accuracy", "perplexity", "topic_match", "style_match"]
)在预留测试集上交叉验证模型。
python
validation = validate_held_out(
predictor=trained_model,
test_set=held_out_interactions,
metrics=["accuracy", "perplexity", "topic_match", "style_match"]
)Target: >80% accuracy on next-topic prediction
目标:下一个主题预测准确率>80%
assert validation.accuracy > 0.80
undefinedassert validation.accuracy > 0.80
undefinedDuckDB Integration
DuckDB集成
Training Data Schema
训练数据Schema
sql
CREATE TABLE interaction_sequences (
sequence_id VARCHAR PRIMARY KEY,
user_id VARCHAR,
interactions JSON, -- Array of interaction objects
created_at TIMESTAMP,
topic_labels VARCHAR[],
sentiment_arc FLOAT[]
);
CREATE TABLE learned_patterns (
pattern_id VARCHAR PRIMARY KEY,
pattern_type VARCHAR, -- 'temporal', 'topic', 'network', 'skill'
pattern_data JSON,
confidence FLOAT,
learned_at TIMESTAMP,
seed BIGINT -- SPI seed for reproducibility
);sql
CREATE TABLE interaction_sequences (
sequence_id VARCHAR PRIMARY KEY,
user_id VARCHAR,
interactions JSON, -- 交互对象数组
created_at TIMESTAMP,
topic_labels VARCHAR[],
sentiment_arc FLOAT[]
);
CREATE TABLE learned_patterns (
pattern_id VARCHAR PRIMARY KEY,
pattern_type VARCHAR, -- 'temporal', 'topic', 'network', 'skill'
pattern_data JSON,
confidence FLOAT,
learned_at TIMESTAMP,
seed BIGINT -- SPI种子,确保可复现
);GF(3) Triad Integration
GF(3)三元组集成
Agent-o-rama forms triads with:
| Trit | Skill | Role |
|---|---|---|
| -1 | self-validation-loop | Validates learned patterns |
| 0 | cognitive-surrogate | Consumes patterns for prediction |
| +1 | agent-o-rama | Generates learned patterns |
Conservation: (-1) + (0) + (+1) = 0 ✓
Agent-o-rama与以下组件形成三元组:
| Trit | Skill | 角色 |
|---|---|---|
| -1 | self-validation-loop | 验证学习到的模式 |
| 0 | cognitive-surrogate | 消费模式以进行预测 |
| +1 | agent-o-rama | 生成学习到的模式 |
守恒性:(-1) + (0) + (+1) = 0 ✓
Configuration
配置
yaml
undefinedyaml
undefinedagent-o-rama.yaml
agent-o-rama.yaml
training:
learning_rate: 0.01
epochs: 100
batch_size: 32
early_stopping: true
patience: 10
patterns:
temporal:
granularity: hour
lookback_days: 90
topic:
n_topics: 20
min_topic_size: 5
skill:
min_frequency: 5
coherence_threshold: 0.7
reproducibility:
seed: 0xf061ebbc2ca74d78
deterministic: true
undefinedtraining:
learning_rate: 0.01
epochs: 100
batch_size: 32
early_stopping: true
patience: 10
patterns:
temporal:
granularity: hour
lookback_days: 90
topic:
n_topics: 20
min_topic_size: 5
skill:
min_frequency: 5
coherence_threshold: 0.7
reproducibility:
seed: 0xf061ebbc2ca74d78
deterministic: true
undefinedExample Workflow
示例工作流
bash
undefinedbash
undefined1. Extract patterns from interaction data
1. 从交互数据中提取模式
just agent-train interactions.duckdb --epochs 100
just agent-train interactions.duckdb --epochs 100
2. Discover skills
2. 发现技能
just agent-discover-skills --min-freq 5
just agent-discover-skills --min-freq 5
3. Validate on held-out set
3. 在预留数据集上验证
just agent-validate --test-split 0.2
just agent-validate --test-split 0.2
4. Export patterns for cognitive-surrogate
4. 导出模式供cognitive-surrogate使用
just agent-export patterns.json
undefinedjust agent-export patterns.json
undefinedRelated Skills
相关技能
- (Layer 6) - Consumes learned patterns
cognitive-surrogate - (Layer 5) - Arranges training data
entropy-sequencer - (Layer 3) - Structured pattern storage
acsets - - Deterministic seeding via SPI
gay-mcp
- (第6层)- 消费学习到的模式
cognitive-surrogate - (第5层)- 整理训练数据
entropy-sequencer - (第3层)- 结构化模式存储
acsets - - 通过SPI实现确定性种子生成
gay-mcp