SuperAPI AI Directory

ai-paper-reader

Writing & research

View repository

Updated 10-15 21:47

About this skill

AI Paper Reading Note Generator

Core Objectives

Generatepaper reading notes that can be published directly to technical communities(Zhihu, Juejin, WeChat official accounts, etc.).

Note requirements:

  • Complete content: no omission of core technical details, in-depth explanation of innovations
  • Professional and readable: technical blog style, both in-depth and easy to understand
  • Objective and accurate: analysis based on paper content, without adding subjective speculation
  • In-depth thinking: help readers gain deeper understanding through a Q&A section

Writing Guidelines

Should Do

  1. Professional and accurate expression

    • Use standard terminology within the field
    • Formulas and symbols strictly correspond to the original paper
    • Technical details described clearly and unambiguously
  2. Explanations that make complex topics accessible

    • For complex concepts, give intuition first, then details
    • Use analogies to help understand abstract concepts
    • Explain the meaning of variables item by item in formulas
  3. Clearly structured organization

    • Logical hierarchy is clear
    • Key content highlighted
    • Use charts and diagrams appropriately to aid explanation
  4. Valuable in-depth analysis

    • Analyze the reasons behind design choices
    • Compare similarities and differences with related work
    • Point out the applicable scope and limitations of the method

Must Avoid

  1. AI clichés and template phrases

    • ❌ "The core contribution of this paper is..."
    • ❌ "The advantage of this method lies in..."
    • ❌ "In summary..."
    • ❌ "It is worth noting that..."
    • ❌ "Of great significance/broad application prospects..."
  2. Empty summaries and evaluations

    • ❌ "This is an important work"
    • ❌ "Provides new ideas for the field"
    • ❌ General talk without specific analysis
  3. Excessive formatting decoration

    • ❌ Large amounts of emoji
    • ❌ Bolding every sentence
    • ❌ Too many nested levels
  4. Unnecessary first person

    • ❌ "I think..."
    • ❌ "My understanding is..."
    • Maintain an objective narrative perspective

Note Structure

Zero, Meta Information (at the beginning of the note)

Each note must include the following information at the beginning to help readers quickly decide whether to continue reading:

> **论文**:Actions Speak Louder than Words: Trillion-Parameter Sequential Transducers for Generative Recommendations
> **作者**:Meta AI
> **发表**:ICML 2024
> **阅读时长**:约 15 分钟
> **难度**:⭐⭐⭐⭐ (需要 Transformer、推荐系统基础)
> **前置知识**:Attention 机制、DLRM、Scaling Law 概念

Difficulty Level Description:

  • ⭐ Beginner: no professional background required
  • ⭐⭐ Basic: understand the fundamentals of deep learning
  • ⭐⭐⭐ Advanced: familiar with related fields
  • ⭐⭐⭐⭐ Professional: requires relatively deep domain knowledge
  • ⭐⭐⭐⭐⭐ Expert: involves complex mathematics or frontier research

One, TL;DR

Summarize the paper's core innovation in 2-3 sentences, allowing readers who have no time to read carefully to quickly grasp the key points.

## TL;DR

DLRM 等传统推荐模型依赖大量人工特征且无法 scale,本文提出将推荐问题转化为序列生成问题。核心创新是 HSTU 架构:用 Pointwise Attention 替代 Softmax 来保留用户偏好的绝对强度信息,使推荐系统首次展现出类似 LLM 的 Scaling Law。

Requirements:

  • 2-3 sentences, no more than 100 characters
  • Must include: problem background + core solution + key innovation points
  • Avoid general talk; include specific technical points

II. Paper Overview

Concisely answer three questions:

  • What problem is solved: Describe in one sentence
  • Core solution: Summarize in one sentence
  • Main contributions: List 2-3 points
## 论文概述

**问题**:大规模推荐系统无法像 LLM 一样通过增加计算量持续提升质量

**方案**:将推荐问题从"特征工程+判别式模型"转变为"序列建模+生成式模型"

**贡献**:
1. 提出 Generative Recommenders (GRs) 范式,实现推荐系统的 Scaling Law
2. 设计 HSTU 架构,用 Pointwise Attention 替代 Softmax 保留强度信息
3. 提出 M-FALCON 推理算法,实现高效的候选打分

III. Background and Motivation

Explain the problems of existing methods and why a new method is needed:

  • How existing methods do it
  • What problems/bottlenecks exist
  • What is the root cause of the problem

IV. Core Method (Focus)

This is the core part of the notes, requiringcomplete, in-depth, and without omissions。

Organization

  1. Overall architecture

    • Provide an architecture diagram
    • Explain the data flow
    • Label key modules
  2. Detailed explanation of core modules(for each key module)

    • Input/output description
    • Core formula + item-by-item explanation
    • Pseudocode/code implementation
    • Analysis of the reasons for design choices
  3. Key technical details

    • Training strategy
    • Hyperparameter settings
    • Implementation tricks

