欢迎光临

Mamba 架构深度解析:状态空间模型如何突破 Transformer 的二次复杂度瓶颈

从序列建模到线性复杂度:状态空间模型的前世今生

在深度学习领域,Transformer 架构凭借其强大的自注意力机制,几乎统治了自然语言处理、计算机视觉等所有主流任务。然而,Transformer 的核心——自注意力——的计算复杂度是 O(n²),其中 n 是序列长度。这意味着当处理长序列(如长文档、基因组数据、长时间序列预测)时,计算成本和显存开销会呈平方级增长,让许多实际应用寸步难行。

为了突破这一瓶颈,研究者们开始重新审视一个被遗忘多年的经典模型——状态空间模型(State Space Model, SSM)。2023年底,Albert Gu 和 Tri Dao 联合提出的 Mamba 架构,将 SSM 与选择性机制相结合,实现了与 Transformer 媲美的建模能力,同时保持了 O(n) 的线性复杂度。本文将深入剖析 Mamba 的技术原理,从 SSM 的数学基础到 Mamba 的核心创新,并辅以完整的代码实现,帮助读者全面掌握这一颠覆性架构。

本文的目标读者是具备一定深度学习基础(熟悉 Transformer 和 RNN 基本概念)的工程师和研究者。我们将从最基础的 SSM 开始,逐步深入到 Mamba 的工程实现细节。

状态空间模型(SSM)基础

连续系统的数学表述

状态空间模型起源于控制理论,用于描述一个动态系统如何随时间演化。在连续时间系统中,SSM 通过两个方程将一个一维输入序列 u(t) 映射到输出序列 y(t):


1
2
状态方程: h'(t) = A · h(t) + B · u(t)
输出方程: y(t) = C · h(t) + D · u(t)

其中:

  • h(t):隐状态向量,维度为 N(状态维度)
  • A:状态转移矩阵 (N × N),决定了系统如何演化
  • B:输入投影矩阵 (N × 1),将输入映射到状态空间
  • C:输出投影矩阵 (1 × N),将状态映射回输出
  • D:跳跃连接(通常视为残差连接,常被忽略)

这个形式看似简单,但正是这种线性时不变(LTI)系统的结构,使得 SSM 能够在推理时以 O(n) 的复杂度处理序列。然而,经典的 LTI-SSM 有一个致命缺陷:它的参数 A、B、C 是固定的,不随输入变化,导致弱表达能力。

离散化:从连续到离散

要将连续时间 SSM 应用于离散序列(如文本 token),需要将系统离散化。最常用的方法是零阶保持(Zero-Order Hold, ZOH)离散化:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import torch
import torch.nn as nn
import torch.nn.functional as F

def discretize_zoh(A, B, delta):
 """
 使用零阶保持法离散化 SSM 参数
 
 参数:
 A: 状态转移矩阵 (N, N)
 B: 输入矩阵 (N, 1)
 delta: 步长 (batch, 1)
 
 返回:
 A_bar: 离散化后的状态转移矩阵
 B_bar: 离散化后的输入矩阵
 """
 # 计算矩阵指数
 A_bar = torch.matrix_exp(delta.unsqueeze(-1) _aegis_article.md ai_chatbot_privacy_article.html ai-seo-tools-article.html ai-seo-tools-article-updated.html alipay-article.html android-privacy-article.html android_privacy_article.html android-privacy-final.html android_privacy_final.html article_2fa.html article-architecture.html article_base64.txt article_body.html article_body.md article_body.txt article_breach_response.html article_clean.html article_complete.html article_content_final.json article-content.html article_content.html article_content.json article_content.txt _article_content.xml article_cookie_consent.html article_data_breach.html article_data.json article_dianping.html article-dns-privacy-final.html article-dns-privacy.html article_dns_privacy.html article_draft.html article_ecommerce.html article-email-marketing.html article_encrypted_cloud.html article-escaped.txt article-final.html article_final.html article_full.html article_game_dev.html article_headshot.html article-hemal-grocery.html article.html article-html.txt article_identity_theft.html article-image-generators.html article_iphone_privacy.html article-longmen-grottoes-final.html article-longmen-grottoes.html article_meituan.html article_meta.json article_passkeys.html article_pg_clean.json article_pg.json article_postgresql.html article-privacy-cloud-storage.html article_public_wifi.html article_python_type_hints.html article-qin-shi-huang.html article_ransomware.html article-rent-apartment.html articles article_search_engines.html article_sim_swap.html article_social_media_privacy.html article_temp.html article_today_point.html article_transcription.html article_vllm.md article-with-images.html article_with_images.html article_with_images.txt article_xiaohongshu.html article.xml article_zhou_final.html article_zhou.html audio_cache auth.json auth.lock _b64_part1.txt beijing-guide.html beijing-opera-article.html beijing_opera_article.html bin bitwarden-article.html browser-comparison-article.html browser-fingerprinting-article.html build_article.py cache capture2.py capture_bitwarden.py capture_hootsuite.py capture_playstore.py capture.py capture_screens2.py capture_screenshots.py capture_screens.py capture.sh capture_stealth.py channel_directory.json check_article.py check_content.py check_post.py check_quality.py chinese-civil-war-article.html chinese-dynasties-article.html chinese-dynasties-final.html chinese-etiquette-article.html chinese-etiquette-article-with-images.html chinese-folk-religion.html chinese_food_article.html chinese-zodiac-article.html config.yaml config.yaml.bak.20260616_091116 config.yaml.bak.20260616_091136 config.yaml.bak.20260616_091148 config.yaml.bak.20260616_150612 config.yaml.bak.20260616_223924 config.yaml.bak.20260616_224702 config.yaml.bak.20260616_225109 config.yaml.bak.20260616_225947 config.yaml.bak.20260617_101814 config.yaml.bak.20260617_102045 config.yaml.bak.20260617_102150 _content_p1.md create-ming-post.php create_post2.py create_post3.py create-post.php create_post.php create_post.py create_post.sh cron current_content.html data_broker_article.html _decoder_b64.txt _deepfake_article.md dl_fallback.py douyin-article-final.html douyin-article.html download_fallback.py download_images.py download_unsplash.py dragon-boat-article.html _dup.md dynasties-article.html ecommerce_content.html email-privacy-article.html feishu_seen_message_ids.json feng-shui-article.html fengshui-article.html fengshui-final.html fetch_unsplash.py final-article.html final_article.html final_article.txt final_check.py final_content.html find_magic.py fix_alt.py fix_content.py fix_html.py fix_image.py fix_images.py fix_imgs.py fix_quotes.py folk-religion-content.html full_article.html _fuzz_article.md gateway.lock gateway.pid gateway_state.json gen_article.py genghis-khan-article.html genghis-khan-final.html _gen.py ghost-festival-article.html git_object_model_article.html google_client_secret.json google_oauth_pending.json google_token.json grand-canal-article.html great-wall-history.html guilin-article.html harbin-article.html hooks huangshan-article-final.html huangshan-article.html image_cache iot-article-final.html iot-article.html jiuzhaigou-article.html jiuzhaigou-clean.html jiuzhaigou-final.html kanban.db kanban.db.init.lock kunming-article.html lantern-article.html li-river-article.html logs luoyang-article.html mao-article-final.html mao-article.html martial-arts-article.html meeting-fallback.jpg memories messaging-apps-article.html mid-autumn-article.html ming-article-final.html ming-article.html models_dev_cache.json nanjing_article.html node notification.md ollama_cloud_models_cache.json outputs pairing payload.json phishing-article.html php_article.html playwright_fdroid.py playwright_metro.py playwright_screenshots.py plugins poll_bilibili.sh porcelain-article.html porcelain-article-v2.html post_data.json prepare_article.sh prepare_content.py prepare_post.py prepare_publish.py prep_post.py processes.json provider_models_cache.json publish_article.php publish_article.py publish-panda.sh publish_post.php qing-article-final.html qing-article.html qing_article.html qingdao-article.html qing-dynasty-article.html qing_dynasty_article.html qin-shi-huang-article.html quality_check2.py quality_check3.py quality_check.py rag_article.xml replace_imgs.py router-article-final.html router-article.html sandboxes scala_article.json _sc.md screenshot_capture2.py screenshot_capture.py screenshot_remote.py screenshot_script2.py screenshot_script3.py screenshot_script.py screenshots.py scripts _sec1.md _sec2.md _sec3.md _sec4.md _sec5.md sessions shang-dynasty-article.html shang-final.html shopping-privacy-article.html silk-article-final.html silk-article.html silk-road-article.html silk-road-final.html _skeleton.md skills social-media-privacy-article.html song-dynasty-article.html song_dynasty_article.html song_dynasty_final.html SOUL.md state.db state.db-shm state.db-wal stone-forest-article.html sui_dynasty_article.html summer-palace-article.html _supply_chain.md suzhou-article.html tang-dynasty-article.html tang-dynasty-full.html tcm_article_final.html tcm-article.html tcm_article.html tea-article.html temp temp_article_content.html temp_article.html _test_content.md _test.txt three-kingdoms-article.html three-kingdoms-final.html tmp update_article.py update_content.py _update_content.xml update_db.py update_images.py update_post2.py update_post.php update_post.py update_post_wp.php update_wp.py upload-img.php verify_article.py verify_post.php verify_post.py verify_post.sh visa-article.html vpn_article.html work write_article_content.py write-article.py write_article.py write_update_script2.py write_update_script.py wu-zetian-article.html wu-zetian-article-with-images.html xia_dynasty_article.html xiamen-article.html yuan-article.html yuan-dynasty-article.html zhangjiajie_article.html zhenghe-article.html zhou-dynasty-article.html A)
 # 计算 B_bar = (A_bar - I) · A^(-1) · B
 # 使用近似公式简化
 B_bar = (A_bar - torch.eye(A.size(-1), device=A.device)) @ torch.linalg.solve(A, B)
 return A_bar, B_bar

离散化后的递推公式变为:


1
2
h_t = A_bar · h_{t-1} + B_bar · u_t
y_t = C · h_t

可以看到,离散化后的 SSM 本质上是一个线性 RNN——每个时间步的状态只依赖于前一步的状态和当前输入。这正是 SSM 能够实现线性推理复杂度的关键。

HiPPO 初始化:长程记忆的秘诀

早期的 SSM 在实际应用中效果不佳,因为普通的随机初始化 A 矩阵无法有效捕获长程依赖关系。2020年,Albert Gu 等人提出了 HiPPO(High-order Polynomial Projection Operators) 初始化方法,从根本上解决了这一问题。

