论文 Signed but Steerable: Measuring and Closing the Text-Vector Integrity Gap in Offline Retrieval-Augmented Generation(G. Feretzakis, A. Papaspyridis, securagen.ai)的代码、数据与结果。
已归档于 Zenodo:10.5281/zenodo.23945569(所有版本;发布版 v1.0.2, 论文中引用:10.5281/zenodo.23948839)。论文的 arXiv 标识符 将在可用时补充。
ragtrust/ 共享库,包括 codeverify.py,即用于所有代码验证结果的参考代码级验证器(歧义仅由验证器的
重新计算决定;仅邻居接受;规范化)。desktop/ 在桌面端运行的实验:弃权评分(E1)及其 MS MARCO 检查、向量失步攻击与边际定律(E7)、BEIR 边际、
向量数据库暴露面、FAISS 演示、代码级验证以及浮点流水线的确定性。device/ 在 Raspberry Pi 5 CPU 上运行的实验:上下文剪枝(E2)、语言模型旁验证的成本(E4)、
设备端嵌入与 INT8 保真度(E5)、端到端攻击(E7)以及包更新(E8)。analysis/ 分析、精度与单位检查,以及 make_figures.py,用于重新生成图表。data/ 由 SQuAD 派生的语料、窗口、问题与向量;results/ 各实验输出;
tests/ 单元测试;remote/ 用于从桌面端驱动 Pi 的辅助脚本(请调整主机名)。PROTOCOL.md 数据收集前固定的假设,以及偏差与探索性分析的日志。
实验编号遵循协议;E3 和 E6 不属于本发布版本。pins.json 模型与工具的固定修订版本。python tests/test_codeverify.py。bash desktop/setup_desktop.sh;图表:python analysis/make_figures.py。device/requirements_device.txt 的 Python,以及 pins.json 中指定提交的 llama.cpp。在 Raspberry Pi 上,执行 cp device/config.env.example device/config.env(调整路径)并将
device/requirements_device.txt 安装到 venv_device 后:
bash device/inner_generate.sh 启动 llama-server 并运行 k3_full(前 60 个问题,
可复现性检查)、k5_ce3、k10_ce3、k10_ce5、k5_bi3、带在线 INT8 选择器的 k5_ce3,以及 E7
配置;仅 CPU-INT8 端到端配置:bash device/run_e7_cpu_int8.sh。变体
k5_ce3w、k3_ce3 和 k3_ce3w 在 llama-server 运行时通过 python device/e2_generate.py --config <name> 运行
(启动方式同 device/inner_generate.sh)。当 results/e2/status_<name>.json
存在时,该配置会被跳过;将这些文件移走即可重新生成已发布的结果。python device/e4_contention.py;E5:python device/e5_reindex.py --backends ort-fp32,ort-int8 --batch 32(
已发布结果所用的批大小:动态 INT8 依赖批大小,批大小为 64 时会产生不同的向量);
E8:python device/e8_device_verify.py --vector-backend ort-fp32。remote/pi_sync.sh 将仓库复制到 Pi,remote/pi_fetch.sh 获取结果。results/e7/margin_law_squad.json;其他语料库与图 1:results/e7/beir_margins.json
和 results/e7/margins/;CPU-INT8 参考阈值下的暴露情况:results/e7/cpu_int8_exposure.json;
数值精度与单位检查:results/e7/margin_precision_check.json;INT8 参考阈值的校准
(精确分位数、其下的诚实窗口、batch 32 下逐位重新编码):
results/e5/int8_calibration_check.json(analysis/e5_int8_calibration_check.py)。results/e7/vecdb_quant.json;FAISS 审计与已执行的攻击:results/e7/faiss_integrity.json;
残差预算:results/e7/guard_budget.json。results/e7/analysis.json(正确答案与拒答)和 results/e7/e2e_checks.json
(相同问题、角度预算、payload 位于 top-3 上下文中)。results/e2/decomposition.json;语言模型旁的开销(E4):results/e4/。results/figures/fig_margin_law.pdf(图 1)和 results/figures/fig_vdb.pdf(图 2),由
analysis/make_figures.py 重新生成。results/e7/squad_question_vectors.npz
(analysis/margin_law_squad.py)和 results/e7/proxy_vectors.npz(analysis/margin_law.py)。results/e7/vecs/(由
desktop/beir_margins.py 写入)、results/e7/scale_*.npy(由代码验证脚本写入)、
data/beir/ 和 artifacts/models/(由 desktop/export_onnx.py 写入)。部分分析脚本会加载它们自己用 numpy.load(..., allow_pickle=True) 创建的缓存;
请仅从你自己的运行中加载此类文件,切勿从不受信任的来源加载。
模型、数据集及其许可证列于 DATA_LICENSES.md。使用相应部分时,请同时引用 SQuAD 2.0(Rajpurkar et al., 2018)、
BEIR(Thakur et al., 2021)、MS MARCO(Bajaj et al., 2016)、BGE-M3(Chen et al., 2024)和 Sentence-BERT(Reimers and
Gurevych, 2019)。
LICENSE)。Copyright 2026 securagen.ai P.C. 代码和我们的结果采用 MIT 许可证;源自 SQuAD 的数据、包含 SQuAD
文本的结果文件以及生成的答案保留 CC BY-SA 4.0;详情及其他数据集和模型的条款
见 LICENSE 和 DATA_LICENSES.md。