spatialchain commited on
Commit
b4a0b9d
Β·
verified Β·
1 Parent(s): 635daad

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +189 -169
README.md CHANGED
@@ -1,207 +1,227 @@
1
  ---
2
  base_model: Qwen/Qwen3-VL-8B-Thinking
3
  library_name: peft
4
- pipeline_tag: text-generation
5
  tags:
6
- - base_model:adapter:Qwen/Qwen3-VL-8B-Thinking
7
- - lora
8
- - transformers
 
 
 
 
 
 
 
 
 
9
  ---
10
 
11
- # Model Card for Model ID
12
 
13
- <!-- Provide a quick summary of what the model is/does. -->
14
 
 
 
 
 
 
 
 
 
15
 
 
16
 
17
  ## Model Details
18
 
19
- ### Model Description
20
-
21
- <!-- Provide a longer summary of what this model is. -->
22
-
23
-
24
-
25
- - **Developed by:** [More Information Needed]
26
- - **Funded by [optional]:** [More Information Needed]
27
- - **Shared by [optional]:** [More Information Needed]
28
- - **Model type:** [More Information Needed]
29
- - **Language(s) (NLP):** [More Information Needed]
30
- - **License:** [More Information Needed]
31
- - **Finetuned from model [optional]:** [More Information Needed]
32
-
33
- ### Model Sources [optional]
34
-
35
- <!-- Provide the basic links for the model. -->
36
-
37
- - **Repository:** [More Information Needed]
38
- - **Paper [optional]:** [More Information Needed]
39
- - **Demo [optional]:** [More Information Needed]
40
-
41
- ## Uses
42
-
43
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
44
-
45
- ### Direct Use
46
-
47
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
48
-
49
- [More Information Needed]
50
-
51
- ### Downstream Use [optional]
52
-
53
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
54
-
55
- [More Information Needed]
56
-
57
- ### Out-of-Scope Use
58
-
59
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
60
-
61
- [More Information Needed]
62
 
63
- ## Bias, Risks, and Limitations
64
-
65
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
66
-
67
- [More Information Needed]
68
-
69
- ### Recommendations
70
-
71
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
72
-
73
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
74
-
75
- ## How to Get Started with the Model
76
 
77
- Use the code below to get started with the model.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
- [More Information Needed]
80
 
81
  ## Training Details
82
 
83
- ### Training Data
84
-
85
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
86
-
87
- [More Information Needed]
88
-
89
- ### Training Procedure
90
-
91
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
92
-
93
- #### Preprocessing [optional]
94
-
95
- [More Information Needed]
96
-
97
-
98
- #### Training Hyperparameters
99
-
100
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
101
-
102
- #### Speeds, Sizes, Times [optional]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
 
104
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
105
-
106
- [More Information Needed]
107
 
108
  ## Evaluation
109
 
110
- <!-- This section describes the evaluation protocols and provides the results. -->
111
-
112
- ### Testing Data, Factors & Metrics
113
-
114
- #### Testing Data
115
-
116
- <!-- This should link to a Dataset Card if possible. -->
117
 
118
- [More Information Needed]
119
 
120
- #### Factors
 
 
 
 
 
 
 
 
 
 
 
121
 
122
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
123
 
124
- [More Information Needed]
125
 
126
- #### Metrics
 
 
127
 
128
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
129
 
130
- [More Information Needed]
 
 
131
 
132
- ### Results
133
-
134
- [More Information Needed]
135
-
136
- #### Summary
137
 
 
 
 
 
138
 
 
139
 
140
- ## Model Examination [optional]
141
 
142
- <!-- Relevant interpretability work for the model goes here -->
 
 
 
 
 
 
 
143
 
144
- [More Information Needed]
145
 
146
  ## Environmental Impact
147
 
