Instructions to use markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf", filename="Llama-3.1-8B-Instruct-Spatial-SQL-1.0-Q3_K_M.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf:Q4_K_M # Run inference directly in the terminal: llama-cli -hf markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf:Q4_K_M # Run inference directly in the terminal: llama-cli -hf markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf:Q4_K_M
Use Docker
docker model run hf.co/markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf:Q4_K_M
- Ollama
How to use markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf with Ollama:
ollama run hf.co/markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf:Q4_K_M
- Unsloth Studio
How to use markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf to start chatting
- Pi
How to use markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf:Q4_K_M
Run Hermes
hermes
- Docker Model Runner
How to use markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf with Docker Model Runner:
docker model run hf.co/markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf:Q4_K_M
- Lemonade
How to use markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf:Q4_K_M
Run and chat with the model
lemonade run user.Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf-Q4_K_M
List all available models
lemonade list
- Model Information
- Model Input / Output Overview:
- Example Prompt / Prompt File
- Examples
- A Few Known Question Variation Examples
- llama.cpp / Hyperparameter Recommendations For Inference
- Agent Considerations
- Further Reference - link this
- Evaluation data
- Training data
- Training hyperparameters
- Training results
- Framework versions
Model Information
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 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.
There are four primary geographic functions released in version 1.0.
Model developer: Mark Rodrigo
Github: https://github.com/mprodrigo/spatialsql
Model Architecture: The model is a QLoRA / Supervised Fine Tuning (SFT)
Model Input / Output Overview:
Input: Text plus coordinate prompt injection.
Output: PostGIS spatial SQL
NOTE: Inputs and outputs are in meters and or geographic decimal degrees WGS 84 coordinates.
| Function | Question Input | Geo Input | SQL Execution Output |
|---|---|---|---|
| Area | Area question | Polygon | Number - Area sq meters |
| Centroid | Center question | Polygon | Point |
| Buffer | Buffer distance | Point | Polygon |
| Length | Length question | Line | Number - Length in meters |
Example Prompt / Prompt File
<|begin_of_text|><|start_header_id|>system<|end_header_id|>
You are a helpful assistant. You are an expert at PostGIS and Postgresql and SQL and psql. <|eot_id|><|start_header_id|>user<|end_header_id|>### Instruction: Write a PostGIS SQL statement for the following.
### Input:
{input}### Response:
<|eot_id|><|start_header_id|>assistant<|end_header_id|>
Examples
AREA
### 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))'
### Input: ยฟCuรกl es el รกrea para el polรญgono? : 'Polygon ((-3.7515154 40.3855551, -3.7514972 40.3856581, -3.7507005 40.3855767, -3.7507167 40.3854722, -3.7515154 40.3855551))'
### Input: ๅค้ๅฝข็้ข็ฉๆฏๅคๅฐ๏ผ : 'Polygon ((-3.7515154 40.3855551, -3.7514972 40.3856581, -3.7507005 40.3855767, -3.7507167 40.3854722, -3.7515154 40.3855551))'
### 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;
CENTROID
### 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))'
### Input: ยฟCuรกl es el centroide del polรญgono? : 'Polygon ((-3.6934636 40.4808785, -3.6933352 40.4811486, -3.6930125 40.4810598, -3.693141 40.4807897, -3.6934636 40.4808785))'
### Input: ๅค้ๅฝข็่ณชๅฟๆฏไป้บผ๏ผ : 'Polygon ((-3.6934636 40.4808785, -3.6933352 40.4811486, -3.6930125 40.4810598, -3.693141 40.4807897, -3.6934636 40.4808785))'### 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;
BUFFER### Input: What is the thousand meter buffer for the following point? : 'Point(-8.7522658 41.3862664)'
### Input: ยฟCuรกl es el buffer de mil metros para lo siguiente punto? : 'Point(-8.7522658 41.3862664)'
### Input: ไปฅไธ้ป็ๅ็ฑณ็ทฉ่กๅๆฏๅคๅฐ๏ผ : 'Point(-8.7522658 41.3862664)'
### Response: SELECT ST_AsText(ST_Buffer(geog, 1000)) as buffer FROM (select 'Point(-8.7522658 41.3862664)' :: geography geog) subquery;
LENGTH### Input: How long is the line? : 'LINESTRING (-3.6976693 40.4263178, -3.6986082 40.4258729)'
### Input: ยฟCuรกnto dura la lรญnea? : 'LINESTRING (-3.6976693 40.4263178, -3.6986082 40.4258729)'
### Input: ้ไผๆๅค้ท๏ผ : 'LINESTRING (-3.6976693 40.4263178, -3.6986082 40.4258729)'
### Response: SELECT ST_Length(geog) As length FROM (select 'LINESTRING (-3.6976693 40.4263178, -3.6986082 40.4258729)' :: geography geog) subquery;
A Few Known Question Variation Examples
AREA What is the area for the geometry? What is the area for this polygon? CENTROID What is the centroid for the geometry? What is the center point of the polygon? BUFFER What is the 100 meter buffer for the following point? Buffer the following point a thousand meters. What is the 1000 meter buffer for the following point? LENGTH What is the length of the line? How long is this line?llama.cpp / Hyperparameter Recommendations For Inference
max context ~ 8,000 or lower
top k ~ 100 temp ~ .4-.5 or lowerAgent Considerations
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.
Further Reference - link this
https://postgis.net/docs/manual-3.3/PostGIS_Special_Functions_Index.html#PostGIS_GeographyFunctions
Evaluation data
More information needed
Training data
Custom synthetic
Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 2e-04
- train_batch_size: 10
- eval_batch_size: 3
- distributed_type: multi-GPU
- num_devices: 2
- optimizer: Adam 8bit
- lr_scheduler_type: linear
- num_epochs: 3
Training results
| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| 0.5438 | 3 | 10 | 0.5247 |
| 0.4889 | 3 | 20 | 0.4494 |
| 0.4072 | 3 | 30 | 0.4051 |
Framework versions
- Transformers 4.44.0
- Pytorch 2.4.0
- peft 0.12.0
- Datasets 2.21.0
- Tokenizers 0.19.1
- Downloads last month
- 67
3-bit
4-bit
5-bit
6-bit
8-bit
16-bit
Model tree for markrodrigo/Llama-3.1-8B-Instruct-Spatial-SQL-1.0-gguf
Base model
meta-llama/Llama-3.1-8B