markrodrigo commited on
Commit
b4429a2
·
verified ·
1 Parent(s): db9cf35

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +164 -154
README.md CHANGED
@@ -1,199 +1,209 @@
1
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  library_name: transformers
3
- tags: []
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
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
 
 
 
 
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]
 
1
  ---
2
+ license: apache-2.0
3
+ base_model:
4
+ - Qwen/Qwen3.5-0.8B
5
+ base_model_relation: finetune
6
+ language:
7
+ - en
8
+ - zh
9
+ pipeline_tag: text-generation
10
+ tags:
11
+ - code
12
+ - spatial
13
+ - SQL
14
+ - GIS
15
+ - PostGIS
16
  library_name: transformers
 
17
  ---
18
 
19
+ ### Model Information
20
 
21
+ This model, Qwen-3.5-0.8B-Spatial-SQL-1.1, is an 0.8B, narrow use case, text to spatial SQL, lightly fine-tuned model. In general, its primary use case
22
+ is the Natural Language command adaptation of particular geographic spatial functions as normally defined in pure SQL. Data input should be a combination of an English prefix in the form of a question, and a coordinate prompt injection, likely from an active mapping system application coordinate list. Output is PostGIS spatial SQL.
23
 
24
+ There are five primary geographic functions released in version 1.1.
25
 
26
+ **Model developer**: Mark Rodrigo
27
 
28
+ **Github**: https://github.com/mprodrigo/spatialsql
29
 
30
+ **Model Architecture**: The model is a QLoRA / Supervised Fine Tuning (SFT)
31
 
32
+ ### Model Input / Output Overview:
33
 
34
+ Input: Text plus coordinate prompt injection.
35
+ </br>
36
+ Output: **PostGIS spatial SQL**
37
+ </br>
38
+ NOTE: Inputs and outputs are in meters and or geographic decimal degrees WGS 84 coordinates.
39
 
40
+ | Function | Question Input | Geo Input | SQL Execution Output |
41
+ |:---------:|:----------------:|:---------:|:-------------------------:|
42
+ | Area | Area question | Polygon | Number - Area sq meters |
43
+ | Centroid | Center question | Polygon | Point |
44
+ | Buffer | Buffer distance | Point | Polygon |
45
+ | Length | Length question | Line | Number - Length in meters |
 
46
 
47
+ </br>
48
 
49
+ | Function | Question Input | Geo Input 1 | Geo Input 2 | SQL Execution Output |
50
+ |:---------:|:----------------:|:-----------------------:|:-----------------------:|:-----------------------------------------------|
51
+ | Distance | Distance question| Point, Line, or Polygon | Point, Line, or Polygon | Number - Distance between geometries in meters |
52
 
53
+ ### Example Prompt / Prompt File
 
 
54
 
55
+ <|begin_of_text|><|start_header_id|>system<|end_header_id|>
56
+ <p></p>
57
+ You are a helpful assistant. You are an expert at PostGIS and Postgresql and SQL and psql.
58
+ <p></p>
59
+ <|eot_id|><|start_header_id|>user<|end_header_id|>
60
 
61
+ \### Instruction: Write a PostGIS SQL statement for the following.
62
+ <p></p>
63
 
64
+ \### Input:
65
 
66
+ <p></p>
67
+ {input}
68
 
69
+ <p></p>
70
 
71
+ \### Response:
72
 
73
+ <|eot_id|><|start_header_id|>assistant<|end_header_id|>
74
 
 
75
 
76
+ ### Examples
77
 
 
78
 
79
+ AREA
80
+ <p></p>
81
 
82
+ \### Input: What is the area for the polygon? : 'Polygon ((-3.7515154 40.3855551, -3.7514972 40.3856581, -3.7507005 40.3855767, -3.7507167 40.3854722, -3.7515154 40.3855551))'
83
+ <p></p>
84
 
85
+ \### Response: SELECT ST_Area(geog) As area FROM (select 'Polygon ((-3.7515154 40.3855551, -3.7514972 40.3856581, -3.7507005 40.3855767, -3.7507167 40.3854722, -3.7515154 40.3855551))' :: geography geog) subquery;
86
+ <p></p>
87
 
88
+ CENTROID
89
+ <p></p>
90
 
91
+ \### Input: What is the centroid for the polygon? : 'Polygon ((-3.6934636 40.4808785, -3.6933352 40.4811486, -3.6930125 40.4810598, -3.693141 40.4807897, -3.6934636 40.4808785))'
92
+ <p></p>
93
 
94
+ \### Response: SELECT ST_AsText(ST_Centroid(geog)) As centroid FROM (select 'Polygon ((-3.6934636 40.4808785, -3.6933352 40.4811486, -3.6930125 40.4810598, -3.693141 40.4807897, -3.6934636 40.4808785))' :: geography geog) subquery;
95
 
