sareena commited on
Commit
abb90c4
·
verified ·
1 Parent(s): 80fec26

Upload 7 files

Browse files
README.md CHANGED
@@ -1,137 +1,202 @@
1
  ---
2
- license: apache-2.0
3
- base_model:
4
- - mistralai/Mistral-7B-Instruct-v0.3
5
  ---
6
- # Introduction
7
 
8
- ## Task Description
9
- This model was fine-tuned to improve its ability to perform spatial
10
- reasoning tasks. The objective is to enable the model to interpret natural language queries related to
11
- spatial relationships, directions, and locations and output actionable responses.
12
- The task addresses limitations in current LLMs, which often fail to perform precise spatial reasoning,
13
- such as determining relationships between points on a map, planning routes, or identifying locations
14
- based on bounding boxes.
15
 
16
- ## Task Importance
17
- Spatial reasoning is important for a wide range of applications such as navigation and geospatial
18
- analysis. Many smaller LLMs, while strong in general reasoning, often lack the ability to interpret
19
- spatial relationships with precision or utilize real-world geographic data effectively. For example, they
20
- struggle to answer queries like “What’s between Point A and Point B?” or “Find me the fastest route
21
- avoiding traffic at 8 AM tomorrow.” I came across this limitation through my work, in which I am
22
- working on prompt engineering for an LLM project that has agentic behavior in calling a geocoding
23
- API. Even when the LLM has access to geospatial information, smaller models struggled to correctly
24
- interpret user questions, so we had to switch to a much newer and larger model.
25
 
26
- ## Related Work/Gap Analysis
27
 
28
- While there is ongoing research in integrating LLMs with geospatial systems, most existing solutions
29
- rely on symbolic AI or rule-based systems rather than leveraging the generalization capabilities of
30
- LLMs. Additionally, the paper “Advancing Spatial Reasoning in Large Language Models: An In-Depth
31
- Evaluation and Enhancement Using the StepGame Benchmark,” concluded that larger models like
32
- GPT-4 perform well in mapping natural language descriptions to spatial relations but struggle with
33
- multi-hop reasoning. This paper used the StepGame as a benchmark for spatial reasoning.
34
- Fine-tuning a model fills the gap identified in the paper, as the only solutions identified in their
35
- research was prompt engineering with Chain of Thought.
36
 
37
- Research by organizations like OpenAI and Google has focused on improving contextual reasoning
38
- through fine-tuning, but there is limited work targeting spatial reasoning.
39
 
40
- ## Main Results
41
 
 
42
 
43
 
44
- # Training Data
45
 
46
- For this fine-tuning task the step-game dataset was used. This dataset is large and provides multi-step
47
- reasoning challenges for geospatial reasoning. The train-test split is predefined with 50,000 rows in the train split and 10,000 in the test
48
- split. It focuses on multi-step problem-solving with
49
- spatial relationships, such as directional logic, relative positioning, and route-based reasoning. It
50
- presents text-based tasks that require stepwise deductions, ensuring the model develops strong
51
- reasoning abilities beyond simple fact recall. This dataset follows the template of story,
52
- question and answer to assess spatial reasoning as depicted below.
53
 