Example format

## 核心方法

### 整体架构

[架构图]

数据流:用户历史序列 → Embedding → HSTU Layers × L → 预测头

### HSTU Layer 详解

#### 输入输出
- 输入:X ∈ R^{N×d},N 为序列长度,d 为嵌入维度
- 输出:Y ∈ R^{N×d}

#### 核心公式

**Pointwise Projection**:
$$U, V, Q, K = \text{Split}(\phi_1(f_1(X)))$$

其中:
- $\phi_1$:SiLU 激活函数
- $f_1$:单层线性变换
- Split 将输出分为四个向量

**Spatial Aggregation**:
$$A(X)V(X) = \phi_2(Q(X)K(X)^T + r_{ab}) V(X)$$

关键点:使用 SiLU 而非 Softmax,保留注意力的绝对强度信息。

#### 代码实现

```python
class HSTULayer(nn.Module):
    def forward(self, x):
        # Pointwise Projection
        projected = F.silu(self.proj_in(x))
        u, v, q, k = projected.split([...], dim=-1)

        # Spatial Aggregation (不是 Softmax!)
        attn = F.silu(q @ k.T + self.rel_bias)
        out = self.norm(attn @ v) * u

        return x + self.proj_out(out)

Design analysis

Why use SiLU instead of Softmax?

Softmax normalizes attention into a probability distribution, which in recommendation scenarios will lose important information...


### 五、实验分析

不是罗列数字,而是提炼关键结论:

- **主实验结果**:与 baseline 对比的核心发现
- **消融实验**:各组件的贡献分析
- **Scaling 分析**:计算量与性能的关系(如有)
- **局限性**:方法在什么情况下效果不好

### 六、深度理解问答

通过精心设计的问题,帮助读者深入理解论文的关键点。

**问答直接展示,不使用折叠**。

```markdown
## 深度理解问答

### Q1: 为什么 Softmax Attention 不适合推荐场景?

推荐场景需要预测用户偏好的**绝对强度**(如观看时长),而非只是**相对排序**。

考虑两个用户:
- 用户 A:10 次历史交互
- 用户 B:100 次历史交互

使用 Softmax 时,两者的注意力权重都会被归一化到 [0,1],导致"用户 B 更活跃"这一信息丢失。

而 Pointwise Attention 保留了累加的原始 magnitude,模型可以学到活跃度差异。

### Q2: HSTU 如何用 2 个线性层替代 Transformer 的 6 个?

标准 Transformer 每层需要:
- Q, K, V 投影:3 个线性层
- Output Projection:1 个线性层
- FFN:2 个线性层(扩展+压缩)

HSTU 的简化:
1. **融合 Q, K, V, U 投影**:一个线性层同时生成四个向量
2. **用 U 门控替代 FFN**:`output * U` 实现类似的非线性变换

代价是单层表达能力下降,但可以通过堆叠更多层来补偿。

### Q3: Stochastic Length 训练为什么能丢弃 70% token 而效果几乎不变?

关键在于用户行为的**统计特性**:

1. **时间重复性**:用户会反复与相似内容交互,信息冗余度高
2. **兴趣低秩性**:10000 次交互可能只涉及 20 个主要兴趣点
3. **最近优先**:采样时对最近行为加权,保留最相关的信息

只要采样数量大于兴趣类别数的一定倍数,就能以高概率覆盖所有兴趣。

VII. Summary and Reflections

Objectively summarize the paper's contributions and limitations:

## 总结

### 核心贡献
- 证明了推荐系统可以遵循 Scaling Law
- 提出了适合推荐场景的 Attention 变体

### 局限性
- 冷启动场景:历史序列太短时优势不明显
- 计算成本:需要大量 GPU 资源
- 实时性:长序列推理的延迟挑战

### 适用场景
- 用户历史丰富的场景(>100 次交互)
- 有充足计算资源
- 对实时性要求不是极端严格

Directory structure specification

Papers and reading notes should be organized under a unified subdirectory for easy management and retrieval:

paper-notes/
├── hstu/                           # 每篇论文一个目录,使用简短名称
│   ├── paper.pdf                   # 原始论文 PDF
│   ├── README.md                   # 阅读笔记(主文件)
│   └── images/                     # 提取的图表
│       ├── fig1_architecture.png
│       ├── fig2_method.png
│       └── fig3_scaling.png
│
├── attention-is-all-you-need/
│   ├── paper.pdf
│   ├── README.md
│   └── images/
│
└── din-deep-interest-network/
    ├── paper.pdf
    ├── README.md
    └── images/

Naming specification:

  • Directory name: paper abbreviation or keywords, lowercase, connected with - connected with -
  • Note file: uniformly named README.md, convenient for direct preview on GitHub
  • Image directory: uniformly named images/

