Pattern Usage Dataset
收藏资源简介:
Pattern Usage Dataset是由圣保罗大学研究团队构建的量子软件模式使用数据集,旨在记录开源项目中量子设计模式的采纳情况。该数据集包含从80个开源项目的904个Python脚本中提取的611个模式检测实例,覆盖23种量子模式,数据来源包括Qiskit、PennyLane、Classiq等五个量子框架。数据集通过qpa管道自动检测生成,结合知识库和语义匹配技术实现高精度识别。该数据集服务于量子软件工程领域,支持模式采纳分析、演化研究及工具评估,为理解量子编程实践提供了实证基础。
The Pattern Usage Dataset is a quantum software pattern usage dataset constructed by a research team from the University of São Paulo, which aims to document the adoption of quantum design patterns in open-source projects. This dataset contains 611 pattern detection instances extracted from 904 Python scripts across 80 open-source projects, covering 23 types of quantum patterns. Its data sources include five quantum frameworks such as Qiskit, PennyLane, and Classiq. The dataset is automatically generated via the qpa pipeline, with high-precision recognition achieved through the combination of knowledge base and semantic matching techniques. This dataset serves the field of quantum software engineering, supporting pattern adoption analysis, evolution research, and tool evaluation, and providing an empirical foundation for understanding quantum programming practices.
qpa — 量子模式分析器(Quantum Patterns Analyzer)数据集详情
概述
qpa 是一个开源的 Python 工具,用于自动挖掘开源项目中的量子计算模式使用情况。它从主流量子框架构建知识库,发现并克隆相关的 GitHub 仓库,并使用语义搜索在 Jupyter Notebook 中检测模式实现。该工具附带两个协同子系统:一个用于构建 Neo4j 谱系图(graph build),另一个用于 LLM 知识库分类评估(KB-classification evaluation)。
工作流程
工具分三个阶段运行:
- 数据收集:通过 GitHub API 查询 Python 量子仓库(按星标、贡献者和活跃度筛选),本地克隆仓库并下载 PlanQK 模式图谱。
- 知识库构建:从五个种子框架(Qiskit、PennyLane、Classiq、Qiskit Algorithms、Qiskit Machine Learning)提取核心量子概念,并对照模式目录分类;自动为每个目标项目构建动态知识库。
- 模式检测:将 Jupyter Notebook 转为 Python 脚本,通过四个活跃语义通道扫描,聚合结果生成结构化报告。
匹配通道
| 通道 | 启用状态 | 阈值 | 匹配内容 |
|---|---|---|---|
name |
是 | 0.88 | AST 提取的函数调用名 vs 知识库概念短名 |
summary |
是 | 0.78 | 文件注释块 vs 知识库概念文档摘要 |
title |
是 | 0.76 | Notebook 标题 vs 知识库概念摘要 |
pattern_desc |
是 | 0.80 | 文件注释块 vs 模式意图文本 |
defined_doc |
否 | 0.85 | 文件中定义的类/函数文档字符串 vs 知识库摘要 |
internal_keywords |
否 | 0.78 | 知识库概念内部标记签名 vs 调用点名称 |
internal_comments |
否 | 0.75 | 知识库概念内联注释 vs 文件注释块 |
后三个通道默认关闭,因为当前阈值下在全量语料上产生零匹配。另有关键词否决机制过滤基于文本的通道,运行时可通过配置文件调节。
当前数据集指标
| 指标 | 主要采用语料库 | 完整混合语料库 |
|---|---|---|
| 仓库数量 | 80 | 83 |
| 含脚本的仓库 | 47 | 50 |
| 分析的 Python 脚本 | 904 | 1,144 |
| 有匹配的项目 | 37 | 40 |
| 唯一检测数 | 611 | 1,100 |
| 唯一文件-模式对 | 500 | 880 |
| 有匹配的文件 | 358 | 531 |
| 检测到的模式(知识库中 23 种) | 23 | 23 |
Qrisp 留出评估结果
| 精确率 | 召回率 | F1 | |
|---|---|---|---|
| 微平均 | 0.913 | 0.583 | 0.712 |
| 宏平均 | 0.636 | 0.413 | 0.488 |
| 微平均(基线,无词汇扩展) | 0.846 | 0.306 | 0.449 |
基线行仅使用种子知识库;动态知识库将召回率从 0.306 提升至 0.583,微平均 F1 从 0.449 提升至 0.712。
关键输出文件
| 文件 | 描述 |
|---|---|
docs/third_party_final_pattern_report.md |
主要实践者采用报告(排除三个官方框架示例仓库) |
data/third_party_quantum_concept_matches_with_patterns.csv |
主要实践者采用检测数据集 |
docs/final_pattern_report.md |
完整混合语料报告 |
data/quantum_concept_matches_with_patterns.csv |
完整混合语料检测数据集 |
data/dynamic_kb/<project>/ |
各项目动态知识库条目 |
data/report/*.csv |
细分统计表 |
环境要求
- Python 3.12+(管道通过
uv创建自有.venv) just命令运行器- Git
- Docker(
just all及图谱构建必需;just lite不需要) - 可选环境变量:
GITHUB_TOKEN(仅用于刷新仓库发现)、TOGETHER_API_KEY(仅用于 LLM 知识库分类评估)
快速入门
使用 just all 可从已提交的仓库列表和固定提交进行端到端复制(首次运行 60–90 分钟),无需 API 密钥。也可单独运行各阶段命令,如种子知识库提取、动态知识库构建、模式检测、Qrisp 评估、图谱构建等。
嵌入模型
使用 all-mpnet-base-v2(sentence-transformers),最大 384 个 token,无 API 调用、无不确定性,保证可复现性。

- 1From Pattern Detection to Composition Analysis in Quantum Software圣保罗大学 · 2026年



