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
+
- code
|
| 8 |
+
- typescript
|
| 9 |
+
- reasoning
|
| 10 |
+
- react
|
| 11 |
+
- nextjs
|
| 12 |
+
- angular
|
| 13 |
+
- nodejs
|
| 14 |
+
- deepseek
|
| 15 |
+
- gguf
|
| 16 |
+
- ollama
|
| 17 |
+
base_model: deepseek-ai/DeepSeek-R1-Distill-Qwen-7B
|
| 18 |
+
datasets:
|
| 19 |
+
- github-code
|
| 20 |
+
model-index:
|
| 21 |
+
- name: TypeScript-SLM-7B-Reasoning-Full
|
| 22 |
+
results: []
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+
# TypeScript-SLM-7B-Reasoning-Full
|
| 26 |
+
|
| 27 |
+
**TypeScript-SLM-7B-Reasoning** is a 7B-parameter DeepSeek-based model fine-tuned for step-by-step TypeScript reasoning. It merges the base model with LoRA adapters and includes GGUF quantization for local/Ollama workflows.
|
| 28 |
+
|
| 29 |
+
This repository hosts the **full merged model** plus **GGUF (q4_k_m)** for lightweight inference.
|
| 30 |
+
|
| 31 |
+
## Model Description
|
| 32 |
+
|
| 33 |
+
- **Base Model**: [deepseek-ai/DeepSeek-R1-Distill-Qwen-7B](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-7B)
|
| 34 |
+
- **Model Type**: Causal LM (code reasoning)
|
| 35 |
+
- **Parameters**: 7B
|
| 36 |
+
- **Context Length**: Inherits base DeepSeek-R1-Distill-Qwen-7B window
|
| 37 |
+
- **Fine-tuning**: LoRA on TypeScript reasoning/debugging tasks
|
| 38 |
+
- **License**: MIT
|
| 39 |
+
- **Language**: English, TypeScript/JavaScript code
|
| 40 |
+
- **System Prompt**: Focus on step-by-step debugging, refactoring, and design-level explanations before giving the final typed solution.
|
| 41 |
+
|
| 42 |
+
### What it is good at
|
| 43 |
+
- ✅ Explaining TypeScript bugs and fixes
|
| 44 |
+
- ✅ Refactoring and API design discussions
|
| 45 |
+
- ✅ Generating strongly-typed code for React/Next.js/Angular/Node.js
|
| 46 |
+
- ✅ Producing clear reasoning traces before final answers
|
| 47 |
+
|
| 48 |
+
## Intended Uses
|
| 49 |
+
|
| 50 |
+
**Primary**: TypeScript reasoning, debugging, refactoring, and guided code generation.
|
| 51 |
+
**Out-of-scope**: Arbitrary natural-language chat unrelated to code; safety-sensitive or factual tasks outside TypeScript.
|
| 52 |
+
|
| 53 |
+
### Prompt Examples
|
| 54 |
+
|
| 55 |
+
```
|
| 56 |
+
"Debug this TypeScript function and explain the bug step by step:\n\nfunction add(a?: number, b?: number) { return a + b; }"
|
| 57 |
+
|
| 58 |
+
"Design a typed API surface for a Next.js todo service. Explain design choices, then show the final code."
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
## How to Use
|
| 62 |
+
|
| 63 |
+
### Ollama (recommended for local)
|
| 64 |
+
|
| 65 |
+
```bash
|
| 66 |
+
ollama create typescript-slm-7b-reasoning -f gguf/Modelfile-q4_k_m
|
| 67 |
+
ollama run typescript-slm-7b-reasoning "Explain why this React hook re-renders too often..."
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
### Transformers
|
| 71 |
+
|
| 72 |
+
```python
|
| 73 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 74 |
+
import torch
|
| 75 |
+
|
| 76 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 77 |
+
"sylvester-francis/typescript-slm-7b-reasoning-full",
|
| 78 |
+
torch_dtype=torch.float16,
|
| 79 |
+
device_map="auto",
|
| 80 |
+
)
|
| 81 |
+
tokenizer = AutoTokenizer.from_pretrained("sylvester-francis/typescript-slm-7b-reasoning-full")
|
| 82 |
+
|
| 83 |
+
prompt = "Refactor this TypeScript service for better typing and error handling..."
|
| 84 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 85 |
+
outputs = model.generate(
|
| 86 |
+
**inputs,
|
| 87 |
+
max_new_tokens=512,
|
| 88 |
+
temperature=0.3,
|
| 89 |
+
top_p=0.95,
|
| 90 |
+
do_sample=True,
|
| 91 |
+
pad_token_id=tokenizer.eos_token_id,
|
| 92 |
+
)
|
| 93 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
### GGUF (llama.cpp)
|
| 97 |
+
|
| 98 |
+
```bash
|
| 99 |
+
huggingface-cli download sylvester-francis/typescript-slm-7b-reasoning-full \
|
| 100 |
+
gguf/typescript-slm-7b-reasoning-q4_k_m.gguf --local-dir ./models
|
| 101 |
+
|
| 102 |
+
./llama-cli -m ./models/gguf/typescript-slm-7b-reasoning-q4_k_m.gguf \
|
| 103 |
+
-p "Explain and fix this TypeScript type error..."
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
## Model Files
|
| 107 |
+
|
| 108 |
+
- `gguf/typescript-slm-7b-reasoning-q4_k_m.gguf` (≈4.7GB)
|
| 109 |
+
- `gguf/Modelfile-q4_k_m` (Ollama import)
|
| 110 |
+
|
| 111 |
+
## Training Data (summary)
|
| 112 |
+
|
| 113 |
+
- Curated TypeScript code from popular GitHub repos (React, Next.js, Angular, Node.js)
|
| 114 |
+
- StackOverflow Q&A focused on debugging and reasoning
|
| 115 |
+
- Filters for strong typing, framework best practices, and reasoning-rich examples
|
| 116 |
+
|
| 117 |
+
## Training Configuration (LoRA)
|
| 118 |
+
|
| 119 |
+
```yaml
|
| 120 |
+
Base Model: deepseek-ai/DeepSeek-R1-Distill-Qwen-7B
|
| 121 |
+
Method: LoRA fine-tuning
|
| 122 |
+
Target Domains: TypeScript reasoning, debugging, refactoring
|
| 123 |
+
LoRA Rank / Alpha: tuned for stability and reasoning depth
|
| 124 |
+
Optimizer: AdamW
|
| 125 |
+
Max Sequence Length: inherits base model context window
|
| 126 |
+
```
|
| 127 |
+
|
| 128 |
+
## Evaluation
|
| 129 |
+
|
| 130 |
+
Qualitative checks on TypeScript debugging/refactoring prompts show:
|
| 131 |
+
- Clear reasoning steps before final code
|
| 132 |
+
- Strong type usage and framework-aware patterns
|
| 133 |
+
- Concise, actionable fixes
|
| 134 |
+
|
| 135 |
+
## Safety & Limitations
|
| 136 |
+
|
| 137 |
+
- May generate incorrect code or hallucinate APIs—review before production use.
|
| 138 |
+
- Not a security scanner; do not rely on it for vulnerability assessments.
|
| 139 |
+
- Avoid non-code or high-stakes factual tasks.
|
| 140 |
+
|
| 141 |
+
## License
|
| 142 |
+
|
| 143 |
+
MIT for the fine-tuned model; base model license and dataset terms also apply.
|
| 144 |
+
|
| 145 |
+
## Contact
|
| 146 |
+
|
| 147 |
+
- Maintainer: Sylvester Francis (`@sylvester-francis` on Hugging Face)
|
| 148 |
+
- Issues/feedback: open a discussion on the model repo
|