mcpField
M
mpep-search

mpep-search

github.com/robthepcguy生产力20670 次安装3 天前更新
代码仓库

关于 mpep-search

mpep-search 是用于检索美国专利审查程序与相关法规的技能,面向查找专利规则依据的用户。它结合向量与关键词检索,并对结果重排。

主要功能

  1. 01混合向量与关键词检索
  2. 02HyDE 查询扩展
  3. 03交叉编码器重排
  4. 04按来源和内容类型筛选
  5. 05检索 MPEP 指定章节

适用场景

  1. 01查找专利审查程序条文
  2. 02检索 Title 35 法规内容
  3. 03定位 2024 年 1 月后的更新

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/robthepcguy/claude-patent-creator --skill mpep-search

安装后在 Claude Code 中输入/mpep-search确认已加载。

附带文件mpep_search.py

详细介绍

MPEP Search Skill

通过混合 RAG(FAISS 向量检索 + BM25 关键词检索 + HyDE + cross-encoder 重排序)搜索 MPEP 语料。

来源:

  • MPEP:专利审查程序手册
  • 35 USC:美国法典第 35 编
  • 37 CFR:联邦法规汇编第 37 编
  • 后续出版物:联邦公报更新(2024 年 1 月之后)

核心操作

1. search_mpep

输入:

  • query(字符串,必需):搜索查询(至少 3 个字符)
  • top_k(int,可选):结果数量(默认值:5,最大值:20)
  • retrieve_k(int | None,可选):重排序前的候选项数量(默认值:top_k * 4,最大值:100)
  • source_filter(string | None,可选):按来源筛选("MPEP"、"35_USC"、"37_CFR"、"SUBSEQUENT" 或 None)
  • is_statute(bool | None,可选):筛选法规内容
  • is_regulation(bool | None,可选):筛选规章内容
  • is_update(bool | None,可选):筛选近期更新

输出:

{
    "rank": int,
    "source": str,
    "section": str,
    "file": str,
    "page": int,
    "has_statute": bool,
    "has_mpep_ref": bool,
    "has_rule_ref": bool,
    "is_statute": bool,
    "is_regulation": bool,
    "is_update": bool,
    "relevance_score": float,
    "text": str,
    # Optional for SUBSEQUENT:
    "doc_type": str,
    "fr_citation": str,
    "effective_date": str
}

示例:

# Basic search
search_mpep("enablement requirement 35 USC 112", top_k=5)

# Search only statutes
search_mpep("written description", top_k=10, is_statute=True)

# Search recent updates
search_mpep("AI inventorship", is_update=True)

# Filter by source
search_mpep("fee schedule", source_filter="37_CFR")
2. get_mpep_section

检索特定 MPEP 章节的全部内容。

输入:

  • section_number(字符串,必需):MPEP 章节编号(例如,"2100"、"608.01")
  • max_chunks(int,可选):返回的最大文本块数(默认值:50)

输出:

{
    "section": str,
    "total_chunks": int,
    "chunks": [
        {
            "text": str,
            "metadata": {
                "source": str,
                "file": str,
                "page": int,
                "section": str,
                "has_statute": bool,
                "has_mpep_ref": bool,
                "has_rule_ref": bool,
                "is_statute": bool,
                "is_regulation": bool,
                "is_update": bool
            }
        }
    ]
}

错误响应:

{"error": "No content found for MPEP section {section_number}"}

示例:

# Get MPEP 2100 (Patentability)
get_mpep_section("2100", max_chunks=50)

# Get subsection
get_mpep_section("608.01")

输入验证

查询验证:

  • 至少 3 个字符
  • 不区分大小写
  • 不允许为空或仅包含空白字符的查询

章节编号验证:

  • 数字,可带小数点(例如,“100”、“2100”、“608.01”)

限制:

  • top_k 上限为 20
  • retrieve_k 上限为 100

实现说明

索引位置:

  • FAISS 索引:mcp_server/index/mpep_index.faiss
  • 元数据:mcp_server/index/mpep_metadata.json
  • BM25 索引:mcp_server/index/mpep_bm25.json

搜索架构:

  1. HyDE 查询扩展(假设文档)
  2. 混合检索(通过 RRF 进行 FAISS 向量检索 + BM25 关键词检索)
  3. Cross-Encoder 重排序(最终相关性评分)
  4. 元数据筛选(来源/类型筛选器)

依赖项:

  • sentence-transformers(BGE-base-en-v1.5)
  • FAISS(向量检索)
  • rank-bm25(关键词检索)
  • Cross-encoder(重排序)
  • HyDE(可选,支持优雅降级)

错误处理:

  • 缺少索引或查询无效时显示清晰的错误消息
  • HyDE 失败时优雅降级
  • 处理前验证输入

评论

支持 Markdown