HiPPO 的核心思想是:将输入序列的历史信息投影到一组多项式基函数上,通过专门设计的 A 矩阵来精确地跟踪这些多项式的系数。具体来说,HiPPO 矩阵定义如下:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
def hippo_matrix(N):
 """
 生成 HiPPO 初始化矩阵 (Legendre 版本)
 
 HiPPO 矩阵确保状态能够记住历史输入的多项式近似。
 当 N 较大时,矩阵的上三角部分是密集的。
 """
 A = torch.zeros(N, N)
 for i in range(N):
 for j in range(N):
 if i > j:
 A[i, j] = -((2 _aegis_article.md ai_chatbot_privacy_article.html ai-seo-tools-article.html ai-seo-tools-article-updated.html alipay-article.html android-privacy-article.html android_privacy_article.html android-privacy-final.html android_privacy_final.html article_2fa.html article-architecture.html article_base64.txt article_body.html article_body.md article_body.txt article_breach_response.html article_clean.html article_complete.html article_content_final.json article-content.html article_content.html article_content.json article_content.txt _article_content.xml article_cookie_consent.html article_data_breach.html article_data.json article_dianping.html article-dns-privacy-final.html article-dns-privacy.html article_dns_privacy.html article_draft.html article_ecommerce.html article-email-marketing.html article_encrypted_cloud.html article-escaped.txt article-final.html article_final.html article_full.html article_game_dev.html article_headshot.html article-hemal-grocery.html article.html article-html.txt article_identity_theft.html article-image-generators.html article_iphone_privacy.html article-longmen-grottoes-final.html article-longmen-grottoes.html article_meituan.html article_meta.json article_passkeys.html article_pg_clean.json article_pg.json article_postgresql.html article-privacy-cloud-storage.html article_public_wifi.html article_python_type_hints.html article-qin-shi-huang.html article_ransomware.html article-rent-apartment.html articles article_search_engines.html article_sim_swap.html article_social_media_privacy.html article_temp.html article_today_point.html article_transcription.html article_vllm.md article-with-images.html article_with_images.html article_with_images.txt article_xiaohongshu.html article.xml article_zhou_final.html article_zhou.html audio_cache auth.json auth.lock _b64_part1.txt beijing-guide.html beijing-opera-article.html beijing_opera_article.html bin bitwarden-article.html browser-comparison-article.html browser-fingerprinting-article.html build_article.py cache capture2.py capture_bitwarden.py capture_hootsuite.py capture_playstore.py capture.py capture_screens2.py capture_screenshots.py capture_screens.py capture.sh capture_stealth.py channel_directory.json check_article.py check_content.py check_post.py check_quality.py chinese-civil-war-article.html chinese-dynasties-article.html chinese-dynasties-final.html chinese-etiquette-article.html chinese-etiquette-article-with-images.html chinese-folk-religion.html chinese_food_article.html chinese-zodiac-article.html config.yaml config.yaml.bak.20260616_091116 config.yaml.bak.20260616_091136 config.yaml.bak.20260616_091148 config.yaml.bak.20260616_150612 config.yaml.bak.20260616_223924 config.yaml.bak.20260616_224702 config.yaml.bak.20260616_225109 config.yaml.bak.20260616_225947 config.yaml.bak.20260617_101814 config.yaml.bak.20260617_102045 config.yaml.bak.20260617_102150 _content_p1.md create-ming-post.php create_post2.py create_post3.py create-post.php create_post.php create_post.py create_post.sh cron current_content.html data_broker_article.html _decoder_b64.txt _deepfake_article.md dl_fallback.py douyin-article-final.html douyin-article.html download_fallback.py download_images.py download_unsplash.py dragon-boat-article.html _dup.md dynasties-article.html ecommerce_content.html email-privacy-article.html feishu_seen_message_ids.json feng-shui-article.html fengshui-article.html fengshui-final.html fetch_unsplash.py final-article.html final_article.html final_article.txt final_check.py final_content.html find_magic.py fix_alt.py fix_content.py fix_html.py fix_image.py fix_images.py fix_imgs.py fix_quotes.py folk-religion-content.html full_article.html _fuzz_article.md gateway.lock gateway.pid gateway_state.json gen_article.py genghis-khan-article.html genghis-khan-final.html _gen.py ghost-festival-article.html git_object_model_article.html google_client_secret.json google_oauth_pending.json google_token.json grand-canal-article.html great-wall-history.html guilin-article.html harbin-article.html hooks huangshan-article-final.html huangshan-article.html image_cache iot-article-final.html iot-article.html jiuzhaigou-article.html jiuzhaigou-clean.html jiuzhaigou-final.html kanban.db kanban.db.init.lock kunming-article.html lantern-article.html li-river-article.html logs luoyang-article.html mao-article-final.html mao-article.html martial-arts-article.html meeting-fallback.jpg memories messaging-apps-article.html mid-autumn-article.html ming-article-final.html ming-article.html models_dev_cache.json nanjing_article.html node notification.md ollama_cloud_models_cache.json outputs pairing payload.json phishing-article.html php_article.html playwright_fdroid.py playwright_metro.py playwright_screenshots.py plugins poll_bilibili.sh porcelain-article.html porcelain-article-v2.html post_data.json prepare_article.sh prepare_content.py prepare_post.py prepare_publish.py prep_post.py processes.json provider_models_cache.json publish_article.php publish_article.py publish-panda.sh publish_post.php qing-article-final.html qing-article.html qing_article.html qingdao-article.html qing-dynasty-article.html qing_dynasty_article.html qin-shi-huang-article.html quality_check2.py quality_check3.py quality_check.py rag_article.xml replace_imgs.py router-article-final.html router-article.html sandboxes scala_article.json _sc.md screenshot_capture2.py screenshot_capture.py screenshot_remote.py screenshot_script2.py screenshot_script3.py screenshot_script.py screenshots.py scripts _sec1.md _sec2.md _sec3.md _sec4.md _sec5.md sessions shang-dynasty-article.html shang-final.html shopping-privacy-article.html silk-article-final.html silk-article.html silk-road-article.html silk-road-final.html _skeleton.md skills social-media-privacy-article.html song-dynasty-article.html song_dynasty_article.html song_dynasty_final.html SOUL.md state.db state.db-shm state.db-wal stone-forest-article.html sui_dynasty_article.html summer-palace-article.html _supply_chain.md suzhou-article.html tang-dynasty-article.html tang-dynasty-full.html tcm_article_final.html tcm-article.html tcm_article.html tea-article.html temp temp_article_content.html temp_article.html _test_content.md _test.txt three-kingdoms-article.html three-kingdoms-final.html tmp update_article.py update_content.py _update_content.xml update_db.py update_images.py update_post2.py update_post.php update_post.py update_post_wp.php update_wp.py upload-img.php verify_article.py verify_post.php verify_post.py verify_post.sh visa-article.html vpn_article.html work write_article_content.py write-article.py write_article.py write_update_script2.py write_update_script.py wu-zetian-article.html wu-zetian-article-with-images.html xia_dynasty_article.html xiamen-article.html yuan-article.html yuan-dynasty-article.html zhangjiajie_article.html zhenghe-article.html zhou-dynasty-article.html i + 1) _aegis_article.md ai_chatbot_privacy_article.html ai-seo-tools-article.html ai-seo-tools-article-updated.html alipay-article.html android-privacy-article.html android_privacy_article.html android-privacy-final.html android_privacy_final.html article_2fa.html article-architecture.html article_base64.txt article_body.html article_body.md article_body.txt article_breach_response.html article_clean.html article_complete.html article_content_final.json article-content.html article_content.html article_content.json article_content.txt _article_content.xml article_cookie_consent.html article_data_breach.html article_data.json article_dianping.html article-dns-privacy-final.html article-dns-privacy.html article_dns_privacy.html article_draft.html article_ecommerce.html article-email-marketing.html article_encrypted_cloud.html article-escaped.txt article-final.html article_final.html article_full.html article_game_dev.html article_headshot.html article-hemal-grocery.html article.html article-html.txt article_identity_theft.html article-image-generators.html article_iphone_privacy.html article-longmen-grottoes-final.html article-longmen-grottoes.html article_meituan.html article_meta.json article_passkeys.html article_pg_clean.json article_pg.json article_postgresql.html article-privacy-cloud-storage.html article_public_wifi.html article_python_type_hints.html article-qin-shi-huang.html article_ransomware.html article-rent-apartment.html articles article_search_engines.html article_sim_swap.html article_social_media_privacy.html article_temp.html article_today_point.html article_transcription.html article_vllm.md article-with-images.html article_with_images.html article_with_images.txt article_xiaohongshu.html article.xml article_zhou_final.html article_zhou.html audio_cache auth.json auth.lock _b64_part1.txt beijing-guide.html beijing-opera-article.html beijing_opera_article.html bin bitwarden-article.html browser-comparison-article.html browser-fingerprinting-article.html build_article.py cache capture2.py capture_bitwarden.py capture_hootsuite.py capture_playstore.py capture.py capture_screens2.py capture_screenshots.py capture_screens.py capture.sh capture_stealth.py channel_directory.json check_article.py check_content.py check_post.py check_quality.py chinese-civil-war-article.html chinese-dynasties-article.html chinese-dynasties-final.html chinese-etiquette-article.html chinese-etiquette-article-with-images.html chinese-folk-religion.html chinese_food_article.html chinese-zodiac-article.html config.yaml config.yaml.bak.20260616_091116 config.yaml.bak.20260616_091136 config.yaml.bak.20260616_091148 config.yaml.bak.20260616_150612 config.yaml.bak.20260616_223924 config.yaml.bak.20260616_224702 config.yaml.bak.20260616_225109 config.yaml.bak.20260616_225947 config.yaml.bak.20260617_101814 config.yaml.bak.20260617_102045 config.yaml.bak.20260617_102150 _content_p1.md create-ming-post.php create_post2.py create_post3.py create-post.php create_post.php create_post.py create_post.sh cron current_content.html data_broker_article.html _decoder_b64.txt _deepfake_article.md dl_fallback.py douyin-article-final.html douyin-article.html download_fallback.py download_images.py download_unsplash.py dragon-boat-article.html _dup.md dynasties-article.html ecommerce_content.html email-privacy-article.html feishu_seen_message_ids.json feng-shui-article.html fengshui-article.html fengshui-final.html fetch_unsplash.py final-article.html final_article.html final_article.txt final_check.py final_content.html find_magic.py fix_alt.py fix_content.py fix_html.py fix_image.py fix_images.py fix_imgs.py fix_quotes.py folk-religion-content.html full_article.html _fuzz_article.md gateway.lock gateway.pid gateway_state.json gen_article.py genghis-khan-article.html genghis-khan-final.html _gen.py ghost-festival-article.html git_object_model_article.html google_client_secret.json google_oauth_pending.json google_token.json grand-canal-article.html great-wall-history.html guilin-article.html harbin-article.html hooks huangshan-article-final.html huangshan-article.html image_cache iot-article-final.html iot-article.html jiuzhaigou-article.html jiuzhaigou-clean.html jiuzhaigou-final.html kanban.db kanban.db.init.lock kunming-article.html lantern-article.html li-river-article.html logs luoyang-article.html mao-article-final.html mao-article.html martial-arts-article.html meeting-fallback.jpg memories messaging-apps-article.html mid-autumn-article.html ming-article-final.html ming-article.html models_dev_cache.json nanjing_article.html node notification.md ollama_cloud_models_cache.json outputs pairing payload.json phishing-article.html php_article.html playwright_fdroid.py playwright_metro.py playwright_screenshots.py plugins poll_bilibili.sh porcelain-article.html porcelain-article-v2.html post_data.json prepare_article.sh prepare_content.py prepare_post.py prepare_publish.py prep_post.py processes.json provider_models_cache.json publish_article.php publish_article.py publish-panda.sh publish_post.php qing-article-final.html qing-article.html qing_article.html qingdao-article.html qing-dynasty-article.html qing_dynasty_article.html qin-shi-huang-article.html quality_check2.py quality_check3.py quality_check.py rag_article.xml replace_imgs.py router-article-final.html router-article.html sandboxes scala_article.json _sc.md screenshot_capture2.py screenshot_capture.py screenshot_remote.py screenshot_script2.py screenshot_script3.py screenshot_script.py screenshots.py scripts _sec1.md _sec2.md _sec3.md _sec4.md _sec5.md sessions shang-dynasty-article.html shang-final.html shopping-privacy-article.html silk-article-final.html silk-article.html silk-road-article.html silk-road-final.html _skeleton.md skills social-media-privacy-article.html song-dynasty-article.html song_dynasty_article.html song_dynasty_final.html SOUL.md state.db state.db-shm state.db-wal stone-forest-article.html sui_dynasty_article.html summer-palace-article.html _supply_chain.md suzhou-article.html tang-dynasty-article.html tang-dynasty-full.html tcm_article_final.html tcm-article.html tcm_article.html tea-article.html temp temp_article_content.html temp_article.html _test_content.md _test.txt three-kingdoms-article.html three-kingdoms-final.html tmp update_article.py update_content.py _update_content.xml update_db.py update_images.py update_post2.py update_post.php update_post.py update_post_wp.php update_wp.py upload-img.php verify_article.py verify_post.php verify_post.py verify_post.sh visa-article.html vpn_article.html work write_article_content.py write-article.py write_article.py write_update_script2.py write_update_script.py wu-zetian-article.html wu-zetian-article-with-images.html xia_dynasty_article.html xiamen-article.html yuan-article.html yuan-dynasty-article.html zhangjiajie_article.html zhenghe-article.html zhou-dynasty-article.html 0.5) _aegis_article.md ai_chatbot_privacy_article.html ai-seo-tools-article.html ai-seo-tools-article-updated.html alipay-article.html android-privacy-article.html android_privacy_article.html android-privacy-final.html android_privacy_final.html article_2fa.html article-architecture.html article_base64.txt article_body.html article_body.md article_body.txt article_breach_response.html article_clean.html article_complete.html article_content_final.json article-content.html article_content.html article_content.json article_content.txt _article_content.xml article_cookie_consent.html article_data_breach.html article_data.json article_dianping.html article-dns-privacy-final.html article-dns-privacy.html article_dns_privacy.html article_draft.html article_ecommerce.html article-email-marketing.html article_encrypted_cloud.html article-escaped.txt article-final.html article_final.html article_full.html article_game_dev.html article_headshot.html article-hemal-grocery.html article.html article-html.txt article_identity_theft.html article-image-generators.html article_iphone_privacy.html article-longmen-grottoes-final.html article-longmen-grottoes.html article_meituan.html article_meta.json article_passkeys.html article_pg_clean.json article_pg.json article_postgresql.html article-privacy-cloud-storage.html article_public_wifi.html article_python_type_hints.html article-qin-shi-huang.html article_ransomware.html article-rent-apartment.html articles article_search_engines.html article_sim_swap.html article_social_media_privacy.html article_temp.html article_today_point.html article_transcription.html article_vllm.md article-with-images.html article_with_images.html article_with_images.txt article_xiaohongshu.html article.xml article_zhou_final.html article_zhou.html audio_cache auth.json auth.lock _b64_part1.txt beijing-guide.html beijing-opera-article.html beijing_opera_article.html bin bitwarden-article.html browser-comparison-article.html browser-fingerprinting-article.html build_article.py cache capture2.py capture_bitwarden.py capture_hootsuite.py capture_playstore.py capture.py capture_screens2.py capture_screenshots.py capture_screens.py capture.sh capture_stealth.py channel_directory.json check_article.py check_content.py check_post.py check_quality.py chinese-civil-war-article.html chinese-dynasties-article.html chinese-dynasties-final.html chinese-etiquette-article.html chinese-etiquette-article-with-images.html chinese-folk-religion.html chinese_food_article.html chinese-zodiac-article.html config.yaml config.yaml.bak.20260616_091116 config.yaml.bak.20260616_091136 config.yaml.bak.20260616_091148 config.yaml.bak.20260616_150612 config.yaml.bak.20260616_223924 config.yaml.bak.20260616_224702 config.yaml.bak.20260616_225109 config.yaml.bak.20260616_225947 config.yaml.bak.20260617_101814 config.yaml.bak.20260617_102045 config.yaml.bak.20260617_102150 _content_p1.md create-ming-post.php create_post2.py create_post3.py create-post.php create_post.php create_post.py create_post.sh cron current_content.html data_broker_article.html _decoder_b64.txt _deepfake_article.md dl_fallback.py douyin-article-final.html douyin-article.html download_fallback.py download_images.py download_unsplash.py dragon-boat-article.html _dup.md dynasties-article.html ecommerce_content.html email-privacy-article.html feishu_seen_message_ids.json feng-shui-article.html fengshui-article.html fengshui-final.html fetch_unsplash.py final-article.html final_article.html final_article.txt final_check.py final_content.html find_magic.py fix_alt.py fix_content.py fix_html.py fix_image.py fix_images.py fix_imgs.py fix_quotes.py folk-religion-content.html full_article.html _fuzz_article.md gateway.lock gateway.pid gateway_state.json gen_article.py genghis-khan-article.html genghis-khan-final.html _gen.py ghost-festival-article.html git_object_model_article.html google_client_secret.json google_oauth_pending.json google_token.json grand-canal-article.html great-wall-history.html guilin-article.html harbin-article.html hooks huangshan-article-final.html huangshan-article.html image_cache iot-article-final.html iot-article.html jiuzhaigou-article.html jiuzhaigou-clean.html jiuzhaigou-final.html kanban.db kanban.db.init.lock kunming-article.html lantern-article.html li-river-article.html logs luoyang-article.html mao-article-final.html mao-article.html martial-arts-article.html meeting-fallback.jpg memories messaging-apps-article.html mid-autumn-article.html ming-article-final.html ming-article.html models_dev_cache.json nanjing_article.html node notification.md ollama_cloud_models_cache.json outputs pairing payload.json phishing-article.html php_article.html playwright_fdroid.py playwright_metro.py playwright_screenshots.py plugins poll_bilibili.sh porcelain-article.html porcelain-article-v2.html post_data.json prepare_article.sh prepare_content.py prepare_post.py prepare_publish.py prep_post.py processes.json provider_models_cache.json publish_article.php publish_article.py publish-panda.sh publish_post.php qing-article-final.html qing-article.html qing_article.html qingdao-article.html qing-dynasty-article.html qing_dynasty_article.html qin-shi-huang-article.html quality_check2.py quality_check3.py quality_check.py rag_article.xml replace_imgs.py router-article-final.html router-article.html sandboxes scala_article.json _sc.md screenshot_capture2.py screenshot_capture.py screenshot_remote.py screenshot_script2.py screenshot_script3.py screenshot_script.py screenshots.py scripts _sec1.md _sec2.md _sec3.md _sec4.md _sec5.md sessions shang-dynasty-article.html shang-final.html shopping-privacy-article.html silk-article-final.html silk-article.html silk-road-article.html silk-road-final.html _skeleton.md skills social-media-privacy-article.html song-dynasty-article.html song_dynasty_article.html song_dynasty_final.html SOUL.md state.db state.db-shm state.db-wal stone-forest-article.html sui_dynasty_article.html summer-palace-article.html _supply_chain.md suzhou-article.html tang-dynasty-article.html tang-dynasty-full.html tcm_article_final.html tcm-article.html tcm_article.html tea-article.html temp temp_article_content.html temp_article.html _test_content.md _test.txt three-kingdoms-article.html three-kingdoms-final.html tmp update_article.py update_content.py _update_content.xml update_db.py update_images.py update_post2.py update_post.php update_post.py update_post_wp.php update_wp.py upload-img.php verify_article.py verify_post.php verify_post.py verify_post.sh visa-article.html vpn_article.html work write_article_content.py write-article.py write_article.py write_update_script2.py write_update_script.py wu-zetian-article.html wu-zetian-article-with-images.html xia_dynasty_article.html xiamen-article.html yuan-article.html yuan-dynasty-article.html zhangjiajie_article.html zhenghe-article.html zhou-dynasty-article.html ((2 _aegis_article.md ai_chatbot_privacy_article.html ai-seo-tools-article.html ai-seo-tools-article-updated.html alipay-article.html android-privacy-article.html android_privacy_article.html android-privacy-final.html android_privacy_final.html article_2fa.html article-architecture.html article_base64.txt article_body.html article_body.md article_body.txt article_breach_response.html article_clean.html article_complete.html article_content_final.json article-content.html article_content.html article_content.json article_content.txt _article_content.xml article_cookie_consent.html article_data_breach.html article_data.json article_dianping.html article-dns-privacy-final.html article-dns-privacy.html article_dns_privacy.html article_draft.html article_ecommerce.html article-email-marketing.html article_encrypted_cloud.html article-escaped.txt article-final.html article_final.html article_full.html article_game_dev.html article_headshot.html article-hemal-grocery.html article.html article-html.txt article_identity_theft.html article-image-generators.html article_iphone_privacy.html article-longmen-grottoes-final.html article-longmen-grottoes.html article_meituan.html article_meta.json article_passkeys.html article_pg_clean.json article_pg.json article_postgresql.html article-privacy-cloud-storage.html article_public_wifi.html article_python_type_hints.html article-qin-shi-huang.html article_ransomware.html article-rent-apartment.html articles article_search_engines.html article_sim_swap.html article_social_media_privacy.html article_temp.html article_today_point.html article_transcription.html article_vllm.md article-with-images.html article_with_images.html article_with_images.txt article_xiaohongshu.html article.xml article_zhou_final.html article_zhou.html audio_cache auth.json auth.lock _b64_part1.txt beijing-guide.html beijing-opera-article.html beijing_opera_article.html bin bitwarden-article.html browser-comparison-article.html browser-fingerprinting-article.html build_article.py cache capture2.py capture_bitwarden.py capture_hootsuite.py capture_playstore.py capture.py capture_screens2.py capture_screenshots.py capture_screens.py capture.sh capture_stealth.py channel_directory.json check_article.py check_content.py check_post.py check_quality.py chinese-civil-war-article.html chinese-dynasties-article.html chinese-dynasties-final.html chinese-etiquette-article.html chinese-etiquette-article-with-images.html chinese-folk-religion.html chinese_food_article.html chinese-zodiac-article.html config.yaml config.yaml.bak.20260616_091116 config.yaml.bak.20260616_091136 config.yaml.bak.20260616_091148 config.yaml.bak.20260616_150612 config.yaml.bak.20260616_223924 config.yaml.bak.20260616_224702 config.yaml.bak.20260616_225109 config.yaml.bak.20260616_225947 config.yaml.bak.20260617_101814 config.yaml.bak.20260617_102045 config.yaml.bak.20260617_102150 _content_p1.md create-ming-post.php create_post2.py create_post3.py create-post.php create_post.php create_post.py create_post.sh cron current_content.html data_broker_article.html _decoder_b64.txt _deepfake_article.md dl_fallback.py douyin-article-final.html douyin-article.html download_fallback.py download_images.py download_unsplash.py dragon-boat-article.html _dup.md dynasties-article.html ecommerce_content.html email-privacy-article.html feishu_seen_message_ids.json feng-shui-article.html fengshui-article.html fengshui-final.html fetch_unsplash.py final-article.html final_article.html final_article.txt final_check.py final_content.html find_magic.py fix_alt.py fix_content.py fix_html.py fix_image.py fix_images.py fix_imgs.py fix_quotes.py folk-religion-content.html full_article.html _fuzz_article.md gateway.lock gateway.pid gateway_state.json gen_article.py genghis-khan-article.html genghis-khan-final.html _gen.py ghost-festival-article.html git_object_model_article.html google_client_secret.json google_oauth_pending.json google_token.json grand-canal-article.html great-wall-history.html guilin-article.html harbin-article.html hooks huangshan-article-final.html huangshan-article.html image_cache iot-article-final.html iot-article.html jiuzhaigou-article.html jiuzhaigou-clean.html jiuzhaigou-final.html kanban.db kanban.db.init.lock kunming-article.html lantern-article.html li-river-article.html logs luoyang-article.html mao-article-final.html mao-article.html martial-arts-article.html meeting-fallback.jpg memories messaging-apps-article.html mid-autumn-article.html ming-article-final.html ming-article.html models_dev_cache.json nanjing_article.html node notification.md ollama_cloud_models_cache.json outputs pairing payload.json phishing-article.html php_article.html playwright_fdroid.py playwright_metro.py playwright_screenshots.py plugins poll_bilibili.sh porcelain-article.html porcelain-article-v2.html post_data.json prepare_article.sh prepare_content.py prepare_post.py prepare_publish.py prep_post.py processes.json provider_models_cache.json publish_article.php publish_article.py publish-panda.sh publish_post.php qing-article-final.html qing-article.html qing_article.html qingdao-article.html qing-dynasty-article.html qing_dynasty_article.html qin-shi-huang-article.html quality_check2.py quality_check3.py quality_check.py rag_article.xml replace_imgs.py router-article-final.html router-article.html sandboxes scala_article.json _sc.md screenshot_capture2.py screenshot_capture.py screenshot_remote.py screenshot_script2.py screenshot_script3.py screenshot_script.py screenshots.py scripts _sec1.md _sec2.md _sec3.md _sec4.md _sec5.md sessions shang-dynasty-article.html shang-final.html shopping-privacy-article.html silk-article-final.html silk-article.html silk-road-article.html silk-road-final.html _skeleton.md skills social-media-privacy-article.html song-dynasty-article.html song_dynasty_article.html song_dynasty_final.html SOUL.md state.db state.db-shm state.db-wal stone-forest-article.html sui_dynasty_article.html summer-palace-article.html _supply_chain.md suzhou-article.html tang-dynasty-article.html tang-dynasty-full.html tcm_article_final.html tcm-article.html tcm_article.html tea-article.html temp temp_article_content.html temp_article.html _test_content.md _test.txt three-kingdoms-article.html three-kingdoms-final.html tmp update_article.py update_content.py _update_content.xml update_db.py update_images.py update_post2.py update_post.php update_post.py update_post_wp.php update_wp.py upload-img.php verify_article.py verify_post.php verify_post.py verify_post.sh visa-article.html vpn_article.html work write_article_content.py write-article.py write_article.py write_update_script2.py write_update_script.py wu-zetian-article.html wu-zetian-article-with-images.html xia_dynasty_article.html xiamen-article.html yuan-article.html yuan-dynasty-article.html zhangjiajie_article.html zhenghe-article.html zhou-dynasty-article.html j + 1) _aegis_article.md ai_chatbot_privacy_article.html ai-seo-tools-article.html ai-seo-tools-article-updated.html alipay-article.html android-privacy-article.html android_privacy_article.html android-privacy-final.html android_privacy_final.html article_2fa.html article-architecture.html article_base64.txt article_body.html article_body.md article_body.txt article_breach_response.html article_clean.html article_complete.html article_content_final.json article-content.html article_content.html article_content.json article_content.txt _article_content.xml article_cookie_consent.html article_data_breach.html article_data.json article_dianping.html article-dns-privacy-final.html article-dns-privacy.html article_dns_privacy.html article_draft.html article_ecommerce.html article-email-marketing.html article_encrypted_cloud.html article-escaped.txt article-final.html article_final.html article_full.html article_game_dev.html article_headshot.html article-hemal-grocery.html article.html article-html.txt article_identity_theft.html article-image-generators.html article_iphone_privacy.html article-longmen-grottoes-final.html article-longmen-grottoes.html article_meituan.html article_meta.json article_passkeys.html article_pg_clean.json article_pg.json article_postgresql.html article-privacy-cloud-storage.html article_public_wifi.html article_python_type_hints.html article-qin-shi-huang.html article_ransomware.html article-rent-apartment.html articles article_search_engines.html article_sim_swap.html article_social_media_privacy.html article_temp.html article_today_point.html article_transcription.html article_vllm.md article-with-images.html article_with_images.html article_with_images.txt article_xiaohongshu.html article.xml article_zhou_final.html article_zhou.html audio_cache auth.json auth.lock _b64_part1.txt beijing-guide.html beijing-opera-article.html beijing_opera_article.html bin bitwarden-article.html browser-comparison-article.html browser-fingerprinting-article.html build_article.py cache capture2.py capture_bitwarden.py capture_hootsuite.py capture_playstore.py capture.py capture_screens2.py capture_screenshots.py capture_screens.py capture.sh capture_stealth.py channel_directory.json check_article.py check_content.py check_post.py check_quality.py chinese-civil-war-article.html chinese-dynasties-article.html chinese-dynasties-final.html chinese-etiquette-article.html chinese-etiquette-article-with-images.html chinese-folk-religion.html chinese_food_article.html chinese-zodiac-article.html config.yaml config.yaml.bak.20260616_091116 config.yaml.bak.20260616_091136 config.yaml.bak.20260616_091148 config.yaml.bak.20260616_150612 config.yaml.bak.20260616_223924 config.yaml.bak.20260616_224702 config.yaml.bak.20260616_225109 config.yaml.bak.20260616_225947 config.yaml.bak.20260617_101814 config.yaml.bak.20260617_102045 config.yaml.bak.20260617_102150 _content_p1.md create-ming-post.php create_post2.py create_post3.py create-post.php create_post.php create_post.py create_post.sh cron current_content.html data_broker_article.html _decoder_b64.txt _deepfake_article.md dl_fallback.py douyin-article-final.html douyin-article.html download_fallback.py download_images.py download_unsplash.py dragon-boat-article.html _dup.md dynasties-article.html ecommerce_content.html email-privacy-article.html feishu_seen_message_ids.json feng-shui-article.html fengshui-article.html fengshui-final.html fetch_unsplash.py final-article.html final_article.html final_article.txt final_check.py final_content.html find_magic.py fix_alt.py fix_content.py fix_html.py fix_image.py fix_images.py fix_imgs.py fix_quotes.py folk-religion-content.html full_article.html _fuzz_article.md gateway.lock gateway.pid gateway_state.json gen_article.py genghis-khan-article.html genghis-khan-final.html _gen.py ghost-festival-article.html git_object_model_article.html google_client_secret.json google_oauth_pending.json google_token.json grand-canal-article.html great-wall-history.html guilin-article.html harbin-article.html hooks huangshan-article-final.html huangshan-article.html image_cache iot-article-final.html iot-article.html jiuzhaigou-article.html jiuzhaigou-clean.html jiuzhaigou-final.html kanban.db kanban.db.init.lock kunming-article.html lantern-article.html li-river-article.html logs luoyang-article.html mao-article-final.html mao-article.html martial-arts-article.html meeting-fallback.jpg memories messaging-apps-article.html mid-autumn-article.html ming-article-final.html ming-article.html models_dev_cache.json nanjing_article.html node notification.md ollama_cloud_models_cache.json outputs pairing payload.json phishing-article.html php_article.html playwright_fdroid.py playwright_metro.py playwright_screenshots.py plugins poll_bilibili.sh porcelain-article.html porcelain-article-v2.html post_data.json prepare_article.sh prepare_content.py prepare_post.py prepare_publish.py prep_post.py processes.json provider_models_cache.json publish_article.php publish_article.py publish-panda.sh publish_post.php qing-article-final.html qing-article.html qing_article.html qingdao-article.html qing-dynasty-article.html qing_dynasty_article.html qin-shi-huang-article.html quality_check2.py quality_check3.py quality_check.py rag_article.xml replace_imgs.py router-article-final.html router-article.html sandboxes scala_article.json _sc.md screenshot_capture2.py screenshot_capture.py screenshot_remote.py screenshot_script2.py screenshot_script3.py screenshot_script.py screenshots.py scripts _sec1.md _sec2.md _sec3.md _sec4.md _sec5.md sessions shang-dynasty-article.html shang-final.html shopping-privacy-article.html silk-article-final.html silk-article.html silk-road-article.html silk-road-final.html _skeleton.md skills social-media-privacy-article.html song-dynasty-article.html song_dynasty_article.html song_dynasty_final.html SOUL.md state.db state.db-shm state.db-wal stone-forest-article.html sui_dynasty_article.html summer-palace-article.html _supply_chain.md suzhou-article.html tang-dynasty-article.html tang-dynasty-full.html tcm_article_final.html tcm-article.html tcm_article.html tea-article.html temp temp_article_content.html temp_article.html _test_content.md _test.txt three-kingdoms-article.html three-kingdoms-final.html tmp update_article.py update_content.py _update_content.xml update_db.py update_images.py update_post2.py update_post.php update_post.py update_post_wp.php update_wp.py upload-img.php verify_article.py verify_post.php verify_post.py verify_post.sh visa-article.html vpn_article.html work write_article_content.py write-article.py write_article.py write_update_script2.py write_update_script.py wu-zetian-article.html wu-zetian-article-with-images.html xia_dynasty_article.html xiamen-article.html yuan-article.html yuan-dynasty-article.html zhangjiajie_article.html zhenghe-article.html zhou-dynasty-article.html 0.5)
 elif i == j:
 A[i, j] = -(i + 1)
 else:
 A[i, j] = 0
 return A

