Text Generation
Transformers
Safetensors
PEFT
llama
tinyllama
lora
python
code
fine-tuning
conversational
text-generation-inference
How to use from
SGLangUse 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 "mo7amed-3bdalla7/tinyllama-python-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": "mo7amed-3bdalla7/tinyllama-python-lora",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'Quick Links
π TinyLLaMA LoRA - Fine-tuned on Python Code
This is a LoRA fine-tuned version of TinyLlama/TinyLlama-1.1B-Chat-v1.0 using a subset of Python code from the codeparrot dataset. It is trained to generate Python functions and code snippets based on natural language or code-based prompts.
π§ Training Details
- Base model:
TinyLlama/TinyLlama-1.1B-Chat-v1.0 - Adapter type: LoRA (PEFT)
- Dataset:
codeparrot/codeparrot-clean-valid[:1000] - Tokenized max length: 512
- Trained on: Apple M3 Pro (MPS backend)
- Epochs: 1
- Batch size: 1 (with gradient accumulation)
π‘ Example Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base_model = "TinyLlama/TinyLlama-1.1B-Chat-v1.0"
adapter_model = "your-username/tinyllama-python-lora"
tokenizer = AutoTokenizer.from_pretrained(base_model)
model = AutoModelForCausalLM.from_pretrained(base_model)
model = PeftModel.from_pretrained(model, adapter_model)
prompt = "<|python|>\ndef fibonacci(n):"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=100)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
π§ Intended Use
Code completion for Python
Teaching LLMs Python function structure
Experimentation with LoRA on small code datasets
##β οΈ Limitations Trained on a small subset of data (1,000 samples)
May hallucinate or generate syntactically incorrect code
Not suitable for production use without further fine-tuning and evaluation
π License
Apache 2.0 β same as the base model.
- Downloads last month
- 2
Model tree for mo7amed-3bdalla7/tinyllama-python-lora
Base model
TinyLlama/TinyLlama-1.1B-Chat-v1.0
Install from pip and serve model
# Install SGLang from pip: pip install sglang# Start the SGLang server: python3 -m sglang.launch_server \ --model-path "mo7amed-3bdalla7/tinyllama-python-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": "mo7amed-3bdalla7/tinyllama-python-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'