Downloads · 30 days
11
28% of all-time downloads
sylvester-francis/typescript-slm-1.5b
typescript-slm-1.5b is a text generation model from sylvester-francis. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as mit.
A specialized Small Language Model for TypeScript code generation and understanding, optimized for React, Next.js, Angular, and Node.js frameworks.
Downloads · 30 days
11
28% of all-time downloads
All-time downloads
39
Public
Repo size
1.3 GB
Likes
1
Public
Click a slice to open those files.
.pt887 MB · 58%
From the Hugging Face model README
A specialized Small Language Model for TypeScript code generation and understanding, optimized for React, Next.js, Angular, and Node.js frameworks.
This model is a fine-tuned version of Qwen/Qwen2.5-Coder-1.5B-Instruct using LoRA (Low-Rank Adaptation) for parameter-efficient fine-tuning. It has been trained on 2,000-8,000 high-quality TypeScript code samples focusing on modern web development frameworks.
Key Features:
The model was trained on a curated dataset of TypeScript code samples with the following distribution:
Dataset Quality Scoring:
Hardware:
Configuration:
Training Time:
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
# Load base model and tokenizer
base_model = "Qwen/Qwen2.5-Coder-1.5B-Instruct"
model = AutoModelForCausalLM.from_pretrained(
base_model,
device_map="auto",
torch_dtype="auto"
)
tokenizer = AutoTokenizer.from_pretrained(base_model)
# Load LoRA adapter
model = PeftModel.from_pretrained(model, "sylvester-francis/typescript-slm-1.5b")
# Generate code
prompt = """Write a React component that fetches user data and displays it in a card:
```typescript
"""
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=256,
temperature=0.7,
do_sample=True,
top_p=0.95
)
generated_code = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(generated_code)
prompt = """Create a TypeScript React component with props for a user profile card:
```typescript
interface UserProfileProps {
"""
# Generate with the model...
prompt = """Write a Next.js API route for user authentication:
```typescript
// pages/api/auth/login.ts
"""
# Generate with the model...
prompt = """Create an Angular service for HTTP data fetching:
```typescript
import { Injectable } from '@angular/core';
"""
# Generate with the model...
Specialized Domain: Works best for TypeScript and related frameworks. Performance degrades for other languages.
Training Data Bias: Reflects patterns from popular open-source repositories, which may not match all coding styles.
Context Length: Limited to 1024 tokens, which may be insufficient for very large files.
No Real-time Updates: Training data is static and doesn't include the latest framework versions or patterns.
Requires Human Review: Generated code should always be reviewed for security, correctness, and best practices.
Type Safety: While trained on typed code, generated types may not always be complete or optimal.
Software Stack:
Platform:
Full training code, dataset filtering, and usage examples: https://github.com/sylvester-francis/slm-typescript-model
@article{qwen2.5,
title={Qwen2.5-Coder Technical Report},
author={Qwen Team},
year={2024},
journal={arXiv preprint},
url={https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B-Instruct}
}
@misc{vonwerra2022trl,
title={{TRL: Transformer Reinforcement Learning}},
author={Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
year={2020},
journal={GitHub repository},
publisher={GitHub},
howpublished={\url{https://github.com/huggingface/trl}}
}
@article{hu2021lora,
title={LoRA: Low-Rank Adaptation of Large Language Models},
author={Hu, Edward J and Shen, Yelong and Wallis, Phillip and Allen-Zhu, Zeyuan and Li, Yuanzhi and Wang, Shean and Wang, Lu and Chen, Weizhu},
journal={arXiv preprint arXiv:2106.09685},
year={2021}
}
MIT License - See repository for full license text.