Text Generation
Transformers
Safetensors
English
qwen2
text-generation-inference
unsloth
lora
fastapi
code-assistant
conversational
Instructions to use LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA") model = AutoModelForCausalLM.from_pretrained("LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA
- SGLang
How to use LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA 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 "LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA" \ --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": "LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA", "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 "LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA" \ --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": "LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA", max_seq_length=2048, ) - Docker Model Runner
How to use LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA with Docker Model Runner:
docker model run hf.co/LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA
File size: 5,474 Bytes
faef391 2fe18f7 faef391 2fe18f7 faef391 2fe18f7 faef391 2fe18f7 faef391 2fe18f7 faef391 2fe18f7 faef391 2fe18f7 faef391 2fe18f7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | ---
license: apache-2.0
base_model: unsloth/Qwen2.5-Coder-7B-Instruct-bnb-4bit
tags:
- text-generation-inference
- transformers
- unsloth
- qwen2
- lora
- fastapi
- code-assistant
language:
- en
library_name: transformers
pipeline_tag: text-generation
---
# Qwen2.5-Coder-7B-FastAPI-LoRA
A LoRA fine-tune of **Qwen2.5-Coder-7B-Instruct** specialized as a **FastAPI documentation assistant**. The model is trained to answer questions, generate code, and explain concepts related to the FastAPI framework, covering everything from basic routing to advanced topics like security and testing.
## Model Details
- **Developed by:** [LadiesMan69](https://huggingface.co/LadiesMan69)
- **License:** apache-2.0
- **Base model:** [unsloth/Qwen2.5-Coder-7B-Instruct-bnb-4bit](https://huggingface.co/unsloth/Qwen2.5-Coder-7B-Instruct-bnb-4bit)
- **Model type:** Causal decoder-only language model (Qwen2 architecture)
- **Fine-tuning method:** LoRA (Low-Rank Adaptation)
- **Language:** English
- **Trained with:** [Unsloth](https://github.com/unslothai/unsloth) + Hugging Face TRL β 2x faster training
## Motivation
General-purpose code models are often imprecise or outdated when it comes to framework-specific APIs. This model was fine-tuned on a curated dataset of FastAPI-focused instruction/response pairs to produce a lightweight, deployable assistant that gives accurate, idiomatic answers for building and debugging FastAPI applications.
## Training Data
The fine-tuning dataset was built specifically for this task using the **ChatML** format and organized into topic categories, including:
- **Tutorial** β core concepts: path/query parameters, request bodies, response models, dependency injection
- **Advanced** β background tasks, middleware, WebSockets, custom exception handlers, lifespan events
- **Security** β OAuth2/JWT authentication, password hashing, CORS, rate limiting
- **Testing** β `TestClient` usage, pytest fixtures, mocking dependencies, async test patterns
Examples were generated in batches per category to ensure balanced topic coverage and consistent formatting across the dataset.
## Intended Use
- Answering questions about FastAPI concepts, patterns, and best practices
- Generating FastAPI route handlers, Pydantic models, and dependency-injected services
- Explaining and debugging FastAPI-related code snippets
- Acting as an in-editor or chat-based documentation assistant for developers working with FastAPI
## How to Use
### With `transformers`
```python
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
messages = [
{"role": "system", "content": "You are a helpful FastAPI documentation assistant."},
{"role": "user", "content": "How do I add JWT-based authentication to a FastAPI route?"},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
```
### With `unsloth`
```python
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
model_name="LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA",
max_seq_length=2048,
)
```
### With `vLLM`
```bash
pip install vllm
vllm serve "LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA"
```
```bash
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA",
"messages": [
{"role": "user", "content": "Show me a minimal FastAPI app with a health check endpoint."}
]
}'
```
## Prompt Format
This model uses the ChatML-style chat template built into the tokenizer (`apply_chat_template`). For best results, include a system message establishing the assistant's role as a FastAPI expert, followed by the user's question.
## Limitations
- Focused specifically on FastAPI; general coding ability outside this domain is inherited from the base model and not specifically enhanced.
- As with any LLM, generated code should be reviewed and tested before use in production.
- May not reflect the very latest FastAPI releases if they postdate the training data.
## Training Procedure
Fine-tuned using LoRA adapters on top of the 4-bit quantized `unsloth/Qwen2.5-Coder-7B-Instruct-bnb-4bit` base model, leveraging Unsloth's optimized training kernels for faster, memory-efficient fine-tuning.
## Model Tree
- Base: [Qwen/Qwen2.5-7B](https://huggingface.co/Qwen/Qwen2.5-7B)
- β [Qwen/Qwen2.5-Coder-7B](https://huggingface.co/Qwen/Qwen2.5-Coder-7B)
- β [Qwen/Qwen2.5-Coder-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct)
- β [unsloth/Qwen2.5-Coder-7B-Instruct-bnb-4bit](https://huggingface.co/unsloth/Qwen2.5-Coder-7B-Instruct-bnb-4bit) (quantized)
- β **LadiesMan69/Qwen2.5-Coder-7B-FastAPI-LoRA** (this model, LoRA fine-tune)
## Acknowledgements
This qwen2 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Hugging Face's TRL library.
[](https://github.com/unslothai/unsloth)
|