Abhaykoul commited on
Commit
ea749e0
·
verified ·
1 Parent(s): e196cdc

Update README with comprehensive architecture and benchmark scores

Browse files
Files changed (1) hide show
  1. README.md +130 -21
README.md CHANGED
@@ -5,45 +5,154 @@ language:
5
  pipeline_tag: text-generation
6
  tags:
7
  - vortex
 
8
  - cybersecurity
9
  - cryptography
10
- - quantum-cryptography
11
- - on-device
12
- - sft
13
  ---
14
 
15
  # Vortex-50M (Cybersecurity & Cryptography Specialist)
16
 
17
- **Vortex-50M** is an on-device, sub-50M parameter decoder-only transformer with a 16,384-token vocabulary, fine-tuned (SFT) on [`VTXAI/cyber-crypto-balanced-qa`](https://huggingface.co/datasets/VTXAI/cyber-crypto-balanced-qa) from the base pretrained model [`VTXAI/vortex-50m-16k`](https://huggingface.co/VTXAI/vortex-50m-16k).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
- This edition balances high-fidelity technical Cybersecurity & Cryptography QA with strong general language modeling regularization, preventing catastrophic forgetting and keeping perplexity low.
20
 
21
- ## Model Architecture
22
- - **Parameters**: 49,846,528 (~49.85M, within 50M budget)
23
- - **Layers**: 18
24
- - **Hidden dimension**: 512
25
- - **Intermediate dimension**: 1072
26
- - **Attention heads**: 8 query heads, 2 key/value heads (Grouped Query Attention)
27
- - **Context length**: 2048
28
- - **Vocabulary size**: 16,387 (tied embeddings)
29
- - **Positional Embeddings**: RoPE (Rotary Position Embeddings)
30
- - **Normalization**: RMSNorm with QK-Norm
31
 
32
- ## Usage
 
 
 
 
 
 
 
 
 
 
33
 
34
  ```python
 
35
  from transformers import AutoModelForCausalLM, AutoTokenizer
36
 
37
  model_id = "VTXAI/vortex-50m"
 
 
38
  tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
39
- model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code=True)
 
 
 
 
 
40
 
 
41
  messages = [
42
- {"role": "user", "content": "What is two-factor authentication and why is it important?"}
 
 
 
 
 
 
 
43
  ]
 
44
  prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
45
- inputs = tokenizer(prompt, return_tensors="pt")
46
 
47
- outputs = model.generate(**inputs, max_new_tokens=60, do_sample=True, temperature=0.3, repetition_penalty=1.15)
48
- print(tokenizer.decode(outputs[0], skip_special_tokens=True))
 
 
 
 
 
 
 
 
 
 
 
 
49
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  pipeline_tag: text-generation
6
  tags:
7
  - vortex
8
+ - sft
9
  - cybersecurity
10
  - cryptography
11
+ - pytorch
12
+ - transformers
 
13
  ---
14
 
15
  # Vortex-50M (Cybersecurity & Cryptography Specialist)
16
 
17
+ A **49,846,528-parameter** instruction-tuned decoder-only Transformer, built from first principles on `torch.nn` and fine-tuned for specialized **cybersecurity, network defense, threat analysis, and cryptographic protocols**.
18
+
19
+ ```
20
+ 49,846,528 params · 512d × 18L · 8Q/2KV GQA · vocab 16,387 (tied)
21
+ 17% embedding / 83% transformer blocks · Strictly within 50M parameter budget
22
+ ```
23
+
24
+ | Specification | Value |
25
+ |:---|:---|
26
+ | **Base Pretrained Model** | [`VTXAI/vortex-50m-16k`](https://huggingface.co/VTXAI/vortex-50m-16k) (trained from scratch on 1B tokens) |
27
+ | **Total Parameters** | **49,846,528** (99.69% of the 50,000,000 competition budget) |
28
+ | **Fine-Tuning Dataset** | [`VTXAI/cyber-crypto-balanced-qa`](https://huggingface.co/datasets/VTXAI/cyber-crypto-balanced-qa) |
29
+ | **Architecture Design** | Custom `VortexForCausalLM` (`trust_remote_code=True`), tied embeddings, QK-Norm, RoPE, ChatML |
30
+ | **Domain Focus** | Network security, CVE triage, symmetric/asymmetric cryptography, reverse engineering, web security |
31
+
32
+ ---
33
+
34
+ ## Benchmark Results
35
+
36
+ Evaluated directly via EleutherAI's `lm-evaluation-harness` across 4 standard multiple-choice and reasoning tasks using length normalization where applicable:
37
+
38
+ | Task / Benchmark | Primary Metric | Score | Stderr | Evaluation Grader |
39
+ |:---|:---:|:---:|:---:|:---|
40
+ | **PIQA** | `acc_norm` | **54.13%** | ±1.16% | Physical commonsense reasoning |
41
+ | **WinoGrande** | `acc` | **52.41%** | ±1.40% | Pronoun disambiguation & commonsense |
42
+ | **ARC-Easy** | `acc_norm` | **35.52%** | ±0.98% | Grade-school science question answering |
43
+ | **HellaSwag** | `acc_norm` | **27.23%** | ±0.44% | Hard commonsense NLI / continuation |
44
+ | **Scored Average** | - | **42.32%** | - | **Mean across all 4 competition tasks** |
45
+
46
+ > **Evaluation Methodology**: All benchmarks are scored using `src/eval_competition.py` with the official EleutherAI harness. No hosted inference APIs were touched during training or evaluation.
47
+
48
+ ---
49
+
50
+ ## Parameter Accounting & Budget
51
+
52
+ The parameter budget is verified from the live module tree using `src/param_count.py`:
53
+
54
+ ```
55
+ ==================================================================
56
+ vortex-50m
57
+ ==================================================================
58
+ hidden 512
59
+ layers 18
60
+ heads 8Q / 2KV
61
+ head_dim 64
62
+ intermediate 1072
63
+ context 2048
64
+ vocab 16,387 (tied=True)
65
+ ------------------------------------------------------------------
66
+ TRAINABLE PARAMS 49,846,528
67
+ budget 50,000,000
68
+ verdict [PASS] 49.847M (99.69% of budget)
69
+ ------------------------------------------------------------------
70
+ embedding 8,390,144 16.8%
71
+ attention 11,798,784 23.7%
72
+ mlp 29,638,656 59.5%
73
+ norm 512 0.0%
74
+ --- ---
75
+ in transformer blocks 41,456,384 83.2%
76
+ ==================================================================
77
+ ```
78
+
79
+ `lm_head` is tied to the input embedding table, ensuring maximum capacity is directed into the 18 transformer layers (83.2% of weights inside transformer blocks).
80
 
81
+ ---
82
 
83
+ ## Architectural Principles at 50M Parameters
 
 
 
 
 
 
 
 
 
84
 
85
+ - **Depth over Width via Compact Vocab**: A custom 16,384 BPE vocabulary costs only ~8.4M parameters in the embedding table (17% of budget). In contrast, standard 32K or 150K vocabularies consume 35% to 150%+ of a 50M budget before a single layer can be placed. This allows Vortex-50M to run **18 deep layers** at 512 hidden dimension.
86
+ - **Grouped-Query Attention (GQA 8/2)**: 8 query heads and 2 key/value heads provide a 4× KV cache reduction for fast on-device inference without sacrificing reasoning quality.
87
+ - **QK-Norm (RMSNorm on Q and K)**: Applied per head before attention computation to prevent attention entropy collapse and numerical instability at small scales.
88
+ - **SwiGLU MLP**: Intermediate dimension of 1,072 (2.09× hidden dimension) with SwiGLU activation for superior non-linear representation capacity.
89
+ - **ChatML Format & Special Control Tokens**: Native support for `<|im_start|>` and `<|im_end|>` sequence markers with assistant-only loss masking during instruction tuning.
90
+
91
+ ---
92
+
93
+ ## Quickstart & Inference
94
+
95
+ Vortex-50M runs natively with Hugging Face `transformers` using `trust_remote_code=True`:
96
 
97
  ```python
98
+ import torch
99
  from transformers import AutoModelForCausalLM, AutoTokenizer
100
 
101
  model_id = "VTXAI/vortex-50m"
102
+
103
+ # Load tokenizer and model
104
  tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
105
+ model = AutoModelForCausalLM.from_pretrained(
106
+ model_id,
107
+ torch_dtype=torch.bfloat16 if torch.cuda.is_available() else torch.float32,
108
+ device_map="auto",
109
+ trust_remote_code=True
110
+ )
111
 
112
+ # Format prompt using ChatML
113
  messages = [
114
+ {
115
+ "role": "system",
116
+ "content": "You are Vortex-50M, an expert cybersecurity and cryptography assistant."
117
+ },
118
+ {
119
+ "role": "user",
120
+ "content": "Explain why AES-GCM is preferred over AES-CBC with HMAC in modern network protocols."
121
+ }
122
  ]
123
+
124
  prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
125
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
126
 
127
+ # Generate response
128
+ with torch.no_grad():
129
+ outputs = model.generate(
130
+ **inputs,
131
+ max_new_tokens=96,
132
+ do_sample=True,
133
+ temperature=0.3,
134
+ repetition_penalty=1.15,
135
+ pad_token_id=tokenizer.pad_token_id,
136
+ eos_token_id=tokenizer.eos_token_id
137
+ )
138
+
139
+ response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
140
+ print(response)
141
  ```
142
+
143
+ ---
144
+
145
+ ## Training & Fine-Tuning Pipeline
146
+
147
+ 1. **Pretraining**: Pretrained from random initialization on 1 Billion tokens of curated high-quality web text (`cosmopedia-v2` + `fineweb-edu-dedup`) using cosine decay down to 10% peak LR.
148
+ 2. **Supervised Instruction Tuning (SFT)**: Fine-tuned with ChatML masking on [`VTXAI/cyber-crypto-balanced-qa`](https://huggingface.co/datasets/VTXAI/cyber-crypto-balanced-qa) using AdamW (`lr=1.8e-5`, weight decay `0.01`, cosine scheduler).
149
+ 3. **Loss Masking**: User prompts and system instructions are masked out of the loss calculation; gradients are computed strictly on assistant generation tokens.
150
+
151
+ ---
152
+
153
+ ## Verification & Integrity
154
+
155
+ The model passes all pre-flight and runtime consistency suites in `src/`:
156
+ - **Parity Check** (`src/test_hf_modeling.py`): Bit-exact agreement between custom `torch.nn` training code and Hugging Face `AutoModelForCausalLM`.
157
+ - **Roundtrip Check** (`src/test_export_hf.py`): Verified export, weight reload, and token generation consistency in clean environments.
158
+ - **Budget Compliance** (`src/param_count.py`): Verified 49,846,528 params ≤ 50,000,000 budget.