Image naming specification:

fig{序号}_{类型}_{简述}.png

类型:
- arch: 架构图
- method: 方法流程
- result: 实验结果
- ablation: 消融实验
- compare: 对比图

示例:
- fig1_arch_overall.png
- fig2_method_attention.png
- fig3_result_scaling.png

Q&A Session Design Guide

Question types

  1. Principle understanding type

    • Why is it designed this way?
    • What advantages does it have compared with alternative solutions?
  2. Detail discrimination type

    • The specific meaning of a certain symbol/operation
    • Distinguishing easily confused concepts
  3. Boundary condition type

    • Under what circumstances will the method fail?
    • What are the assumptions?
  4. Extended thinking type

    • Can it be transferred to other scenarios?
    • What possible directions for improvement are there?

Answer requirements

  • Display directly: Do not use folding, so readers can read smoothly
  • Well-reasoned: Answers should have argumentation, not simple assertions
  • Give appropriate examples: Use specific examples to aid understanding
  • Acknowledge uncertainty: For parts not explained in the paper, you may mark them as "speculation"

Chart handling

Charts that must be extracted

  • Overall architecture diagram
  • Core method flowchart
  • Key experimental results (Scaling Law curves, etc.)

Chart description specification

![架构图](images/fig1_architecture.png)

**图示内容**:HSTU 的整体架构,左侧为 DLRM 对比

**关键信息**:
- 输入为统一的物品-行为交替序列
- HSTU Layer 可以无限堆叠
- 输出为多任务预测头

**与正文对应**:第 3.2 节详细描述

Image extraction tools

Figures and tables in academic papers come in two types and require different extraction methods:

Type Characteristics Extraction method
Embedded images PNG/JPEG inserted by the author get_images()
Vector graphics Graphics drawn as architecture diagrams, flowcharts, etc. cluster_drawings()

Method 1: Extract embedded images

Suitable for bitmaps inserted directly into the paper (such as experimental result screenshots, photos, etc.):

import fitz  # PyMuPDF
import os

def extract_embedded_images(pdf_path, output_dir):
    """提取 PDF 中嵌入的位图"""
    os.makedirs(output_dir, exist_ok=True)
    doc = fitz.open(pdf_path)

    for page_num in range(len(doc)):
        page = doc[page_num]
        images = page.get_images(full=True)

        for img_idx, img in enumerate(images):
            xref = img[0]
            base = doc.extract_image(xref)
            image_bytes = base["image"]
            image_ext = base["ext"]

            # 过滤过小的图片(可能是图标/装饰)
            if base["width"] > 100 and base["height"] > 100:
                output_path = f"{output_dir}/page{page_num+1}_img{img_idx+1}.{image_ext}"
                with open(output_path, "wb") as f:
                    f.write(image_bytes)

    doc.close()

Method 2: Extract vector graphics (recommended)

Suitable for vector graphics such as architecture diagrams, flowcharts, and charts drawn in the paper:

import fitz
import os

def extract_vector_figures(pdf_path, output_dir, dpi=200, min_size=100):
    """
    使用 cluster_drawings() 识别矢量图形区域并截图

    Args:
        pdf_path: PDF 文件路径
        output_dir: 输出目录
        dpi: 输出分辨率(默认 200,可提高到 300 获得更清晰的图片)
        min_size: 最小尺寸阈值,过滤装饰线条(默认 100pt)
    """
    os.makedirs(output_dir, exist_ok=True)
    doc = fitz.open(pdf_path)

    figures = []
    for page_num in range(len(doc)):
        page = doc[page_num]

        # 识别矢量图形的聚类区域
        # x_tolerance/y_tolerance 控制相邻元素的合并距离
        try:
            drawing_rects = page.cluster_drawings(
                x_tolerance=3,
                y_tolerance=3
            )
        except Exception:
            # 某些 PDF 可能不支持,跳过
            continue

        for idx, rect in enumerate(drawing_rects):
            # 过滤过小的区域(可能是线条/装饰)
            if rect.width < min_size or rect.height < min_size:
                continue

            # 扩展边界,避免裁切太紧
            rect = rect + (-10, -10, 10, 10)
            # 确保不超出页面边界
            rect = rect & page.rect

            # 高分辨率截图
            zoom = dpi / 72
            mat = fitz.Matrix(zoom, zoom)
            pix = page.get_pixmap(matrix=mat, clip=rect)

            output_path = f"{output_dir}/page{page_num+1}_fig{idx+1}.png"
            pix.save(output_path)
            figures.append({
                "page": page_num + 1,
                "path": output_path,
                "rect": rect
            })

    doc.close()
    return figures

Method 3: Manually specify a region to crop

When automatic recognition is not satisfactory, you can manually specify coordinates:

