[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-hila-chefer--Transformer-Explainability":3,"tool-hila-chefer--Transformer-Explainability":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",138956,2,"2026-04-05T11:33:21",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":79,"owner_location":79,"owner_email":79,"owner_twitter":80,"owner_website":81,"owner_url":82,"languages":83,"stars":92,"forks":93,"last_commit_at":94,"license":95,"difficulty_score":23,"env_os":96,"env_gpu":97,"env_ram":96,"env_deps":98,"category_tags":106,"github_topics":107,"view_count":10,"oss_zip_url":79,"oss_zip_packed_at":79,"status":16,"created_at":120,"updated_at":121,"faqs":122,"releases":151},682,"hila-chefer\u002FTransformer-Explainability","Transformer-Explainability","[CVPR 2021] Official PyTorch implementation for Transformer Interpretability Beyond Attention Visualization, a novel method to visualize classifications by Transformer based networks.","Transformer-Explainability 是一个基于 PyTorch 的开源项目，致力于让 Transformer 模型的内部决策过程变得透明可视。它超越了传统的注意力机制可视化，能够针对特定分类生成精确的解释热力图，帮助理解模型在视觉识别或文本分析任务中的关注点。\n\n面对深度学习模型常被诟病为“黑盒”且注意力图可能误导人的问题，Transformer-Explainability 提供了一套可靠的解决方案。它特别适合 AI 研究人员、算法工程师以及对模型可解释性有需求的开发者。其核心技术亮点在于结合了改进的层间相关性传播（LRP）、梯度反向传播与层聚合（Rollup）方法，不仅适用于 Vision Transformer 和 BERT，还支持多模态及编码器 - 解码器架构。\n\n为了降低使用门槛，Transformer-Explainability 提供了丰富的 Google Colab 笔记本示例，用户只需上传图像或文本即可快速获得可视化结果，甚至能从解释中生成目标检测的分割掩码。无论是调试模型还是探索新架构，它都是理解 Transformer 行为的有效助手。","# PyTorch Implementation of [Transformer Interpretability Beyond Attention Visualization](https:\u002F\u002Farxiv.org\u002Fabs\u002F2012.09838) [CVPR 2021]\n\n#### Check out our new advancements- [Generic Attention-model Explainability for Interpreting Bi-Modal and Encoder-Decoder Transformers](https:\u002F\u002Fgithub.com\u002Fhila-chefer\u002FTransformer-MM-Explainability)!\nFaster, more general, and can be applied to *any* type of attention!\nAmong the features:\n* We remove LRP for a simple and quick solution, and prove that the great results from our first paper still hold!\n* We expand our work to *any* type of Transformer- not just self-attention based encoders, but also co-attention encoders and encoder-decoders!\n* We show that VQA models can actually understand both image and text and make connections!\n* We use a DETR object detector and create segmentation masks from our explanations!\n* We provide a colab notebook with all the examples. You can very easily add images and questions of your own!\n\n\u003Cp align=\"center\">\n  \u003Cimg width=\"400\" height=\"450\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhila-chefer_Transformer-Explainability_readme_78b7eba87584.jpg\">\n\u003C\u002Fp>\n\n---\n## ViT explainability notebook:\n[![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fhila-chefer\u002FTransformer-Explainability\u002Fblob\u002Fmain\u002FTransformer_explainability.ipynb)\n\n## BERT explainability notebook:\n[![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fhila-chefer\u002FTransformer-Explainability\u002Fblob\u002Fmain\u002FBERT_explainability.ipynb)\n---\n\n## Updates\nApril 5 2021: Check out this new [post](https:\u002F\u002Fanalyticsindiamag.com\u002Fcompute-relevancy-of-transformer-networks-via-novel-interpretable-transformer\u002F) about our paper! A great resource for understanding the main concepts behind our work.\n\nMarch 15 2021: [A Colab notebook for BERT for sentiment analysis added!](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fhila-chefer\u002FTransformer-Explainability\u002Fblob\u002Fmain\u002FBERT_explainability.ipynb)\n\nFeb 28 2021: Our paper was accepted to CVPR 2021! \n\nFeb 17 2021: [A Colab notebook with all examples added!](https:\u002F\u002Fgithub.com\u002Fhila-chefer\u002FTransformer-Explainability\u002Fblob\u002Fmain\u002FTransformer_explainability.ipynb)\n\nJan 5 2021: [A Jupyter notebook for DeiT added!](https:\u002F\u002Fgithub.com\u002Fhila-chefer\u002FTransformer-Explainability\u002Fblob\u002Fmain\u002FDeiT_example.ipynb)\n\n\n\u003Cp align=\"center\">\n  \u003Cimg width=\"300\" height=\"460\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhila-chefer_Transformer-Explainability_readme_887898e476a4.png\">\n\u003C\u002Fp>\n\n\n## Introduction\nOfficial implementation of [Transformer Interpretability Beyond Attention Visualization](https:\u002F\u002Farxiv.org\u002Fabs\u002F2012.09838).\n\nWe introduce a novel method which allows to visualize classifications made by a Transformer based model for both vision and NLP tasks.\nOur method also allows to visualize explanations per class.\n\n\u003Cp align=\"center\">\n  \u003Cimg width=\"600\" height=\"200\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhila-chefer_Transformer-Explainability_readme_849d3bd4f818.jpg\">\n\u003C\u002Fp>\nMethod consists of 3 phases:\n\n1. Calculating relevance for each attention matrix using our novel formulation of LRP.\n\n2. Backpropagation of gradients for each attention matrix w.r.t. the visualized class. Gradients are used to average attention heads.\n\n3. Layer aggregation with rollout.\n\nPlease notice our [Jupyter notebook](https:\u002F\u002Fgithub.com\u002Fhila-chefer\u002FTransformer-Explainability\u002Fblob\u002Fmain\u002Fexample.ipynb) where you can run the two class specific examples from the paper.\n\n\n![alt text](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhila-chefer_Transformer-Explainability_readme_fce16a0f911e.png)\n\nTo add another input image, simply add the image to the [samples folder](https:\u002F\u002Fgithub.com\u002Fhila-chefer\u002FTransformer-Explainability\u002Ftree\u002Fmain\u002Fsamples), and use the `generate_visualization` function for your selected class of interest (using the `class_index={class_idx}`), not specifying the index will visualize the top class.\n\n## Credits\nViT implementation is based on:\n- https:\u002F\u002Fgithub.com\u002Frwightman\u002Fpytorch-image-models\n- https:\u002F\u002Fgithub.com\u002Flucidrains\u002Fvit-pytorch\n- pretrained weights from: https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fvision_transformer\n\nBERT implementation is taken from the huggingface Transformers library:\nhttps:\u002F\u002Fhuggingface.co\u002Ftransformers\u002F\n\nERASER benchmark code adapted from the ERASER GitHub implementation: https:\u002F\u002Fgithub.com\u002Fjayded\u002Feraserbenchmark\n\nText visualizations in supplementary were created using TAHV heatmap generator for text: https:\u002F\u002Fgithub.com\u002Fjiesutd\u002FText-Attention-Heatmap-Visualization\n\n## Reproducing results on ViT\n\n### Section A. Segmentation Results\n\nExample:\n```\nCUDA_VISIBLE_DEVICES=0 PYTHONPATH=.\u002F:$PYTHONPATH python3 baselines\u002FViT\u002Fimagenet_seg_eval.py --method transformer_attribution --imagenet-seg-path \u002Fpath\u002Fto\u002Fgtsegs_ijcv.mat\n\n```\n[Link to download dataset](http:\u002F\u002Fcalvin-vision.net\u002Fbigstuff\u002Fproj-imagenet\u002Fdata\u002Fgtsegs_ijcv.mat).\n\nIn the exmaple above we run a segmentation test with our method. Notice you can choose which method you wish to run using the `--method` argument. \nYou must provide a path to imagenet segmentation data in `--imagenet-seg-path`.\n\n### Section B. Perturbation Results\n\nExample:\n```\nCUDA_VISIBLE_DEVICES=0 PYTHONPATH=.\u002F:$PYTHONPATH python3 baselines\u002FViT\u002Fgenerate_visualizations.py --method transformer_attribution --imagenet-validation-path \u002Fpath\u002Fto\u002Fimagenet_validation_directory\n```\n\nNotice that you can choose to visualize by target or top class by using the `--vis-cls` argument.\n\nNow to run the perturbation test run the following command:\n```\nCUDA_VISIBLE_DEVICES=0 PYTHONPATH=.\u002F:$PYTHONPATH python3 baselines\u002FViT\u002Fpertubation_eval_from_hdf5.py --method transformer_attribution\n```\n\nNotice that you can use the `--neg` argument to run either positive or negative perturbation.\n\n## Reproducing results on BERT\n\n1. Download the pretrained weights:\n\n- Download `classifier.zip` from https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1kGMTr69UWWe70i-o2_JfjmWDQjT66xwQ\u002Fview?usp=sharing\n- mkdir -p `.\u002Fbert_models\u002Fmovies`\n- unzip classifier.zip -d .\u002Fbert_models\u002Fmovies\u002F\n\n2. Download the dataset pkl file:\n\n- Download `preprocessed.pkl` from https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1-gfbTj6D87KIm_u1QMHGLKSL3e93hxBH\u002Fview?usp=sharing\n- mv preprocessed.pkl .\u002Fbert_models\u002Fmovies\n\n3. Download the dataset:\n\n- Download `movies.zip` from https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F11faFLGkc0hkw3wrGTYJBr1nIvkRb189F\u002Fview?usp=sharing\n- unzip movies.zip -d .\u002Fdata\u002F\n\n4. Now you can run the model.\n\nExample:\n```\nCUDA_VISIBLE_DEVICES=0 PYTHONPATH=.\u002F:$PYTHONPATH python3 BERT_rationale_benchmark\u002Fmodels\u002Fpipeline\u002Fbert_pipeline.py --data_dir data\u002Fmovies\u002F --output_dir bert_models\u002Fmovies\u002F --model_params BERT_params\u002Fmovies_bert.json\n```\nTo control which algorithm to use for explanations change the `method` variable in `BERT_rationale_benchmark\u002Fmodels\u002Fpipeline\u002Fbert_pipeline.py` (Defaults to 'transformer_attribution' which is our method).\nRunning this command will create a directory for the method in `bert_models\u002Fmovies\u002F\u003Cmethod_name>`.\n\nIn order to run f1 test with k, run the following command:\n```\nPYTHONPATH=.\u002F:$PYTHONPATH python3 BERT_rationale_benchmark\u002Fmetrics.py --data_dir data\u002Fmovies\u002F --split test --results bert_models\u002Fmovies\u002F\u003Cmethod_name>\u002Fidentifier_results_k.json\n```\n\nAlso, in the method directory there will be created `.tex` files containing the explanations extracted for each example. This corresponds to our visualizations in the supplementary.\n\n## Citing our paper\nIf you make use of our work, please cite our paper:\n```\n@InProceedings{Chefer_2021_CVPR,\n    author    = {Chefer, Hila and Gur, Shir and Wolf, Lior},\n    title     = {Transformer Interpretability Beyond Attention Visualization},\n    booktitle = {Proceedings of the IEEE\u002FCVF Conference on Computer Vision and Pattern Recognition (CVPR)},\n    month     = {June},\n    year      = {2021},\n    pages     = {782-791}\n}\n```\n","# [Transformer（一种深度学习模型架构）可解释性超越注意力可视化](https:\u002F\u002Farxiv.org\u002Fabs\u002F2012.09838) 的 PyTorch 实现 [CVPR 2021]\n\n#### 查看我们的新进展 - [用于解释双模态和编码器 - 解码器 Transformer 的通用注意力模型可解释性](https:\u002F\u002Fgithub.com\u002Fhila-chefer\u002FTransformer-MM-Explainability)!\n更快、更通用，并且可以应用于*任何*类型的注意力机制！\n具有以下特性：\n* 我们移除了 LRP（层相关传播），提供了一个简单快速的解决方案，并证明了我们第一篇论文中的优秀结果依然成立！\n* 我们将工作扩展到*任何*类型的 Transformer——不仅是基于自注意力的编码器，还包括共注意力编码器和编码器 - 解码器！\n* 我们展示了 VQA（视觉问答）模型实际上可以理解图像和文本并建立联系！\n* 我们使用 DETR（检测 Transformer）目标检测器，并从我们的解释中创建分割掩码！\n* 我们提供了一个包含所有示例的 Colab（云端笔记本）。您可以非常轻松地添加自己的图像和问题！\n\n\u003Cp align=\"center\">\n  \u003Cimg width=\"400\" height=\"450\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhila-chefer_Transformer-Explainability_readme_78b7eba87584.jpg\">\n\u003C\u002Fp>\n\n---\n## ViT（视觉 Transformer）可解释性笔记本：\n[![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fhila-chefer\u002FTransformer-Explainability\u002Fblob\u002Fmain\u002FTransformer_explainability.ipynb)\n\n## BERT（预训练语言模型）可解释性笔记本：\n[![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fhila-chefer\u002FTransformer-Explainability\u002Fblob\u002Fmain\u002FBERT_explainability.ipynb)\n---\n\n## 更新\n2021 年 4 月 5 日：查看这篇关于我们论文的新 [帖子](https:\u002F\u002Fanalyticsindiamag.com\u002Fcompute-relevancy-of-transformer-networks-via-novel-interpretable-transformer\u002F)！这是理解我们工作背后主要概念的优秀资源。\n\n2021 年 3 月 15 日：[添加了用于情感分析的 BERT Colab 笔记本！](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fhila-chefer\u002FTransformer-Explainability\u002Fblob\u002Fmain\u002FBERT_explainability.ipynb)\n\n2021 年 2 月 28 日：我们的论文被 CVPR 2021 接收！ \n\n2021 年 2 月 17 日：[添加了包含所有示例的 Colab 笔记本！](https:\u002F\u002Fgithub.com\u002Fhila-chefer\u002FTransformer-Explainability\u002Fblob\u002Fmain\u002FTransformer_explainability.ipynb)\n\n2021 年 1 月 5 日：[添加了 DeiT 的 Jupyter 笔记本！](https:\u002F\u002Fgithub.com\u002Fhila-chefer\u002FTransformer-Explainability\u002Fblob\u002Fmain\u002FDeiT_example.ipynb)\n\n\n\u003Cp align=\"center\">\n  \u003Cimg width=\"300\" height=\"460\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhila-chefer_Transformer-Explainability_readme_887898e476a4.png\">\n\u003C\u002Fp>\n\n\n## 简介\n[Transformer 可解释性超越注意力可视化](https:\u002F\u002Farxiv.org\u002Fabs\u002F2012.09838) 的官方实现。\n\n我们介绍了一种新颖的方法，允许可视化基于 Transformer 的模型在视觉和 NLP（自然语言处理）任务中做出的分类。\n我们的方法还允许按类别可视化解释。\n\n\u003Cp align=\"center\">\n  \u003Cimg width=\"600\" height=\"200\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhila-chefer_Transformer-Explainability_readme_849d3bd4f818.jpg\">\n\u003C\u002Fp>\n该方法由 3 个阶段组成：\n\n1. 使用我们新颖的 LRP 公式计算每个注意力矩阵的相关性。\n\n2. 针对可视化类别对每个注意力矩阵进行梯度反向传播。梯度用于平均注意力头。\n\n3. 使用 rollout 进行层聚合。\n\n请注意我们的 [Jupyter 笔记本](https:\u002F\u002Fgithub.com\u002Fhila-chefer\u002FTransformer-Explainability\u002Fblob\u002Fmain\u002Fexample.ipynb)，您可以在其中运行论文中的两个特定类别示例。\n\n\n![alt text](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhila-chefer_Transformer-Explainability_readme_fce16a0f911e.png)\n\n要添加另一个输入图像，只需将图像添加到 [samples 文件夹](https:\u002F\u002Fgithub.com\u002Fhila-chefer\u002FTransformer-Explainability\u002Ftree\u002Fmain\u002Fsamples)，并使用 `generate_visualization` 函数为您感兴趣的选定类别（使用 `class_index={class_idx}`），不指定索引将可视化顶级类别。\n\n## 致谢\nViT 实现基于：\n- https:\u002F\u002Fgithub.com\u002Frwightman\u002Fpytorch-image-models\n- https:\u002F\u002Fgithub.com\u002Flucidrains\u002Fvit-pytorch\n- 来自以下内容的预训练权重：https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fvision_transformer\n\nBERT 实现取自 Huggingface Transformers 库：\nhttps:\u002F\u002Fhuggingface.co\u002Ftransformers\u002F\n\nERASER 基准代码改编自 ERASER GitHub 实现：https:\u002F\u002Fgithub.com\u002Fjayded\u002Feraserbenchmark\n\n补充材料中的文本可视化是使用 TAHV 文本注意力热力图生成器创建的：https:\u002F\u002Fgithub.com\u002Fjiesutd\u002FText-Attention-Heatmap-Visualization\n\n## 在 ViT 上复现结果\n\n### A 节。分割结果\n\n示例：\n```\nCUDA_VISIBLE_DEVICES=0 PYTHONPATH=.\u002F:$PYTHONPATH python3 baselines\u002FViT\u002Fimagenet_seg_eval.py --method transformer_attribution --imagenet-seg-path \u002Fpath\u002Fto\u002Fgtsegs_ijcv.mat\n\n```\n[下载数据集链接](http:\u002F\u002Fcalvin-vision.net\u002Fbigstuff\u002Fproj-imagenet\u002Fdata\u002Fgtsegs_ijcv.mat)。\n\n在上例中，我们使用我们的方法运行了分割测试。请注意，您可以使用 `--method` 参数选择要运行的方法。 \n您必须在 `--imagenet-seg-path` 中提供 imagenet 分割数据的路径。\n\n### B 节。扰动结果\n\n示例：\n```\nCUDA_VISIBLE_DEVICES=0 PYTHONPATH=.\u002F:$PYTHONPATH python3 baselines\u002FViT\u002Fgenerate_visualizations.py --method transformer_attribution --imagenet-validation-path \u002Fpath\u002Fto\u002Fimagenet_validation_directory\n```\n\n请注意，您可以使用 `--vis-cls` 参数选择按目标类别或顶级类别可视化。\n\n现在要运行扰动测试，请运行以下命令：\n```\nCUDA_VISIBLE_DEVICES=0 PYTHONPATH=.\u002F:$PYTHONPATH python3 baselines\u002FViT\u002Fpertubation_eval_from_hdf5.py --method transformer_attribution\n```\n\n请注意，您可以使用 `--neg` 参数运行正向或负向扰动。\n\n## 在 BERT (双向编码器表示转换器) 上复现结果\n\n1. 下载预训练权重：\n\n- 从 https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1kGMTr69UWWe70i-o2_JfjmWDQjT66xwQ\u002Fview?usp=sharing 下载 `classifier.zip`\n- mkdir -p `.\u002Fbert_models\u002Fmovies`\n- unzip classifier.zip -d .\u002Fbert_models\u002Fmovies\u002F\n\n2. 下载数据集 pkl (pickle) 文件：\n\n- 从 https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1-gfbTj6D87KIm_u1QMHGLKSL3e93hxBH\u002Fview?usp=sharing 下载 `preprocessed.pkl`\n- mv preprocessed.pkl .\u002Fbert_models\u002Fmovies\n\n3. 下载数据集：\n\n- 从 https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F11faFLGkc0hkw3wrGTYJBr1nIvkRb189F\u002Fview?usp=sharing 下载 `movies.zip`\n- unzip movies.zip -d .\u002Fdata\u002F\n\n4. 现在您可以运行模型。\n\n示例：\n```\nCUDA_VISIBLE_DEVICES=0 PYTHONPATH=.\u002F:$PYTHONPATH python3 BERT_rationale_benchmark\u002Fmodels\u002Fpipeline\u002Fbert_pipeline.py --data_dir data\u002Fmovies\u002F --output_dir bert_models\u002Fmovies\u002F --model_params BERT_params\u002Fmovies_bert.json\n```\n要控制用于解释的算法，请更改 `BERT_rationale_benchmark\u002Fmodels\u002Fpipeline\u002Fbert_pipeline.py` 中的 `method` 变量（默认为 'transformer_attribution'，即我们的方法）。\n运行此命令将在 `bert_models\u002Fmovies\u002F\u003Cmethod_name>` 中为该方法创建一个目录。\n\n为了运行带有 k 的 f1 (F1 Score) 测试，请运行以下命令：\n```\nPYTHONPATH=.\u002F:$PYTHONPATH python3 BERT_rationale_benchmark\u002Fmetrics.py --data_dir data\u002Fmovies\u002F --split test --results bert_models\u002Fmovies\u002F\u003Cmethod_name>\u002Fidentifier_results_k.json\n```\n\n此外，在方法目录中将创建包含每个示例提取的解释的 `.tex` 文件。这对应于我们在补充材料中的可视化内容。\n\n## 引用我们的论文\n如果您使用了我们的工作，请引用我们的论文：\n```\n@InProceedings{Chefer_2021_CVPR,\n    author    = {Chefer, Hila and Gur, Shir and Wolf, Lior},\n    title     = {Transformer Interpretability Beyond Attention Visualization},\n    booktitle = {Proceedings of the IEEE\u002FCVF Conference on Computer Vision and Pattern Recognition (CVPR)},\n    month     = {June},\n    year      = {2021},\n    pages     = {782-791}\n}\n```","# Transformer-Explainability 快速上手指南\n\n## 简介\n**Transformer-Explainability** 是基于 PyTorch 实现的 Transformer 可解释性工具。它通过新颖的方法可视化 Vision Transformer (ViT) 和 NLP 模型（如 BERT）的分类决策及注意力机制，支持生成每类的解释可视化图。\n\n## 环境准备\n*   **操作系统**: Linux \u002F macOS \u002F Windows\n*   **Python**: 建议版本 3.7+\n*   **深度学习框架**: PyTorch (推荐 CUDA 加速)\n*   **其他依赖**: `transformers`, `torchvision`, `numpy`, `matplotlib` 等\n\n> 💡 **国内加速建议**: 安装 PyTorch 时建议使用清华或阿里云镜像源以提升下载速度。\n\n## 安装步骤\n\n### 1. 克隆仓库\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fhila-chefer\u002FTransformer-Explainability.git\ncd Transformer-Explainability\n```\n\n### 2. 安装核心依赖\n确保已安装 PyTorch，并安装其他必要库。推荐使用国内镜像源安装 PyTorch：\n\n```bash\n# 示例：使用清华源安装 PyTorch (根据实际 CUDA 版本调整)\npip install torch torchvision torchaudio --index-url https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n\n# 安装其他依赖\npip install transformers\npip install matplotlib numpy\n```\n\n### 3. 配置环境变量\n运行脚本前需设置 `PYTHONPATH` 以包含当前目录：\n```bash\nexport PYTHONPATH=.\u002F:$PYTHONPATH\n```\n\n## 基本使用\n\n### 方法一：Google Colab (推荐新手)\n无需本地配置，直接在云端运行 Jupyter Notebook。\n\n*   **ViT 可解释性**: [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fhila-chefer\u002FTransformer-Explainability\u002Fblob\u002Fmain\u002FTransformer_explainability.ipynb)\n*   **BERT 可解释性**: [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fhila-chefer\u002FTransformer-Explainability\u002Fblob\u002Fmain\u002FBERT_explainability.ipynb)\n\n### 方法二：本地命令行 (ViT 示例)\n适用于复现论文中的扰动测试或分割结果。\n\n**1. 运行扰动评估 (Perturbation Evaluation)**\n```bash\nCUDA_VISIBLE_DEVICES=0 PYTHONPATH=.\u002F:$PYTHONPATH python3 baselines\u002FViT\u002Fgenerate_visualizations.py --method transformer_attribution --imagenet-validation-path \u002Fpath\u002Fto\u002Fimagenet_validation_directory\n```\n*   `--vis-cls`: 可选参数，指定可视化目标类别或 Top 类别。\n\n**2. 运行分割测试 (Segmentation Results)**\n```bash\nCUDA_VISIBLE_DEVICES=0 PYTHONPATH=.\u002F:$PYTHONPATH python3 baselines\u002FViT\u002Fimagenet_seg_eval.py --method transformer_attribution --imagenet-seg-path \u002Fpath\u002Fto\u002Fgtsegs_ijcv.mat\n```\n*   需提前下载 ImageNet 分割数据集。\n\n### 方法三：本地命令行 (BERT 示例)\n适用于情感分析任务的可解释性。\n\n1.  **下载预训练权重与数据**：按照 README 指引下载 `classifier.zip`、`preprocessed.pkl` 和 `movies.zip` 并解压至对应目录。\n2.  **运行模型**：\n```bash\nCUDA_VISIBLE_DEVICES=0 PYTHONPATH=.\u002F:$PYTHONPATH python3 BERT_rationale_benchmark\u002Fmodels\u002Fpipeline\u002Fbert_pipeline.py --data_dir data\u002Fmovies\u002F --output_dir bert_models\u002Fmovies\u002F --model_params BERT_params\u002Fmovies_bert.json\n```\n*   默认算法为 `transformer_attribution`，可在脚本中修改 `method` 变量。","医疗影像分析团队正在部署基于 Vision Transformer 的肺结节检测模型，急需验证模型是否真正关注病灶区域而非背景噪声。\n\n### 没有 Transformer-Explainability 时\n- 传统注意力可视化往往过于分散，难以区分关键病灶与无关背景纹理。\n- 面对误检案例，工程师无法定位模型是依据真实病理特征还是图像伪影做出的错误判断。\n- 医生质疑黑盒模型的可靠性，导致模型难以通过严格的临床审核流程上线。\n- 调试过程中缺乏量化指标，优化方向主要靠经验猜测，迭代效率低下。\n\n### 使用 Transformer-Explainability 后\n- 生成的类特异性热力图精准高亮病灶区域，利用 LRP 方法显著降低背景干扰。\n- 支持按类别可视化，清晰展示模型识别“恶性”或“良性”时的具体像素贡献依据。\n- 结合梯度回传与 Layer Aggregation，让工程师能快速定位特征提取层的异常权重分布。\n- 提供现成 Colab 示例，快速复现并生成符合医学逻辑的解释报告，加速模型验证。\n\n它让 Transformer 决策过程透明化，成为连接算法精度与临床信任的关键桥梁。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhila-chefer_Transformer-Explainability_e9fafe4d.png","hila-chefer","Hila Chefer","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fhila-chefer_96b2b515.jpg","Researcher @ Black Forest Labs",null,"hila_chefer","https:\u002F\u002Fhila-chefer.github.io\u002F","https:\u002F\u002Fgithub.com\u002Fhila-chefer",[84,88],{"name":85,"color":86,"percentage":87},"Jupyter Notebook","#DA5B0B",79.5,{"name":89,"color":90,"percentage":91},"Python","#3572A5",20.5,1988,259,"2026-04-05T05:08:30","MIT","未说明","需要 NVIDIA GPU 及 CUDA 环境，具体型号和显存大小未说明",{"notes":99,"python":96,"dependencies":100},"需手动下载 ImageNet 分割数据、预训练权重及电影数据集；部分脚本需设置 PYTHONPATH 环境变量；提供 Google Colab 笔记本示例；需配置数据路径参数",[101,102,103,104,105],"torch","transformers","pytorch-image-models","h5py","vit-pytorch",[14,13,26],[108,109,110,111,112,113,114,115,116,117,118,119],"deep-learning","vision-transformer","bert-model","bert","explainability","transformer-interpretability","perturbation","attention-visualization","visualize-classifications","vit","attention-matrix","cvpr2021","2026-03-27T02:49:30.150509","2026-04-06T05:35:33.212119",[123,128,132,137,141,146],{"id":124,"question_zh":125,"answer_zh":126,"source_url":127},2843,"是否可以在没有 [CLS] 标记的情况下使用此工具（例如回归任务）？","可以。对于回归任务或不依赖分类标记的场景，可以使用隐藏状态序列的第 i 个位置代替第 0 个位置（即 CLS 标记所在位置）。这意味着你需要调整输入处理逻辑以匹配你的任务需求，而不是强制使用 CLS 向量。","https:\u002F\u002Fgithub.com\u002Fhila-chefer\u002FTransformer-Explainability\u002Fissues\u002F16",{"id":129,"question_zh":130,"answer_zh":131,"source_url":127},2844,"如果没有 [CLS] 标记，应该如何配置起始层（start_layer）和 Rollout 设置？","起始层（start_layer）应设置为 0。Rollout 组件允许考虑所有前几层中混合的标记，因此对应于某一层（如第 10 层）的矩阵实际上包含了直到该层的所有层信息。建议从第 0 层开始 rollout 直到你感兴趣的层，这样生成的分数代表了经过所有前序层上下文化后的结果。",{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},2845,"如何将此方法应用于其他文本数据集（如虚假新闻检测或情感分析）？","首先，笔记本中的脚本应该可以直接使用，只需将其添加到克隆仓库的主文件夹中。其次，确保解释性方法的输出符合你的具体场景需求。如果模型结构复杂（例如在 BERT 上连接其他模型），可能需要为整个网络实现 LRP；若希望简化，可使用新仓库的方法（仅需传播梯度）。","https:\u002F\u002Fgithub.com\u002Fhila-chefer\u002FTransformer-Explainability\u002Fissues\u002F17",{"id":138,"question_zh":139,"answer_zh":140,"source_url":136},2846,"能否在 `BERTModel`（而非 `BERTForSequenceClassification`）上使用此方法获取注意力权重？","可以使用。该方法能提供反映每个标记对其他标记影响的注意力类矩阵。如果你的流程是使用 `BERTModel` 获取表示并结合其他特征（如拓扑特征）进行分类，可以通过本方法获取注意力权重进行可视化。注意，若涉及自定义架构组合，可能需要针对整个网络实现 LRP，或使用新库的方法简化梯度传播。",{"id":142,"question_zh":143,"answer_zh":144,"source_url":145},2847,"加载本地微调的 BERT 模型时报错 `RuntimeError: cannot register a hook...` 如何解决？","请检查模型权重的保存方式。建议使用与实验相同的保存代码（参考 `bert_pipeline.py` 第 404 行附近的实现）。确保使用 `save_pretrained` 正确保存模型和 tokenizer，并验证模型在推理时是否能正确注册钩子（hook）。如果使用了分布式训练，请确保正确处理 `model.module`。","https:\u002F\u002Fgithub.com\u002Fhila-chefer\u002FTransformer-Explainability\u002Fissues\u002F25",{"id":147,"question_zh":148,"answer_zh":149,"source_url":150},2848,"是否支持混合模型（如 ResNetV2+ViT）的实现？","目前主要针对 ViT 优化。对于混合模型，建议参考关于 Grad-CAM 的相关 Issue（#6），因为 Grad-CAM 不需要 LRP 传播。你可以选择对 ViT 部分不使用 LRP 传播，或者仅在最后一层使用 LRP（ablation），亦或仅对最后一层使用 LRP 而不集成梯度。","https:\u002F\u002Fgithub.com\u002Fhila-chefer\u002FTransformer-Explainability\u002Fissues\u002F8",[]]