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")# pip install -U transformers accelerate # 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
Update README.md
Browse files
README.md
CHANGED
|
@@ -7,4 +7,69 @@ base_model:
|
|
| 7 |
- google/flan-t5-base
|
| 8 |
pipeline_tag: text-generation
|
| 9 |
library_name: adapter-transformers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
---
|
|
|
|
| 7 |
- google/flan-t5-base
|
| 8 |
pipeline_tag: text-generation
|
| 9 |
library_name: adapter-transformers
|
| 10 |
+
license: apache-2.0
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# flan-python-expert 🚀
|
| 14 |
+
|
| 15 |
+
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.
|
| 16 |
+
|
| 17 |
+
It is designed to generate Python code from natural language instructions.
|
| 18 |
+
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
## 🧠 Model Details
|
| 22 |
+
|
| 23 |
+
- **Base Model:** FLAN-T5 Base
|
| 24 |
+
- **Fine-tuned on:** Python code dataset (`codeagent-python`)
|
| 25 |
+
- **Task:** Text-to-code generation
|
| 26 |
+
- **Language:** English
|
| 27 |
+
- **Framework:** 🤗 Transformers
|
| 28 |
+
- **Library:** `adapter-transformers`
|
| 29 |
+
|
| 30 |
+
---
|
| 31 |
+
|
| 32 |
+
## 🏋️ Training
|
| 33 |
+
|
| 34 |
+
The model was trained using the following setup:
|
| 35 |
+
|
| 36 |
+
```python
|
| 37 |
+
from transformers import TrainingArguments
|
| 38 |
+
|
| 39 |
+
training_args = TrainingArguments(
|
| 40 |
+
output_dir="flan-python-expert",
|
| 41 |
+
evaluation_strategy="epoch",
|
| 42 |
+
learning_rate=2e-6,
|
| 43 |
+
per_device_train_batch_size=1,
|
| 44 |
+
per_device_eval_batch_size=1,
|
| 45 |
+
num_train_epochs=1,
|
| 46 |
+
weight_decay=0.01,
|
| 47 |
+
save_total_limit=2,
|
| 48 |
+
logging_steps=1,
|
| 49 |
+
push_to_hub=False,
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
Trained for 1 epoch
|
| 56 |
+
|
| 57 |
+
Optimized for low-resource fine-tuning
|
| 58 |
+
|
| 59 |
+
Training performed using Hugging Face Trainer
|
| 60 |
+
|
| 61 |
+
## Example Usage
|
| 62 |
+
```python
|
| 63 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 64 |
+
|
| 65 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("MalikIbrar/flan-python-expert")
|
| 66 |
+
tokenizer = AutoTokenizer.from_pretrained("MalikIbrar/flan-python-expert")
|
| 67 |
+
|
| 68 |
+
input_text = "Write a Python function to check if a number is prime."
|
| 69 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
| 70 |
+
|
| 71 |
+
outputs = model.generate(**inputs, max_length=256)
|
| 72 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
---
|