markrodrigo commited on
Commit
629f5a9
·
verified ·
1 Parent(s): 988097f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +170 -164
README.md CHANGED
@@ -1,199 +1,205 @@
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: 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