54
- ![Description of StepGame Training Data](https://huggingface.co/sareena/spatial_lora_mistral/resolve/main/stepgame.jpg)
55
 
 
56
 
57
- # Training Method
 
 
58
 
59
- For this task of spatial reasoning LoRA (Low-Rank Adaptation) was used as the training method.
60
- LoRA allows for efficient fine-tuning of large language models by freezing the majority of the model weights and only updating small,
61
- low-rank adapter matrices within attention layers. It significantly reduces the computational cost and memory requirements of full
62
- fine-tuning, making it ideal for working with limited GPU resources. LoRA is especially effective for task-specific
63
- adaptation when the dataset is moderately sized and instruction formatting is consistent as in the case of this dataset of stepGame.
64
- In previous experiments with spatial reasoning fine-tuning, LoRA performed better than prompt tuning. While prompt tuning resulted in close to 0% accuracy on both the StepGame and
65
- MMLU evaluations, LoRA preserved partial task performance (18% accuracy) and retained some general knowledge ability (46% accuracy on
66
- MMLU geography vs. 52% before training). I used a learning rate of 2e-4, batch size of 8, and trained for 2 epochs.
67
- This setup preserved general reasoning ability while improving spatial accuracy.
68
 
69
- # Evaluation
70
 
 
71
 
 
72
 
73
- # Usage and Intended Uses
74
- This model is designed to assist with natural language spatial reasoning, particularly in tasks that involve multi-step relational
75
- inference between objects or locations described in text. This could be implemented in agentic spatial systems and/or text-based game bots.
76
 
 
77
 
 
78
 
79
- ```python
80
- from transformers import AutoTokenizer, AutoModelForCausalLM
81
- import torch
82
 
83
- model = AutoModelForCausalLM.from_pretrained("sareena/spatial_lora_mistral")
84
- tokenizer = AutoTokenizer.from_pretrained("sareena/spatial_lora_mistral")
85
 
86
- inputs = tokenizer("Q: The couch is to the left of the table. The lamp is on the couch. Where is the lamp?", return_tensors="pt")
87
- outputs = model.generate(**inputs, max_new_tokens=50)
88
- print(tokenizer.decode(outputs[0], skip_special_tokens=True))
89
 
90
- ```
91
 
92
- # Prompt Format
93
- The model is trained on instruction-style input with a spatial reasoning question:
94
 
95
- ```text
96
- Q: The couch is to the left of the table. The lamp is on the couch. Where is the lamp in relation to the table?
97
- ```
98
 
99
- # Expected Output Format
100
- The output is a short, natural language spatial answer:
101
 
102
- ```text
103
- A: left
104
- ```
105
 
106
- # Limitations
107
 
108
- The model is still limited in deep reasoning capabilities and sometimes fails multi-hop spatial tasks.
109
- LoRA helps balance this trade-off, but fine-tuning on more diverse spatial tasks could yield stronger generalization.
110
- )erformance on the SpatialEval benchmark dropped drastically, due to incompatibility between the prompt style used for training and the
111
- multiple-choice formatting in SpatialEval. Future work to remediate this would be to test more prompt formats in training or use instruction-tuned datasets
112
- more similar to the downstream evaluations.m
113
 
114
- ## Citation
115
 
116
- 1. **Hendrycks, Dan**, Collin Burns, Steven Basart, Andy Zou, Mantas Mazeika, Dawn Song, and Jacob Steinhardt.
117
- *"Measuring Massive Multitask Language Understanding."* arXiv preprint arXiv:2009.03300 (2020).
118
 
