Instructions to use Vishva007/Qwen3.5-4B-Signature with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Vishva007/Qwen3.5-4B-Signature with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Vishva007/Qwen3.5-4B-Signature") 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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("Vishva007/Qwen3.5-4B-Signature") model = AutoModelForMultimodalLM.from_pretrained("Vishva007/Qwen3.5-4B-Signature", device_map="auto") 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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Vishva007/Qwen3.5-4B-Signature with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Vishva007/Qwen3.5-4B-Signature" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Vishva007/Qwen3.5-4B-Signature", "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" } } ] } ] }'Use Docker
docker model run hf.co/Vishva007/Qwen3.5-4B-Signature
- SGLang
How to use Vishva007/Qwen3.5-4B-Signature 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 "Vishva007/Qwen3.5-4B-Signature" \ --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": "Vishva007/Qwen3.5-4B-Signature", "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" } } ] } ] }'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 "Vishva007/Qwen3.5-4B-Signature" \ --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": "Vishva007/Qwen3.5-4B-Signature", "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" } } ] } ] }' - Unsloth Desktop
- Docker Model Runner
How to use Vishva007/Qwen3.5-4B-Signature with Docker Model Runner:
docker model run hf.co/Vishva007/Qwen3.5-4B-Signature
Qwen3.5 Signature Detection & Visual Grounding Suite
Fine-tuned Qwen3.5 vision-language models (9B and 4B) specialized in document signature verification, signer role attribution, counting, and normalized [0, 1000] bounding-box localization.
Trained using Unsloth on Vishva007/signature-detection-sft, this model family outputs deterministic, Pydantic-validated JSON across single-role queries, hard-negative checks, full-page open discovery, and document VQA.
Recommended Checkpoint:
Vishva007/Qwen3.5-9B-Signature(and itsW4A16quantized release) delivers the strongest spatial precision, role disambiguation, and hard-negative rejection performance across complex multi-signer forms and vouchers.
Model Family & Available Artifacts
All checkpoints are grouped in the Qwen3.5 Signature Detection & Visual Grounding Collection:
| Repository | Base Model | Format / Precision | Recommended Use Case |
|---|---|---|---|
Vishva007/Qwen3.5-9B-Signature |
Qwen/Qwen3.5-9B |
Merged BF16 |
Best overall accuracy, fine-grained bounding boxes, and downstream quantization |
Vishva007/Qwen3.5-9B-Signature-W4A16 |
Qwen/Qwen3.5-9B |
W4A16 Quantized |
High-throughput production serving on single-GPU setups via vLLM |
Vishva007/Qwen3.5-9B-Signature-Adapter |
Qwen/Qwen3.5-9B |
LoRA Adapter (r=16, alpha=16) |
Lightweight adapter loading or multi-LoRA serving |
Vishva007/Qwen3.5-4B-Signature |
Qwen/Qwen3.5-4B |
Merged BF16 |
Low-latency / constrained-VRAM document extraction |
Vishva007/Qwen3.5-4B-Signature-Adapter |
Qwen/Qwen3.5-4B |
LoRA Adapter (r=16, alpha=32) |
Lightweight 4B adapter deployment |
Capabilities & Supported Tasks
The models are trained across four complementary document-understanding tasks:
- Positive Grounding (
positive_grounding): Verifies whether a specific role (e.g., Director, Secretary, Applicant, Authorized Signatory) has signed the document and returns exact[x1, y1, x2, y2]coordinates. - Hard-Negative Rejection (
hard_negative_grounding): Accurately returns"is_present": falseand"signatures": []when queried for plausible roles that are absent from the page, suppressing false-positive hallucinations. - Open Discovery (
open_discovery): Scans the entire page ("Identify and locate all signatures present on this document.") and extracts every signature alongside its associated role label and bounding box. - Document VQA (
pure_vqa): Answers signature count and signer-role inventory questions in the unified JSON schema.
Output JSON Schema
Every response strictly conforms to the following Pydantic schema:
{
"answer": "Yes, the Director signature is present on this document.",
"is_present": true,
"count": 2,
"signatures": [
{
"role": "Director",
"bbox_2d": [730, 309, 914, 377]
},
{
"role": "Director",
"bbox_2d": [788, 809, 942, 882]
}
]
}
answer(str): Natural-language summary answering the prompt.is_present(bool):trueif at least one matching signature is detected;falseotherwise.count(int): Total number of items insignatures.signatures(list[dict]):role(str): Signer role, title, or label associated with the signature.bbox_2d(list[int]):[xmin, ymin, xmax, ymax]normalized to[0, 1000]relative to the upright image width and height.
Serving & Inference
1. High-Throughput Serving with vLLM
Option A: Serving Merged or Quantized Checkpoints (Recommended)
vllm serve Vishva007/Qwen3.5-9B-Signature-W4A16 \
--host 0.0.0.0 \
--port 8000 \
--trust-remote-code \
--max-model-len 16384 \
--enable-prefix-caching \
--default-chat-template-kwargs '{"enable_thinking": false}'
Option B: Serving the LoRA Adapter on Top of the Base Model
vllm serve Vishva007/Qwen3.5-9B-W4A16-AutoRound-GPTQ \
--host 0.0.0.0 \
--port 8000 \
--enable-lora \
--lora-modules signature-adapter=Vishva007/Qwen3.5-9B-Signature-Adapter \
--max-lora-rank 16 \
--max-loras 1 \
--trust-remote-code \
--max-model-len 16384 \
--enable-prefix-caching \
--default-chat-template-kwargs '{"enable_thinking": false}'
Note: When serving with
--lora-modules, pass (the registered adapter name) in your OpenAI SDK requests instead of the base model ID. For the 4B adapter, swap the base model and path toQwen/Qwen3.5-4BandVishva007/Qwen3.5-4B-Signature-Adapter.
2. Structured Extraction with OpenAI SDK & Pydantic
Important: Ensure input images are EXIF-transposed and rotated upright (
0°) before inference, as all training coordinates are normalized to upright page orientations.
import base64
from io import BytesIO
from openai import OpenAI
from PIL import Image, ImageOps
from pydantic import BaseModel, ConfigDict
class SignatureItem(BaseModel):
model_config = ConfigDict(extra="forbid")
role: str
bbox_2d: list[int]
class SignatureResponse(BaseModel):
model_config = ConfigDict(extra="forbid")
answer: str
is_present: bool
count: int
signatures: list[SignatureItem]
def encode_upright_image(image_path: str) -> tuple[str, int, int]:
img = ImageOps.exif_transpose(Image.open(image_path)).convert("RGB")
width, height = img.size
buf = BytesIO()
img.save(buf, format="JPEG", quality=95)
b64 = base64.b64encode(buf.getvalue()).decode("utf-8")
return b64, width, height
client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
b64_img, width, height = encode_upright_image("document.jpg")
completion = client.chat.completions.parse(
model="Vishva007/Qwen3.5-9B-Signature-W4A16",
temperature=0.0,
messages=[
{
"role": "user",
"content": [
{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{b64_img}"}},
{"type": "text", "text": "Identify and locate all signatures present on this document."},
],
}
],
response_format=SignatureResponse,
)
result: SignatureResponse = completion.choices[0].message.parsed
print(result.model_dump_json(indent=2))
# Convert normalized [0, 1000] coordinates back to pixel coordinates
for sig in result.signatures:
x1, y1, x2, y2 = sig.bbox_2d
pixel_box = [
int(x1 / 1000 * width),
int(y1 / 1000 * height),
int(x2 / 1000 * width),
int(y2 / 1000 * height),
]
print(f"Role: {sig.role} | Pixel Box: {pixel_box}")
Training Details
Both model variants were fine-tuned with Unsloth (gradient_checkpointing: unsloth, train_on_completions: true) on Vishva007/signature-detection-sft (12,000 training examples / 2,530 validation examples across orientation-corrected document scans), updating both vision and language layers (q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj):
| Hyperparameter | Qwen3.5-9B Configuration | Qwen3.5-4B Configuration |
|---|---|---|
| Max Sequence Length | 8192 |
8192 |
| Epochs | 1 |
1 |
| Effective Batch Size | 16 (batch_size=4, grad_accum=4) |
16 (batch_size=2, grad_accum=8) |
| Learning Rate | 5e-5 (Cosine, 40 warmup steps) |
1e-4 (Cosine, 40 warmup steps) |
| Optimizer & Weight Decay | adamw_8bit, 0.05 |
adamw_8bit, 0.02 |
| LoRA Rank / Alpha | r=16, alpha=16 (use_rslora=true) |
r=16, alpha=32 (use_rslora=true) |
| LoRA Dropout | 0.1 |
0.05 |
| Fine-Tuned Modules | Vision + Language (Attention & MLP) | Vision + Language (Attention & MLP) |
🚀 Deploy on RunPod
One-click launch environments pre-configured with PyTorch, CUDA, and dependencies for fine-tuning or quantization.
🎁 Need GPU compute? Sign up via RunPod and get $5–$500 in free credits when you add your first $10.
PyTorch 2.15
PyTorch 2.14
PyTorch 2.13
PyTorch 2.12
Limitations & Recommendations
- Page Orientation: Bounding boxes are trained exclusively on upright (
0°) images. For rotated or scanned PDFs, run an orientation classifier (e.g., PaddleOCRPP-LCNet_x1_0_doc_ori) prior to inference. - Role Label Supervision: Signer role annotations in the underlying training split were generated via VLM teacher distillation and may occasionally normalize rare institutional titles to standard role names.
- Model Selection: Use
Qwen3.5-9B-Signature(orQwen3.5-9B-Signature-W4A16) for production banking/legal documents; use the4Bvariant only when strict edge-memory or latency budgets apply.
- Downloads last month
- 33