即使只有单个输出词元的API访问,也能推断大模型的架构参数。
Black-Box Inference of LLM Architectural Properties with Restrictive API Access

- 通过共现提示与谱分析,从有限输出中推断隐藏维度。
- 在32个开源模型上,隐藏维度平均误差仅23%(MoE模型9%)。
- 适合关注模型安全、逆向工程的研究者或开发者。
实践中,多数商业大模型提供商不公开底层架构细节。尽管先前研究显示,在仅有顶部k个logits或对数偏置函数的有限API访问下,仍可恢复部分架构信息(如前馈网络隐藏维度),但如今多数厂商已将API限制为仅返回每个解码词元的单一logit,且不再允许用户修改logits。本文提出NightVision,一种基于受限黑盒API的攻击方法,可在当前接口限制下仍估计模型的隐藏维度、深度及参数量。其核心是新颖的共现提示技术:多个提示暴露相同输出词元集的对数概率,通过谱分析推断隐藏维度;结合端到端首次生成时间(TTFT)与估算的隐藏维度,进一步推断深度与参数量。我们在32个开源模型上进行实证评估,隐藏维度平均相对误差为23%(MoE模型仅9%),参数量超三亿的模型深度和参数量估计误差在53%以内。通过大量消融实验,验证了精度随词元预算和模型特性变化的趋势。结果表明,现有大模型API仍未充分遮蔽底层架构细节。
原文摘要 · Abstract (English)
In practice, most commercial LLM providers do not publicly release details of underlying LLM architectures. However, prior work has shown that given limited API access to an LLM (namely, top-$k$ logits and/or a logit bias function), one can recover certain architectural details of an LLM, such as the hidden dimension of the feed-forward network. Perhaps in response to these results, most commercial LLM providers have restricted their APIs to expose only the single logit for each decoded token, and they no longer give users the ability to bias logits. We show that even under current restrictive APIs, several architectural parameters are still recoverable. We present NightVision, an attack that uses restrictive black-box API access to estimate the hidden dimension, depth, and parameter count of an LLM. Algorithmically, NightVision relies on a novel common set prompting technique in which multiple prompts expose log probabilities for the same set of output tokens; a spectral analysis of these results is used to infer hidden dimension. NightVision additionally uses end-to-end time to first token (TTFT) measurements and the estimated hidden dimension to estimate depth and parameter count. We empirically evaluate NightVision on 32 open-source LLMs, recovering hidden dimension to within 23% average relative error across all models (9% on MoE models), and depth and parameter count to within 53% for models exceeding three billion parameters. We run extensive ablations to demonstrate how these accuracies scale with token budget and model properties. Overall, our results suggest that current LLM APIs are not sufficiently restricted to fully obfuscate the architectural details of their underlying models.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。