Image-Text-to-Text
Transformers
Safetensors
qwen3_5
signature-detection
visual-grounding
document-ai
vqa
structured-outputs
pydantic
unsloth
qwen3.5
vllm
conversational
Run this model with HF Jobs
Run OpenTensorLab/Qwen3.5-9B-Signature on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/OpenTensorLab/Qwen3.5-9B-Signature. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/OpenTensorLab/Qwen3.5-9B-Signature on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/OpenTensorLab/Qwen3.5-9B-Signature. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/OpenTensorLab/Qwen3.5-9B-Signature. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use OpenTensorLab/Qwen3.5-9B-Signature with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenTensorLab/Qwen3.5-9B-Signature with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="OpenTensorLab/Qwen3.5-9B-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("OpenTensorLab/Qwen3.5-9B-Signature") model = AutoModelForMultimodalLM.from_pretrained("OpenTensorLab/Qwen3.5-9B-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 OpenTensorLab/Qwen3.5-9B-Signature with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenTensorLab/Qwen3.5-9B-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": "OpenTensorLab/Qwen3.5-9B-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/OpenTensorLab/Qwen3.5-9B-Signature
- SGLang
How to use OpenTensorLab/Qwen3.5-9B-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 "OpenTensorLab/Qwen3.5-9B-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": "OpenTensorLab/Qwen3.5-9B-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 "OpenTensorLab/Qwen3.5-9B-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": "OpenTensorLab/Qwen3.5-9B-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 OpenTensorLab/Qwen3.5-9B-Signature with Docker Model Runner:
docker model run hf.co/OpenTensorLab/Qwen3.5-9B-Signature
Vishva R commited on
Update README.md
Browse files123456729103456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888913909192931516179495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112121921321421215216217---base_model: Qwen/Qwen3.5-9Btags:- text-generation-inference- transformers- unsloth- qwen3_5license: apache-2.0language:- enlibrary_name: transformerspipeline_tag: image-text-to-textbase_model: - Qwen/Qwen3.5-9Bdatasets: - Vishva007/signature-detection-sfttags: - signature-detection - visual-grounding - document-ai - vqa - structured-outputs - pydantic - unsloth - qwen3.5 - vllm---
# 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`](https://huggingface.co/datasets/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 its **`W4A16`** quantized 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](https://huggingface.co/collections/Vishva007/signature-detection):
| Repository | Base Model | Format / Precision | Recommended Use Case || :--- | :--- | :--- | :--- || **[`Vishva007/Qwen3.5-9B-Signature`](https://huggingface.co/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`](https://huggingface.co/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`](https://huggingface.co/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`](https://huggingface.co/Vishva007/Qwen3.5-4B-Signature)** | `Qwen/Qwen3.5-4B` | Merged `BF16` | Low-latency / constrained-VRAM document extraction || **[`Vishva007/Qwen3.5-4B-Signature-Adapter`](https://huggingface.co/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:
1. **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.2. **Hard-Negative Rejection (`hard_negative_grounding`):** Accurately returns `"is_present": false` and `"signatures": []` when queried for plausible roles that are absent from the page, suppressing false-positive hallucinations.3. **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.4. **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:
```json{ "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`): `true` if at least one matching signature is detected; `false` otherwise.* **`count`** (`int`): Total number of items in `signatures`.* **`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.
---
# Uploaded finetuned 16-bit (FP16) model## Serving & Inference
### 1. High-Throughput Serving with vLLM
- **Developed by:** Vishva007- **License:** apache-2.0- **Finetuned from model :** Qwen/Qwen3.5-9B#### Option A: Serving Merged or Quantized Checkpoints (Recommended)
```bashvllm 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
```bashvllm 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 to `Qwen/Qwen3.5-4B` and `Vishva007/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.
```pythonimport base64from io import BytesIOfrom openai import OpenAIfrom PIL import Image, ImageOpsfrom 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.parsedprint(result.model_dump_json(indent=2))
# Convert normalized [0, 1000] coordinates back to pixel coordinatesfor 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) |
---
This qwen3_5 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.## Limitations & Recommendations
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)* **Page Orientation:** Bounding boxes are trained exclusively on upright (`0°`) images. For rotated or scanned PDFs, run an orientation classifier (e.g., PaddleOCR `PP-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`** (or **`Qwen3.5-9B-Signature-W4A16`**) for production banking/legal documents; use the **`4B`** variant only when strict edge-memory or latency budgets apply.README.md+210-14