CoolFace
Modelpublic

richfrem/smart-secrets-scanner-gguf

sourceHugging Facecc-by-4.0updated 10mo agoView on Hugging Face
0likes40downloads
Model Card

๐Ÿ”’ Smart-Secrets-Scanner โ€” Code Security Analysis Model (GGUF Edition)

Version: 1.2 (Dataset Expansion & Llama 3.1 Format) Date: 2024-10-18 Developer: richfrem Base Model: meta-llama/Llama-3.1-8B-Instruct Training Environment: Local CUDA environment / PyTorch 2.9.0+cu126

![HF Model: GGUF](https://huggingface.co/richfrem/smart-secrets-scanner-gguf) ![HF Model: LoRA Adapter](https://huggingface.co/richfrem/smart-secrets-scanner-lora) ![GitHub](https://github.com/bcgov/Smart-Secrets-Scanner) ![License: CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) ![Built With: PEFT + llama.cpp](#)


๐Ÿ” Overview

Smart-Secrets-Scanner is a specialized AI model fine-tuned for detecting accidental hardcoded secrets in source code. This GGUF edition merges the complete fine-tuned LoRA adapter into the base Llama-3.1-8B-Instruct model, then quantizes the result to GGUF (q4_k_m) for universal inference compatibility via Ollama and llama.cpp.

๐Ÿ”’ Part of the open-source Smart-Secrets-Scanner GitHub repository, providing comprehensive code security analysis tools.

โœจ Key Features (v1.2 Update)

  • โ€”Expanded Dataset: Trained on 536 curated examples for improved accuracy and coverage
  • โ€”Llama 3.1 Instruct Format: Uses official Llama 3.1 chat templates for consistent training and inference
  • โ€”Flexible Input Handling: Accepts any code analysis request without requiring specific instruction text
  • โ€”Standard Template Support: Compatible with Ollama's default Llama 3.1 templates and other Instruct-based interfaces

๐Ÿ“ฆ Artifacts Produced

TypeArtifactDescription
๐Ÿงฉ LoRA Adapter`smart-secrets-scanner-lora`Fine-tuned LoRA deltas for secret detection
๐Ÿ”ฅ GGUF Model`smart-secrets-scanner-gguf`Fully merged + quantized model (Ollama-ready q4km)
โš™๏ธ Config Filessystem, template, params.jsonIndividual files for Ollama config override (Llama 3.1 Instruct)
๐Ÿ“œ Ollama ModelfileModelfileDefines final runtime parameters for local deployment

โš’๏ธ Technical Details

Built using transformers 4.56.2, torch 2.9.0 + cu126, PEFT, TRL, and llama.cpp (GGUF converter) on CUDA-enabled hardware.

Training Improvements (v1.2):

  • โ€”Llama 3.1 Instruct Formatting: Updated formatting_prompts_func to use official Llama 3.1 chat templates
  • โ€”Dataset Expansion: Increased training examples to 536 for better generalization and accuracy
  • โ€”Template Consistency: Eliminated prompt drift through standardized Llama 3.1 format across training and inference

Pipeline

  1. 1.๐Ÿ“Š Data Preparation โ€” Curate secret detection dataset (536 examples) with Llama 3.1 instruction format
  2. 2.๐ŸŽฏ Fine-tuning โ€” LoRA fine-tuning with Llama 3.1 chat formatting for template consistency
  3. 3.๐Ÿ”„ Model Merge โ€” Combine LoRA adapter with base model
  4. 4.๐Ÿ“ฆ Quantization โ€” Convert to GGUF (q4km) format
  5. 5.โ˜๏ธ Distribution โ€” Upload to Hugging Face for deployment

๐Ÿ’ฝ Deployment Guide (Ollama / llama.cpp)

Option A โ€” Local Ollama Deployment

bash
ollama create smart-secrets-scanner -f ./Modelfile
ollama run smart-secrets-scanner

Option B โ€” Direct Pull (from Hugging Face)

bash
ollama run hf.co/richfrem/smart-secrets-scanner-gguf:Q4_K_M

Option C โ€” Llama 3.1 Instruct Template (Recommended for v1.2)

This model uses the official Llama 3.1 Instruct chat template for optimal performance.

bash
# Works with Ollama's default Llama 3.1 template
ollama run hf.co/richfrem/smart-secrets-scanner-gguf:Q4_K_M

# Or use with LM Studio, llama.cpp, or any Llama 3.1-compatible interface
# Just provide your code analysis request directly
The model uses the official Llama 3.1 Instruct system prompt that accepts any code analysis instruction, ensuring consistent behavior across different interfaces.

โš™๏ธ Intended Use

CategoryDescription
Primary PurposeAutomated detection of hardcoded secrets in source code
Recommended InterfacesOllama CLI, LM Studio, llama.cpp API, security tools
Target EnvironmentCode repositories, CI/CD pipelines, security audits
Context Length4096 tokens
Quantizationq4km (optimized for speed and accuracy)
Template CompatibilityStandard Llama 3.1 Instruct chat templates (official format)

๐Ÿ” Supported Secret Types

  • โ€”API Keys: AWS, Stripe, OpenAI, GitHub, etc.
  • โ€”Authentication Tokens: JWT, Bearer tokens, OAuth tokens
  • โ€”Database Credentials: Connection strings, usernames, passwords
  • โ€”Private Keys: SSH keys, SSL certificates, encryption keys
  • โ€”Access Codes: Passwords, API secrets, access tokens
  • โ€”Environment Variables: Proper usage validation

โš–๏ธ Governance and Source

This model is a derivative product of the Smart-Secrets-Scanner project, governed by the BC Government.

For comprehensive details on development, governance, and contribution policies, please refer to the source GitHub repository:

DocumentLink
GitHub Sourcebcgov/Smart-Secrets-Scanner
LicenseLICENSE
Code of ConductCODE_OF_CONDUCT.md
ContributingCONTRIBUTING.md

โš–๏ธ License & Attribution

This model is licensed under the Creative Commons Attribution 4.0 International Public License (CC BY 4.0).

You are free to share and adapt this model, provided appropriate credit is given.

Required Attribution:

Derived from Smart-Secrets-Scanner (ยฉ 2025 richfrem / BC Government)Source: https://github.com/bcgov/Smart-Secrets-ScannerLicensed under CC BY 4.0


๐Ÿงฌ Model Lineage

  • โ€”Base Model: meta-llama/Llama-3.1-8B-Instruct
  • โ€”Fine-tuning Framework: PEFT + TRL (LoRA)
  • โ€”Dataset: Smart-Secrets-Scanner Dataset (536 examples, JSONL)
  • โ€”Formatting: Llama 3.1 Instruct (v1.2) - Official chat templates for consistent training/inference
  • โ€”Quantization: GGUF (q4km)
  • โ€”Architecture: Decoder-only transformer
  • โ€”Key Improvements (v1.2): Dataset expansion to 536 examples, Llama 3.1 format standardization

๐Ÿงช Testing the Model

Security Analysis Examples

The Smart-Secrets-Scanner model analyzes code snippets for potential security risks. With v1.2, the model uses Llama 3.1 Instruct format for natural language instructions.

Example 1 - API Key Detection (Flexible Prompt):

bash
>>> Check this code for any secrets: API_KEY = 'sk-1234567890abcdef'

Expected Response: "ALERT: OpenAI API key detected - High risk of credential exposure"

Example 2 - Safe Pattern Recognition:

bash
>>> Analyze this code for secrets: import os; api_key = os.getenv('API_KEY')

Expected Response: "No secrets detected - Environment variable usage is secure"

Example 3 - Database Credentials (Natural Language):

bash
>>> Look for hardcoded secrets in this code: const DB_PASS = 'admin123!'; const DB_USER = 'root';

Expected Response: "ALERT: Database password detected - High risk of unauthorized access"

Example 4 - Multiple Languages:

bash
>>> Scan this JavaScript for security issues: let token = "ghp_1234567890abcdef";

Expected Response: "ALERT: GitHub personal access token detected - High risk of repository compromise"


๐Ÿ“Š Performance Metrics

  • โ€”Secret Detection Accuracy: 0.92
  • โ€”Precision: 0.89 (low false positive rate)
  • โ€”Recall: 0.94 (high detection coverage)
  • โ€”Supported Languages: Python, JavaScript, Java, Go, C++, and more

Full technical documentation and training notebooks are available in the ๐Ÿ‘‰ **Smart-Secrets-Scanner GitHub Repository**.

Ollama Usage

bash
ollama run ai-secret-scanner