In the modern era of AI-accelerated software development, the speed at which code is written has introduced a new, critical challenge: the accidental exposure of sensitive credentials. Developers, moving at the pace of rapid iteration, occasionally push tokens, API keys, and passwords into repositories. While GitHub has long provided tools to mitigate this risk, the balance between catching legitimate security threats and avoiding "alert fatigue"—where developers are overwhelmed by false positives—has remained a difficult hurdle to clear. Today, GitHub is fundamentally changing that dynamic by moving away from heavy, remote large language model (LLM) calls in favor of a specialized, highly efficient, and context-aware classification pipeline.
The new approach marks a significant leap forward in security operations. By integrating a custom-trained, compact model into its scanning infrastructure, GitHub has achieved a 11.5% increase in alert precision—measured by how often repository owners accept the validity of a flagged secret—while simultaneously slashing median scan execution time by 86%. Perhaps most impressively, the transition from remote LLM calls to a compact, locally hosted model has reduced serving costs by more than 98%, proving that when it comes to security at scale, precision and efficiency often trump sheer model size.
The Problem with Traditional Secret Detection
At the heart of the challenge lies the ambiguity of "generic secrets." Many credentials, such as API tokens or internal passwords, do not always follow a distinct, easily identifiable syntax. In many cases, a string that appears to be a sensitive credential might, in fact, be a harmless documentation placeholder, a test fixture, or a benign build identifier. When security scanners rely solely on pattern-matching rules, they frequently flag these "lookalikes" as legitimate threats.
This creates a "hard negative" problem. If the scanning rules are too loose, the system misses real credentials, leaving repositories vulnerable to exploitation. If the rules are too strict, developers are bombarded with alerts that require manual investigation, consuming valuable time and breeding distrust in the security tool. As GitHub noted in its broader discussion on scaling secret protection, the rise of AI-driven coding assistants means that code is being generated and committed faster than ever. Security measures must not only keep pace with this velocity but must do so without creating a bottleneck for the developer experience.
A Two-Stage Pipeline for Precision
To solve this, GitHub has implemented a sophisticated, two-stage scanning architecture that prioritizes both breadth and accuracy. The system begins with a wide-reaching net, using traditional regular expression (regex) patterns to identify any string that even remotely resembles a credential. This ensures that the system does not miss potential threats at the outset.

However, rather than alerting the developer immediately, the system passes these candidates to a second, more discerning stage: a fine-tuned ModernBERT classifier. This model is designed specifically to understand context. It evaluates the candidate string not in isolation, but alongside the file path, surrounding code, variable names, and textual indicators. By analyzing whether a string is labeled as an "example" or "dummy" value, or whether it is assigned to an environment variable in a sensitive configuration file, the classifier can distinguish between a harmless test credential and a high-risk production key.
This hybrid approach leverages the strengths of both methodologies. Regex remains the gold standard for rapid, deterministic identification of potential candidates, while the ModernBERT classifier provides the "intelligent" layer of discernment required to filter out false positives. By keeping the model compact, GitHub ensures that this classification process happens with minimal latency, allowing the system to provide feedback to developers in real-time, often before they even finalize a push.
Redefining the Role of AI in Security
A common misconception in the current tech landscape is that larger models are inherently better at every task. The results of this new pipeline challenge that assumption. While general-purpose LLMs are powerful, their use in high-throughput, latency-sensitive environments like secret scanning often introduces unnecessary computational overhead and excessive serving costs.
For this specific task, GitHub found that a smaller, encoder-based model was not just more efficient, but actually more effective. Because the decision boundary for secret scanning is well-defined, the team could train the model directly on that boundary, ensuring high recall and precision. By focusing on a "compact" model, the engineers were able to export it to an ONNX format with 8-bit quantization, enabling near-instantaneous inference. This architecture demonstrates that for specialized security tasks, the "serving shape" of the model—how it fits into the broader production environment—is just as important as its raw performance.
Training for Real-World Scenarios
The efficacy of this new system is rooted in its training data. The team behind the scanner focused heavily on the "hard negatives"—the cases where syntax is misleading. The model was trained using a combination of real-world secrets, realistic false positives, and syntactically similar but benign strings. By exposing the model to these confusing examples, the developers taught it to look beyond the character composition of a string and toward the semantic meaning of its environment.
To ensure the model remains robust, GitHub implemented a rigorous evaluation process. Data was grouped by repository and example type to prevent "data leakage," where near-duplicates might bias the training or evaluation phases. Before any code was rolled out to production, the model underwent offline evaluation followed by rigorous A/B testing on live traffic. This measured approach allowed the engineering team to tune the classifier’s sensitivity threshold, ensuring that the system strikes the right balance between catching every possible threat and minimizing the friction caused by false alarms.
The Path Forward for Developer Security
The impact of this development extends beyond the raw metrics of speed and cost. For the developer, it means a more reliable security experience. When a tool provides high-quality, actionable alerts, it becomes a trusted partner in the development lifecycle rather than an annoyance to be ignored. By reducing the noise of false positives, GitHub is enabling developers to focus their energy on building software, confident that the security infrastructure is working quietly and effectively in the background.
Looking ahead, the success of this pipeline signals a shift in how GitHub approaches its broader security initiatives. The ability to deploy context-aware, lightweight classifiers creates new possibilities for detecting other types of vulnerabilities that have traditionally been difficult to catch with static analysis. As GitHub continues to refine its AI-driven security suite, the focus remains clear: building systems that are not only accurate and scalable but deeply integrated into the developer workflow.
This accomplishment, driven by the collaborative efforts of engineering and science teams across Microsoft and GitHub, underscores a fundamental truth in modern software development. Security, when done correctly, is not about adding friction—it is about providing the right level of intelligence at the right time. By moving from a reliance on heavy, remote models to a precision-engineered, local classification architecture, GitHub has set a new standard for what it means to keep software safe in the age of AI.