148
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
149
-
150
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
151
-
152
- - **Hardware Type:** [More Information Needed]
153
- - **Hours used:** [More Information Needed]
154
- - **Cloud Provider:** [More Information Needed]
155
- - **Compute Region:** [More Information Needed]
156
- - **Carbon Emitted:** [More Information Needed]
157
-
158
- ## Technical Specifications [optional]
159
-
160
- ### Model Architecture and Objective
161
-
162
- [More Information Needed]
163
-
164
- ### Compute Infrastructure
165
-
166
- [More Information Needed]
167
-
168
- #### Hardware
169
-
170
- [More Information Needed]
171
-
172
- #### Software
173
-
174
- [More Information Needed]
175
-
176
- ## Citation [optional]
177
-
178
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
179
-
180
- **BibTeX:**
181
-
182
- [More Information Needed]
183
-
184
- **APA:**
185
-
186
- [More Information Needed]
187
-
188
- ## Glossary [optional]
189
-
190
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
191
-
192
- [More Information Needed]
193
-
194
- ## More Information [optional]
195
-
196
- [More Information Needed]
197
-
198
- ## Model Card Authors [optional]
199
-
200
- [More Information Needed]
201
-
202
- ## Model Card Contact
203
-
204
- [More Information Needed]
205
- ### Framework versions
206
-
207
- - PEFT 0.19.1
 
1
  ---
2
  base_model: Qwen/Qwen3-VL-8B-Thinking
3
  library_name: peft
4
+ pipeline_tag: image-text-to-text
5
  tags:
6
+ - base_model:adapter:Qwen/Qwen3-VL-8B-Thinking
7
+ - lora
8
+ - peft
9
+ - transformers
10
+ - spatial-reasoning
11
+ - visual-question-answering
12
+ - chain-of-thought
13
+ license: apache-2.0
14
+ datasets:
15
+ - spatialchain/SpatialChain-Benchmark
16
+ language:
17
+ - en
18
  ---
19
 
20
+ # Qwen3-VL-8B-Thinking β€” SpatialChain LoRA Adapter
21
 
