Instructions to use MalikIbrar/flan-python-expert with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MalikIbrar/flan-python-expert with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MalikIbrar/flan-python-expert")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("MalikIbrar/flan-python-expert") model = AutoModelForSeq2SeqLM.from_pretrained("MalikIbrar/flan-python-expert", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MalikIbrar/flan-python-expert with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MalikIbrar/flan-python-expert" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MalikIbrar/flan-python-expert", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/MalikIbrar/flan-python-expert
- SGLang
How to use MalikIbrar/flan-python-expert 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 "MalikIbrar/flan-python-expert" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MalikIbrar/flan-python-expert", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "MalikIbrar/flan-python-expert" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MalikIbrar/flan-python-expert", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use MalikIbrar/flan-python-expert with Docker Model Runner:
docker model run hf.co/MalikIbrar/flan-python-expert
File size: 1,809 Bytes
c308fbf ebb7e65 e619a34 c308fbf | 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 | ---
datasets:
- Programming-Language/codeagent-python
language:
- en
base_model:
- google/flan-t5-base
pipeline_tag: text-generation
library_name: transformers
license: apache-2.0
---
# flan-python-expert 🚀
This model is a fine-tuned version of [`google/flan-t5-base`](https://huggingface.co/google/flan-t5-base) on the [`codeagent-python`](https://huggingface.co/datasets/Programming-Language/codeagent-python) dataset.
It is designed to generate Python code from natural language instructions.
---
## 🧠 Model Details
- **Base Model:** FLAN-T5 Base
- **Fine-tuned on:** Python code dataset (`codeagent-python`)
- **Task:** Text-to-code generation
- **Language:** English
- **Framework:** 🤗 Transformers
- **Library:** `adapter-transformers`
---
## 🏋️ Training
The model was trained using the following setup:
```python
from transformers import TrainingArguments
training_args = TrainingArguments(
output_dir="flan-python-expert",
evaluation_strategy="epoch",
learning_rate=2e-6,
per_device_train_batch_size=1,
per_device_eval_batch_size=1,
num_train_epochs=1,
weight_decay=0.01,
save_total_limit=2,
logging_steps=1,
push_to_hub=False,
)
```
Trained for 1 epoch
Optimized for low-resource fine-tuning
Training performed using Hugging Face Trainer
## Example Usage
```python
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
model = AutoModelForSeq2SeqLM.from_pretrained("MalikIbrar/flan-python-expert")
tokenizer = AutoTokenizer.from_pretrained("MalikIbrar/flan-python-expert")
input_text = "Write a Python function to check if a number is prime."
inputs = tokenizer(input_text, return_tensors="pt")
outputs = model.generate(**inputs, max_length=256)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```
--- |