96
+ BUFFER
97
+ <p></p>
98
 
99
+ \### Input: What is the thousand meter buffer for the following point? : 'Point(-8.7522658 41.3862664)'
100
+ <p></p>
101
 
102
+ \### Response: SELECT ST_AsText(ST_Buffer(geog, 1000)) as buffer FROM (select 'Point(-8.7522658 41.3862664)' :: geography geog) subquery;
103
 
104
+ <p></p>
105
+ LENGTH
106
+ <p></p>
107
 
108
+ \### Input: How long is the line? : 'LINESTRING (-3.6976693 40.4263178, -3.6986082 40.4258729)'
109
+ <p></p>
110
 
111
+ \### Response: SELECT ST_Length(geog) As length FROM (select 'LINESTRING (-3.6976693 40.4263178, -3.6986082 40.4258729)' :: geography geog) subquery;
112
+ <p></p>
113
+ DISTANCE
114
+ <p></p>
115
 
116
+ \### INPUT: How far apart is the point and line? : 'Point(-109.87549823 38.60574249)' 'LineString(-109.24324628 38.76349931, -109.4821773 38.6875815)'
117
+ <p></p>
118
 
119
+ \### Response: SELECT ST_Distance(gg1, gg2) As distance FROM (select 'Point(-109.87549823 38.60574249)' :: geography gg1, 'LineString(-109.24324628 38.76349931, -109.4821773 38.6875815)' :: geography gg2) subquery;
120
+ <p></p>
121
 
122
+ ### A Few Known Question Variation Examples
123
 
124
+ <p></p>
125
+ AREA
126
+ <p></p>
127
+ What is the area for the geometry?
128
+ <p></p>
129
+ What is the area for this polygon?
130
+ <p></p>
131
+ CENTROID
132
+ <p></p>
133
+ What is the centroid for the geometry?
134
+ <p></p>
135
+ What is the center point of the polygon?
136
+ <p></p>
137
+ BUFFER
138
+ <p></p>
139
+ What is the 100 meter buffer for the following point?
140
+ <p></p>
141
+ Buffer the following point a thousand meters.
142
+ <p></p>
143
+ What is the 1000 meter buffer for the following point?
144
+ <p></p>
145
+ LENGTH
146
+ <p></p>
147
+ What is the length of the line?
148
+ <p></p>
149
+ How long is this line?
150
+ <p></p>
151
+ DISTANCE
152
+ <p></p>
153
+ The distance between the polygon and the line is?
154
+ <p></p>
155
+ What is the distance between the points?
156
+ <p></p>
157
+ How far apart are the two lines?
158
 
159
+ ### llama.cpp / Hyperparameter Recommendations For Inference
160
+ max context ~ 262,000
161
+ <p></p>
162
+ top k ~ 100
163
+ <p></p>
164
+ temp ~ .4-.5 or lower
165
 
166
+ ### Agent Considerations
167
+ Agents are being considered as a separate project. Agents would mostly be related to pulling the coordinates from a mapping UI, and executing the SQL from responses against a PostGIS database.
168
 
169
+ ### Further Reference - link this
170
+ https://postgis.net/docs/manual-3.3/PostGIS_Special_Functions_Index.html#PostGIS_GeographyFunctions
171
 
172
+ ### Evaluation data
173
+ More information needed
174
+
175
+ ### Training data
176
+ Custom synthetic
177
+
178
+ ### Training hyperparameters
179
+
180
+ The following hyperparameters were used during training:
181
+ - learning_rate: 1e-4
182
+ - distributed_type: multi-GPU
183
+ - num_devices: 2
184
+ - optimizer: Adam 8bit
185
+ - lr_scheduler_type: linear
186
+
187
+ ### Training results
188
+
189
+ | Training Loss | Step | Validation Loss |
190
+ |:-------------:|:----:|:---------------:|
191
+ | 1.1339 | 10 | 0.9006 |
192
+ | 0.8021 | 20 | 0.7433 |
193
+ | 0.7347 | 30 | 0.6840 |
194
+ | 0.6844 | 40 | 0.6384 |
195
+ | 0.6200 | 50 | 0.5959 |
196
+ | 0.5957 | 60 | 0.5635 |
197
+ | 0.5564 | 70 | 0.5511 |
198
+
199
+
200
+
201
+
202
+ ### Framework versions
203
+
204
+ - transformers 5.14.1
205
+ - torch 2.13.0
206
+ - peft 0.20.0
207
+ - bitsandbytes 0.50.0
208
+ - datasets 5.0.1
209
+ - tokenizers 0.23.1