22
+ A LoRA adapter for **Qwen3-VL-8B-Thinking** fine-tuned on the [SpatialChain-Benchmark](https://huggingface.co/datasets/spatialchain/SpatialChain-Benchmark) dataset. The model learns to produce **scene-graph-grounded chain-of-thought reasoning** for binary spatial visual questions, structured as:
23
 
24
+ ```
25
+ <think>
26
+ [step-by-step spatial reasoning]
27
+ </think>
28
+ <answer>
29
+ yes / no
30
+ </answer>
31
+ ```
32
 
33
+ ---
34
 
35
  ## Model Details
36
 
37
+ | Field | Value |
38
+ |-------|-------|
39
+ | **Base model** | [Qwen/Qwen3-VL-8B-Thinking](https://huggingface.co/Qwen/Qwen3-VL-8B-Thinking) |
40
+ | **Adapter type** | LoRA (PEFT) |
41
+ | **Training data** | [SpatialChain-Benchmark](https://huggingface.co/datasets/spatialchain/SpatialChain-Benchmark) train split (28,350 examples) |
42
+ | **Task** | Binary spatial VQA with chain-of-thought |
43
+ | **Language** | English |
44
+ | **License** | Apache 2.0 |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
+ ---
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
+ ## Quick Start
49
+
50
+ ```python
51
+ from transformers import AutoProcessor, AutoModelForVision2Seq
52
+ from peft import PeftModel
53
+ from PIL import Image
54
+ import torch
55
+
56
+ base = "Qwen/Qwen3-VL-8B-Thinking"
57
+ adapter = "spatialchain/Qwen3-VL-8B-Thinking-SpatialChain"
58
+
59
+ processor = AutoProcessor.from_pretrained(base, trust_remote_code=True)
60
+ model = AutoModelForVision2Seq.from_pretrained(
61
+ base, torch_dtype=torch.bfloat16, device_map="auto", trust_remote_code=True
62
+ )
63
+ model = PeftModel.from_pretrained(model, adapter)
64
+ model.eval()
65
+
66
+ image = Image.open("your_image.jpg").convert("RGB")
67
+
68
+ messages = [
69
+ {
70
+ "role": "system",
71
+ "content": [{"type": "text", "text": (
72
+ "Your task:\n"
73
+ "1. Analyze the image carefully.\n"
74
+ "2. Provide concise reasoning grounded in visible evidence from the image.\n"
75
+ "3. End your response with 'Answer: <one short sentence>'."
76
+ )}],
77
+ },
78
+ {
79
+ "role": "user",
80
+ "content": [
81
+ {"type": "image", "image": image},
82
+ {"type": "text", "text": "Is there a fence to the left of the person?"},
83
+ ],
84
+ },
85
+ ]
86
+
87
+ text = processor.apply_chat_template(
88
+ messages, tokenize=False, add_generation_prompt=True
89
+ )
90
+ inputs = processor(text=text, images=[image], return_tensors="pt").to(model.device)
91
+
92
+ with torch.inference_mode():
93
+ ids = model.generate(
94
+ **inputs,
95
+ max_new_tokens=512,
96
+ do_sample=True,
97
+ temperature=0.6,
98
+ top_p=0.95,
99
+ top_k=20,
100
+ )
101
+
102
+ print(processor.tokenizer.decode(ids[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
103
+ ```
104
+
105
+ ### With 4-bit quantization (lower VRAM)
106
+
107
+ ```python
108
+ from transformers import BitsAndBytesConfig
109
+
110
+ bnb = BitsAndBytesConfig(
111
+ load_in_8Bit=True,
112
+ bnb_8Bit_quant_type="nf4",
113
+ bnb_8Bit_compute_dtype=torch.bfloat16,
114
+ bnb_8Bit_use_double_quant=True,
115
+ )
116
+ model = AutoModelForVision2Seq.from_pretrained(
117
+ base, quantization_config=bnb, device_map="auto", trust_remote_code=True
118
+ )
119
+ model = PeftModel.from_pretrained(model, adapter)
120
+ ```
121
 
122
+ ---
123
 
124
  ## Training Details
125
 
126
+ ### Dataset
127
+
128
+ [SpatialChain-Benchmark](https://huggingface.co/datasets/spatialchain/SpatialChain-Benchmark) β€” 28,350 training examples pairing spatially-oriented GQA questions with scene-graph-grounded reasoning chains. Questions cover 11 spatial relation types (`left_of`, `right_of`, `above`, `behind`, `near`, `inside`, …); chains were generated with Claude Haiku 4.5 (extended thinking) and retained only when the generated answer matched the GQA ground truth.
129
+
130
+ Each training example target:
131
+ ```
132
+ <think>
133
+ Looking at the image, let me trace through this step-by-step:
134
+ (1) Locating the knife β€” I can see a knife on the left side of the plate.
135
+ (2) Finding the bread to the right of the knife β€” there is a large piece of bread ...
136
+ (3) Examining what is to the right of that bread β€” gray birds are standing on the plate.
137
+ (4) Looking for kittens β€” I do not see any kittens anywhere in the image.
138
+ </think>
139
+ <answer>
140
+ No, there is a bird to the right of the bread.
141
+ </answer>
142
+ ```
143
+
144
+ ### Hyperparameters
145
+
146
+ | Hyperparameter | Value |
147
+ |----------------|-------|
148
+ | Base model | Qwen3-VL-8B-Thinking |
149
+ | Quantization | 4-bit NF4 (BitsAndBytes) |
150
+ | LoRA rank (r) | 16 |
151
+ | LoRA alpha | 32 |
152
+ | LoRA dropout | 0.05 |
153
+ | RSLoRA | βœ“ |
154
+ | Target modules | all-linear |
155
+ | Modules to save | `lm_head`, `embed_tokens` |
156
+ | Epochs | 2 |
157
+ | Per-device batch size | 4 |
158
+ | Gradient accumulation | 3 (effective batch = 12) |
159
+ | Learning rate | 3 Γ— 10⁻⁡ |
160
+ | LR schedule | cosine |
161
+ | Warmup ratio | 0.05 |
162
+ | Max sequence length | 32,768 |
163
+ | Image max size | 640 px |
164
+ | Optimizer | AdamW fused |
165
+ | Hardware | 1 Γ— A100 80 GB |
166
+ | Training framework | HuggingFace Transformers + PEFT |
167
 
168
+ ---
 
 
169
 
170
  ## Evaluation
171
 
172
+ ### SpatialChain test set (n = 899)
 
 
 
 
 
 
173
 
174
+ Evaluation uses two complementary axes. **Axis 1** measures VQA accuracy (exact match after normalisation). **Axis 2** uses a scene-graph-aware LLM judge scoring reasoning faithfulness and completeness independently of the final answer β€” see the [evaluation code](https://huggingface.co/datasets/spatialchain/SpatialChain-Benchmark) for the full judge protocol.
175
 
176
+ | Metric | Base (8B) | **This model (8B FT)** |
177
+ |--------|-----------|------------------------|
178
+ | VQA Accuracy | 78.44% | **82.23%** |
179
+ | Macro F1 | 82.01% | **86.67%** |
180
+ | Yes-accuracy | 77.74% | 91.34% |
181
+ | No-accuracy | 79.64% | 66.57% |
182
+ | ROUGE-1 vs. reference chain | 0.403 | **0.657** |
183
+ | Token F1 vs. reference chain | 0.392 | **0.646** |
184
+ | Reasoning faithfulness (judge) | 0.585 | **0.631** |
185
+ | Reasoning completeness (judge) | 0.658 | **0.708** |
186
+ | Pass rate | 77.6% | **80.2%** |
187
+ | Shortcut rate ↓ | 26.4% | **19.4%** |
188
 
189
+ **Shortcut rate** = fraction of *correct* answers where the judge scores reasoning faithfulness < 0.5. Lower is better.
190
 
191
+ ## Intended Use
192
 
193
+ - **Spatial VQA** β€” binary yes/no questions about object positions and relations in images
194
+ - **Reasoning audit** β€” producing interpretable spatial chains that can be verified against scene structure
195
+ - **Research** β€” studying the relationship between chain-of-thought quality and answer correctness in VLMs
196
 
197
+ ## Out-of-Scope Use
198
 
199
+ - Tasks requiring metric depth or 3D reasoning (scene graphs are symbolic, not metric)
200
+ - Open-ended image captioning or generation
201
+ - Non-English inputs
202
 
203
+ ## Bias and Limitations
 
 
 
 
204
 
205
+ - **Yes-bias** β€” the fine-tuned model exhibits a larger yes/no accuracy gap (+24.8 pp) than the base model (+1.9 pp), consistent with the 58% yes-rate in training data. Evaluation should report Yes-acc and No-acc separately.
206
+ - **Stylistic specialisation** β€” the model adopts a fixed reasoning format ("Looking at the image, let me trace through this step-by-step…") on all inputs, which may degrade performance on benchmarks with different prompt styles.
207
+ - **GQA domain** β€” training images are sourced from GQA (Visual Genome); performance on non-natural-image domains is unknown.
208
+ - **Projective bias** β€” 62.7% of training examples involve `left_of` / `right_of` relations; depth-ordered relations (`close`, `far`) are underrepresented.
209
 
210
+ ---
211
 
212
+ ## Citation
213
 
214
+ ```bibtex
215
+ @article{spatialchain2026,
216
+ title = {SpatialChain: A Benchmark for Auditing Spatial Reasoning Faithfulness in VLMs},
217
+ author = {Anonymous},
218
+ journal = {Under review at NeurIPS 2026},
219
+ year = {2026}
220
+ }
221
+ ```
222
 
223
+ ---
224
 
225
  ## Environmental Impact
226
 
227
+ Training ran for approximately **5 hours** on a single **A100 80 GB** GPU (cloud instance). Carbon emissions can be estimated with the [ML Impact Calculator](https://mlco2.github.io/impact#compute).