HiPPO 初始化的 A 矩阵具有一个关键特性:它的特征值全部具有负实部,使得系统是稳定的(不会发散),同时能够记住从当前时刻回溯到初始时刻的整个历史信息。实验表明,使用 HiPPO 初始化的 SSM 在长程依赖任务(如 LRA 基准测试)上,性能远超传统 RNN 和 LSTM。

从 S4 到 Mamba:选择性机制的革命

S4:结构化状态空间

2021年,Gu 和 Goel 等人提出了 S4(Structured State Space for Sequence Modeling),这是第一个真正可用的 SSM 架构。S4 的主要贡献在于解决了 SSM 的两个核心问题:

  1. 计算效率:通过将 A 矩阵结构化为对角阵加低秩矩阵(DPLR 形式),将计算复杂度从 O(N²) 降低到 O(N log N)
  2. 训练稳定性:利用卷积核并行化训练,避免了 RNN 式的逐时间步递推

S4 在 Long Range Arena(LRA)基准测试上取得了当时的最优结果,证明了 SSM 架构在长序列建模上的潜力。然而,S4 仍然是线性时不变系统——它的参数不依赖于输入内容,这限制了它在需要”内容感知”的任务(如语言建模)上的表现。

Mamba 的核心创新:选择性 SSM

Mamba 的关键洞察是:SSM 的参数应该是输入的函数。具体来说,Mamba 让 B、C 和步长 Δ 都依赖于当前输入,而 A 矩阵仍然保持固定(使用 HiPPO 初始化):

参数 S4(固定) Mamba(选择性)
A 固定(HiPPO) 固定(HiPPO)
B 固定向量 B(x) = Linear_B(x),随输入变化
C 固定向量 C(x) = Linear_C(x),随输入变化
Δ 固定标量 Δ(x) = softplus(Linear_Δ(x)),随输入变化

这种”选择性”机制带来了一个质变:模型现在可以根据输入内容决定”记住什么”和”忘记什么”。例如,在处理自然语言时,SSM 可以对冠词、介词等”低信息量”token 选择性地”遗忘”(通过减小 Δ 或调整 B),而对关键词、实体名称等”高信息量”token 选择性地”记住”。

这种能力使得 Mamba 在语言建模任务上首次超越了同规模的 Transformer。下图展示了 Mamba 模块的完整架构:

Mamba架构示意图 - 深度学习状态空间模型

Mamba 模块的完整实现