119
- 2. **Li, Fangjun**, et al.
120
- *“Advancing Spatial Reasoning in Large Language Models: An in-Depth Evaluation and Enhancement Using the StepGame Benchmark.”*
121
- *arXiv.Org*, 8 Jan. 2024. [https://arxiv.org/abs/2401.03991](https://arxiv.org/abs/2401.03991)
122
 
123
- 3. **Mirzaee, Roshanak**, Hossein Rajaby Faghihi, Qiang Ning, and Parisa Kordjamshidi.
124
- *"SpartQA: A Textual Question Answering Benchmark for Spatial Reasoning."* arXiv preprint arXiv:2104.05832 (2021).
125
 
126
- 4. **Shi, Zhengxiang**, et al.
127
- *“StepGame: A New Benchmark for Robust Multi-Hop Spatial Reasoning in Texts.”*
128
- *arXiv.Org*, 18 Apr. 2022. [https://arxiv.org/abs/2204.08292](https://arxiv.org/abs/2204.08292)
129
 
130
- 5. **Shi, Zhengxiang**, Qiang Zhang, and Aldo Lipani.
131
- *"StepGame: A New Benchmark for Robust Multi-Hop Spatial Reasoning in Texts."* arXiv preprint arXiv:2204.08292 (2022).
132
 
133
- 6. **Wang, Mila**, Xiang Lorraine Li, and William Yang Wang.
134
- *"SpatialEval: A Benchmark for Spatial Reasoning Evaluation."* arXiv preprint arXiv:2104.08635 (2021).
135
 
136
- 7. **Weston, Jason**, Antoine Bordes, Sumit Chopra, and Tomas Mikolov.
137
- *"Towards AI-Complete Question Answering: A Set of Prerequisite Toy Tasks."* arXiv preprint arXiv:1502.05698 (2015).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ base_model: mistralai/Mistral-7B-v0.1
3
+ library_name: peft
 
4
  ---
 
5
 
6
+ # Model Card for Model ID
 
 
 
 
 
 
7
 
8
+ <!-- Provide a quick summary of what the model is/does. -->
 
 
 
 
 
 
 
 
9
 
 
10
 
 
 
 
 
 
 
 
 
11
 
12
+ ## Model Details
 
13
 
14
+ ### Model Description
15
 
16
+ <!-- Provide a longer summary of what this model is. -->
17
 
18
 
 
19
 
20
+ - **Developed by:** [More Information Needed]
21
+ - **Funded by [optional]:** [More Information Needed]
22
+ - **Shared by [optional]:** [More Information Needed]
23
+ - **Model type:** [More Information Needed]
24
+ - **Language(s) (NLP):** [More Information Needed]
25
+ - **License:** [More Information Needed]
26
+ - **Finetuned from model [optional]:** [More Information Needed]
27
 
28
+ ### Model Sources [optional]
29
 
30
+ <!-- Provide the basic links for the model. -->
31
 
32
+ - **Repository:** [More Information Needed]
33
+ - **Paper [optional]:** [More Information Needed]
34
+ - **Demo [optional]:** [More Information Needed]
35
 
36
+ ## Uses
 
 
 
 
 
 
 
 
37
 
38
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
 
40
+ ### Direct Use
41
 
42
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
 
44
+ [More Information Needed]
 
 
45
 
46
+ ### Downstream Use [optional]
47
 
48
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
 
50
+ [More Information Needed]
 
 
51
 
52
+ ### Out-of-Scope Use
 
53
 
54
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
 
 
55
 
56
+ [More Information Needed]
57
 
58
+ ## Bias, Risks, and Limitations
 
59
 
60
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
 
 
61
 
62
+ [More Information Needed]
 
63
 
64
+ ### Recommendations
 
 
65
 
66
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
 
68
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
 
 
 
 
69
 
70
+ ## How to Get Started with the Model
71
 
72
+ Use the code below to get started with the model.
 
73
 
74
+ [More Information Needed]
 
 
75
 
76
+ ## Training Details
 
77
 
78
+ ### Training Data
 
 
79
 
80
+ <!-- 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. -->
 
81
 
82
+ [More Information Needed]
 
83
 
84
+ ### Training Procedure
85
+
86
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
+
88
+ #### Preprocessing [optional]
89
+
90
+ [More Information Needed]
91
+
92
+
93
+ #### Training Hyperparameters
94
+
95
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
+
97
+ #### Speeds, Sizes, Times [optional]
98
+
99
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
+
101
+ [More Information Needed]
102
+
103
+ ## Evaluation
104
+
105
+ <!-- This section describes the evaluation protocols and provides the results. -->
106
+
107
+ ### Testing Data, Factors & Metrics
108
+
109
+ #### Testing Data
110
+
111
+ <!-- This should link to a Dataset Card if possible. -->
112
+
113
+ [More Information Needed]
114
+
115
+ #### Factors
116
+
117
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
+
119
+ [More Information Needed]
120
+
121
+ #### Metrics
122
+
123
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
+
125
+ [More Information Needed]
126
+
127
+ ### Results
128
+
129
+ [More Information Needed]
130
+
131
+ #### Summary
132
+
133
+
134
+
135
+ ## Model Examination [optional]
136
+
137
+ <!-- Relevant interpretability work for the model goes here -->
138
+
139
+ [More Information Needed]
140
+
141
+ ## Environmental Impact
142
+
143
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
+
145
+ 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).
146
+
147
+ - **Hardware Type:** [More Information Needed]
148
+ - **Hours used:** [More Information Needed]
149
+ - **Cloud Provider:** [More Information Needed]
150
+ - **Compute Region:** [More Information Needed]
151
+ - **Carbon Emitted:** [More Information Needed]
152
+
153
+ ## Technical Specifications [optional]
154
+
155
+ ### Model Architecture and Objective
156
+
157
+ [More Information Needed]
158
+
159
+ ### Compute Infrastructure
160
+
161
+ [More Information Needed]
162
+
163
+ #### Hardware
164
+
165
+ [More Information Needed]
166
+
167
+ #### Software
168
+
169
+ [More Information Needed]
170
+
171
+ ## Citation [optional]
172
+
173
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
+
175
+ **BibTeX:**
176
+
177
+ [More Information Needed]
178
+
179
+ **APA:**
180
+
181
+ [More Information Needed]
182
+
183
+ ## Glossary [optional]
184
+
185
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
+
187
+ [More Information Needed]
188
+
189
+ ## More Information [optional]
190
+
191
+ [More Information Needed]
192
+
193
+ ## Model Card Authors [optional]
194
+
195
+ [More Information Needed]
196
+
197
+ ## Model Card Contact
198
+
199
+ [More Information Needed]
200
+ ### Framework versions
201
+
202
+ - PEFT 0.15.1
adapter_config.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "mistralai/Mistral-7B-v0.1",
5
+ "bias": "none",
6
+ "corda_config": null,
7
+ "eva_config": null,
8
+ "exclude_modules": null,
9
+ "fan_in_fan_out": false,
10
+ "inference_mode": true,
11
+ "init_lora_weights": true,
12
+ "layer_replication": null,
13
+ "layers_pattern": null,
14
+ "layers_to_transform": null,
15
+ "loftq_config": {},
16
+ "lora_alpha": 32,
17
+ "lora_bias": false,
18
+ "lora_dropout": 0.05,
19
+ "megatron_config": null,
20
+ "megatron_core": "megatron.core",
21
+ "modules_to_save": null,
22
+ "peft_type": "LORA",
23
+ "r": 8,
24
+ "rank_pattern": {},
25
+ "revision": null,
26
+ "target_modules": [
27
+ "q_proj",
28
+ "v_proj"
29
+ ],
30
+ "task_type": "CAUSAL_LM",
31
+ "trainable_token_indices": null,
32
+ "use_dora": false,
33
+ "use_rslora": false
34
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:69bd02adcb3c97a720467e452ba2a2c83589ffe568acc39fd5fa5032fc05d83b
3
+ size 13648432
special_tokens_map.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "</s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": "</s>",
17
+ "unk_token": {
18
+ "content": "<unk>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ }
24
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dadfd56d766715c61d2ef780a525ab43b8e6da4de6865bda3d95fdef5e134055
3
+ size 493443
tokenizer_config.json ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": null,
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "<unk>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<s>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "2": {
23
+ "content": "</s>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": true
29
+ }
30
+ },
31
+ "additional_special_tokens": [],
32
+ "bos_token": "<s>",
33
+ "clean_up_tokenization_spaces": false,
34
+ "eos_token": "</s>",
35
+ "extra_special_tokens": {},
36
+ "legacy": false,
37
+ "model_max_length": 1000000000000000019884624838656,
38
+ "pad_token": "</s>",
39
+ "sp_model_kwargs": {},
40
+ "spaces_between_special_tokens": false,
41
+ "tokenizer_class": "LlamaTokenizer",
42
+ "unk_token": "<unk>",
43
+ "use_default_system_prompt": false
44
+ }