Autoregressive Flow Matching (AFM) framework for probabilistic prediction of neural dynamics from multimodal sensory input, enabling conditional distribution learning of future neural activity with closed-loop neurotechnology applications.
Scanned 9/11/2026
Install to Claude Code
npx -y skills add hiyenwong/ai_collection --skill autoregressive-flow-matching-neural --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Autoregressive Flow Matching Neural?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/hiyenwong-autoregressive-flow-matching-neural)More formats (shields.io, HTML) on the badges page.
---
name: autoregressive-flow-matching-neural
description: "Autoregressive Flow Matching (AFM) framework for probabilistic prediction of neural dynamics from multimodal sensory input, enabling conditional distribution learning of future neural activity with closed-loop neurotechnology applications."
triggers:
- neural dynamics prediction
- flow matching
- probabilistic forecasting
- brain dynamics
- autoregressive flow
- neural activity prediction
- BOLD signal
- closed loop neurotechnology
- multimodal sensory
paper: "2604.11178"
date_created: "2026-04-23"
---
# 自回归流匹配神经动力学预测方法论 (AFM)
## 概述
自回归流匹配(Autoregressive Flow Matching, AFM)是一种用于神经动力学概率预测的框架。该方法从多模态感官输入学习未来神经活动的条件分布,通过自回归因式分解和连续归一化流实现高质量的概率预测。研究发现,过去BOLD动力学信号是未来神经活动的最主要驱动因素。
## 核心架构
### 1. 问题形式化
```
目标:学习条件分布 p(Y_{future} | X_{past})
其中:
- Y_{future} = [y_{t+1}, y_{t+2}, ..., y_{t+T}] : 未来神经活动
- X_{past} = [x_1, x_2, ..., x_t] : 多模态感官输入历史
- 感官模态包括:视觉、听觉、体感等
概率预测目标:
max Σ log p(y_{t+k} | y_{t+1:t+k-1}, X_{past})
```
### 2. 自回归流匹配(AFM)框架
```
架构组成:
1. 条件编码器 h(X_{past}) → c (上下文向量)
2. 自回归核心:逐步预测未来时间步
3. 流匹配层:每个时间步的条件分布建模
Flow Matching 公式:
给定条件 c 和过去预测 ŷ_{t+1:t+k-1}:
z_0 ~ N(0, I) (噪声样本)
z_1 = y_{t+k} (目标神经活动)
学习向量场 v_θ(z_t, t, c, ŷ_{past}) 使得:
dz_t/dt = v_θ(z_t, t, c, ŷ_{past})
生成过程:z_0 →[v_θ]→ z_1 = ŷ_{t+k}
```
### 3. 条件分布学习
```python
class AutoregressiveFlowMatching(nn.Module):
def __init__(self, dim_neural, dim_sensory, hidden_dim=256, n_flows=4):
super().__init__()
# 多模态感官编码器
self.sensory_encoder = nn.LSTM(
input_size=dim_sensory,
hidden_size=hidden_dim,
num_layers=2,
bidirectional=True
)
# 自回归状态更新器
self.ar_updater = nn.GRUCell(
input_size=dim_neural,
hidden_size=hidden_dim
)
# 流匹配网络
self.flow_nets = nn.ModuleList([
ConditionalFlowNet(hidden_dim, dim_neural)
for _ in range(n_flows)
])
def forward(self, sensory_input, n_future_steps, n_samples=100):
# 编码感官历史
context, _ = self.sensory_encoder(sensory_input)
c = context[-1]
predictions = []
prev_neural = torch.zeros(context.size(1), dim_neural)
for k in range(n_future_steps):
h = self.ar_updater(prev_neural, c)
z_0 = torch.randn(n_samples, *prev_neural.shape)
z_1 = self.flow_match(z_0, h, n_steps=10)
predictions.append(z_1)
prev_neural = z_1.mean(dim=0)
c = h
return torch.stack(predictions)
```
### 4. 关键发现:BOLD动力学的主导驱动作用
```
实验发现:
- 过去BOLD信号解释了未来神经活动变异的 >80%
- 视觉/听觉等特定感官模态的贡献相对较小
- 自回归结构(依赖过去预测)是关键
- BOLD的血流动力学响应函数(HRF)本身提供时间平滑性
启示:
1. 神经活动的自相关性是最强的预测信号
2. 多模态感官输入主要提供"扰动"信息
3. 简单的AR基线已经很强,AFM的优势在于不确定性量化
```
### 5. 闭环神经技术应用
```
AFM在闭环系统中的应用:
1. 实时预测:
- 从当前/过去神经信号预测未来状态
- 提供概率分布而非点估计
- 置信区间用于决策阈值设定
2. 自适应刺激:
- 基于预测的异常检测触发干预
- 预测性刺激时序优化
- 不确定性引导的保守/激进策略切换
3. 临床应用场景:
- 癫痫预测与预防性刺激
- 帕金森病深部脑刺激优化
- 抑郁症闭环神经调控
- 中风康复脑机接口
系统架构:
[神经信号采集] → [AFM预测器] → [概率决策器] → [刺激控制器]
↑ │
└────────────── [反馈信号] ←──────────────────────────┘
```
## 训练流程
```python
def train_afm(model, dataloader, optimizer, n_epochs=100):
for epoch in range(n_epochs):
for batch in dataloader:
sensory_past = batch['sensory']
neural_future = batch['neural_fut']
context = model.encode_sensory(sensory_past)
total_loss = 0
prev_neural = torch.zeros_like(neural_future[0])
for k in range(neural_future.size(0)):
target = neural_future[k]
t = torch.rand(target.size(0), 1)
z_0 = torch.randn_like(target)
z_t = (1 - t) * z_0 + t * target
v_pred = model.predict_velocity(z_t, t, context, prev_neural)
v_target = target - z_0
loss = F.mse_loss(v_pred, v_target)
total_loss += loss
prev_neural = target.detach()
optimizer.zero_grad()
total_loss.backward()
optimizer.step()
```
### 不确定性量化
```python
def predict_with_uncertainty(model, sensory_input, n_future=50, n_samples=500):
predictions = model(sensory_input, n_future, n_samples)
mean = predictions.mean(dim=1)
std = predictions.std(dim=1)
ci_95 = torch.quantile(predictions, torch.tensor([0.025, 0.975]), dim=1)
return {
'mean': mean,
'std': std,
'ci_95_lower': ci_95[0],
'ci_95_upper': ci_95[1],
'samples': predictions
}
```
## 关键优势
1. **概率预测**:提供完整的未来神经活动分布,而非点估计
2. **自回归结构**:自然处理时序依赖性
3. **多模态融合**:整合不同感官模态的信息
4. **不确定性量化**:支持风险感知的闭环决策
5. **灵活的分布建模**:Flow Matching避免分布假设限制
## 应用场景
- **闭环脑机接口**:预测性神经调控
- **癫痫预测**:发作前概率预警
- **神经康复**:个性化恢复轨迹预测
- **药物试验**:预测神经药理效应
- **认知神经科学**:多模态感知-神经映射
## 注意事项
- Flow Matching训练需要足够样本以稳定向量场学习
- 自回归误差累积:长程预测不确定性随时间增长
- BOLD信号的时间分辨率限制(~2s TR)影响实时性
- 闭环应用中预测延迟需要纳入考虑
- 多被试泛化需要个体化微调
## 参考文献
- Paper: 2604.11178 "Probabilistic Prediction of Neural Dynamics via Autoregressive Flow Matching"
- 相关:Flow Matching, Continuous Normalizing Flows, Neural Dynamics Forecasting
## Activation Keywords
- autoregressive-flow-matching-neural
- autoregressive flow matching
- autoregressive flow matching neural
## Tools Used
- `read` - 读取技能文档
- `write` - 创建输出
- `exec` - 执行相关命令
## Instructions for Agents
1. 理解技能的核心方法论
2. 根据用户问题提供针对性回答
3. 遵循最佳实践
## Examples
### Example 1: 基本查询
**User:** 请解释 Autoregressive Flow Matching Neural
**Agent:** Autoregressive Flow Matching Neural 是关于...
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!