下面我们给出 Mamba 核心模块的完整 PyTorch 实现。这个实现参考了官方 Mamba 仓库,但进行了简化和注释,便于理解:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
class MambaBlock(nn.Module):
 """
 Mamba 核心模块

 包含:
 1. 输入投影 + 1D 卷积 + SiLU 激活
 2. 选择性 SSM 层
 3. 输出投影 + 残差连接
 """
 def __init__(self, d_model, d_state=16, expand_factor=2, d_conv=4):
 super().__init__()
 self.d_model = d_model
 self.d_state = d_state
 self.expand = expand_factor
 self.d_inner = d_model _aegis_article.md ai_chatbot_privacy_article.html ai-seo-tools-article.html ai-seo-tools-article-updated.html alipay-article.html android-privacy-article.html android_privacy_article.html android-privacy-final.html android_privacy_final.html article_2fa.html article-architecture.html article_base64.txt article_body.html article_body.md article_body.txt article_breach_response.html article_clean.html article_complete.html article_content_final.json article-content.html article_content.html article_content.json article_content.txt _article_content.xml article_cookie_consent.html article_data_breach.html article_data.json article_dianping.html article-dns-privacy-final.html article-dns-privacy.html article_dns_privacy.html article_draft.html article_ecommerce.html article-email-marketing.html article_encrypted_cloud.html article-escaped.txt article-final.html article_final.html article_full.html article_game_dev.html article_headshot.html article-hemal-grocery.html article.html article-html.txt article_identity_theft.html article-image-generators.html article_iphone_privacy.html article-longmen-grottoes-final.html article-longmen-grottoes.html article_meituan.html article_meta.json article_passkeys.html article_pg_clean.json article_pg.json article_postgresql.html article-privacy-cloud-storage.html article_public_wifi.html article_python_type_hints.html article-qin-shi-huang.html article_ransomware.html article-rent-apartment.html articles article_search_engines.html article_sim_swap.html article_social_media_privacy.html article_temp.html article_today_point.html article_transcription.html article_vllm.md article-with-images.html article_with_images.html article_with_images.txt article_xiaohongshu.html article.xml article_zhou_final.html article_zhou.html audio_cache auth.json auth.lock _b64_part1.txt beijing-guide.html beijing-opera-article.html beijing_opera_article.html bin bitwarden-article.html browser-comparison-article.html browser-fingerprinting-article.html build_article.py cache capture2.py capture_bitwarden.py capture_hootsuite.py capture_playstore.py capture.py capture_screens2.py capture_screenshots.py capture_screens.py capture.sh capture_stealth.py channel_directory.json check_article.py check_content.py check_post.py check_quality.py chinese-civil-war-article.html chinese-dynasties-article.html chinese-dynasties-final.html chinese-etiquette-article.html chinese-etiquette-article-with-images.html chinese-folk-religion.html chinese_food_article.html chinese-zodiac-article.html config.yaml config.yaml.bak.20260616_091116 config.yaml.bak.20260616_091136 config.yaml.bak.20260616_091148 config.yaml.bak.20260616_150612 config.yaml.bak.20260616_223924 config.yaml.bak.20260616_224702 config.yaml.bak.20260616_225109 config.yaml.bak.20260616_225947 config.yaml.bak.20260617_101814 config.yaml.bak.20260617_102045 config.yaml.bak.20260617_102150 _content_p1.md create-ming-post.php create_post2.py create_post3.py create-post.php create_post.php create_post.py create_post.sh cron current_content.html data_broker_article.html _decoder_b64.txt _deepfake_article.md dl_fallback.py douyin-article-final.html douyin-article.html download_fallback.py download_images.py download_unsplash.py dragon-boat-article.html _dup.md dynasties-article.html ecommerce_content.html email-privacy-article.html feishu_seen_message_ids.json feng-shui-article.html fengshui-article.html fengshui-final.html fetch_unsplash.py final-article.html final_article.html final_article.txt final_check.py final_content.html find_magic.py fix_alt.py fix_content.py fix_html.py fix_image.py fix_images.py fix_imgs.py fix_quotes.py folk-religion-content.html full_article.html _fuzz_article.md gateway.lock gateway.pid gateway_state.json gen_article.py genghis-khan-article.html genghis-khan-final.html _gen.py ghost-festival-article.html git_object_model_article.html google_client_secret.json google_oauth_pending.json google_token.json grand-canal-article.html great-wall-history.html guilin-article.html harbin-article.html hooks huangshan-article-final.html huangshan-article.html image_cache iot-article-final.html iot-article.html jiuzhaigou-article.html jiuzhaigou-clean.html jiuzhaigou-final.html kanban.db kanban.db.init.lock kunming-article.html lantern-article.html li-river-article.html logs luoyang-article.html mao-article-final.html mao-article.html martial-arts-article.html meeting-fallback.jpg memories messaging-apps-article.html mid-autumn-article.html ming-article-final.html ming-article.html models_dev_cache.json nanjing_article.html node notification.md ollama_cloud_models_cache.json outputs pairing payload.json phishing-article.html php_article.html playwright_fdroid.py playwright_metro.py playwright_screenshots.py plugins poll_bilibili.sh porcelain-article.html porcelain-article-v2.html post_data.json prepare_article.sh prepare_content.py prepare_post.py prepare_publish.py prep_post.py processes.json provider_models_cache.json publish_article.php publish_article.py publish-panda.sh publish_post.php qing-article-final.html qing-article.html qing_article.html qingdao-article.html qing-dynasty-article.html qing_dynasty_article.html qin-shi-huang-article.html quality_check2.py quality_check3.py quality_check.py rag_article.xml replace_imgs.py router-article-final.html router-article.html sandboxes scala_article.json _sc.md screenshot_capture2.py screenshot_capture.py screenshot_remote.py screenshot_script2.py screenshot_script3.py screenshot_script.py screenshots.py scripts _sec1.md _sec2.md _sec3.md _sec4.md _sec5.md sessions shang-dynasty-article.html shang-final.html shopping-privacy-article.html silk-article-final.html silk-article.html silk-road-article.html silk-road-final.html _skeleton.md skills social-media-privacy-article.html song-dynasty-article.html song_dynasty_article.html song_dynasty_final.html SOUL.md state.db state.db-shm state.db-wal stone-forest-article.html sui_dynasty_article.html summer-palace-article.html _supply_chain.md suzhou-article.html tang-dynasty-article.html tang-dynasty-full.html tcm_article_final.html tcm-article.html tcm_article.html tea-article.html temp temp_article_content.html temp_article.html _test_content.md _test.txt three-kingdoms-article.html three-kingdoms-final.html tmp update_article.py update_content.py _update_content.xml update_db.py update_images.py update_post2.py update_post.php update_post.py update_post_wp.php update_wp.py upload-img.php verify_article.py verify_post.php verify_post.py verify_post.sh visa-article.html vpn_article.html work write_article_content.py write-article.py write_article.py write_update_script2.py write_update_script.py wu-zetian-article.html wu-zetian-article-with-images.html xia_dynasty_article.html xiamen-article.html yuan-article.html yuan-dynasty-article.html zhangjiajie_article.html zhenghe-article.html zhou-dynasty-article.html expand_factor
 self.d_conv = d_conv

 # 输入投影:将 d_model 映射到 d_inner _aegis_article.md ai_chatbot_privacy_article.html ai-seo-tools-article.html ai-seo-tools-article-updated.html alipay-article.html android-privacy-article.html android_privacy_article.html android-privacy-final.html android_privacy_final.html article_2fa.html article-architecture.html article_base64.txt article_body.html article_body.md article_body.txt article_breach_response.html article_clean.html article_complete.html article_content_final.json article-content.html article_content.html article_content.json article_content.txt _article_content.xml article_cookie_consent.html article_data_breach.html article_data.json article_dianping.html article-dns-privacy-final.html article-dns-privacy.html article_dns_privacy.html article_draft.html article_ecommerce.html article-email-marketing.html article_encrypted_cloud.html article-escaped.txt article-final.html article_final.html article_full.html article_game_dev.html article_headshot.html article-hemal-grocery.html article.html article-html.txt article_identity_theft.html article-image-generators.html article_iphone_privacy.html article-longmen-grottoes-final.html article-longmen-grottoes.html article_meituan.html article_meta.json article_passkeys.html article_pg_clean.json article_pg.json article_postgresql.html article-privacy-cloud-storage.html article_public_wifi.html article_python_type_hints.html article-qin-shi-huang.html article_ransomware.html article-rent-apartment.html articles article_search_engines.html article_sim_swap.html article_social_media_privacy.html article_temp.html article_today_point.html article_transcription.html article_vllm.md article-with-images.html article_with_images.html article_with_images.txt article_xiaohongshu.html article.xml article_zhou_final.html article_zhou.html audio_cache auth.json auth.lock _b64_part1.txt beijing-guide.html beijing-opera-article.html beijing_opera_article.html bin bitwarden-article.html browser-comparison-article.html browser-fingerprinting-article.html build_article.py cache capture2.py capture_bitwarden.py capture_hootsuite.py capture_playstore.py capture.py capture_screens2.py capture_screenshots.py capture_screens.py capture.sh capture_stealth.py channel_directory.json check_article.py check_content.py check_post.py check_quality.py chinese-civil-war-article.html chinese-dynasties-article.html chinese-dynasties-final.html chinese-etiquette-article.html chinese-etiquette-article-with-images.html chinese-folk-religion.html chinese_food_article.html chinese-zodiac-article.html config.yaml config.yaml.bak.20260616_091116 config.yaml.bak.20260616_091136 config.yaml.bak.20260616_091148 config.yaml.bak.20260616_150612 config.yaml.bak.20260616_223924 config.yaml.bak.20260616_224702 config.yaml.bak.20260616_225109 config.yaml.bak.20260616_225947 config.yaml.bak.20260617_101814 config.yaml.bak.20260617_102045 config.yaml.bak.20260617_102150 _content_p1.md create-ming-post.php create_post2.py create_post3.py create-post.php create_post.php create_post.py create_post.sh cron current_content.html data_broker_article.html _decoder_b64.txt _deepfake_article.md dl_fallback.py douyin-article-final.html douyin-article.html download_fallback.py download_images.py download_unsplash.py dragon-boat-article.html _dup.md dynasties-article.html ecommerce_content.html email-privacy-article.html feishu_seen_message_ids.json feng-shui-article.html fengshui-article.html fengshui-final.html fetch_unsplash.py final-article.html final_article.html final_article.txt final_check.py final_content.html find_magic.py fix_alt.py fix_content.py fix_html.py fix_image.py fix_images.py fix_imgs.py fix_quotes.py folk-religion-content.html full_article.html _fuzz_article.md gateway.lock gateway.pid gateway_state.json gen_article.py genghis-khan-article.html genghis-khan-final.html _gen.py ghost-festival-article.html git_object_model_article.html google_client_secret.json google_oauth_pending.json google_token.json grand-canal-article.html great-wall-history.html guilin-article.html harbin-article.html hooks huangshan-article-final.html huangshan-article.html image_cache iot-article-final.html iot-article.html jiuzhaigou-article.html jiuzhaigou-clean.html jiuzhaigou-final.html kanban.db kanban.db.init.lock kunming-article.html lantern-article.html li-river-article.html logs luoyang-article.html mao-article-final.html mao-article.html martial-arts-article.html meeting-fallback.jpg memories messaging-apps-article.html mid-autumn-article.html ming-article-final.html ming-article.html models_dev_cache.json nanjing_article.html node notification.md ollama_cloud_models_cache.json outputs pairing payload.json phishing-article.html php_article.html playwright_fdroid.py playwright_metro.py playwright_screenshots.py plugins poll_bilibili.sh porcelain-article.html porcelain-article-v2.html post_data.json prepare_article.sh prepare_content.py prepare_post.py prepare_publish.py prep_post.py processes.json provider_models_cache.json publish_article.php publish_article.py publish-panda.sh publish_post.php qing-article-final.html qing-article.html qing_article.html qingdao-article.html qing-dynasty-article.html qing_dynasty_article.html qin-shi-huang-article.html quality_check2.py quality_check3.py quality_check.py rag_article.xml replace_imgs.py router-article-final.html router-article.html sandboxes scala_article.json _sc.md screenshot_capture2.py screenshot_capture.py screenshot_remote.py screenshot_script2.py screenshot_script3.py screenshot_script.py screenshots.py scripts _sec1.md _sec2.md _sec3.md _sec4.md _sec5.md sessions shang-dynasty-article.html shang-final.html shopping-privacy-article.html silk-article-final.html silk-article.html silk-road-article.html silk-road-final.html _skeleton.md skills social-media-privacy-article.html song-dynasty-article.html song_dynasty_article.html song_dynasty_final.html SOUL.md state.db state.db-shm state.db-wal stone-forest-article.html sui_dynasty_article.html summer-palace-article.html _supply_chain.md suzhou-article.html tang-dynasty-article.html tang-dynasty-full.html tcm_article_final.html tcm-article.html tcm_article.html tea-article.html temp temp_article_content.html temp_article.html _test_content.md _test.txt three-kingdoms-article.html three-kingdoms-final.html tmp update_article.py update_content.py _update_content.xml update_db.py update_images.py update_post2.py update_post.php update_post.py update_post_wp.php update_wp.py upload-img.php verify_article.py verify_post.php verify_post.py verify_post.sh visa-article.html vpn_article.html work write_article_content.py write-article.py write_article.py write_update_script2.py write_update_script.py wu-zetian-article.html wu-zetian-article-with-images.html xia_dynasty_article.html xiamen-article.html yuan-article.html yuan-dynasty-article.html zhangjiajie_article.html zhenghe-article.html zhou-dynasty-article.html 2(门控结构)
 self.in_proj = nn.Linear(d_model, self.d_inner _aegis_article.md ai_chatbot_privacy_article.html ai-seo-tools-article.html ai-seo-tools-article-updated.html alipay-article.html android-privacy-article.html android_privacy_article.html android-privacy-final.html android_privacy_final.html article_2fa.html article-architecture.html article_base64.txt article_body.html article_body.md article_body.txt article_breach_response.html article_clean.html article_complete.html article_content_final.json article-content.html article_content.html article_content.json article_content.txt _article_content.xml article_cookie_consent.html article_data_breach.html article_data.json article_dianping.html article-dns-privacy-final.html article-dns-privacy.html article_dns_privacy.html article_draft.html article_ecommerce.html article-email-marketing.html article_encrypted_cloud.html article-escaped.txt article-final.html article_final.html article_full.html article_game_dev.html article_headshot.html article-hemal-grocery.html article.html article-html.txt article_identity_theft.html article-image-generators.html article_iphone_privacy.html article-longmen-grottoes-final.html article-longmen-grottoes.html article_meituan.html article_meta.json article_passkeys.html article_pg_clean.json article_pg.json article_postgresql.html article-privacy-cloud-storage.html article_public_wifi.html article_python_type_hints.html article-qin-shi-huang.html article_ransomware.html article-rent-apartment.html articles article_search_engines.html article_sim_swap.html article_social_media_privacy.html article_temp.html article_today_point.html article_transcription.html article_vllm.md article-with-images.html article_with_images.html article_with_images.txt article_xiaohongshu.html article.xml article_zhou_final.html article_zhou.html audio_cache auth.json auth.lock _b64_part1.txt beijing-guide.html beijing-opera-article.html beijing_opera_article.html bin bitwarden-article.html browser-comparison-article.html browser-fingerprinting-article.html build_article.py cache capture2.py capture_bitwarden.py capture_hootsuite.py capture_playstore.py capture.py capture_screens2.py capture_screenshots.py capture_screens.py capture.sh capture_stealth.py channel_directory.json check_article.py check_content.py check_post.py check_quality.py chinese-civil-war-article.html chinese-dynasties-article.html chinese-dynasties-final.html chinese-etiquette-article.html chinese-etiquette-article-with-images.html chinese-folk-religion.html chinese_food_article.html chinese-zodiac-article.html config.yaml config.yaml.bak.20260616_091116 config.yaml.bak.20260616_091136 config.yaml.bak.20260616_091148 config.yaml.bak.20260616_150612 config.yaml.bak.20260616_223924 config.yaml.bak.20260616_224702 config.yaml.bak.20260616_225109 config.yaml.bak.20260616_225947 config.yaml.bak.20260617_101814 config.yaml.bak.20260617_102045 config.yaml.bak.20260617_102150 _content_p1.md create-ming-post.php create_post2.py create_post3.py create-post.php create_post.php create_post.py create_post.sh cron current_content.html data_broker_article.html _decoder_b64.txt _deepfake_article.md dl_fallback.py douyin-article-final.html douyin-article.html download_fallback.py download_images.py download_unsplash.py dragon-boat-article.html _dup.md dynasties-article.html ecommerce_content.html email-privacy-article.html feishu_seen_message_ids.json feng-shui-article.html fengshui-article.html fengshui-final.html fetch_unsplash.py final-article.html final_article.html final_article.txt final_check.py final_content.html find_magic.py fix_alt.py fix_content.py fix_html.py fix_image.py fix_images.py fix_imgs.py fix_quotes.py folk-religion-content.html full_article.html _fuzz_article.md gateway.lock gateway.pid gateway_state.json gen_article.py genghis-khan-article.html genghis-khan-final.html _gen.py ghost-festival-article.html git_object_model_article.html google_client_secret.json google_oauth_pending.json google_token.json grand-canal-article.html great-wall-history.html guilin-article.html harbin-article.html hooks huangshan-article-final.html huangshan-article.html image_cache iot-article-final.html iot-article.html jiuzhaigou-article.html jiuzhaigou-clean.html jiuzhaigou-final.html kanban.db kanban.db.init.lock kunming-article.html lantern-article.html li-river-article.html logs luoyang-article.html mao-article-final.html mao-article.html martial-arts-article.html meeting-fallback.jpg memories messaging-apps-article.html mid-autumn-article.html ming-article-final.html ming-article.html models_dev_cache.json nanjing_article.html node notification.md ollama_cloud_models_cache.json outputs pairing payload.json phishing-article.html php_article.html playwright_fdroid.py playwright_metro.py playwright_screenshots.py plugins poll_bilibili.sh porcelain-article.html porcelain-article-v2.html post_data.json prepare_article.sh prepare_content.py prepare_post.py prepare_publish.py prep_post.py processes.json provider_models_cache.json publish_article.php publish_article.py publish-panda.sh publish_post.php qing-article-final.html qing-article.html qing_article.html qingdao-article.html qing-dynasty-article.html qing_dynasty_article.html qin-shi-huang-article.html quality_check2.py quality_check3.py quality_check.py rag_article.xml replace_imgs.py router-article-final.html router-article.html sandboxes scala_article.json _sc.md screenshot_capture2.py screenshot_capture.py screenshot_remote.py screenshot_script2.py screenshot_script3.py screenshot_script.py screenshots.py scripts _sec1.md _sec2.md _sec3.md _sec4.md _sec5.md sessions shang-dynasty-article.html shang-final.html shopping-privacy-article.html silk-article-final.html silk-article.html silk-road-article.html silk-road-final.html _skeleton.md skills social-media-privacy-article.html song-dynasty-article.html song_dynasty_article.html song_dynasty_final.html SOUL.md state.db state.db-shm state.db-wal stone-forest-article.html sui_dynasty_article.html summer-palace-article.html _supply_chain.md suzhou-article.html tang-dynasty-article.html tang-dynasty-full.html tcm_article_final.html tcm-article.html tcm_article.html tea-article.html temp temp_article_content.html temp_article.html _test_content.md _test.txt three-kingdoms-article.html three-kingdoms-final.html tmp update_article.py update_content.py _update_content.xml update_db.py update_images.py update_post2.py update_post.php update_post.py update_post_wp.php update_wp.py upload-img.php verify_article.py verify_post.php verify_post.py verify_post.sh visa-article.html vpn_article.html work write_article_content.py write-article.py write_article.py write_update_script2.py write_update_script.py wu-zetian-article.html wu-zetian-article-with-images.html xia_dynasty_article.html xiamen-article.html yuan-article.html yuan-dynasty-article.html zhangjiajie_article.html zhenghe-article.html zhou-dynasty-article.html 2, bias=False)

 # 1D 卷积:对序列维度进行局部建模
 self.conv1d = nn.Conv1d(
 in_channels=self.d_inner,
 out_channels=self.d_inner,
 kernel_size=d_conv,
 padding=d_conv - 1,
 groups=self.d_inner, # depthwise conv
 )

 # 选择性 SSM 参数投影
 # x_proj 同时输出 Δ, B, C 的投影
 # 输出维度: d_state _aegis_article.md ai_chatbot_privacy_article.html ai-seo-tools-article.html ai-seo-tools-article-updated.html alipay-article.html android-privacy-article.html android_privacy_article.html android-privacy-final.html android_privacy_final.html article_2fa.html article-architecture.html article_base64.txt article_body.html article_body.md article_body.txt article_breach_response.html article_clean.html article_complete.html article_content_final.json article-content.html article_content.html article_content.json article_content.txt _article_content.xml article_cookie_consent.html article_data_breach.html article_data.json article_dianping.html article-dns-privacy-final.html article-dns-privacy.html article_dns_privacy.html article_draft.html article_ecommerce.html article-email-marketing.html article_encrypted_cloud.html article-escaped.txt article-final.html article_final.html article_full.html article_game_dev.html article_headshot.html article-hemal-grocery.html article.html article-html.txt article_identity_theft.html article-image-generators.html article_iphone_privacy.html article-longmen-grottoes-final.html article-longmen-grottoes.html article_meituan.html article_meta.json article_passkeys.html article_pg_clean.json article_pg.json article_postgresql.html article-privacy-cloud-storage.html article_public_wifi.html article_python_type_hints.html article-qin-shi-huang.html article_ransomware.html article-rent-apartment.html articles article_search_engines.html article_sim_swap.html article_social_media_privacy.html article_temp.html article_today_point.html article_transcription.html article_vllm.md article-with-images.html article_with_images.html article_with_images.txt article_xiaohongshu.html article.xml article_zhou_final.html article_zhou.html audio_cache auth.json auth.lock _b64_part1.txt beijing-guide.html beijing-opera-article.html beijing_opera_article.html bin bitwarden-article.html browser-comparison-article.html browser-fingerprinting-article.html build_article.py cache capture2.py capture_bitwarden.py capture_hootsuite.py capture_playstore.py capture.py capture_screens2.py capture_screenshots.py capture_screens.py capture.sh capture_stealth.py channel_directory.json check_article.py check_content.py check_post.py check_quality.py chinese-civil-war-article.html chinese-dynasties-article.html chinese-dynasties-final.html chinese-etiquette-article.html chinese-etiquette-article-with-images.html chinese-folk-religion.html chinese_food_article.html chinese-zodiac-article.html config.yaml config.yaml.bak.20260616_091116 config.yaml.bak.20260616_091136 config.yaml.bak.20260616_091148 config.yaml.bak.20260616_150612 config.yaml.bak.20260616_223924 config.yaml.bak.20260616_224702 config.yaml.bak.20260616_225109 config.yaml.bak.20260616_225947 config.yaml.bak.20260617_101814 config.yaml.bak.20260617_102045 config.yaml.bak.20260617_102150 _content_p1.md create-ming-post.php create_post2.py create_post3.py create-post.php create_post.php create_post.py create_post.sh cron current_content.html data_broker_article.html _decoder_b64.txt _deepfake_article.md dl_fallback.py douyin-article-final.html douyin-article.html download_fallback.py download_images.py download_unsplash.py dragon-boat-article.html _dup.md dynasties-article.html ecommerce_content.html email-privacy-article.html feishu_seen_message_ids.json feng-shui-article.html fengshui-article.html fengshui-final.html fetch_unsplash.py final-article.html final_article.html final_article.txt final_check.py final_content.html find_magic.py fix_alt.py fix_content.py fix_html.py fix_image.py fix_images.py fix_imgs.py fix_quotes.py folk-religion-content.html full_article.html _fuzz_article.md gateway.lock gateway.pid gateway_state.json gen_article.py genghis-khan-article.html genghis-khan-final.html _gen.py ghost-festival-article.html git_object_model_article.html google_client_secret.json google_oauth_pending.json google_token.json grand-canal-article.html great-wall-history.html guilin-article.html harbin-article.html hooks huangshan-article-final.html huangshan-article.html image_cache iot-article-final.html iot-article.html jiuzhaigou-article.html jiuzhaigou-clean.html jiuzhaigou-final.html kanban.db kanban.db.init.lock kunming-article.html lantern-article.html li-river-article.html logs luoyang-article.html mao-article-final.html mao-article.html martial-arts-article.html meeting-fallback.jpg memories messaging-apps-article.html mid-autumn-article.html ming-article-final.html ming-article.html models_dev_cache.json nanjing_article.html node notification.md ollama_cloud_models_cache.json outputs pairing payload.json phishing-article.html php_article.html playwright_fdroid.py playwright_metro.py playwright_screenshots.py plugins poll_bilibili.sh porcelain-article.html porcelain-article-v2.html post_data.json prepare_article.sh prepare_content.py prepare_post.py prepare_publish.py prep_post.py processes.json provider_models_cache.json publish_article.php publish_article.py publish-panda.sh publish_post.php qing-article-final.html qing-article.html qing_article.html qingdao-article.html qing-dynasty-article.html qing_dynasty_article.html qin-shi-huang-article.html quality_check2.py quality_check3.py quality_check.py rag_article.xml replace_imgs.py router-article-final.html router-article.html sandboxes scala_article.json _sc.md screenshot_capture2.py screenshot_capture.py screenshot_remote.py screenshot_script2.py screenshot_script3.py screenshot_script.py screenshots.py scripts _sec1.md _sec2.md _sec3.md _sec4.md _sec5.md sessions shang-dynasty-article.html shang-final.html shopping-privacy-article.html silk-article-final.html silk-article.html silk-road-article.html silk-road-final.html _skeleton.md skills social-media-privacy-article.html song-dynasty-article.html song_dynasty_article.html song_dynasty_final.html SOUL.md state.db state.db-shm state.db-wal stone-forest-article.html sui_dynasty_article.html summer-palace-article.html _supply_chain.md suzhou-article.html tang-dynasty-article.html tang-dynasty-full.html tcm_article_final.html tcm-article.html tcm_article.html tea-article.html temp temp_article_content.html temp_article.html _test_content.md _test.txt three-kingdoms-article.html three-kingdoms-final.html tmp update_article.py update_content.py _update_content.xml update_db.py update_images.py update_post2.py update_post.php update_post.py update_post_wp.php update_wp.py upload-img.php verify_article.py verify_post.php verify_post.py verify_post.sh visa-article.html vpn_article.html work write_article_content.py write-article.py write_article.py write_update_script2.py write_update_script.py wu-zetian-article.html wu-zetian-article-with-images.html xia_dynasty_article.html xiamen-article.html yuan-article.html yuan-dynasty-article.html zhangjiajie_article.html zhenghe-article.html zhou-dynasty-article.html 2 + d_inner(B和C各d_state,Δ需要d_inner)
 self.x_proj = nn.Linear(self.d_inner, d_state _aegis_article.md ai_chatbot_privacy_article.html ai-seo-tools-article.html ai-seo-tools-article-updated.html alipay-article.html android-privacy-article.html android_privacy_article.html android-privacy-final.html android_privacy_final.html article_2fa.html article-architecture.html article_base64.txt article_body.html article_body.md article_body.txt article_breach_response.html article_clean.html article_complete.html article_content_final.json article-content.html article_content.html article_content.json article_content.txt _article_content.xml article_cookie_consent.html article_data_breach.html article_data.json article_dianping.html article-dns-privacy-final.html article-dns-privacy.html article_dns_privacy.html article_draft.html article_ecommerce.html article-email-marketing.html article_encrypted_cloud.html article-escaped.txt article-final.html article_final.html article_full.html article_game_dev.html article_headshot.html article-hemal-grocery.html article.html article-html.txt article_identity_theft.html article-image-generators.html article_iphone_privacy.html article-longmen-grottoes-final.html article-longmen-grottoes.html article_meituan.html article_meta.json article_passkeys.html article_pg_clean.json article_pg.json article_postgresql.html article-privacy-cloud-storage.html article_public_wifi.html article_python_type_hints.html article-qin-shi-huang.html article_ransomware.html article-rent-apartment.html articles article_search_engines.html article_sim_swap.html article_social_media_privacy.html article_temp.html article_today_point.html article_transcription.html article_vllm.md article-with-images.html article_with_images.html article_with_images.txt article_xiaohongshu.html article.xml article_zhou_final.html article_zhou.html audio_cache auth.json auth.lock _b64_part1.txt beijing-guide.html beijing-opera-article.html beijing_opera_article.html bin bitwarden-article.html browser-comparison-article.html browser-fingerprinting-article.html build_article.py cache capture2.py capture_bitwarden.py capture_hootsuite.py capture_playstore.py capture.py capture_screens2.py capture_screenshots.py capture_screens.py capture.sh capture_stealth.py channel_directory.json check_article.py check_content.py check_post.py check_quality.py chinese-civil-war-article.html chinese-dynasties-article.html chinese-dynasties-final.html chinese-etiquette-article.html chinese-etiquette-article-with-images.html chinese-folk-religion.html chinese_food_article.html chinese-zodiac-article.html config.yaml config.yaml.bak.20260616_091116 config.yaml.bak.20260616_091136 config.yaml.bak.20260616_091148 config.yaml.bak.20260616_150612 config.yaml.bak.20260616_223924 config.yaml.bak.20260616_224702 config.yaml.bak.20260616_225109 config.yaml.bak.20260616_225947 config.yaml.bak.20260617_101814 config.yaml.bak.20260617_102045 config.yaml.bak.20260617_102150 _content_p1.md create-ming-post.php create_post2.py create_post3.py create-post.php create_post.php create_post.py create_post.sh cron current_content.html data_broker_article.html _decoder_b64.txt _deepfake_article.md dl_fallback.py douyin-article-final.html douyin-article.html download_fallback.py download_images.py download_unsplash.py dragon-boat-article.html _dup.md dynasties-article.html ecommerce_content.html email-privacy-article.html feishu_seen_message_ids.json feng-shui-article.html fengshui-article.html fengshui-final.html fetch_unsplash.py final-article.html final_article.html final_article.txt final_check.py final_content.html find_magic.py fix_alt.py fix_content.py fix_html.py fix_image.py fix_images.py fix_imgs.py fix_quotes.py folk-religion-content.html full_article.html _fuzz_article.md gateway.lock gateway.pid gateway_state.json gen_article.py genghis-khan-article.html genghis-khan-final.html _gen.py ghost-festival-article.html git_object_model_article.html google_client_secret.json google_oauth_pending.json google_token.json grand-canal-article.html great-wall-history.html guilin-article.html harbin-article.html hooks huangshan-article-final.html huangshan-article.html image_cache iot-article-final.html iot-article.html jiuzhaigou-article.html jiuzhaigou-clean.html jiuzhaigou-final.html kanban.db kanban.db.init.lock kunming-article.html lantern-article.html li-river-article.html logs luoyang-article.html mao-article-final.html mao-article.html martial-arts-article.html meeting-fallback.jpg memories messaging-apps-article.html mid-autumn-article.html ming-article-final.html ming-article.html models_dev_cache.json nanjing_article.html node notification.md ollama_cloud_models_cache.json outputs pairing payload.json phishing-article.html php_article.html playwright_fdroid.py playwright_metro.py playwright_screenshots.py plugins poll_bilibili.sh porcelain-article.html porcelain-article-v2.html post_data.json prepare_article.sh prepare_content.py prepare_post.py prepare_publish.py prep_post.py processes.json provider_models_cache.json publish_article.php publish_article.py publish-panda.sh publish_post.php qing-article-final.html qing-article.html qing_article.html qingdao-article.html qing-dynasty-article.html qing_dynasty_article.html qin-shi-huang-article.html quality_check2.py quality_check3.py quality_check.py rag_article.xml replace_imgs.py router-article-final.html router-article.html sandboxes scala_article.json _sc.md screenshot_capture2.py screenshot_capture.py screenshot_remote.py screenshot_script2.py screenshot_script3.py screenshot_script.py screenshots.py scripts _sec1.md _sec2.md _sec3.md _sec4.md _sec5.md sessions shang-dynasty-article.html shang-final.html shopping-privacy-article.html silk-article-final.html silk-article.html silk-road-article.html silk-road-final.html _skeleton.md skills social-media-privacy-article.html song-dynasty-article.html song_dynasty_article.html song_dynasty_final.html SOUL.md state.db state.db-shm state.db-wal stone-forest-article.html sui_dynasty_article.html summer-palace-article.html _supply_chain.md suzhou-article.html tang-dynasty-article.html tang-dynasty-full.html tcm_article_final.html tcm-article.html tcm_article.html tea-article.html temp temp_article_content.html temp_article.html _test_content.md _test.txt three-kingdoms-article.html three-kingdoms-final.html tmp update_article.py update_content.py _update_content.xml update_db.py update_images.py update_post2.py update_post.php update_post.py update_post_wp.php update_wp.py upload-img.php verify_article.py verify_post.php verify_post.py verify_post.sh visa-article.html vpn_article.html work write_article_content.py write-article.py write_article.py write_update_script2.py write_update_script.py wu-zetian-article.html wu-zetian-article-with-images.html xia_dynasty_article.html xiamen-article.html yuan-article.html yuan-dynasty-article.html zhangjiajie_article.html zhenghe-article.html zhou-dynasty-article.html 2 + self.d_inner, bias=False)

 # Δ 的 softplus 偏置和缩放
 self.dt_proj = nn.Parameter(torch.randn(self.d_inner, 1))

 # 输出投影
 self.out_proj = nn.Linear(self.d_inner, d_model, bias=False)

 # HiPPO 初始化 A 矩阵
 A = self._hippo_init(d_state)
 self.A = nn.Parameter(A, requires_grad=False) # 冻结 A

 def _hippo_init(self, N):
 """HiPPO-Legendre 矩阵初始化"""
 A = torch.zeros(N, N)
 for i in range(N):
 for j in range(N):
 if i > j:
 A[i, j] = -((2 _aegis_article.md ai_chatbot_privacy_article.html ai-seo-tools-article.html ai-seo-tools-article-updated.html alipay-article.html android-privacy-article.html android_privacy_article.html android-privacy-final.html android_privacy_final.html article_2fa.html article-architecture.html article_base64.txt article_body.html article_body.md article_body.txt article_breach_response.html article_clean.html article_complete.html article_content_final.json article-content.html article_content.html article_content.json article_content.txt _article_content.xml article_cookie_consent.html article_data_breach.html article_data.json article_dianping.html article-dns-privacy-final.html article-dns-privacy.html article_dns_privacy.html article_draft.html article_ecommerce.html article-email-marketing.html article_encrypted_cloud.html article-escaped.txt article-final.html article_final.html article_full.html article_game_dev.html article_headshot.html article-hemal-grocery.html article.html article-html.txt article_identity_theft.html article-image-generators.html article_iphone_privacy.html article-longmen-grottoes-final.html article-longmen-grottoes.html article_meituan.html article_meta.json article_passkeys.html article_pg_clean.json article_pg.json article_postgresql.html article-privacy-cloud-storage.html article_public_wifi.html article_python_type_hints.html article-qin-shi-huang.html article_ransomware.html article-rent-apartment.html articles article_search_engines.html article_sim_swap.html article_social_media_privacy.html article_temp.html article_today_point.html article_transcription.html article_vllm.md article-with-images.html article_with_images.html article_with_images.txt article_xiaohongshu.html article.xml article_zhou_final.html article_zhou.html audio_cache auth.json auth.lock _b64_part1.txt beijing-guide.html beijing-opera-article.html beijing_opera_article.html bin bitwarden-article.html browser-comparison-article.html browser-fingerprinting-article.html build_article.py cache capture2.py capture_bitwarden.py capture_hootsuite.py capture_playstore.py capture.py capture_screens2.py capture_screenshots.py capture_screens.py capture.sh capture_stealth.py channel_directory.json check_article.py check_content.py check_post.py check_quality.py chinese-civil-war-article.html chinese-dynasties-article.html chinese-dynasties-final.html chinese-etiquette-article.html chinese-etiquette-article-with-images.html chinese-folk-religion.html chinese_food_article.html chinese-zodiac-article.html config.yaml config.yaml.bak.20260616_091116 config.yaml.bak.20260616_091136 config.yaml.bak.20260616_091148 config.yaml.bak.20260616_150612 config.yaml.bak.20260616_223924 config.yaml.bak.20260616_224702 config.yaml.bak.20260616_225109 config.yaml.bak.20260616_225947 config.yaml.bak.20260617_101814 config.yaml.bak.20260617_102045 config.yaml.bak.20260617_102150 _content_p1.md create-ming-post.php create_post2.py create_post3.py create-post.php create_post.php create_post.py create_post.sh cron current_content.html data_broker_article.html _decoder_b64.txt _deepfake_article.md dl_fallback.py douyin-article-final.html douyin-article.html download_fallback.py download_images.py download_unsplash.py dragon-boat-article.html _dup.md dynasties-article.html ecommerce_content.html email-privacy-article.html feishu_seen_message_ids.json feng-shui-article.html fengshui-article.html fengshui-final.html fetch_unsplash.py final-article.html final_article.html final_article.txt final_check.py final_content.html find_magic.py fix_alt.py fix_content.py fix_html.py fix_image.py fix_images.py fix_imgs.py fix_quotes.py folk-religion-content.html full_article.html _fuzz_article.md gateway.lock gateway.pid gateway_state.json gen_article.py genghis-khan-article.html genghis-khan-final.html _gen.py ghost-festival-article.html git_object_model_article.html google_client_secret.json google_oauth_pending.json google_token.json grand-canal-article.html great-wall-history.html guilin-article.html harbin-article.html hooks huangshan-article-final.html huangshan-article.html image_cache iot-article-final.html iot-article.html jiuzhaigou-article.html jiuzhaigou-clean.html jiuzhaigou-final.html kanban.db kanban.db.init.lock kunming-article.html lantern-article.html li-river-article.html logs luoyang-article.html mao-article-final.html mao-article.html martial-arts-article.html meeting-fallback.jpg memories messaging-apps-article.html mid-autumn-article.html ming-article-final.html ming-article.html models_dev_cache.json nanjing_article.html node notification.md ollama_cloud_models_cache.json outputs pairing payload.json phishing-article.html php_article.html playwright_fdroid.py playwright_metro.py playwright_screenshots.py plugins poll_bilibili.sh porcelain-article.html porcelain-article-v2.html post_data.json prepare_article.sh prepare_content.py prepare_post.py prepare_publish.py prep_post.py processes.json provider_models_cache.json publish_article.php publish_article.py publish-panda.sh publish_post.php qing-article-final.html qing-article.html qing_article.html qingdao-article.html qing-dynasty-article.html qing_dynasty_article.html qin-shi-huang-article.html quality_check2.py quality_check3.py quality_check.py rag_article.xml replace_imgs.py router-article-final.html router-article.html sandboxes scala_article.json _sc.md screenshot_capture2.py screenshot_capture.py screenshot_remote.py screenshot_script2.py screenshot_script3.py screenshot_script.py screenshots.py scripts _sec1.md _sec2.md _sec3.md _sec4.md _sec5.md sessions shang-dynasty-article.html shang-final.html shopping-privacy-article.html silk-article-final.html silk-article.html silk-road-article.html silk-road-final.html _skeleton.md skills social-media-privacy-article.html song-dynasty-article.html song_dynasty_article.html song_dynasty_final.html SOUL.md state.db state.db-shm state.db-wal stone-forest-article.html sui_dynasty_article.html summer-palace-article.html _supply_chain.md suzhou-article.html tang-dynasty-article.html tang-dynasty-full.html tcm_article_final.html tcm-article.html tcm_article.html tea-article.html temp temp_article_content.html temp_article.html _test_content.md _test.txt three-kingdoms-article.html three-kingdoms-final.html tmp update_article.py update_content.py _update_content.xml update_db.py update_images.py update_post2.py update_post.php update_post.py update_post_wp.php update_wp.py upload-img.php verify_article.py verify_post.php verify_post.py verify_post.sh visa-article.html vpn_article.html work write_article_content.py write-article.py write_article.py write_update_script2.py write_update_script.py wu-zetian-article.html wu-zetian-article-with-images.html xia_dynasty_article.html xiamen-article.html yuan-article.html yuan-dynasty-article.html zhangjiajie_article.html zhenghe-article.html zhou-dynasty-article.html i + 1) _aegis_article.md ai_chatbot_privacy_article.html ai-seo-tools-article.html ai-seo-tools-article-updated.html alipay-article.html android-privacy-article.html android_privacy_article.html android-privacy-final.html android_privacy_final.html article_2fa.html article-architecture.html article_base64.txt article_body.html article_body.md article_body.txt article_breach_response.html article_clean.html article_complete.html article_content_final.json article-content.html article_content.html article_content.json article_content.txt _article_content.xml article_cookie_consent.html article_data_breach.html article_data.json article_dianping.html article-dns-privacy-final.html article-dns-privacy.html article_dns_privacy.html article_draft.html article_ecommerce.html article-email-marketing.html article_encrypted_cloud.html article-escaped.txt article-final.html article_final.html article_full.html article_game_dev.html article_headshot.html article-hemal-grocery.html article.html article-html.txt article_identity_theft.html article-image-generators.html article_iphone_privacy.html article-longmen-grottoes-final.html article-longmen-grottoes.html article_meituan.html article_meta.json article_passkeys.html article_pg_clean.json article_pg.json article_postgresql.html article-privacy-cloud-storage.html article_public_wifi.html article_python_type_hints.html article-qin-shi-huang.html article_ransomware.html article-rent-apartment.html articles article_search_engines.html article_sim_swap.html article_social_media_privacy.html article_temp.html article_today_point.html article_transcription.html article_vllm.md article-with-images.html article_with_images.html article_with_images.txt article_xiaohongshu.html article.xml article_zhou_final.html article_zhou.html audio_cache auth.json auth.lock _b64_part1.txt beijing-guide.html beijing-opera-article.html beijing_opera_article.html bin bitwarden-article.html browser-comparison-article.html browser-fingerprinting-article.html build_article.py cache capture2.py capture_bitwarden.py capture_hootsuite.py capture_playstore.py capture.py capture_screens2.py capture_screenshots.py capture_screens.py capture.sh capture_stealth.py channel_directory.json check_article.py check_content.py check_post.py check_quality.py chinese-civil-war-article.html chinese-dynasties-article.html chinese-dynasties-final.html chinese-etiquette-article.html chinese-etiquette-article-with-images.html chinese-folk-religion.html chinese_food_article.html chinese-zodiac-article.html config.yaml config.yaml.bak.20260616_091116 config.yaml.bak.20260616_091136 config.yaml.bak.20260616_091148 config.yaml.bak.20260616_150612 config.yaml.bak.20260616_223924 config.yaml.bak.20260616_224702 config.yaml.bak.20260616_225109 config.yaml.bak.20260616_225947 config.yaml.bak.20260617_101814 config.yaml.bak.20260617_102045 config.yaml.bak.20260617_102150 _content_p1.md create-ming-post.php create_post2.py create_post3.py create-post.php create_post.php create_post.py create_post.sh cron current_content.html data_broker_article.html _decoder_b64.txt _deepfake_article.md dl_fallback.py douyin-article-final.html douyin-article.html download_fallback.py download_images.py download_unsplash.py dragon-boat-article.html _dup.md dynasties-article.html ecommerce_content.html email-privacy-article.html feishu_seen_message_ids.json feng-shui-article.html fengshui-article.html fengshui-final.html fetch_unsplash.py final-article.html final_article.html final_article.txt final_check.py final_content.html find_magic.py fix_alt.py fix_content.py fix_html.py fix_image.py fix_images.py fix_imgs.py fix_quotes.py folk-religion-content.html full_article.html _fuzz_article.md gateway.lock gateway.pid gateway_state.json gen_article.py genghis-khan-article.html genghis-khan-final.html _gen.py ghost-festival-article.html git_object_model_article.html google_client_secret.json google_oauth_pending.json google_token.json grand-canal-article.html great-wall-history.html guilin-article.html harbin-article.html hooks huangshan-article-final.html huangshan-article.html image_cache iot-article-final.html iot-article.html jiuzhaigou-article.html jiuzhaigou-clean.html jiuzhaigou-final.html kanban.db kanban.db.init.lock kunming-article.html lantern-article.html li-river-article.html logs luoyang-article.html mao-article-final.html mao-article.html martial-arts-article.html meeting-fallback.jpg memories messaging-apps-article.html mid-autumn-article.html ming-article-final.html ming-article.html models_dev_cache.json nanjing_article.html node notification.md ollama_cloud_models_cache.json outputs pairing payload.json phishing-article.html php_article.html playwright_fdroid.py playwright_metro.py playwright_screenshots.py plugins poll_bilibili.sh porcelain-article.html porcelain-article-v2.html post_data.json prepare_article.sh prepare_content.py prepare_post.py prepare_publish.py prep_post.py processes.json provider_models_cache.json publish_article.php publish_article.py publish-panda.sh publish_post.php qing-article-final.html qing-article.html qing_article.html qingdao-article.html qing-dynasty-article.html qing_dynasty_article.html qin-shi-huang-article.html quality_check2.py quality_check3.py quality_check.py rag_article.xml replace_imgs.py router-article-final.html router-article.html sandboxes scala_article.json _sc.md screenshot_capture2.py screenshot_capture.py screenshot_remote.py screenshot_script2.py screenshot_script3.py screenshot_script.py screenshots.py scripts _sec1.md _sec2.md _sec3.md _sec4.md _sec5.md sessions shang-dynasty-article.html shang-final.html shopping-privacy-article.html silk-article-final.html silk-article.html silk-road-article.html silk-road-final.html _skeleton.md skills social-media-privacy-article.html song-dynasty-article.html song_dynasty_article.html song_dynasty_final.html SOUL.md state.db state.db-shm state.db-wal stone-forest-article.html sui_dynasty_article.html summer-palace-article.html _supply_chain.md suzhou-article.html tang-dynasty-article.html tang-dynasty-full.html tcm_article_final.html tcm-article.html tcm_article.html tea-article.html temp temp_article_content.html temp_article.html _test_content.md _test.txt three-kingdoms-article.html three-kingdoms-final.html tmp update_article.py update_content.py _update_content.xml update_db.py update_images.py update_post2.py update_post.php update_post.py update_post_wp.php update_wp.py upload-img.php verify_article.py verify_post.php verify_post.py verify_post.sh visa-article.html vpn_article.html work write_article_content.py write-article.py write_article.py write_update_script2.py write_update_script.py wu-zetian-article.html wu-zetian-article-with-images.html xia_dynasty_article.html xiamen-article.html yuan-article.html yuan-dynasty-article.html zhangjiajie_article.html zhenghe-article.html zhou-dynasty-article.html 0.5) _aegis_article.md ai_chatbot_privacy_article.html ai-seo-tools-article.html ai-seo-tools-article-updated.html alipay-article.html android-privacy-article.html android_privacy_article.html android-privacy-final.html android_privacy_final.html article_2fa.html article-architecture.html article_base64.txt article_body.html article_body.md article_body.txt article_breach_response.html article_clean.html article_complete.html article_content_final.json article-content.html article_content.html article_content.json article_content.txt _article_content.xml article_cookie_consent.html article_data_breach.html article_data.json article_dianping.html article-dns-privacy-final.html article-dns-privacy.html article_dns_privacy.html article_draft.html article_ecommerce.html article-email-marketing.html article_encrypted_cloud.html article-escaped.txt article-final.html article_final.html article_full.html article_game_dev.html article_headshot.html article-hemal-grocery.html article.html article-html.txt article_identity_theft.html article-image-generators.html article_iphone_privacy.html article-longmen-grottoes-final.html article-longmen-grottoes.html article_meituan.html article_meta.json article_passkeys.html article_pg_clean.json article_pg.json article_postgresql.html article-privacy-cloud-storage.html article_public_wifi.html article_python_type_hints.html article-qin-shi-huang.html article_ransomware.html article-rent-apartment.html articles article_search_engines.html article_sim_swap.html article_social_media_privacy.html article_temp.html article_today_point.html article_transcription.html article_vllm.md article-with-images.html article_with_images.html article_with_images.txt article_xiaohongshu.html article.xml article_zhou_final.html article_zhou.html audio_cache auth.json auth.lock _b64_part1.txt beijing-guide.html beijing-opera-article.html beijing_opera_article.html bin bitwarden-article.html browser-comparison-article.html browser-fingerprinting-article.html build_article.py cache capture2.py capture_bitwarden.py capture_hootsuite.py capture_playstore.py capture.py capture_screens2.py capture_screenshots.py capture_screens.py capture.sh capture_stealth.py channel_directory.json check_article.py check_content.py check_post.py check_quality.py chinese-civil-war-article.html chinese-dynasties-article.html chinese-dynasties-final.html chinese-etiquette-article.html chinese-etiquette-article-with-images.html chinese-folk-religion.html chinese_food_article.html chinese-zodiac-article.html config.yaml config.yaml.bak.20260616_091116 config.yaml.bak.20260616_091136 config.yaml.bak.20260616_091148 config.yaml.bak.20260616_150612 config.yaml.bak.20260616_223924 config.yaml.bak.20260616_224702 config.yaml.bak.20260616_225109 config.yaml.bak.20260616_225947 config.yaml.bak.20260617_101814 config.yaml.bak.20260617_102045 config.yaml.bak.20260617_102150 _content_p1.md create-ming-post.php create_post2.py create_post3.py create-post.php create_post.php create_post.py create_post.sh cron current_content.html data_broker_article.html _decoder_b64.txt _deepfake_article.md dl_fallback.py douyin-article-final.html douyin-article.html download_fallback.py download_images.py download_unsplash.py dragon-boat-article.html _dup.md dynasties-article.html ecommerce_content.html email-privacy-article.html feishu_seen_message_ids.json feng-shui-article.html fengshui-article.html fengshui-final.html fetch_unsplash.py final-article.html final_article.html final_article.txt final_check.py final_content.html find_magic.py fix_alt.py fix_content.py fix_html.py fix_image.py fix_images.py fix_imgs.py fix_quotes.py folk-religion-content.html full_article.html _fuzz_article.md gateway.lock gateway.pid gateway_state.json gen_article.py genghis-khan-article.html genghis-khan-final.html _gen.py ghost-festival-article.html git_object_model_article.html google_client_secret.json google_oauth_pending.json google_token.json grand-canal-article.html great-wall-history.html guilin-article.html harbin-article.html hooks huangshan-article-final.html huangshan-article.html image_cache iot-article-final.html iot-article.html jiuzhaigou-article.html jiuzhaigou-clean.html jiuzhaigou-final.html kanban.db kanban.db.init.lock kunming-article.html lantern-article.html li-river-article.html logs luoyang-article.html mao-article-final.html mao-article.html martial-arts-article.html meeting-fallback.jpg memories messaging-apps-article.html mid-autumn-article.html ming-article-final.html ming-article.html models_dev_cache.json nanjing_article.html node notification.md ollama_cloud_models_cache.json outputs pairing payload.json phishing-article.html php_article.html playwright_fdroid.py playwright_metro.py playwright_screenshots.py plugins poll_bilibili.sh porcelain-article.html porcelain-article-v2.html post_data.json prepare_article.sh prepare_content.py prepare_post.py prepare_publish.py prep_post.py processes.json provider_models_cache.json publish_article.php publish_article.py publish-panda.sh publish_post.php qing-article-final.html qing-article.html qing_article.html qingdao-article.html qing-dynasty-article.html qing_dynasty_article.html qin-shi-huang-article.html quality_check2.py quality_check3.py quality_check.py rag_article.xml replace_imgs.py router-article-final.html router-article.html sandboxes scala_article.json _sc.md screenshot_capture2.py screenshot_capture.py screenshot_remote.py screenshot_script2.py screenshot_script3.py screenshot_script.py screenshots.py scripts _sec1.md _sec2.md _sec3.md _sec4.md _sec5.md sessions shang-dynasty-article.html shang-final.html shopping-privacy-article.html silk-article-final.html silk-article.html silk-road-article.html silk-road-final.html _skeleton.md skills social-media-privacy-article.html song-dynasty-article.html song_dynasty_article.html song_dynasty_final.html SOUL.md state.db state.db-shm state.db-wal stone-forest-article.html sui_dynasty_article.html summer-palace-article.html _supply_chain.md suzhou-article.html tang-dynasty-article.html tang-dynasty-full.html tcm_article_final.html tcm-article.html tcm_article.html tea-article.html temp temp_article_content.html temp_article.html _test_content.md _test.txt three-kingdoms-article.html three-kingdoms-final.html tmp update_article.py update_content.py _update_content.xml update_db.py update_images.py update_post2.py update_post.php update_post.py update_post_wp.php update_wp.py upload-img.php verify_article.py verify_post.php verify_post.py verify_post.sh visa-article.html vpn_article.html work write_article_content.py write-article.py write_article.py write_update_script2.py write_update_script.py wu-zetian-article.html wu-zetian-article-with-images.html xia_dynasty_article.html xiamen-article.html yuan-article.html yuan-dynasty-article.html zhangjiajie_article.html zhenghe-article.html zhou-dynasty-article.html ((2 _aegis_article.md ai_chatbot_privacy_article.html ai-seo-tools-article.html ai-seo-tools-article-updated.html alipay-article.html android-privacy-article.html android_privacy_article.html android-privacy-final.html android_privacy_final.html article_2fa.html article-architecture.html article_base64.txt article_body.html article_body.md article_body.txt article_breach_response.html article_clean.html article_complete.html article_content_final.json article-content.html article_content.html article_content.json article_content.txt _article_content.xml article_cookie_consent.html article_data_breach.html article_data.json article_dianping.html article-dns-privacy-final.html article-dns-privacy.html article_dns_privacy.html article_draft.html article_ecommerce.html article-email-marketing.html article_encrypted_cloud.html article-escaped.txt article-final.html article_final.html article_full.html article_game_dev.html article_headshot.html article-hemal-grocery.html article.html article-html.txt article_identity_theft.html article-image-generators.html article_iphone_privacy.html article-longmen-grottoes-final.html article-longmen-grottoes.html article_meituan.html article_meta.json article_passkeys.html article_pg_clean.json article_pg.json article_postgresql.html article-privacy-cloud-storage.html article_public_wifi.html article_python_type_hints.html article-qin-shi-huang.html article_ransomware.html article-rent-apartment.html articles article_search_engines.html article_sim_swap.html article_social_media_privacy.html article_temp.html article_today_point.html article_transcription.html article_vllm.md article-with-images.html article_with_images.html article_with_images.txt article_xiaohongshu.html article.xml article_zhou_final.html article_zhou.html audio_cache auth.json auth.lock _b64_part1.txt beijing-guide.html beijing-opera-article.html beijing_opera_article.html bin bitwarden-article.html browser-comparison-article.html browser-fingerprinting-article.html build_article.py cache capture2.py capture_bitwarden.py capture_hootsuite.py capture_playstore.py capture.py capture_screens2.py capture_screenshots.py capture_screens.py capture.sh capture_stealth.py channel_directory.json check_article.py check_content.py check_post.py check_quality.py chinese-civil-war-article.html chinese-dynasties-article.html chinese-dynasties-final.html chinese-etiquette-article.html chinese-etiquette-article-with-images.html chinese-folk-religion.html chinese_food_article.html chinese-zodiac-article.html config.yaml config.yaml.bak.20260616_091116 config.yaml.bak.20260616_091136 config.yaml.bak.20260616_091148 config.yaml.bak.20260616_150612 config.yaml.bak.20260616_223924 config.yaml.bak.20260616_224702 config.yaml.bak.20260616_225109 config.yaml.bak.20260616_225947 config.yaml.bak.20260617_101814 config.yaml.bak.20260617_102045 config.yaml.bak.20260617_102150 _content_p1.md create-ming-post.php create_post2.py create_post3.py create-post.php create_post.php create_post.py create_post.sh cron current_content.html data_broker_article.html _decoder_b64.txt _deepfake_article.md dl_fallback.py douyin-article-final.html douyin-article.html download_fallback.py download_images.py download_unsplash.py dragon-boat-article.html _dup.md dynasties-article.html ecommerce_content.html email-privacy-article.html feishu_seen_message_ids.json feng-shui-article.html fengshui-article.html fengshui-final.html fetch_unsplash.py final-article.html final_article.html final_article.txt final_check.py final_content.html find_magic.py fix_alt.py fix_content.py fix_html.py fix_image.py fix_images.py fix_imgs.py fix_quotes.py folk-religion-content.html full_article.html _fuzz_article.md gateway.lock gateway.pid gateway_state.json gen_article.py genghis-khan-article.html genghis-khan-final.html _gen.py ghost-festival-article.html git_object_model_article.html google_client_secret.json google_oauth_pending.json google_token.json grand-canal-article.html great-wall-history.html guilin-article.html harbin-article.html hooks huangshan-article-final.html huangshan-article.html image_cache iot-article-final.html iot-article.html jiuzhaigou-article.html jiuzhaigou-clean.html jiuzhaigou-final.html kanban.db kanban.db.init.lock kunming-article.html lantern-article.html li-river-article.html logs luoyang-article.html mao-article-final.html mao-article.html martial-arts-article.html meeting-fallback.jpg memories messaging-apps-article.html mid-autumn-article.html ming-article-final.html ming-article.html models_dev_cache.json nanjing_article.html node notification.md ollama_cloud_models_cache.json outputs pairing payload.json phishing-article.html php_article.html playwright_fdroid.py playwright_metro.py playwright_screenshots.py plugins poll_bilibili.sh porcelain-article.html porcelain-article-v2.html post_data.json prepare_article.sh prepare_content.py prepare_post.py prepare_publish.py prep_post.py processes.json provider_models_cache.json publish_article.php publish_article.py publish-panda.sh publish_post.php qing-article-final.html qing-article.html qing_article.html qingdao-article.html qing-dynasty-article.html qing_dynasty_article.html qin-shi-huang-article.html quality_check2.py quality_check3.py quality_check.py rag_article.xml replace_imgs.py router-article-final.html router-article.html sandboxes scala_article.json _sc.md screenshot_capture2.py screenshot_capture.py screenshot_remote.py screenshot_script2.py screenshot_script3.py screenshot_script.py screenshots.py scripts _sec1.md _sec2.md _sec3.md _sec4.md _sec5.md sessions shang-dynasty-article.html shang-final.html shopping-privacy-article.html silk-article-final.html silk-article.html silk-road-article.html silk-road-final.html _skeleton.md skills social-media-privacy-article.html song-dynasty-article.html song_dynasty_article.html song_dynasty_final.html SOUL.md state.db state.db-shm state.db-wal stone-forest-article.html sui_dynasty_article.html summer-palace-article.html _supply_chain.md suzhou-article.html tang-dynasty-article.html tang-dynasty-full.html tcm_article_final.html tcm-article.html tcm_article.html tea-article.html temp temp_article_content.html temp_article.html _test_content.md _test.txt three-kingdoms-article.html three-kingdoms-final.html tmp update_article.py update_content.py _update_content.xml update_db.py update_images.py update_post2.py update_post.php update_post.py update_post_wp.php update_wp.py upload-img.php verify_article.py verify_post.php verify_post.py verify_post.sh visa-article.html vpn_article.html work write_article_content.py write-article.py write_article.py write_update_script2.py write_update_script.py wu-zetian-article.html wu-zetian-article-with-images.html xia_dynasty_article.html xiamen-article.html yuan-article.html yuan-dynasty-article.html zhangjiajie_article.html zhenghe-article.html zhou-dynasty-article.html j + 1) _aegis_article.md ai_chatbot_privacy_article.html ai-seo-tools-article.html ai-seo-tools-article-updated.html alipay-article.html android-privacy-article.html android_privacy_article.html android-privacy-final.html android_privacy_final.html article_2fa.html article-architecture.html article_base64.txt article_body.html article_body.md article_body.txt article_breach_response.html article_clean.html article_complete.html article_content_final.json article-content.html article_content.html article_content.json article_content.txt _article_content.xml article_cookie_consent.html article_data_breach.html article_data.json article_dianping.html article-dns-privacy-final.html article-dns-privacy.html article_dns_privacy.html article_draft.html article_ecommerce.html article-email-marketing.html article_encrypted_cloud.html article-escaped.txt article-final.html article_final.html article_full.html article_game_dev.html article_headshot.html article-hemal-grocery.html article.html article-html.txt article_identity_theft.html article-image-generators.html article_iphone_privacy.html article-longmen-grottoes-final.html article-longmen-grottoes.html article_meituan.html article_meta.json article_passkeys.html article_pg_clean.json article_pg.json article_postgresql.html article-privacy-cloud-storage.html article_public_wifi.html article_python_type_hints.html article-qin-shi-huang.html article_ransomware.html article-rent-apartment.html articles article_search_engines.html article_sim_swap.html article_social_media_privacy.html article_temp.html article_today_point.html article_transcription.html article_vllm.md article-with-images.html article_with_images.html article_with_images.txt article_xiaohongshu.html article.xml article_zhou_final.html article_zhou.html audio_cache auth.json auth.lock _b64_part1.txt beijing-guide.html beijing-opera-article.html beijing_opera_article.html bin bitwarden-article.html browser-comparison-article.html browser-fingerprinting-article.html build_article.py cache capture2.py capture_bitwarden.py capture_hootsuite.py capture_playstore.py capture.py capture_screens2.py capture_screenshots.py capture_screens.py capture.sh capture_stealth.py channel_directory.json check_article.py check_content.py check_post.py check_quality.py chinese-civil-war-article.html chinese-dynasties-article.html chinese-dynasties-final.html chinese-etiquette-article.html chinese-etiquette-article-with-images.html chinese-folk-religion.html chinese_food_article.html chinese-zodiac-article.html config.yaml config.yaml.bak.20260616_091116 config.yaml.bak.20260616_091136 config.yaml.bak.20260616_091148 config.yaml.bak.20260616_150612 config.yaml.bak.20260616_223924 config.yaml.bak.20260616_224702 config.yaml.bak.20260616_225109 config.yaml.bak.20260616_225947 config.yaml.bak.20260617_101814 config.yaml.bak.20260617_102045 config.yaml.bak.20260617_102150 _content_p1.md create-ming-post.php create_post2.py create_post3.py create-post.php create_post.php create_post.py create_post.sh cron current_content.html data_broker_article.html _decoder_b64.txt _deepfake_article.md dl_fallback.py douyin-article-final.html douyin-article.html download_fallback.py download_images.py download_unsplash.py dragon-boat-article.html _dup.md dynasties-article.html ecommerce_content.html email-privacy-article.html feishu_seen_message_ids.json feng-shui-article.html fengshui-article.html fengshui-final.html fetch_unsplash.py final-article.html final_article.html final_article.txt final_check.py final_content.html find_magic.py fix_alt.py fix_content.py fix_html.py fix_image.py fix_images.py fix_imgs.py fix_quotes.py folk-religion-content.html full_article.html _fuzz_article.md gateway.lock gateway.pid gateway_state.json gen_article.py genghis-khan-article.html genghis-khan-final.html _gen.py ghost-festival-article.html git_object_model_article.html google_client_secret.json google_oauth_pending.json google_token.json grand-canal-article.html great-wall-history.html guilin-article.html harbin-article.html hooks huangshan-article-final.html huangshan-article.html image_cache iot-article-final.html iot-article.html jiuzhaigou-article.html jiuzhaigou-clean.html jiuzhaigou-final.html kanban.db kanban.db.init.lock kunming-article.html lantern-article.html li-river-article.html logs luoyang-article.html mao-article-final.html mao-article.html martial-arts-article.html meeting-fallback.jpg memories messaging-apps-article.html mid-autumn-article.html ming-article-final.html ming-article.html models_dev_cache.json nanjing_article.html node notification.md ollama_cloud_models_cache.json outputs pairing payload.json phishing-article.html php_article.html playwright_fdroid.py playwright_metro.py playwright_screenshots.py plugins poll_bilibili.sh porcelain-article.html porcelain-article-v2.html post_data.json prepare_article.sh prepare_content.py prepare_post.py prepare_publish.py prep_post.py processes.json provider_models_cache.json publish_article.php publish_article.py publish-panda.sh publish_post.php qing-article-final.html qing-article.html qing_article.html qingdao-article.html qing-dynasty-article.html qing_dynasty_article.html qin-shi-huang-article.html quality_check2.py quality_check3.py quality_check.py rag_article.xml replace_imgs.py router-article-final.html router-article.html sandboxes scala_article.json _sc.md screenshot_capture2.py screenshot_capture.py screenshot_remote.py screenshot_script2.py screenshot_script3.py screenshot_script.py screenshots.py scripts _sec1.md _sec2.md _sec3.md _sec4.md _sec5.md sessions shang-dynasty-article.html shang-final.html shopping-privacy-article.html silk-article-final.html silk-article.html silk-road-article.html silk-road-final.html _skeleton.md skills social-media-privacy-article.html song-dynasty-article.html song_dynasty_article.html song_dynasty_final.html SOUL.md state.db state.db-shm state.db-wal stone-forest-article.html sui_dynasty_article.html summer-palace-article.html _supply_chain.md suzhou-article.html tang-dynasty-article.html tang-dynasty-full.html tcm_article_final.html tcm-article.html tcm_article.html tea-article.html temp temp_article_content.html temp_article.html _test_content.md _test.txt three-kingdoms-article.html three-kingdoms-final.html tmp update_article.py update_content.py _update_content.xml update_db.py update_images.py update_post2.py update_post.php update_post.py update_post_wp.php update_wp.py upload-img.php verify_article.py verify_post.php verify_post.py verify_post.sh visa-article.html vpn_article.html work write_article_content.py write-article.py write_article.py write_update_script2.py write_update_script.py wu-zetian-article.html wu-zetian-article-with-images.html xia_dynasty_article.html xiamen-article.html yuan-article.html yuan-dynasty-article.html zhangjiajie_article.html zhenghe-article.html zhou-dynasty-article.html 0.5)
 elif i == j:
 A[i, j] = -(i + 1)
 return A

 def forward(self, x):
 """
 x: (batch, seq_len, d_model)
 """
 batch, seq_len, _ = x.shape

 # 1. 输入投影 + 门控
 x_proj = self.in_proj(x) # (batch, seq_len, d_inner _aegis_article.md ai_chatbot_privacy_article.html ai-seo-tools-article.html ai-seo-tools-article-updated.html alipay-article.html android-privacy-article.html android_privacy_article.html android-privacy-final.html android_privacy_final.html article_2fa.html article-architecture.html article_base64.txt article_body.html article_body.md article_body.txt article_breach_response.html article_clean.html article_complete.html article_content_final.json article-content.html article_content.html article_content.json article_content.txt _article_content.xml article_cookie_consent.html article_data_breach.html article_data.json article_dianping.html article-dns-privacy-final.html article-dns-privacy.html article_dns_privacy.html article_draft.html article_ecommerce.html article-email-marketing.html article_encrypted_cloud.html article-escaped.txt article-final.html article_final.html article_full.html article_game_dev.html article_headshot.html article-hemal-grocery.html article.html article-html.txt article_identity_theft.html article-image-generators.html article_iphone_privacy.html article-longmen-grottoes-final.html article-longmen-grottoes.html article_meituan.html article_meta.json article_passkeys.html article_pg_clean.json article_pg.json article_postgresql.html article-privacy-cloud-storage.html article_public_wifi.html article_python_type_hints.html article-qin-shi-huang.html article_ransomware.html article-rent-apartment.html articles article_search_engines.html article_sim_swap.html article_social_media_privacy.html article_temp.html article_today_point.html article_transcription.html article_vllm.md article-with-images.html article_with_images.html article_with_images.txt article_xiaohongshu.html article.xml article_zhou_final.html article_zhou.html audio_cache auth.json auth.lock _b64_part1.txt beijing-guide.html beijing-opera-article.html beijing_opera_article.html bin bitwarden-article.html browser-comparison-article.html browser-fingerprinting-article.html build_article.py cache capture2.py capture_bitwarden.py capture_hootsuite.py capture_playstore.py capture.py capture_screens2.py capture_screenshots.py capture_screens.py capture.sh capture_stealth.py channel_directory.json check_article.py check_content.py check_post.py check_quality.py chinese-civil-war-article.html chinese-dynasties-article.html chinese-dynasties-final.html chinese-etiquette-article.html chinese-etiquette-article-with-images.html chinese-folk-religion.html chinese_food_article.html chinese-zodiac-article.html config.yaml config.yaml.bak.20260616_091116 config.yaml.bak.20260616_091136 config.yaml.bak.20260616_091148 config.yaml.bak.20260616_150612 config.yaml.bak.20260616_223924 config.yaml.bak.20260616_224702 config.yaml.bak.20260616_225109 config.yaml.bak.20260616_225947 config.yaml.bak.20260617_101814 config.yaml.bak.20260617_102045 config.yaml.bak.20260617_102150 _content_p1.md create-ming-post.php create_post2.py create_post3.py create-post.php create_post.php create_post.py create_post.sh cron current_content.html data_broker_article.html _decoder_b64.txt _deepfake_article.md dl_fallback.py douyin-article-final.html douyin-article.html download_fallback.py download_images.py download_unsplash.py dragon-boat-article.html _dup.md dynasties-article.html ecommerce_content.html email-privacy-article.html feishu_seen_message_ids.json feng-shui-article.html fengshui-article.html fengshui-final.html fetch_unsplash.py final-article.html final_article.html final_article.txt final_check.py final_content.html find_magic.py fix_alt.py fix_content.py fix_html.py fix_image.py fix_images.py fix_imgs.py fix_quotes.py folk-religion-content.html full_article.html _fuzz_article.md gateway.lock gateway.pid gateway_state.json gen_article.py genghis-khan-article.html genghis-khan-final.html _gen.py ghost-festival-article.html git_object_model_article.html google_client_secret.json google_oauth_pending.json google_token.json grand-canal-article.html great-wall-history.html guilin-article.html harbin-article.html hooks huangshan-article-final.html huangshan-article.html image_cache iot-article-final.html iot-article.html jiuzhaigou-article.html jiuzhaigou-clean.html jiuzhaigou-final.html kanban.db kanban.db.init.lock kunming-article.html lantern-article.html li-river-article.html logs luoyang-article.html mao-article-final.html mao-article.html martial-arts-article.html meeting-fallback.jpg memories messaging-apps-article.html mid-autumn-article.html ming-article-final.html ming-article.html models_dev_cache.json nanjing_article.html node notification.md ollama_cloud_models_cache.json outputs pairing payload.json phishing-article.html php_article.html playwright_fdroid.py playwright_metro.py playwright_screenshots.py plugins poll_bilibili.sh porcelain-article.html porcelain-article-v2.html post_data.json prepare_article.sh prepare_content.py prepare_post.py prepare_publish.py prep_post.py processes.json provider_models_cache.json publish_article.php publish_article.py publish-panda.sh publish_post.php qing-article-final.html qing-article.html qing_article.html qingdao-article.html qing-dynasty-article.html qing_dynasty_article.html qin-shi-huang-article.html quality_check2.py quality_check3.py quality_check.py rag_article.xml replace_imgs.py router-article-final.html router-article.html sandboxes scala_article.json _sc.md screenshot_capture2.py screenshot_capture.py screenshot_remote.py screenshot_script2.py screenshot_script3.py screenshot_script.py screenshots.py scripts _sec1.md _sec2.md _sec3.md _sec4.md _sec5.md sessions shang-dynasty-article.html shang-final.html shopping-privacy-article.html silk-article-final.html silk-article.html silk-road-article.html silk-road-final.html _skeleton.md skills social-media-privacy-article.html song-dynasty-article.html song_dynasty_article.html song_dynasty_final.html SOUL.md state.db state.db-shm state.db-wal stone-forest-article.html sui_dynasty_article.html summer-palace-article.html _supply_chain.md suzhou-article.html tang-dynasty-article.html tang-dynasty-full.html tcm_article_final.html tcm-article.html tcm_article.html tea-article.html temp temp_article_content.html temp_article.html _test_content.md _test.txt three-kingdoms-article.html three-kingdoms-final.html tmp update_article.py update_content.py _update_content.xml update_db.py update_images.py update_post2.py update_post.php update_post.py update_post_wp.php update_wp.py upload-img.php verify_article.py verify_post.php verify_post.py verify_post.sh visa-article.html vpn_article.html work write_article_content.py write-article.py write_article.py write_update_script2.py write_update_script.py wu-zetian-article.html wu-zetian-article-with-images.html xia_dynasty_article.html xiamen-article.html yuan-article.html yuan-dynasty-article.html zhangjiajie_article.html zhenghe-article.html zhou-dynasty-article.html 2)
 x_proj, gate = x_proj.chunk(2, dim=-1)
 gate = F.silu(gate)

 # 2. 1D 卷积
 x_conv = x_proj.transpose(-1, -2) # (batch, d_inner, seq_len)
 x_conv = self.conv1d(x_conv)[:, :, :seq_len] # 去除 padding
 x_conv = F.silu(x_conv)
 x_conv = x_conv.transpose(-1, -2) # (batch, seq_len, d_inner)

 # 3. 选择性 SSM
 # 计算 Δ, B, C
 delta_bc = self.x_proj(x_conv) # (batch, seq_len, d_state*2 + d_inner)
 delta, B, C = torch.split(
 delta_bc,
 [self.d_inner, self.d_state, self.d_state],
 dim=-1
 )
 delta = F.softplus(delta @ self.dt_proj)

 # 离散化
 delta = delta.unsqueeze(-1) # (batch, seq_len, d_inner, 1)
 A = self.A.unsqueeze(0).unsqueeze(0) # (1, 1, d_state, d_state)
 A_bar = torch.matrix_exp(delta _aegis_article.md ai_chatbot_privacy_article.html ai-seo-tools-article.html ai-seo-tools-article-updated.html alipay-article.html android-privacy-article.html android_privacy_article.html android-privacy-final.html android_privacy_final.html article_2fa.html article-architecture.html article_base64.txt article_body.html article_body.md article_body.txt article_breach_response.html article_clean.html article_complete.html article_content_final.json article-content.html article_content.html article_content.json article_content.txt _article_content.xml article_cookie_consent.html article_data_breach.html article_data.json article_dianping.html article-dns-privacy-final.html article-dns-privacy.html article_dns_privacy.html article_draft.html article_ecommerce.html article-email-marketing.html article_encrypted_cloud.html article-escaped.txt article-final.html article_final.html article_full.html article_game_dev.html article_headshot.html article-hemal-grocery.html article.html article-html.txt article_identity_theft.html article-image-generators.html article_iphone_privacy.html article-longmen-grottoes-final.html article-longmen-grottoes.html article_meituan.html article_meta.json article_passkeys.html article_pg_clean.json article_pg.json article_postgresql.html article-privacy-cloud-storage.html article_public_wifi.html article_python_type_hints.html article-qin-shi-huang.html article_ransomware.html article-rent-apartment.html articles article_search_engines.html article_sim_swap.html article_social_media_privacy.html article_temp.html article_today_point.html article_transcription.html article_vllm.md article-with-images.html article_with_images.html article_with_images.txt article_xiaohongshu.html article.xml article_zhou_final.html article_zhou.html audio_cache auth.json auth.lock _b64_part1.txt beijing-guide.html beijing-opera-article.html beijing_opera_article.html bin bitwarden-article.html browser-comparison-article.html browser-fingerprinting-article.html build_article.py cache capture2.py capture_bitwarden.py capture_hootsuite.py capture_playstore.py capture.py capture_screens2.py capture_screenshots.py capture_screens.py capture.sh capture_stealth.py channel_directory.json check_article.py check_content.py check_post.py check_quality.py chinese-civil-war-article.html chinese-dynasties-article.html chinese-dynasties-final.html chinese-etiquette-article.html chinese-etiquette-article-with-images.html chinese-folk-religion.html chinese_food_article.html chinese-zodiac-article.html config.yaml config.yaml.bak.20260616_091116 config.yaml.bak.20260616_091136 config.yaml.bak.20260616_091148 config.yaml.bak.20260616_150612 config.yaml.bak.20260616_223924 config.yaml.bak.20260616_224702 config.yaml.bak.20260616_225109 config.yaml.bak.20260616_225947 config.yaml.bak.20260617_101814 config.yaml.bak.20260617_102045 config.yaml.bak.20260617_102150 _content_p1.md create-ming-post.php create_post2.py create_post3.py create-post.php create_post.php create_post.py create_post.sh cron current_content.html data_broker_article.html _decoder_b64.txt _deepfake_article.md dl_fallback.py douyin-article-final.html douyin-article.html download_fallback.py download_images.py download_unsplash.py dragon-boat-article.html _dup.md dynasties-article.html ecommerce_content.html email-privacy-article.html feishu_seen_message_ids.json feng-shui-article.html fengshui-article.html fengshui-final.html fetch_unsplash.py final-article.html final_article.html final_article.txt final_check.py final_content.html find_magic.py fix_alt.py fix_content.py fix_html.py fix_image.py fix_images.py fix_imgs.py fix_quotes.py folk-religion-content.html full_article.html _fuzz_article.md gateway.lock gateway.pid gateway_state.json gen_article.py genghis-khan-article.html genghis-khan-final.html _gen.py ghost-festival-article.html git_object_model_article.html google_client_secret.json google_oauth_pending.json google_token.json grand-canal-article.html great-wall-history.html guilin-article.html harbin-article.html hooks huangshan-article-final.html huangshan-article.html image_cache iot-article-final.html iot-article.html jiuzhaigou-article.html jiuzhaigou-clean.html jiuzhaigou-final.html kanban.db kanban.db.init.lock kunming-article.html lantern-article.html li-river-article.html logs luoyang-article.html mao-article-final.html mao-article.html martial-arts-article.html meeting-fallback.jpg memories messaging-apps-article.html mid-autumn-article.html ming-article-final.html ming-article.html models_dev_cache.json nanjing_article.html node notification.md ollama_cloud_models_cache.json outputs pairing payload.json phishing-article.html php_article.html playwright_fdroid.py playwright_metro.py playwright_screenshots.py plugins poll_bilibili.sh porcelain-article.html porcelain-article-v2.html post_data.json prepare_article.sh prepare_content.py prepare_post.py prepare_publish.py prep_post.py processes.json provider_models_cache.json publish_article.php publish_article.py publish-panda.sh publish_post.php qing-article-final.html qing-article.html qing_article.html qingdao-article.html qing-dynasty-article.html qing_dynasty_article.html qin-shi-huang-article.html quality_check2.py quality_check3.py quality_check.py rag_article.xml replace_imgs.py router-article-final.html router-article.html sandboxes scala_article.json _sc.md screenshot_capture2.py screenshot_capture.py screenshot_remote.py screenshot_script2.py screenshot_script3.py screenshot_script.py screenshots.py scripts _sec1.md _sec2.md _sec3.md _sec4.md _sec5.md sessions shang-dynasty-article.html shang-final.html shopping-privacy-article.html silk-article-final.html silk-article.html silk-road-article.html silk-road-final.html _skeleton.md skills social-media-privacy-article.html song-dynasty-article.html song_dynasty_article.html song_dynasty_final.html SOUL.md state.db state.db-shm state.db-wal stone-forest-article.html sui_dynasty_article.html summer-palace-article.html _supply_chain.md suzhou-article.html tang-dynasty-article.html tang-dynasty-full.html tcm_article_final.html tcm-article.html tcm_article.html tea-article.html temp temp_article_content.html temp_article.html _test_content.md _test.txt three-kingdoms-article.html three-kingdoms-final.html tmp update_article.py update_content.py _update_content.xml update_db.py update_images.py update_post2.py update_post.php update_post.py update_post_wp.php update_wp.py upload-img.php verify_article.py verify_post.php verify_post.py verify_post.sh visa-article.html vpn_article.html work write_article_content.py write-article.py write_article.py write_update_script2.py write_update_script.py wu-zetian-article.html wu-zetian-article-with-images.html xia_dynasty_article.html xiamen-article.html yuan-article.html yuan-dynasty-article.html zhangjiajie_article.html zhenghe-article.html zhou-dynasty-article.html A)

 # 离散化 B
 B = B.unsqueeze(-1) # (batch, seq_len, d_state, 1)
 A_bar_minus_I = A_bar - torch.eye(self.d_state, device=A.device)
 # 简化:B_bar = (A_bar - I) @ A_inv @ B
 # 实际的 Mamba 实现在这里使用了更高效的近似
 B_bar = A_bar_minus_I @ torch.linalg.solve(A.squeeze(), B)

 # 4. SSM 递推(扫描)
 # 初始化状态 h0 = 0
 h = torch.zeros(batch, self.d_inner, self.d_state, device=x.device)
 outputs = []
 for t in range(seq_len):
 A_bar_t = A_bar[:, t] # (batch, d_inner, d_state, d_state)
 B_bar_t = B_bar[:, t] # (batch, d_inner, d_state, 1)
 C_t = C[:, t] # (batch, d_inner, d_state)
 x_t = x_conv[:, t] # (batch, d_inner)

 # h_t = A_bar @ h_{t-1} + B_bar @ x_t
 # 注意:这里每个 d_inner 维度有自己的状态
 h = torch.einsum('bnd,bi...->bni...', A_bar_t, h) + \
 torch.einsum('bnd,bd->bn', B_bar_t.squeeze(-1), x_t)

 # y_t = C @ h_t
 y_t = torch.einsum('bnd,bn->bd', C_t, h)
 outputs.append(y_t)

 y = torch.stack(outputs, dim=1) # (batch, seq_len, d_inner)

 # 5. 门控 + 输出投影
 y = y _aegis_article.md ai_chatbot_privacy_article.html ai-seo-tools-article.html ai-seo-tools-article-updated.html alipay-article.html android-privacy-article.html android_privacy_article.html android-privacy-final.html android_privacy_final.html article_2fa.html article-architecture.html article_base64.txt article_body.html article_body.md article_body.txt article_breach_response.html article_clean.html article_complete.html article_content_final.json article-content.html article_content.html article_content.json article_content.txt _article_content.xml article_cookie_consent.html article_data_breach.html article_data.json article_dianping.html article-dns-privacy-final.html article-dns-privacy.html article_dns_privacy.html article_draft.html article_ecommerce.html article-email-marketing.html article_encrypted_cloud.html article-escaped.txt article-final.html article_final.html article_full.html article_game_dev.html article_headshot.html article-hemal-grocery.html article.html article-html.txt article_identity_theft.html article-image-generators.html article_iphone_privacy.html article-longmen-grottoes-final.html article-longmen-grottoes.html article_meituan.html article_meta.json article_passkeys.html article_pg_clean.json article_pg.json article_postgresql.html article-privacy-cloud-storage.html article_public_wifi.html article_python_type_hints.html article-qin-shi-huang.html article_ransomware.html article-rent-apartment.html articles article_search_engines.html article_sim_swap.html article_social_media_privacy.html article_temp.html article_today_point.html article_transcription.html article_vllm.md article-with-images.html article_with_images.html article_with_images.txt article_xiaohongshu.html article.xml article_zhou_final.html article_zhou.html audio_cache auth.json auth.lock _b64_part1.txt beijing-guide.html beijing-opera-article.html beijing_opera_article.html bin bitwarden-article.html browser-comparison-article.html browser-fingerprinting-article.html build_article.py cache capture2.py capture_bitwarden.py capture_hootsuite.py capture_playstore.py capture.py capture_screens2.py capture_screenshots.py capture_screens.py capture.sh capture_stealth.py channel_directory.json check_article.py check_content.py check_post.py check_quality.py chinese-civil-war-article.html chinese-dynasties-article.html chinese-dynasties-final.html chinese-etiquette-article.html chinese-etiquette-article-with-images.html chinese-folk-religion.html chinese_food_article.html chinese-zodiac-article.html config.yaml config.yaml.bak.20260616_091116 config.yaml.bak.20260616_091136 config.yaml.bak.20260616_091148 config.yaml.bak.20260616_150612 config.yaml.bak.20260616_223924 config.yaml.bak.20260616_224702 config.yaml.bak.20260616_225109 config.yaml.bak.20260616_225947 config.yaml.bak.20260617_101814 config.yaml.bak.20260617_102045 config.yaml.bak.20260617_102150 _content_p1.md create-ming-post.php create_post2.py create_post3.py create-post.php create_post.php create_post.py create_post.sh cron current_content.html data_broker_article.html _decoder_b64.txt _deepfake_article.md dl_fallback.py douyin-article-final.html douyin-article.html download_fallback.py download_images.py download_unsplash.py dragon-boat-article.html _dup.md dynasties-article.html ecommerce_content.html email-privacy-article.html feishu_seen_message_ids.json feng-shui-article.html fengshui-article.html fengshui-final.html fetch_unsplash.py final-article.html final_article.html final_article.txt final_check.py final_content.html find_magic.py fix_alt.py fix_content.py fix_html.py fix_image.py fix_images.py fix_imgs.py fix_quotes.py folk-religion-content.html full_article.html _fuzz_article.md gateway.lock gateway.pid gateway_state.json gen_article.py genghis-khan-article.html genghis-khan-final.html _gen.py ghost-festival-article.html git_object_model_article.html google_client_secret.json google_oauth_pending.json google_token.json grand-canal-article.html great-wall-history.html guilin-article.html harbin-article.html hooks huangshan-article-final.html huangshan-article.html image_cache iot-article-final.html iot-article.html jiuzhaigou-article.html jiuzhaigou-clean.html jiuzhaigou-final.html kanban.db kanban.db.init.lock kunming-article.html lantern-article.html li-river-article.html logs luoyang-article.html mao-article-final.html mao-article.html martial-arts-article.html meeting-fallback.jpg memories messaging-apps-article.html mid-autumn-article.html ming-article-final.html ming-article.html models_dev_cache.json nanjing_article.html node notification.md ollama_cloud_models_cache.json outputs pairing payload.json phishing-article.html php_article.html playwright_fdroid.py playwright_metro.py playwright_screenshots.py plugins poll_bilibili.sh porcelain-article.html porcelain-article-v2.html post_data.json prepare_article.sh prepare_content.py prepare_post.py prepare_publish.py prep_post.py processes.json provider_models_cache.json publish_article.php publish_article.py publish-panda.sh publish_post.php qing-article-final.html qing-article.html qing_article.html qingdao-article.html qing-dynasty-article.html qing_dynasty_article.html qin-shi-huang-article.html quality_check2.py quality_check3.py quality_check.py rag_article.xml replace_imgs.py router-article-final.html router-article.html sandboxes scala_article.json _sc.md screenshot_capture2.py screenshot_capture.py screenshot_remote.py screenshot_script2.py screenshot_script3.py screenshot_script.py screenshots.py scripts _sec1.md _sec2.md _sec3.md _sec4.md _sec5.md sessions shang-dynasty-article.html shang-final.html shopping-privacy-article.html silk-article-final.html silk-article.html silk-road-article.html silk-road-final.html _skeleton.md skills social-media-privacy-article.html song-dynasty-article.html song_dynasty_article.html song_dynasty_final.html SOUL.md state.db state.db-shm state.db-wal stone-forest-article.html sui_dynasty_article.html summer-palace-article.html _supply_chain.md suzhou-article.html tang-dynasty-article.html tang-dynasty-full.html tcm_article_final.html tcm-article.html tcm_article.html tea-article.html temp temp_article_content.html temp_article.html _test_content.md _test.txt three-kingdoms-article.html three-kingdoms-final.html tmp update_article.py update_content.py _update_content.xml update_db.py update_images.py update_post2.py update_post.php update_post.py update_post_wp.php update_wp.py upload-img.php verify_article.py verify_post.php verify_post.py verify_post.sh visa-article.html vpn_article.html work write_article_content.py write-article.py write_article.py write_update_script2.py write_update_script.py wu-zetian-article.html wu-zetian-article-with-images.html xia_dynasty_article.html xiamen-article.html yuan-article.html yuan-dynasty-article.html zhangjiajie_article.html zhenghe-article.html zhou-dynasty-article.html gate
 return self.out_proj(y)

