ahazimeh/slide2svg
Viewer • Updated • 39.7k • 254 • 11
How to use Bombek1/slide2svg-vl-2b with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-text-to-text", model="Bombek1/slide2svg-vl-2b")
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 AutoModel
model = AutoModel.from_pretrained("Bombek1/slide2svg-vl-2b", dtype="auto")How to use Bombek1/slide2svg-vl-2b with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Bombek1/slide2svg-vl-2b"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Bombek1/slide2svg-vl-2b",
"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/Bombek1/slide2svg-vl-2b
How to use Bombek1/slide2svg-vl-2b with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "Bombek1/slide2svg-vl-2b" \
--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": "Bombek1/slide2svg-vl-2b",
"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 "Bombek1/slide2svg-vl-2b" \
--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": "Bombek1/slide2svg-vl-2b",
"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 Bombek1/slide2svg-vl-2b with Unsloth Studio:
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 Bombek1/slide2svg-vl-2b to start chatting
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 Bombek1/slide2svg-vl-2b to start chatting
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Bombek1/slide2svg-vl-2b to start chatting
pip install unsloth
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
model_name="Bombek1/slide2svg-vl-2b",
max_seq_length=2048,
)How to use Bombek1/slide2svg-vl-2b with Docker Model Runner:
docker model run hf.co/Bombek1/slide2svg-vl-2b
A vision-language model fine-tuned to convert presentation slides (images) into structured SVG format.
This model takes an image of a presentation slide and generates corresponding SVG markup, preserving:
| Parameter | Value |
|---|---|
| Base Model | Qwen3-VL-2B-Instruct |
| Dataset | ahazimeh/slide2svg (~39,500 samples) |
| Method | LoRA (r=64, alpha=128) |
| Epochs | 2 |
| Batch Size | 16 (2 × 8 gradient accumulation) |
| Learning Rate | 1e-4 |
| Context Length | 12,288 tokens |
| Precision | 16-bit |
| Training Time | ~5.5 hours |
| Hardware | NVIDIA RTX 5090 (32GB) |
| Metric | Score |
|---|---|
| Valid XML Structure | 100% (20/20) |
Has <svg> tag |
100% (20/20) |
Has <foreignObject> |
100% (20/20) |
| Final Training Loss | 0.091 |
| Final Validation Loss | 0.091 |
| Avg Output Length | 91% of reference |
from unsloth import FastVisionModel
from PIL import Image
# Load model
model, tokenizer = FastVisionModel.from_pretrained(
"Bombek1/slide2svg-vl-2b",
load_in_4bit=True, # or False for 16-bit
)
FastVisionModel.for_inference(model)
# Prepare input
image = Image.open("your_slide.png")
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": image},
{"type": "text", "text": "Convert this presentation slide to SVG format."}
]
}
]
# Generate
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt",
return_dict=True,
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=4096, do_sample=False)
generated_ids = outputs[0][inputs["input_ids"].shape[1]:]
svg_output = tokenizer.decode(generated_ids, skip_special_tokens=True)
print(svg_output)
The model generates SVG with the following structure:
<?xml version="1.0" encoding="utf-8"?>
<html>
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="768" fill="white">
<image x="0.0%" y="0.0%" width="100.0%" href="background.png" />
<g id="images">
<image x="14.3%" y="28.5%" width="35.8%" href="image_0.png" />
</g>
<g id="text">
<foreignObject x="5.4%" y="8.1%" width="32.0%" height="12.0%" overflow="visible">
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Inter; font-size: 74px; font-weight: bold; color: #000000;">
<div>Your Text Here</div>
</div>
</foreignObject>
</g>
</svg>
</html>
Apache 2.0 (inherited from Qwen3-VL base model)