markrodrigo
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -1,199 +1,205 @@
|
|
1 |
---
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
---
|
5 |
|
6 |
-
|
7 |
|
8 |
-
|
9 |
|
|
|
|
|
10 |
|
|
|
11 |
|
12 |
-
|
|
|
13 |
|
14 |
-
|
15 |
|
16 |
-
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
-
|
26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
|
28 |
-
###
|
29 |
|
30 |
-
|
|
|
|
|
|
|
|
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
- **Demo [optional]:** [More Information Needed]
|
35 |
|
36 |
-
|
37 |
|
38 |
-
|
|
|
39 |
|
40 |
-
|
41 |
|
42 |
-
|
43 |
|
44 |
-
|
45 |
|
46 |
-
### Downstream Use [optional]
|
47 |
|
48 |
-
|
49 |
|
50 |
-
[More Information Needed]
|
51 |
|
52 |
-
|
|
|
53 |
|
54 |
-
|
|
|
55 |
|
56 |
-
|
|
|
57 |
|
58 |
-
|
|
|
59 |
|
60 |
-
|
|
|
61 |
|
62 |
-
|
63 |
|
64 |
-
|
|
|
65 |
|
66 |
-
|
|
|
67 |
|
68 |
-
|
|
|
|
|
|
|
|
|
69 |
|
70 |
-
|
|
|
71 |
|
72 |
-
|
|
|
73 |
|
74 |
-
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
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: llama3.2
|
3 |
+
base_model: meta-llama/Meta-Llama-3.2-1B
|
4 |
+
language:
|
5 |
+
- en
|
6 |
+
pipeline_tag: text-generation
|
7 |
+
tags:
|
8 |
+
- code
|
9 |
+
- spatial
|
10 |
+
- sql
|
11 |
+
- GIS
|
12 |
+
- PostGIS
|
13 |
---
|
14 |
|
15 |
+
**ENGLISH ONLY - Use 8b models for alternate languages.**
|
16 |
|
17 |
+
### Model Information
|
18 |
|
19 |
+
This model, Llama-3.2-1B-Instruct-Spatial-SQL-1.0, is an 1B, narrow use case, text to spatial SQL, lightly fine-tuned model. In general, its primary use case
|
20 |
+
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.
|
21 |
|
22 |
+
There are four primary geographic functions released in version 1.0.
|
23 |
|
24 |
+
**Model developer**: Mark Rodrigo
|
25 |
+
- Chat to Map interfacing.
|
26 |
|
27 |
+
**Model Architecture**: The model is a QLoRA / Supervised Fine Tuning (SFT)
|
28 |
|
29 |
+
### Model Input / Output Overview:
|
30 |
|
31 |
+
Input: Text plus coordinate prompt injection.
|
32 |
+
</br>
|
33 |
+
Output: **PostGIS spatial SQL**
|
34 |
+
</br>
|
35 |
+
NOTE: Inputs and outputs are in meters and or geographic decimal degrees WGS 84 coordinates.
|
36 |
|
37 |
+
| Function | Question Input | Geo Input | SQL Execution Output |
|
38 |
+
|:---------:|:---------------:|:---------:|:-------------------------:|
|
39 |
+
| Area | Area question | Polygon | Number - Area sq meters |
|
40 |
+
| Centroid | Center question | Polygon | Point |
|
41 |
+
| Buffer | Buffer distance | Point | Polygon |
|
42 |
+
| Length | Length question | Line | Number - Length in meters |
|
|
|
43 |
|
44 |
+
### Example Prompt / Prompt File
|
45 |
|
46 |
+
<|begin_of_text|><|start_header_id|>system<|end_header_id|>
|
47 |
+
<p></p>
|
48 |
+
You are a helpful assistant. You are an expert at PostGIS and Postgresql and SQL and psql.
|
49 |
+
<p></p>
|
50 |
+
<|eot_id|><|start_header_id|>user<|end_header_id|>
|
51 |
|
52 |
+
\### Instruction: Write a PostGIS SQL statement for the following.
|
53 |
+
<p></p>
|
|
|
54 |
|
55 |
+
\### Input:
|
56 |
|
57 |
+
<p></p>
|
58 |
+
{input}
|
59 |
|
60 |
+
<p></p>
|
61 |
|
62 |
+
\### Response:
|
63 |
|
64 |
+
<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
65 |
|
|
|
66 |
|
67 |
+
### Examples
|
68 |
|
|
|
69 |
|
70 |
+
AREA
|
71 |
+
<p></p>
|
72 |
|
73 |
+
\### 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))'
|
74 |
+
<p></p>
|
75 |
|
76 |
+
\### 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;
|
77 |
+
<p></p>
|
78 |
|
79 |
+
CENTROID
|
80 |
+
<p></p>
|
81 |
|
82 |
+
\### 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))'
|
83 |
+
<p></p>
|
84 |
|
85 |
+
\### 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;
|
86 |
|
87 |
+
BUFFER
|
88 |
+
<p></p>
|
89 |
|
90 |
+
\### Input: What is the thousand meter buffer for the following point? : 'Point(-8.7522658 41.3862664)'
|
91 |
+
<p></p>
|
92 |
|
93 |
+
\### Response: SELECT ST_AsText(ST_Buffer(geog, 1000)) as buffer FROM (select 'Point(-8.7522658 41.3862664)' :: geography geog) subquery;
|
94 |
+
|
95 |
+
<p></p>
|
96 |
+
LENGTH
|
97 |
+
<p></p>
|
98 |
|
99 |
+
\### Input: How long is the line? : 'LINESTRING (-3.6976693 40.4263178, -3.6986082 40.4258729)'
|
100 |
+
<p></p>
|
101 |
|
102 |
+
\### Response: SELECT ST_Length(geog) As length FROM (select 'LINESTRING (-3.6976693 40.4263178, -3.6986082 40.4258729)' :: geography geog) subquery;
|
103 |
+
<p></p>
|
104 |
|
105 |
+
### A Few Known Question Variation Examples
|
106 |
|
107 |
+
<p></p>
|
108 |
+
AREA
|
109 |
+
<p></p>
|
110 |
+
What is the area for the geometry?
|
111 |
+
<p></p>
|
112 |
+
What is the area for this polygon?
|
113 |
+
<p></p>
|
114 |
+
CENTROID
|
115 |
+
<p></p>
|
116 |
+
What is the centroid for the geometry?
|
117 |
+
<p></p>
|
118 |
+
What is the center point of the polygon?
|
119 |
+
<p></p>
|
120 |
+
BUFFER
|
121 |
+
<p></p>
|
122 |
+
What is the 100 meter buffer for the following point?
|
123 |
+
<p></p>
|
124 |
+
Buffer the following point a thousand meters.
|
125 |
+
<p></p>
|
126 |
+
What is the 1000 meter buffer for the following point?
|
127 |
+
<p></p>
|
128 |
+
LENGTH
|
129 |
+
<p></p>
|
130 |
+
What is the length of the line?
|
131 |
+
<p></p>
|
132 |
+
How long is this line?
|
133 |
+
|
134 |
+
|
135 |
+
### llama.cpp / Hyperparameter Recommendations For Inference
|
136 |
+
max context ~ 8,000 or lower
|
137 |
+
<p></p>
|
138 |
+
top k ~ 100 or lower
|
139 |
+
<p></p>
|
140 |
+
temp ~ .4-.7 or lower
|
141 |
+
|
142 |
+
### Agent Considerations
|
143 |
+
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.
|
144 |
+
|
145 |
+
### Further Reference - link this
|
146 |
+
https://postgis.net/docs/manual-3.3/PostGIS_Special_Functions_Index.html#PostGIS_GeographyFunctions
|
147 |
+
|
148 |
+
### Evaluation data
|
149 |
+
More information needed
|
150 |
+
|
151 |
+
### Training data
|
152 |
+
Custom synthetic
|
153 |
+
|
154 |
+
### Training hyperparameters
|
155 |
+
|
156 |
+
The following hyperparameters were used during training:
|
157 |
+
- learning_rate: 3e-05
|
158 |
+
- train_batch_size: 10
|
159 |
+
- eval_batch_size: 3
|
160 |
+
- distributed_type: multi-GPU
|
161 |
+
- num_devices: 2
|
162 |
+
- optimizer: Adam 8bit
|
163 |
+
- lr_scheduler_type: linear
|
164 |
+
- num_epochs: 20
|
165 |
+
|
166 |
+
### Training results
|
167 |
+
|
168 |
+
| Training Loss | Epoch | Step | Validation Loss |
|
169 |
+
|:-------------:|:------:|:----:|:---------------:|
|
170 |
+
| 1.9106 | 20 | 10 | 1.9183 |
|
171 |
+
| 1.1674 | 20 | 20 | 1.1710 |
|
172 |
+
| 0.7446 | 20 | 30 | 0.7589 |
|
173 |
+
| 0.6143 | 20 | 40 | 0.6220 |
|
174 |
+
| 0.5773 | 20 | 50 | 0.5695 |
|
175 |
+
| 0.5328 | 20 | 60 | 0.5334 |
|
176 |
+
| 0.5146 | 20 | 70 | 0.5096 |
|
177 |
+
| 0.4895 | 20 | 80 | 0.4925 |
|
178 |
+
| 0.4893 | 20 | 90 | 0.4772 |
|
179 |
+
| 0.4710 | 20 | 100 | 0.4612 |
|
180 |
+
| 0.4572 | 20 | 110 | 0.4438 |
|
181 |
+
| 0.4358 | 20 | 120 | 0.4233 |
|
182 |
+
| 0.4002 | 20 | 130 | 0.4014 |
|
183 |
+
| 0.3812 | 20 | 140 | 0.3768 |
|
184 |
+
| 0.3461 | 20 | 150 | 0.3492 |
|
185 |
+
| 0.3222 | 20 | 160 | 0.3202 |
|
186 |
+
| 0.3043 | 20 | 170 | 0.2921 |
|
187 |
+
| 0.2727 | 20 | 180 | 0.2651 |
|
188 |
+
| 0.2378 | 20 | 190 | 0.2403 |
|
189 |
+
| 0.2229 | 20 | 200 | 0.2184 |
|
190 |
+
| 0.2121 | 20 | 210 | 0.1990 |
|
191 |
+
| 0.1891 | 20 | 220 | 0.1834 |
|
192 |
+
| 0.1867 | 20 | 230 | 0.1723 |
|
193 |
+
| 0.1848 | 20 | 240 | 0.1654 |
|
194 |
+
| 0.1732 | 20 | 250 | 0.1631 |
|
195 |
+
|
196 |
+
|
197 |
+
|
198 |
+
|
199 |
+
### Framework versions
|
200 |
+
|
201 |
+
- Transformers 4.45.1
|
202 |
+
- Pytorch 2.5.0
|
203 |
+
- peft 0.13.2
|
204 |
+
- Datasets 3.0.1
|
205 |
+
- Tokenizers 0.20.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|