注意:上述代码为了可读性使用了显式的 for 循环,实际 Mamba 的实现使用了高效的并行扫描算法(associative scan),可以在 GPU 上以 O(n log n) 的复杂度完成递推计算。

硬件感知的并行扫描算法

上面实现的显式 for 循环虽然直观,但在 GPU 上效率极低。Mamba 的另一个关键创新是 硬件感知的并行扫描(Hardware-Aware Parallel Scan)

并行扫描的核心思想是:SSM 的递推公式 h_t = A_bar · h_{t-1} + B_bar · u_t 是一个”结合律”运算(associative operator),即:


1
combine((A₁, B₁u₁), (A₂, B₂u₂)) = (A₂·A₁, A₂·B₁u₁ + B₂u₂)

利用这个性质,我们可以使用二叉树的归约策略,将 O(n) 的串行扫描转化为 O(log n) 的并行扫描。具体来说,算法分为三步:

  1. Up-sweep(向上归约):从叶子节点开始,逐层合并相邻元素,构建二叉树
  2. Down-sweep(向下分发):从根节点开始,将累积结果向下分发
  3. 最终计算:每个叶子节点使用分发下来的累积结果计算最终输出

Mamba 的官方实现使用了 CUDA 自定义 kernel,在 SRAM 中完成整个扫描过程,避免了中间结果在 HBM 和 SRAM 之间的频繁搬移。这种”kernel fusion”策略使得 Mamba 在长序列上比 FlashAttention 加速的 Transformer 还要快 2-5 倍。

