Introduction
Proprietary embedding models from industry leaders like OpenAI and Cohere are often perceived as secure assets, protected by the "black-box" nature of their APIs. These models serve as the critical infrastructure for modern dense retrieval systems, enabling search engines to move beyond keyword matching to semantic understanding. However, new research demonstrates that these models are far more vulnerable than previously thought. For less than $300, an adversary can effectively "steal" the retrieval capabilities of these commercial models by training open-source student models to mimic their outputs.
Methodology: Black-Box Distillation
The core of this attack is a technique known as black-box distillation. Unlike traditional knowledge distillation, which requires access to a teacher model's internal weights or logits, this approach relies solely on the final embedding vectors returned by the API.
The Thief's Architecture
The researchers utilized standard, open-source BERT-base (110M parameters) and BERT-large (340M parameters) models as the "student" or "thief" models. To bridge the gap between BERT’s native output dimensions and the larger dimensions of commercial APIs (e.g., OpenAI’s 3072-dimensional vectors), a simple learnable linear layer was added to the student model.
Training and Loss Functions
The training process involved querying the target APIs with approximately 8.7 million passages from the MSMARCO v1 dataset. The primary objective was to align the direction of the student’s vectors with the teacher’s vectors using Cosine Distance Loss. While the researchers also experimented with Contrastive Loss, the simpler Cosine approach proved more effective and efficient for replicating the teacher's representation space.
Key Results: High-Fidelity Replication
The results of the distillation were striking. The "thief" models achieved retrieval effectiveness remarkably close to the original commercial APIs. In several in-domain tests using the TREC 2019 and 2020 Deep Learning tracks, the distilled models matched or even slightly exceeded the performance of the black-box teachers.
Beyond in-domain performance, the stolen models demonstrated impressive generalization capabilities. When evaluated on the BEIR benchmark—which covers diverse domains like biomedical search (BioASQ) and financial document retrieval (FiQA)—the models maintained high fidelity. This suggests that the distillation process captures the underlying semantic logic of the commercial models rather than merely memorizing the training data.
Advanced Insights: Teacher Synergy and Efficiency
One of the most significant findings was the benefit of Multi-Teacher Distillation. By distilling from both OpenAI and Cohere simultaneously into a single student model, the researchers created a more robust representation that outperformed students trained on a single teacher. This "synergy" allows the student to triangulate and aggregate the strengths of multiple proprietary systems.
Furthermore, the research highlighted that the "cost of theft" is remarkably low. Replicating flagship models cost under $300 in API fees and GPU rentals. The researchers also noted that Cohere’s use of a public BertTokenizer likely made their model easier to replicate, as the student and teacher shared a similar architectural "DNA."
Implications and Defensive Strategies
The ability to replicate high-value embedding models for a nominal fee has serious implications for intellectual property and security. An adversary could use a stolen model to avoid API costs, bypass privacy constraints by running models locally, or craft adversarial attacks to manipulate search rankings (black-hat SEO).
To defend against such attacks, the authors suggest that companies move away from standard, predictable backbones like BERT. Implementing customized or "noisy" architectures could make it significantly more difficult for an attacker to initialize a successful student model. In the interest of responsible disclosure, the researchers notified both OpenAI and Cohere of these vulnerabilities prior to publication and have withheld the release of their trained weights.
Summary updated