markrodrigo commited on
Commit
4263e68
1 Parent(s): 541748e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +164 -4
README.md CHANGED
@@ -1,16 +1,176 @@
1
  ---
2
  license: llama3.1
3
  base_model: meta-llama/Meta-Llama-3.1-8B
 
 
4
  pipeline_tag: text2text-generation
5
  ---
6
 
7
- ** See https://huggingface.co/markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0 **
8
-
9
  ### Model Information
10
 
11
- This Quantized model, Llama-3.1-8B-Instruct-Spatial-SQL-1.0, is an 8B, narrow use case, text to spatial SQL, lightly fine-tuned model. In general, its primary use case
12
  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.
13
 
14
  There are four primary geographic functions released in version 1.0.
15
 
16
- **Model developer**: Mark Rodrigo
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: llama3.1
3
  base_model: meta-llama/Meta-Llama-3.1-8B
4
+ language:
5
+ - en
6
  pipeline_tag: text2text-generation
7
  ---
8
 
 
 
9
  ### Model Information
10
 
11
+ This model, Llama-3.1-8B-Instruct-Spatial-SQL-1.0, is an 8B, narrow use case, text to spatial SQL, lightly fine-tuned model. In general, its primary use case
12
  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.
13
 
14
  There are four primary geographic functions released in version 1.0.
15
 
16
+ **Model developer**: Mark Rodrigo
17
+
18
+ **Model Architecture**: The model is a QLoRA / Supervised Fine Tuning (SFT)
19
+
20
+ ### Model Input / Output Overview:
21
+
22
+ Input: Text plus coordinate prompt injection.
23
+ Output: **PostGIS spatial SQL**
24
+ NOTE: Inputs and outputs are in meters and or geographic decimal degrees WGS 84 coordinates.
25
+
26
+ | Function | Question Input | Geo Input | SQL Execution Output |
27
+ |:---------:|:---------------:|:---------:|:-------------------------:|
28
+ | Area | Area question | Polygon | Number - Area sq meters |
29
+ | Centroid | Center question | Polygon | Point |
30
+ | Buffer | Buffer distance | Point | Polygon |
31
+ | Length | Length question | Line | Number - Length in meters |
32
+
33
+ ### Example Prompt / Prompt File
34
+
35
+ <|begin_of_text|><|start_header_id|>system<|end_header_id|>
36
+ <p></p>
37
+ You are a helpful assistant. You are an expert at PostGIS and Postgresql and SQL and psql.
38
+ <p></p>
39
+ <|eot_id|><|start_header_id|>user<|end_header_id|>
40
+
41
+ \### Instruction: Write a PostGIS SQL statement for the following.
42
+ <p></p>
43
+
44
+ \### Input:
45
+
46
+ <p></p>
47
+ {input}
48
+
49
+ <p></p>
50
+
51
+ \### Response:
52
+
53
+ <|eot_id|><|start_header_id|>assistant<|end_header_id|>
54
+
55
+
56
+ ### Examples
57
+
58
+ AREA
59
+ <p></p>
60
+
61
+ \### 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))'
62
+ <p></p>
63
+
64
+ \### 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;
65
+
66
+ <p></p>
67
+ CENTROID
68
+ <p></p>
69
+
70
+ \### 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))'
71
+ <p></p>
72
+
73
+ \### Response: SELECT ST_AsText(ST_AsText(ST_Centroid(geog))) As centroid FROM (select 'Polygon ((
74
+ -3.6934636 40.4808785, -3.6933352 40.4811486, -3.6930125 40.4810598, -3.693141 40.4807897, -3.6934636 40.4808785))' :: geography geog) subquery;
75
+
76
+ <p></p>
77
+ BUFFER
78
+ <p></p>
79
+
80
+ \### Input: What is the thousand meter buffer for the following point? : 'Point(-8.7522658 41.3862664)'
81
+ <p></p>
82
+
83
+ \### Response: SELECT ST_AsText(ST_Buffer(geog, 1000)) as buffer FROM (select 'Point(-8.7522658 41.3862664)' :: geography geog) subquery;
84
+
85
+ <p></p>
86
+ LENGTH
87
+ <p></p>
88
+
89
+ \### Input: How long is the line? : 'LINESTRING (-3.6976693 40.4263178, -3.6986082 40.4258729)'
90
+ <p></p>
91
+
92
+ \### Response: SELECT ST_Length(geog) As length FROM (select 'LINESTRING (-3.6976693 40.4263178, -3.6986082 40.4258729)' :: geography geog) subquery;
93
+ <p></p>
94
+
95
+
96
+ ### A Few Known Question Variation Examples
97
+
98
+ <p></p>
99
+ AREA
100
+ <p></p>
101
+ What is the area for the geometry?
102
+ <p></p>
103
+ What is the area for this polygon?
104
+ <p></p>
105
+ CENTROID
106
+ <p></p>
107
+ What is the centroid for the geometry?
108
+ <p></p>
109
+ What is the center point of the polygon?
110
+ <p></p>
111
+ BUFFER
112
+ <p></p>
113
+ What is the 100 meter buffer for the following point?
114
+ <p></p>
115
+ Buffer the following point a thousand meters.
116
+ <p></p>
117
+ What is the 1000 meter buffer for the following point?
118
+ <p></p>
119
+ LENGTH
120
+ <p></p>
121
+ What is the length of the line?
122
+ <p></p>
123
+ How long is this line?
124
+
125
+
126
+ ### llama.cpp / Hyperparameter Recommendations For Inference
127
+ max context ~ 8,000 or lower
128
+ <p></p>
129
+ top k ~ 100
130
+ <p></p>
131
+ temp ~ .4-.5 or lower
132
+
133
+ ### Agent Considerations
134
+ 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.
135
+
136
+ ### Further Reference - link this
137
+ https://postgis.net/docs/manual-3.3/PostGIS_Special_Functions_Index.html#PostGIS_GeographyFunctions
138
+
139
+ ### Evaluation data
140
+ More information needed
141
+
142
+ ### Training data
143
+ Custom synthetic
144
+
145
+
146
+ ### Training hyperparameters
147
+
148
+ The following hyperparameters were used during training:
149
+ - learning_rate: 2e-06
150
+ - train_batch_size: 1
151
+ - eval_batch_size: 1
152
+ - distributed_type: multi-GPU
153
+ - num_devices: 2
154
+ - total_train_batch_size: 100
155
+ - total_eval_batch_size: 10
156
+ - optimizer: Adam 8bit
157
+ - lr_scheduler_type: linear
158
+ - lr_scheduler_warmup_steps: 10
159
+ - num_epochs: 3
160
+
161
+ ### Training results
162
+
163
+ | Training Loss | Epoch | Step | Validation Loss |
164
+ |:-------------:|:------:|:----:|:---------------:|
165
+ | 0.5438 | 1 | 10 | 0.5247 |
166
+ | 0.4889 | 2 | 20 | 0.4494 |
167
+ | 0.4072 | 3 | 30 | 0.4051 |
168
+
169
+
170
+ ### Framework versions
171
+
172
+ - Transformers 4.44.0
173
+ - Pytorch 2.4.0
174
+ - peft 0.12.0
175
+ - Datasets 2.21.0
176
+ - Tokenizers 0.19.1