Mamba 2:结构化状态空间对偶性

2024年,Mamba 团队又推出了 Mamba 2,进一步将 SSM 与注意力机制统一起来。Mamba 2 的核心贡献是揭示了 SSM 与注意力机制之间的数学对偶性:

选择性 SSM 实际上等价于一种带有结构化掩码的线性注意力机制。 更具体地说,Mamba 2 证明了:


1
SSM 的输出 = softmax(QK^T) · V 的线性近似

这种对偶性带来了几个重要的改进:

  • 张量并行(Tensor Parallelism):Mamba 2 借鉴了注意力机制的张量并行策略,支持多 GPU 训练
  • 更高效的扫描:利用对偶性,Mamba 2 可以使用矩阵乘法来加速计算
  • 更好的扩展性:在相同参数量的情况下,Mamba 2 的训练速度比 Mamba 1 快 2-3 倍

Mamba 2 的出现进一步缩小了 SSM 与 Transformer 之间的差距。在多项基准测试中,Mamba 2 在 2.8B 参数规模下已经能够与同等规模的 LLaMA 模型一较高下。

Mamba 的实际应用与部署

在 Hugging Face 中使用 Mamba

目前,Mamba 已经集成到 Hugging Face Transformers 库中,可以直接使用:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from transformers import MambaForCausalLM, AutoTokenizer
import torch

