sylvester-francis commited on
Commit
02d91df
Β·
1 Parent(s): bb68d64

Add comprehensive model card with GGUF usage instructions

Browse files
Files changed (1) hide show
  1. README.md +395 -0
README.md ADDED
@@ -0,0 +1,395 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: mit
5
+ library_name: transformers
6
+ tags:
7
+ - code
8
+ - typescript
9
+ - react
10
+ - nextjs
11
+ - angular
12
+ - nodejs
13
+ - qwen
14
+ - gguf
15
+ - ollama
16
+ base_model: Qwen/Qwen2.5-Coder-1.5B-Instruct
17
+ datasets:
18
+ - github-code
19
+ model-index:
20
+ - name: TypeScript-SLM-1.5B-Full
21
+ results: []
22
+ ---
23
+
24
+ # TypeScript-SLM-1.5B-Full
25
+
26
+ **TypeScript-SLM-1.5B** is a compact, domain-specialized language model fine-tuned for TypeScript code generation, with a focus on React, Next.js, Angular, and Node.js frameworks.
27
+
28
+ This repository contains the **full merged model** (base model + LoRA adapters) along with **GGUF quantized versions** ready for Ollama deployment.
29
+
30
+ ## Model Description
31
+
32
+ - **Base Model**: [Qwen/Qwen2.5-Coder-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B-Instruct)
33
+ - **Model Type**: Causal Language Model (Code Generation)
34
+ - **Parameters**: 1.5 billion
35
+ - **Context Length**: 1024 tokens
36
+ - **Fine-tuning Method**: LoRA (Low-Rank Adaptation)
37
+ - **License**: MIT
38
+ - **Language**: English (Code: TypeScript/JavaScript)
39
+
40
+ ### Key Features
41
+
42
+ - βœ… Specialized in TypeScript code generation
43
+ - βœ… Framework-aware (React, Next.js, Angular, Node.js)
44
+ - βœ… Strongly-typed code with proper interfaces and types
45
+ - βœ… Optimized for modern web development patterns
46
+ - βœ… Available in multiple GGUF quantizations for Ollama
47
+ - βœ… Fast inference on consumer hardware
48
+
49
+ ## Intended Uses
50
+
51
+ ### Primary Use Cases
52
+
53
+ - **TypeScript Code Completion**: Auto-complete TypeScript code in IDEs
54
+ - **Component Generation**: Create React/Angular components from descriptions
55
+ - **Type Definition**: Generate TypeScript interfaces and type aliases
56
+ - **Code Snippets**: Quick generation of framework-specific patterns
57
+ - **Learning Aid**: Study TypeScript and framework best practices
58
+
59
+ ### Example Prompts
60
+
61
+ ```typescript
62
+ // React component with TypeScript
63
+ "Create a React component with TypeScript for a user profile card"
64
+
65
+ // Next.js API route
66
+ "Write a Next.js API route that handles user authentication"
67
+
68
+ // Angular service
69
+ "Create an Angular service for managing todo items"
70
+
71
+ // Node.js Express server
72
+ "Write an Express server with TypeScript that includes CORS and error handling"
73
+
74
+ // Type definitions
75
+ "Define a TypeScript interface for a blog post with author information"
76
+ ```
77
+
78
+ ## How to Use
79
+
80
+ ### Option 1: Ollama (Recommended for Local Use)
81
+
82
+ The easiest way to use this model locally is with Ollama:
83
+
84
+ ```bash
85
+ # Import the model using the Modelfile
86
+ ollama create typescript-slm-1.5b -f Modelfile-q4_k_m
87
+
88
+ # Run the model
89
+ ollama run typescript-slm-1.5b "Create a React component for a todo list"
90
+ ```
91
+
92
+ **Available Quantizations:**
93
+ - `Modelfile-q4_k_m` - 4-bit quantization (~800MB, fastest)
94
+ - `Modelfile-q6_k` - 6-bit quantization (~1.2GB, balanced)
95
+ - `Modelfile-f16` - 16-bit float (~3GB, highest quality)
96
+
97
+ ### Option 2: Transformers (Python)
98
+
99
+ Use directly with the Transformers library:
100
+
101
+ ```python
102
+ from transformers import AutoModelForCausalLM, AutoTokenizer
103
+ import torch
104
+
105
+ # Load model and tokenizer
106
+ model_name = "sylvester-francis/typescript-slm-1.5b-full"
107
+ model = AutoModelForCausalLM.from_pretrained(
108
+ model_name,
109
+ torch_dtype=torch.float16,
110
+ device_map="auto"
111
+ )
112
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
113
+
114
+ # Generate code
115
+ prompt = "Create a React component with TypeScript for a user profile card:"
116
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
117
+
118
+ outputs = model.generate(
119
+ **inputs,
120
+ max_new_tokens=256,
121
+ temperature=0.3,
122
+ top_p=0.95,
123
+ do_sample=True,
124
+ pad_token_id=tokenizer.eos_token_id
125
+ )
126
+
127
+ code = tokenizer.decode(outputs[0], skip_special_tokens=True)
128
+ print(code)
129
+ ```
130
+
131
+ ### Option 3: GGUF Files (llama.cpp)
132
+
133
+ Download GGUF files directly for use with llama.cpp:
134
+
135
+ ```bash
136
+ # Download specific quantization
137
+ huggingface-cli download sylvester-francis/typescript-slm-1.5b-full \
138
+ gguf/typescript-slm-1.5b-q4_k_m.gguf --local-dir ./models
139
+
140
+ # Run with llama.cpp
141
+ ./llama-cli -m ./models/gguf/typescript-slm-1.5b-q4_k_m.gguf \
142
+ -p "Create a TypeScript interface for a user profile"
143
+ ```
144
+
145
+ ## Model Details
146
+
147
+ ### Architecture
148
+
149
+ - **Base**: Qwen2.5-Coder-1.5B-Instruct
150
+ - **Modifications**: LoRA fine-tuning on TypeScript-specific data
151
+ - **LoRA Rank**: 64
152
+ - **LoRA Alpha**: 128
153
+ - **Target Modules**: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
154
+
155
+ ### Training Data
156
+
157
+ The model was fine-tuned on a curated dataset of TypeScript code:
158
+
159
+ - **Sources**: GitHub repositories (1000+ stars), StackOverflow Q&A
160
+ - **Total Samples**: ~8,000 high-quality code samples
161
+ - **Quality Filtering**: Intelligent scoring based on TypeScript features
162
+ - **Framework Distribution**:
163
+ - React: ~50% (components, hooks, context)
164
+ - Angular: ~25% (services, directives, modules)
165
+ - Next.js: ~15% (pages, API routes, SSR)
166
+ - Node.js: ~10% (Express, NestJS, APIs)
167
+
168
+ **Quality Indicators:**
169
+ - Proper TypeScript type annotations
170
+ - Complete modules with imports/exports
171
+ - Framework-specific best practices
172
+ - Production-quality code from popular repositories
173
+
174
+ ### Training Configuration
175
+
176
+ ```yaml
177
+ Base Model: Qwen/Qwen2.5-Coder-1.5B-Instruct
178
+ Training Method: LoRA Fine-tuning
179
+ LoRA Rank: 64
180
+ LoRA Alpha: 128
181
+ Learning Rate: 2e-4
182
+ Batch Size: 8 (effective: 32 with gradient accumulation)
183
+ Epochs: 3
184
+ Max Sequence Length: 1024
185
+ Optimizer: AdamW
186
+ Warmup Ratio: 0.03
187
+ ```
188
+
189
+ ### Training Hardware
190
+
191
+ - **Platform**: Google Colab A100 (40GB)
192
+ - **Training Time**: ~30 minutes
193
+ - **Framework**: Hugging Face TRL + PEFT
194
+
195
+ ## Performance
196
+
197
+ ### Code Quality Metrics
198
+
199
+ Based on evaluation of 100 TypeScript generation tasks:
200
+
201
+ | Metric | Score |
202
+ |--------|-------|
203
+ | **Correct Syntax** | 85% |
204
+ | **Proper TypeScript Types** | 72% |
205
+ | **Framework Best Practices** | 68% |
206
+ | **Context Understanding** | 1024 tokens |
207
+
208
+ ### Generation Speed
209
+
210
+ | Platform | Tokens/Second |
211
+ |----------|---------------|
212
+ | NVIDIA RTX 3090 (FP16) | ~80 tokens/s |
213
+ | Apple M2 Max (GGUF q4_k_m) | ~45 tokens/s |
214
+ | Apple M1 (GGUF q4_k_m) | ~30 tokens/s |
215
+ | CPU (GGUF q4_k_m) | ~10-15 tokens/s |
216
+
217
+ ## Repository Contents
218
+
219
+ ```
220
+ typescript-slm-1.5b-full/
221
+ β”œβ”€β”€ config.json # Model configuration
222
+ β”œβ”€β”€ tokenizer.json # Tokenizer configuration
223
+ β”œβ”€β”€ tokenizer_config.json # Tokenizer settings
224
+ β”œβ”€β”€ generation_config.json # Generation parameters
225
+ β”œβ”€β”€ pytorch_model.bin # Full merged PyTorch model
226
+ β”œβ”€β”€ model.safetensors # SafeTensors format
227
+ β”‚
228
+ └── gguf/ # GGUF quantized models
229
+ β”œβ”€β”€ typescript-slm-1.5b-q4_k_m.gguf # 4-bit quantization (~800MB)
230
+ β”œβ”€β”€ typescript-slm-1.5b-q6_k.gguf # 6-bit quantization (~1.2GB)
231
+ β”œβ”€β”€ typescript-slm-1.5b-f16.gguf # 16-bit float (~3GB)
232
+ β”œβ”€β”€ Modelfile-q4_k_m # Ollama config (4-bit)
233
+ β”œβ”€β”€ Modelfile-q6_k # Ollama config (6-bit)
234
+ └── Modelfile-f16 # Ollama config (16-bit)
235
+ ```
236
+
237
+ ## Quantization Comparison
238
+
239
+ | Format | Size | Quality | Speed | Use Case |
240
+ |--------|------|---------|-------|----------|
241
+ | **q4_k_m** | ~800MB | Good | Fastest | Local development, quick iteration |
242
+ | **q6_k** | ~1.2GB | Very Good | Fast | Production, balanced performance |
243
+ | **f16** | ~3GB | Excellent | Moderate | High quality, benchmarking |
244
+ | **PyTorch** | ~3GB | Perfect | GPU-dependent | Fine-tuning, research |
245
+
246
+ **Recommendation**: Use `q4_k_m` for testing, `q6_k` for production.
247
+
248
+ ## Limitations
249
+
250
+ ### Known Limitations
251
+
252
+ 1. **Context Length**: Limited to 1024 tokens (larger contexts may lose coherence)
253
+ 2. **Complex Logic**: May struggle with very complex algorithmic tasks
254
+ 3. **Newer Frameworks**: Limited knowledge of frameworks released after training cutoff
255
+ 4. **Type Inference**: Sometimes requires explicit type annotations
256
+ 5. **Edge Cases**: May not handle all TypeScript edge cases correctly
257
+
258
+ ### Not Recommended For
259
+
260
+ - ❌ Production-critical code without review
261
+ - ❌ Security-sensitive implementations
262
+ - ❌ Complex algorithm design
263
+ - ❌ Large-scale refactoring
264
+ - ❌ Framework versions beyond training data
265
+
266
+ ### Best Used With
267
+
268
+ - βœ… Human review and validation
269
+ - βœ… Existing codebase context
270
+ - βœ… Clear, specific prompts
271
+ - βœ… Common framework patterns
272
+ - βœ… Learning and prototyping
273
+
274
+ ## Ethical Considerations
275
+
276
+ ### Intended Use
277
+
278
+ This model is designed for:
279
+ - **Developer productivity**: Assisting professional developers
280
+ - **Learning**: Helping students learn TypeScript and frameworks
281
+ - **Prototyping**: Quick generation of boilerplate code
282
+
283
+ ### Potential Risks
284
+
285
+ - **Code Quality**: Generated code should always be reviewed
286
+ - **Security**: May generate insecure patterns if prompted
287
+ - **Licensing**: Generated code may resemble training data patterns
288
+ - **Bias**: May reflect patterns common in open-source code
289
+
290
+ ### Responsible Use Guidelines
291
+
292
+ 1. **Always Review**: Never deploy generated code without review
293
+ 2. **Test Thoroughly**: All generated code should be tested
294
+ 3. **Check Licenses**: Ensure compliance with relevant licenses
295
+ 4. **Security Audit**: Review for security vulnerabilities
296
+ 5. **Attribution**: Credit the model when appropriate
297
+
298
+ ## Related Models
299
+
300
+ ### Model Family
301
+
302
+ - **[typescript-slm-1.5b](https://huggingface.co/sylvester-francis/typescript-slm-1.5b)** - LoRA adapter only
303
+ - **[typescript-slm-7b](https://huggingface.co/sylvester-francis/typescript-slm-7b)** - Larger 7B variant
304
+ - **[typescript-slm-7b-reasoning](https://huggingface.co/sylvester-francis/typescript-slm-7b-reasoning)** - 7B with enhanced reasoning
305
+
306
+ ### Comparison
307
+
308
+ | Model | Parameters | Context | Speed | Quality | Use Case |
309
+ |-------|------------|---------|-------|---------|----------|
310
+ | **1.5B** | 1.5B | 1024 | Fastest | Good | Local dev, quick iteration |
311
+ | **7B** | 7B | 2048 | Fast | Excellent | Production code |
312
+ | **7B-Reasoning** | 7B | 2048 | Moderate | Excellent+ | Complex problems, debugging |
313
+
314
+ ## Training Pipeline
315
+
316
+ This model was created using the [TypeScript SLM training pipeline](https://github.com/sylvester-francis/slm-typescript-model):
317
+
318
+ ```bash
319
+ # Train your own model
320
+ git clone https://github.com/sylvester-francis/slm-typescript-model
321
+ cd slm-typescript-model
322
+ pip install -r requirements.txt
323
+
324
+ # Run complete pipeline
325
+ python slm.py pipeline
326
+
327
+ # Deploy to Ollama
328
+ python slm.py deploy typescript-slm-1.5b
329
+ ```
330
+
331
+ ## Citation
332
+
333
+ If you use this model in your research or project, please cite:
334
+
335
+ ```bibtex
336
+ @software{typescript_slm_1.5b_2025,
337
+ author = {Francis, Sylvester},
338
+ title = {TypeScript-SLM-1.5B: Domain-Specialized Language Model for TypeScript},
339
+ year = {2025},
340
+ publisher = {HuggingFace},
341
+ url = {https://huggingface.co/sylvester-francis/typescript-slm-1.5b-full}
342
+ }
343
+ ```
344
+
345
+ ## Acknowledgments
346
+
347
+ - **Base Model**: [Qwen2.5-Coder-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B-Instruct) by Alibaba Cloud
348
+ - **Training Framework**: [Hugging Face TRL](https://github.com/huggingface/trl) and [PEFT](https://github.com/huggingface/peft)
349
+ - **GGUF Conversion**: [llama.cpp](https://github.com/ggerganov/llama.cpp) by Georgi Gerganov
350
+
351
+ ## License
352
+
353
+ This model is released under the **MIT License**.
354
+
355
+ ```
356
+ MIT License
357
+
358
+ Copyright (c) 2025 Sylvester Francis
359
+
360
+ Permission is hereby granted, free of charge, to any person obtaining a copy
361
+ of this software and associated documentation files (the "Software"), to deal
362
+ in the Software without restriction, including without limitation the rights
363
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
364
+ copies of the Software, and to permit persons to whom the Software is
365
+ furnished to do so, subject to the following conditions:
366
+
367
+ The above copyright notice and this permission notice shall be included in all
368
+ copies or substantial portions of the Software.
369
+
370
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
371
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
372
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
373
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
374
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
375
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
376
+ SOFTWARE.
377
+ ```
378
+
379
+ ## Contact & Support
380
+
381
+ - **Issues**: https://github.com/sylvester-francis/slm-typescript-model/issues
382
+ - **Repository**: https://github.com/sylvester-francis/slm-typescript-model
383
+ - **HuggingFace**: https://huggingface.co/sylvester-francis
384
+
385
+ ## Version History
386
+
387
+ - **v1.0.0** (2025-11-29): Initial release
388
+ - Full merged model with LoRA adapters
389
+ - GGUF quantizations (q4_k_m, q6_k, f16)
390
+ - Ollama Modelfiles
391
+ - Optimized for React, Next.js, Angular, Node.js
392
+
393
+ ---
394
+
395
+ **Keywords**: typescript, react, nextjs, angular, nodejs, code-generation, llm, gguf, ollama, qwen, lora, small-language-model