NanoShield ๐Ÿ›ก๏ธ

On-Device 50M Parameter Cryptographic & Cyber Assistant

A privacy-first, ultra-lightweight language model trained from scratch to audit source code and detect vulnerabilities entirely offline. Built strictly under the 50-million parameter limit for the Global Innovation Build Challenge V2 (Track 1: TECH).


๐Ÿ’ก Project Story

Inspiration

Developers consistently leak proprietary source code, API keys, and internal logs by pasting them into cloud-hosted LLMs for quick security checks. This exposes sensitive corporate data, creates vendor lock-in, and introduces network latency.

We wanted to solve this by ditching the bloated billions of parameters used for general conversation. Instead, we focused on a singular question: Can we compress elite cryptographic and security auditing capabilities into a model tiny enough to run locally on a standard laptop or smartphone? This drove us to build a custom, privacy-centric model within a strict 50M parameter ceiling.

โš™๏ธ What it Does

NanoShield is an on-device security assistant that requires zero internet connectivity. It scans code blocks, catches cryptographic mistakes (like weak hashing or hardcoded credentials), and identifies common OWASP vulnerabilities. Operating entirely in local memory, it eliminates data leakage risks and cuts API latency down to milliseconds.

๐Ÿ› ๏ธ How We Built It

Staying under the 50M parameter cap required tight architectural constraints and highly selective data choices:

  • The Architecture: Designed a custom, lean Transformer with optimized hidden dimensions, a shallow layer depth, and a restricted vocabulary size to maximize reasoning efficiency per parameter.
  • The Dataset: Ignored general web text to save capacity. We curated a specialized dataset focused entirely on clean code syntax, cryptographic primitives, and known vulnerability patterns.
  • The Training: Programmed a raw PyTorch training loop utilizing Mixed Precision (FP16), cosine learning rate decay, and strict tokenization filters to prevent the model from wasting capacity on redundant text patterns.

๐Ÿšง Challenges We Ran Into

With only 50 million parameters, there is no buffer for noisy data. Early training runs resulted in severe loss spikes and syntax confusion on longer code files. We also fought overfitting because security code patterns can be highly repetitive. We resolved this by aggressively deduplicating our source data, adjusting our attention head scaling, and tuning the dropout rates to stabilize convergence.

๐Ÿ† Accomplishments That We're Proud Of

We successfully engineered and trained a functional language model from the ground up that respects the strict 50M parameter limit. The model demonstrates genuine, localized understanding of code syntax and security flawsโ€”proving that hyper-curated data and architectural discipline can achieve deep utility at a fraction of commercial model sizes.

๐Ÿ”ฎ What's Next

  • Quantization: Compress the model weights to 4-bit to minimize the RAM footprint on low-spec mobile hardware.
  • IDE Integration: Wrap the local inference engine into a lightweight VS Code extension for live, offline code security warnings as you type.
  • Dataset Expansion: Extend training data to cover smart contract vulnerabilities and modern Rust/Go memory safety edge cases.

๐Ÿ“ Repository Structure

โ”œโ”€โ”€ config/
โ”‚   โ””โ”€โ”€ model_config.json      # Custom 50M parameter hyperparameters
โ”œโ”€โ”€ data/
โ”‚   โ”œโ”€โ”€ prepare_data.py        # Tokenization & code syntax preprocessing
โ”‚   โ””โ”€โ”€ secure_dataset.txt     # Curated security/crypto training text
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ model.py               # Custom Transformer architecture definition
โ”‚   โ”œโ”€โ”€ train.py               # PyTorch training loop & validation
โ”‚   โ””โ”€โ”€ inference.py           # Local CLI text generation & code scanner
โ”œโ”€โ”€ requirements.txt           # Minimal dependency list
โ””โ”€โ”€ README.md                  # Project documentation

๐Ÿš€ Quick Start (Local Inference)

1. Clone & Install

git clone https://github.com
cd nanoshield
pip install -r requirements.txt

2. Run the Security Scanner

Pass a local file to the model to scan for flaws securely:

python src/inference.py --checkpoint weights/best_model.pt --input sample_code.py

Built With

Share this project:

Updates

Submission history