RLHFlow/RLHFlow-SFT-Dataset-ver2
Viewer • Updated • 2.32M • 56 • 5
How to use dtiapkin/gemma3-4b-sft with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-text-to-text", model="dtiapkin/gemma3-4b-sft")
messages = [
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
{"type": "text", "text": "What animal is on the candy?"}
]
},
]
pipe(text=messages) # Load model directly
from transformers import AutoProcessor, AutoModelForImageTextToText
processor = AutoProcessor.from_pretrained("dtiapkin/gemma3-4b-sft")
model = AutoModelForImageTextToText.from_pretrained("dtiapkin/gemma3-4b-sft")
messages = [
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
{"type": "text", "text": "What animal is on the candy?"}
]
},
]
inputs = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use dtiapkin/gemma3-4b-sft with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "dtiapkin/gemma3-4b-sft"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "dtiapkin/gemma3-4b-sft",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image in one sentence."
},
{
"type": "image_url",
"image_url": {
"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
}
}
]
}
]
}'docker model run hf.co/dtiapkin/gemma3-4b-sft
How to use dtiapkin/gemma3-4b-sft with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "dtiapkin/gemma3-4b-sft" \
--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": "dtiapkin/gemma3-4b-sft",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image in one sentence."
},
{
"type": "image_url",
"image_url": {
"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
}
}
]
}
]
}'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 "dtiapkin/gemma3-4b-sft" \
--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": "dtiapkin/gemma3-4b-sft",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image in one sentence."
},
{
"type": "image_url",
"image_url": {
"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
}
}
]
}
]
}'How to use dtiapkin/gemma3-4b-sft with Docker Model Runner:
docker model run hf.co/dtiapkin/gemma3-4b-sft
axolotl version: 0.13.0.dev0
# =========================
# Axolotl SFT config (Gemma3 4B PT, full finetune, bf16, grad ckpt)
# =========================
# ---- Model ----
base_model: google/gemma-3-4b-pt
model_type: AutoModelForCausalLM
tokenizer_type: AutoTokenizer
# Train only text generation (language model) layers
unfrozen_parameters:
- "model.language_model.*"
trust_remote_code: true
strict: false
# Quantization OFF (full finetune)
load_in_8bit: false
load_in_4bit: false
# ---- Chat formatting ----
chat_template: gemma3
# ---- Dataset ----
# Option A: your dataset is already ShareGPT-style (list of turns with roles)
datasets:
- path: RLHFlow/RLHFlow-SFT-Dataset-ver2
type: chat_template
field_messages: conversations
roles_to_train: ["assistant"]
split: train
train_on_split: train
val_set_size: 0.01
train_on_inputs: false # only learn on assistant tokens
# ---- Tokenization / packing ----
sequence_len: 8192 # <- start with 4096; later you can go 8192 once stable
sample_packing: true
pad_to_sequence_len: true
# Cache the prepared dataset (put on $WORK on Jean Zay)
dataset_prepared_path: ./prepared/gemma3-4b-8192
dataset_processes: 32
dataloader_pin_memory: true
dataloader_num_workers: 8
dataloader_prefetch_factor: 2
# ---- Output / logging ----
output_dir: ./outputs/gemma3-4b-sft
save_safetensors: true
logging_steps: 10
save_strategy: "epoch"
saves_per_epoch: 2
save_total_limit: 10
# Optional W&B
wandb_project: gemma3-sft
wandb_name: gemma3-4b-pt_seq8192_lr1.5e-5_bs128
wandb_watch:
wandb_log_model:
# ---- Precision / speed ----
bf16: true
fp16: false
tf32: true
flash_attention: true
xformers_attention:
# ---- Training hyperparams ----
num_epochs: 3 # start with 1 epoch to validate end-to-end; then increase
micro_batch_size: 1
gradient_accumulation_steps: 16
auto_resume_from_checkpoints: True
optimizer: adamw_torch_fused # simplest baseline (no bitsandbytes dependency surprises)
lr_scheduler: cosine
learning_rate: 1.5e-5 # good starting point for 12B full finetune
warmup_ratio: 0.05
weight_decay: 0.0
max_grad_norm: 1.0
group_by_length: false
# ---- Memory knobs ----
gradient_checkpointing: true
gradient_checkpointing_kwargs:
use_reentrant: false
overrides_of_model_config:
use_cache: false
# ---- Distributed ----
# When you launch with torchrun, Axolotl will use DDP.
# Keep these empty so you do NOT enable ZeRO/FSDP.
ddp:
deepspeed:
fsdp:
fsdp_config:
# ---- Debug ----
debug:
This model is a fine-tuned version of google/gemma-3-4b-pt on the RLHFlow/RLHFlow-SFT-Dataset-ver2 dataset.
More information needed
More information needed
More information needed
The following hyperparameters were used during training:
Base model
google/gemma-3-4b-pt