# 加载预训练模型
model_name = "state-spaces/mamba-2.8b-hf"
model = MambaForCausalLM.from_pretrained(
 model_name,
 torch_dtype=torch.bfloat16,
 device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)

# 推理
prompt = "状态空间模型的核心优势是"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)

with torch.no_grad():
 outputs = model.generate(
 **inputs,
 max_new_tokens=200,
 temperature=0.7,
 do_sample=True,
 )

print(tokenizer.decode(outputs[0], skip_special_tokens=True))

SSM 与 Transformer 的对比

维度 Transformer Mamba (SSM)
计算复杂度 O(n²) 自注意力 O(n) 线性扫描
长序列处理 显存随序列长度平方增长 显存随序列长度线性增长
推理速度(长序列) 需要 KV Cache,随序列增长 固定大小状态,无需 Cache
训练效率 高度优化的 CUDA kernel 需要自定义扫描 kernel
内容感知能力 强(自注意力机制) 强(选择性 SSM)
生态支持 极其成熟 快速发展中
硬件利用率 矩阵乘法为主,GPU 利用率高 扫描操作,GPU 利用率略低

未来展望:SSM 是否会取代 Transformer?

尽管 Mamba 在长序列建模、推理效率等方面展现出显著优势,但要说它会完全取代 Transformer 还为时过早。目前来看,最可能的趋势是 混合架构——将 SSM 与注意力机制结合,取长补短。

实际上,已经出现了多个混合架构的成功案例:

  • Jamba(AI21 Labs):将 Mamba 层与 Transformer 层交错堆叠,在保持长序列能力的同时,利用注意力层处理需要精确位置关系的任务
  • Zamba(Zyphra):在每 N 个 Mamba 层后插入一个共享注意力层,大幅减少了注意力层的数量
  • Samba(Microsoft):将 Mamba 作为滑动窗口层,与全局注意力层配合,实现了比纯 Transformer 更好的长文档理解能力

这些混合架构表明,未来的 LLM 很可能不再是”纯 Transformer”或”纯 SSM”,而是根据任务需求灵活组合多种机制。对于工程师来说,理解 SSM 的工作原理意味着在模型选型、性能优化和长序列处理上拥有了更多的选择空间。

最后,值得一提的是,Mamba 的成功也启发了其他领域的序列建模工作。在视频理解、音频处理、时间序列预测和基因组学等领域,基于 SSM 的架构正在快速涌现。状态空间模型的复兴,正在深刻改变整个深度学习领域的格局。

【本站文章皆为原创,未经允许不得转载】:汤不热吧 » Mamba 架构深度解析:状态空间模型如何突破 Transformer 的二次复杂度瓶颈
分享到: 更多 (0)