Text Generation
PEFT
Safetensors
Transformers
English
typescript
code-generation
react
nextjs
angular
nodejs
lora
sft
7b
trl
conversational
Instructions to use sylvester-francis/typescript-slm-7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use sylvester-francis/typescript-slm-7b with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-Coder-7B-Instruct") model = PeftModel.from_pretrained(base_model, "sylvester-francis/typescript-slm-7b") - Transformers
How to use sylvester-francis/typescript-slm-7b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="sylvester-francis/typescript-slm-7b") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("sylvester-francis/typescript-slm-7b", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use sylvester-francis/typescript-slm-7b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "sylvester-francis/typescript-slm-7b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sylvester-francis/typescript-slm-7b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/sylvester-francis/typescript-slm-7b
- SGLang
How to use sylvester-francis/typescript-slm-7b with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "sylvester-francis/typescript-slm-7b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sylvester-francis/typescript-slm-7b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "sylvester-francis/typescript-slm-7b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sylvester-francis/typescript-slm-7b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use sylvester-francis/typescript-slm-7b with Docker Model Runner:
docker model run hf.co/sylvester-francis/typescript-slm-7b
TypeScript SLM 7B
Standard 7B TypeScript model for TypeScript code generation, optimized for React, Next.js, Angular, and Node.js.
Model Details
- Base Model: Qwen/Qwen2.5-Coder-7B-Instruct
- Model Size: 7B parameters
- Training Method: LoRA (Low-Rank Adaptation)
- Context Length: 2048 tokens
- LoRA Rank: 64
- Training Dataset: 5,000 high-quality TypeScript samples
Training Configuration
- Batch Size: 2
- Gradient Accumulation: 16
- Effective Batch Size: 32
- Learning Rate: 0.0001
- Epochs: 3
- Hardware: Google Colab A100 40GB
Usage
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
base_model = "Qwen/Qwen2.5-Coder-7B-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-7b")
# Generate code
prompt = "Write a React component with TypeScript:"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512)
print(tokenizer.decode(outputs[0]))
Repository
- Downloads last month
- 2