import fitz

def crop_figure(pdf_path, page_num, rect, output_path, dpi=200):
    """
    从 PDF 指定页面裁剪特定区域

    Args:
        pdf_path: PDF 路径
        page_num: 页码(从 1 开始)
        rect: (x0, y0, x1, y1) 坐标,单位为点(pt),72pt = 1英寸
        output_path: 输出图片路径
        dpi: 分辨率
    """
    doc = fitz.open(pdf_path)
    page = doc[page_num - 1]

    clip = fitz.Rect(rect)
    zoom = dpi / 72
    mat = fitz.Matrix(zoom, zoom)

    pix = page.get_pixmap(matrix=mat, clip=clip)
    pix.save(output_path)
    doc.close()

# 使用示例:裁剪第 2 页的某个区域
# 坐标可通过 PDF 阅读器查看,或先用方法 2 识别后微调
crop_figure(
    "paper.pdf",
    page_num=2,
    rect=(50, 100, 550, 400),  # 左上角(50,100) 到 右下角(550,400)
    output_path="./images/fig1_architecture.png"
)

Smart extraction (comprehensive solution)

Automatically try multiple methods to extract all figures and tables:

import fitz
import os

def smart_extract_figures(pdf_path, output_dir, dpi=200):
    """
    智能提取论文中的所有图表
    1. 先使用 cluster_drawings 识别矢量图形
    2. 再提取嵌入式位图
    3. 自动过滤和去重
    """
    os.makedirs(output_dir, exist_ok=True)
    doc = fitz.open(pdf_path)
    results = {"vector": [], "embedded": []}

    for page_num in range(len(doc)):
        page = doc[page_num]

        # 1. 提取矢量图形
        try:
            rects = page.cluster_drawings(x_tolerance=3, y_tolerance=3)
            for idx, rect in enumerate(rects):
                if rect.width > 100 and rect.height > 100:
                    rect = (rect + (-10, -10, 10, 10)) & page.rect
                    zoom = dpi / 72
                    pix = page.get_pixmap(matrix=fitz.Matrix(zoom, zoom), clip=rect)
                    path = f"{output_dir}/p{page_num+1}_vec{idx+1}.png"
                    pix.save(path)
                    results["vector"].append(path)
        except:
            pass

        # 2. 提取嵌入式图片
        for img_idx, img in enumerate(page.get_images(full=True)):
            xref = img[0]
            base = doc.extract_image(xref)
            if base["width"] > 100 and base["height"] > 100:
                path = f"{output_dir}/p{page_num+1}_img{img_idx+1}.{base['ext']}"
                with open(path, "wb") as f:
                    f.write(base["image"])
                results["embedded"].append(path)

    doc.close()
    print(f"提取完成: {len(results['vector'])} 个矢量图, {len(results['embedded'])} 个位图")
    return results

# 使用示例
results = smart_extract_figures("paper.pdf", "./images/")

Common issues

Q: The extracted image contains multiple Figures merged together?

Decrease the x_tolerance and y_tolerance parameters (e.g., 1-2) to make clustering stricter.

Q: The same Figure is split into multiple parts?

Increase the tolerance parameters (e.g., 10-20) to merge adjacent elements.

Q: Some Figures are not recognized?

  1. It may be an embedded image; try the get_images() method
  2. Use the method of manually specifying a region

Q: The image is blurry?

Increase the dpi parameter to 300 or higher.


Usage

Basic usage

请阅读这篇论文,生成一篇专业的阅读笔记,适合发布到技术社区。

Specify the focus

请阅读这篇论文,重点分析:
1. HSTU 与标准 Transformer 的区别
2. Scaling Law 实验的设置和结论
3. 在工业场景的落地可行性

Comparative analysis

请对比分析这两篇论文在 XXX 问题上的不同解法。

Technical requirements

Content completeness

  • Core formulas must be included, explained item by item
  • Key algorithms have pseudocode implementations
  • Important hyperparameters and training details are not omitted
  • The key conclusions of ablation experiments should be distilled

Depth requirements

  • Analyze "why it is designed this way"
  • Establish connections with related work
  • Point out the boundaries and limitations of the method

Readability

  • Intuition first, then details
  • Code and formulas work together
  • Long formulas are explained step by step

Dependency configuration

# 图片提取
pip install pymupdf

# PDF 转图片(可选)
pip install pdf2image

MCP configuration (optional)

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@anthropic/mcp-server-filesystem", "/path/to/papers"]
    },
    "notion": {
      "command": "npx",
      "args": ["-y", "@notionhq/notion-mcp-server"],
      "env": {
        "OPENAPI_MCP_HEADERS": "{\"Authorization\": \"Bearer YOUR_TOKEN\", \"Notion-Version\": \"2022-06-28\"}"
      }
    }
  }
}