sandeeprdy1729 commited on
Commit
7bf1702
Β·
verified Β·
1 Parent(s): 9dad944

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +227 -0
README.md ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: Qwen/Qwen2.5-Coder-3B-Instruct
4
+ tags:
5
+ - prisma
6
+ - orm
7
+ - text-to-code
8
+ - code-generation
9
+ - qlora
10
+ - dpo
11
+ - grpo
12
+ - reinforcement-learning
13
+ language:
14
+ - en
15
+ library_name: transformers
16
+ pipeline_tag: text-generation
17
+ ---
18
+
19
+ # PrismaCoder-3B
20
+
21
+ PrismaCoder-3B is a [Qwen2.5-Coder-3B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-3B-Instruct)
22
+ fine-tune specialized for generating and editing [Prisma ORM](https://www.prisma.io/)
23
+ schemas and client code from natural-language instructions. It was trained
24
+ with a full SFT β†’ DPO β†’ GRPO pipeline, using a verifier (gate) as both the
25
+ data-quality filter and the reinforcement-learning reward signal.
26
+
27
+ > **Evaluation status:** full 1,200-task PrismaBench has been run and the
28
+ > numbers below are real. They currently reflect **static (V0) gate
29
+ > checking only** β€” parses correctly, code fences balanced, referenced
30
+ > models/fields grounded in the schema β€” **not** verified compile-and-execute
31
+ > correctness against a real database (the full V1–V5 gate chain, which
32
+ > needs a Node β‰₯18 environment not available during this evaluation). See
33
+ > Evaluation and Limitations below before treating pass@1 as "code that
34
+ > works."
35
+
36
+ ## Model Details
37
+
38
+ - **Base model:** Qwen/Qwen2.5-Coder-3B-Instruct
39
+ - **Parameters:** ~3B
40
+ - **Fine-tuning method:** QLoRA (r=16, Ξ±=32, all linear projections) at each
41
+ stage, LoRA weights merged into the base model between stages
42
+ - **Training stages:** SFT β†’ DPO β†’ GRPO (online RL, verifier reward) β†’
43
+ iterative self-play RL round (attempted; see Limitations)
44
+ - **Precision:** 4-bit NF4 (bitsandbytes) during training, fp16/bf16 merged
45
+ weights for release
46
+ - **License:** apache-2.0 (matches the base model)
47
+
48
+ ## Training Procedure
49
+
50
+ | Stage | Method | Key hyperparameters |
51
+ |---|---|---|
52
+ | SFT | Completion-only loss, soft-ordering difficulty mixture | QLoRA r16/Ξ±32, lr 1e-4, cosine schedule, 3% warmup, effective batch 16, 3 epochs |
53
+ | DPO | Preference optimization on gate-differential pairs (static + on-policy mined) | Ξ²=0.05, lr 5e-7, 1 epoch, effective batch 16 |
54
+ | GRPO | Online RL, reward = the same verifier used to filter training data | lr 1e-6, Ξ²=0.04, group size 2, effective batch 8 completions/step |
55
+ | RL round 2 | Best-of-*k* self-play distilled into a short DPO round | Attempted; skipped this run (see Limitations) |
56
+
57
+ All stages used seed `20260830` and ran on a single Kaggle T4 GPU (16GB) with
58
+ gradient checkpointing and paged 8-bit AdamW.
59
+
60
+ **Reward/gate design:** every stage is filtered or scored by the same static
61
+ verifier (`LightValidator`, "V0" in the project's internal gate numbering):
62
+ it checks that generated Prisma schema/client code parses, has balanced code
63
+ fences, and that referenced models/fields are actually grounded in the
64
+ provided schema. It does **not** check that the generated client code
65
+ compiles or executes correctly against a real database β€” that requires the
66
+ full gate chain (V1–V5, Node-based), which did not run in this training
67
+ environment. See Limitations.
68
+
69
+ ## Training Data
70
+
71
+ - **Corpus:** PrismaForge, a two-track dataset β€” a small mined track (real
72
+ `schema.prisma` files and call sites crawled from permissively-licensed
73
+ public repos) and a larger synthetic track (mechanically generated
74
+ task/schema pairs across families, domains, and difficulty levels).
75
+ - **Scale actually used for this model:** ~3,000 of ~17,500 available
76
+ finalized training records (`MAX_TRAIN_SAMPLES=3000`). This is smaller
77
+ than the project's full-scale design target (120,000 synthetic records);
78
+ results should be read as a proof-of-concept at this data scale, not the
79
+ ceiling of the method.
80
+ - **Contamination firewall:** training records whose provenance hash
81
+ matches a PrismaBench benchmark task are excluded from the training
82
+ splits before SFT.
83
+
84
+ ## Evaluation
85
+
86
+ **Benchmark:** PrismaBench, a 1,200-task benchmark (categories T1–T12,
87
+ difficulty levels L1–L3) built by the same project, with canary strings and
88
+ a provenance registry used for the contamination firewall above.
89
+
90
+ **Gate mode:** static V0 gates only (`static evaluation mode (no Node or
91
+ --full-gates not passed)` β€” printed by the evaluator on every run in this
92
+ environment). This distinction matters: V0-only pass@1 measures well-formed,
93
+ schema-grounded output; full-gate pass@1 (not yet run) would measure whether
94
+ the generated code actually compiles, migrates, and executes correctly.
95
+
96
+ | Stage | pass@1 (40-prompt internal proxy, V0 gates) |
97
+ |---|---|
98
+ | Base model (untrained) | 0.700 |
99
+ | + SFT | 0.975 |
100
+ | + DPO | 0.975 |
101
+ | + GRPO | 0.975 |
102
+ | + RL round 2 | 0.975 |
103
+
104
+ **Full PrismaBench, N=1,200, static V0 gates β€” checkpoint: `merged/grpo`**
105
+
106
+ | Metric | Value |
107
+ |---|---|
108
+ | pass@1 | 0.9992 |
109
+ | Wilson 95% CI | [0.9953, 0.9999] |
110
+ | Exact match | 0.0175 |
111
+ | CodeBLEU | 0.9332 |
112
+
113
+ The low exact-match alongside near-perfect pass@1 is expected, not a
114
+ red flag: pass@1 checks gate-level correctness (parses, balanced fences,
115
+ schema-grounded references), not verbatim agreement with a single reference
116
+ solution β€” code that is correct but phrased differently from the reference
117
+ scores low on exact-match by design.
118
+
119
+ **Per-category pass@1 (1,200 tasks):**
120
+
121
+ | Category | pass@1 |
122
+ |---|---|
123
+ | T1_schema_greenfield | 120/120 (1.00) |
124
+ | T2_schema_edit | 120/120 (1.00) |
125
+ | T3_migration_plan | 90/90 (1.00) |
126
+ | T4_client_crud | 150/150 (1.00) |
127
+ | T5_complex_reads | 139/140 (0.99) |
128
+ | T6_nested_writes_txn | 120/120 (1.00) |
129
+ | T7_aggregations | 100/100 (1.00) |
130
+ | T8_repo_completion | 120/120 (1.00) |
131
+ | T9_bug_fix | 100/100 (1.00) |
132
+ | T10_cross_file | 60/60 (1.00) |
133
+ | T11_performance | 60/60 (1.00) |
134
+ | T12_security | 20/20 (1.00) |
135
+
136
+ **Error taxonomy:** 1 failure classified `E4`; no other error classes
137
+ observed across 1,200 tasks.
138
+
139
+ **Which checkpoint this reflects:** RL round 2 also completed successfully
140
+ in training (self-play produced enough separable pairs this run, unlike an
141
+ earlier attempt) and reached the same 0.975 proxy score as GRPO, but the
142
+ 1,200-task benchmark above was run against the **GRPO** checkpoint
143
+ (`merged/grpo`), not `merged/rl2`. The RL round 2 checkpoint has not yet
144
+ been scored on the full benchmark β€” see Next Steps in the project repo
145
+ before treating GRPO as the final, best checkpoint.
146
+
147
+ **Baseline comparison:** the only benchmark comparison currently valid for
148
+ this card is against the *untrained* Qwen2.5-Coder-3B-Instruct base model,
149
+ scored on the identical 1,200-task set (0.700 proxy pass@1 pre-training;
150
+ full-benchmark base-model pass@1 not separately run). Comparisons against
151
+ other released coding models are not included here because they have not
152
+ been run through this same evaluator on this same held-out task set β€” a
153
+ fair comparison requires that, and until it's done, any such claim on this
154
+ card would be a number this project didn't actually measure.
155
+
156
+ ## Intended Use
157
+
158
+ - Generating and editing Prisma schema definitions and Prisma Client
159
+ TypeScript code from natural-language instructions.
160
+ - Assistance with schema migrations, CRUD operations, and query
161
+ composition against an existing Prisma schema.
162
+
163
+ ## Out-of-Scope / Limitations
164
+
165
+ - **Static gates only, by default.** Unless the model card above states
166
+ full V1–V5 gates were used, evaluation numbers reflect syntactic/grounding
167
+ correctness, not verified compile-and-run correctness.
168
+ - **RL round 2 completed but is not the published checkpoint.** In the
169
+ training run that produced these results, RL round 2 (self-play
170
+ distillation on top of GRPO) completed successfully and matched GRPO's
171
+ proxy score, but has not yet been scored on the full 1,200-task benchmark.
172
+ The checkpoint published here is **GRPO**, not RL round 2. If RL round 2
173
+ is later found to score higher on the full benchmark, this card and the
174
+ published weights will be updated to reflect that β€” check the repo's
175
+ commit history for the latest evaluated checkpoint.
176
+ - **DPO's curated (non-mined) pair supply was very small** in this training
177
+ run (2 static gate-differential pairs); most of DPO's signal came from
178
+ on-policy mining rather than the project's intended curated pair set.
179
+ - **Domain-specific.** This model is fine-tuned narrowly for Prisma ORM
180
+ code generation and is not evaluated on, or intended for, general-purpose
181
+ coding tasks outside that domain.
182
+ - Not evaluated for safety, security-sensitive code generation (e.g.
183
+ auth/permission logic beyond the benchmark's T12_security category), or
184
+ adversarial inputs.
185
+
186
+ ## How to Use
187
+
188
+ ```python
189
+ from transformers import AutoModelForCausalLM, AutoTokenizer
190
+
191
+ model_id = "sandeeprdy1729/PrismaCoder-3B"
192
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
193
+ model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
194
+
195
+ messages = [
196
+ {"role": "system", "content": "You are a Prisma ORM code generation assistant."},
197
+ {"role": "user", "content": "Add a `Comment` model related to an existing `Post` model, with a body field and a createdAt timestamp."},
198
+ ]
199
+ prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
200
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
201
+ out = model.generate(**inputs, max_new_tokens=640)
202
+ print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
203
+ ```
204
+
205
+ A GGUF export (`PrismaCoder-3B-f16.gguf`) is also provided for
206
+ llama.cpp/Ollama-based inference.
207
+
208
+ ## Training Infrastructure
209
+
210
+ Trained on Kaggle (single NVIDIA T4, 16GB), 4-bit QLoRA throughout, with
211
+ step-level checkpointing every 10–25 steps and cross-session resume to fit
212
+ within Kaggle's 12-hour session limit.
213
+
214
+ ## Citation
215
+
216
+ If you use this model, please cite the base model and note this fine-tune:
217
+
218
+ ```
219
+ @misc{prismacoder3b,
220
+ title = {PrismaCoder-3B: QLoRA/DPO/GRPO fine-tune of Qwen2.5-Coder-3B for Prisma ORM code generation},
221
+ author = {Thummala, Sandeep},
222
+ year = {2026},
223
+ url = {https://huggingface.co/sandeeprdy1729/PrismaCoder-3B}
224
+ }
225
+ ```
226
+
227
+ Base model: [Qwen2.5-Coder-3B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-3B-Instruct).