Text Generation
PEFT
Safetensors
English
code
gis
geospatial
geopandas
shapely
rasterio
osmnx
folium
lora
trl
sft
conversational
Run this model with HF Jobs
Run RhodWeo/GIS-Coder-7B on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/RhodWeo/GIS-Coder-7B. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/RhodWeo/GIS-Coder-7B on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/RhodWeo/GIS-Coder-7B. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/RhodWeo/GIS-Coder-7B. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use RhodWeo/GIS-Coder-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use RhodWeo/GIS-Coder-7B with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-Coder-0.5B-Instruct") model = PeftModel.from_pretrained(base_model, "RhodWeo/GIS-Coder-7B") - Notebooks
- Google Colab
- Kaggle
Update README with full training package documentation
Browse files19 unmodified lines202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214319 unmodified lineslibrary_name: peft---# GIS-Coder: A Code Model for Geographic Information Systems**GIS-Coder** is a LoRA fine-tuned code model specialized in GIS (Geographic Information Systems) and geospatial analysis. Built on top of [Qwen2.5-Coder-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-0.5B-Instruct), it has been fine-tuned on expert-curated GIS code instruction data covering 13+ geospatial Python libraries.## πΊοΈ What Can GIS-Coder Do?- **OSMnx**: Road network analysis, routing, isochrones, POI extraction from OpenStreetMap- **GeoPandas**: Spatial joins, buffering, dissolving, geocoding, file I/O- **Rasterio**: Raster reprojection, NDVI calculation, zonal statistics, hillshade- **Shapely**: Geometry creation, boolean operations, validation, simplification- **GDAL/OGR**: Raster merging, clipping, format conversion- **PyProj**: CRS conversions, UTM zone detection, coordinate transformations- **Folium**: Interactive web maps, heatmaps, choropleths, marker clusters- **MovingPandas**: GPS trajectory analysis, stop detection, generalization- **H3**: Hexagonal spatial indexing, density aggregation- **Fiona**: Low-level vector I/O, filtering, format conversion- **xarray/rioxarray**: Climate data analysis, NetCDF processing, raster export- **PyQGIS**: QGIS scripting, processing algorithms, map layouts- **PySAL**: Spatial autocorrelation (Moran's I), LISA clusters## π Training Details| Metric | Value ||--------|-------|| **Base Model** | Qwen/Qwen2.5-Coder-0.5B-Instruct (494M params) || **Method** | LoRA SFT (r=8, Ξ±=16, target: q/k/v/o/gate/up/down_proj) || **Dataset** | 30 expert-curated GIS code instruction pairs with CoT || **Training Loss** | 1.52 β 0.88 (β42% over 3 epochs) || **Token Accuracy** | 69.3% β 79.3% (+10pp) || **Evaluation Score** | 85% (code + GIS lib + CoT + function quality) |### Training RecipeBased on research from:- **CFD fine-tuning paper** (arxiv:2504.09602): LoRA SFT recipe that outperformed 72B models with a 7B model- **MapCoder-Lite** (arxiv:2509.17489): Qwen2.5-Coder as best backbone for domain code tasks- **GIS benchmark** (arxiv:2410.04617): Identified critical gaps in OSMNX, MovingPandas, Rasterio coverage### Hyperparameters```yamllearning_rate: 2e-4lr_scheduler: cosinewarmup_ratio: 0.1epochs: 3batch_size: 1 (gradient_accumulation_steps: 4)max_length: 1024lora_r: 8lora_alpha: 16lora_dropout: 0.05```## π Usage```pythonfrom transformers import AutoModelForCausalLM, AutoTokenizerfrom peft import PeftModel# Load base model + adapterbase_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-Coder-0.5B-Instruct",trust_remote_code=True,)model = PeftModel.from_pretrained(base_model, "RhodWeo/GIS-Coder-7B")tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-Coder-0.5B-Instruct")# Create promptmessages = [{"role": "system", "content": "You are GIS-Coder, an expert Python programmer specializing in GIS and geospatial analysis."},{"role": "user", "content": "Write a function to calculate NDVI from a satellite image using rasterio."}]text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)inputs = tokenizer(text, return_tensors="pt")outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.7, top_p=0.9)print(tokenizer.decode(outputs[0], skip_special_tokens=True))```## π Training Curves| Epoch | Loss | Token Accuracy ||-------|------|----------------|| 0.13 | 1.520 | 69.3% || 1.00 | 1.238 | 72.2% || 2.00 | 1.007 | 75.5% || 3.00 | 0.880 | **79.3%** |## π¬ Evaluation ResultsTested on 5 GIS code generation prompts covering OSMnx, Rasterio, GeoPandas, CRS handling, and multi-library workflows:| Metric | Score ||--------|-------|| Code blocks generated | 100% || Correct GIS library usage | 100% || Chain-of-thought reasoning | 60% || Function definitions | 80% || **Overall Quality** | **85%** |## π DatasetTraining dataset: [RhodWeo/gis-code-instructions](https://huggingface.co/datasets/RhodWeo/gis-code-instructions)30 expert-curated instruction pairs covering:- Tier 1 (models score 0%): OSMnx, MovingPandas, Rasterio, GDAL, PyProj- Tier 2 (partial coverage): GeoPandas, Shapely, H3- Tier 3 (workflow): Folium, xarray, PyQGIS, Fiona, PySAL## β‘ Scaling UpThis model was trained on CPU with a 0.5B parameter base. For production use, we recommend:1. **Scale the base model**: Use `Qwen/Qwen2.5-Coder-7B-Instruct` with QLoRA on A100 GPU2. **Scale the dataset**: Generate 20K+ examples using OSS-Instruct (Magicoder) pattern with GIS code as seeds3. **Add execution-based filtering**: Test all generated code and keep only passing examples4. **Include CoT annotations**: +20.9% pass@1 improvement per CFD paper ablation## LicenseApache 2.0 (same as base model)19 unmodified lines202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010119 unmodified lineslibrary_name: peft---# GIS-Coder β A Code Model for Geographic Information SystemsA LoRA-adapted code model specialized for GIS and geospatial Python programming. Includes a **ready-to-run training package** for scaling up to 7B on your own GPU cluster.## π¦ This Repo Contains| File | Description ||------|-------------|| `adapter_model.safetensors` | Trained LoRA adapter (0.5B base, proof of concept) || `train_7b.py` | **Production 7B QLoRA training script** with CLI args || `evaluate.py` | Evaluation suite (12 GIS benchmarks with scoring) || `requirements.txt` | All dependencies || `TRAINING_README.md` | **Detailed training guide** β hardware, hyperparameters, ablations |## π Train the 7B Model on Your GPUs```bash# 1. Clone this repogit clone https://huggingface.co/RhodWeo/GIS-Coder-7Bcd GIS-Coder-7B# 2. Install depspip install -r requirements.txt# 3. Loginhuggingface-cli login# 4. Train! (A100 80GB recommended)python train_7b.py# For A10G/RTX 4090 (24GB):python train_7b.py --batch_size 1 --grad_accum 16 --max_length 2048# For H100:python train_7b.py --batch_size 4 --grad_accum 4 --max_length 8192# 5. Evaluatepython evaluate.py --adapter_id ./gis-coder-7b-output/final --compare_base```See **[TRAINING_README.md](TRAINING_README.md)** for the full guide with hardware-specific settings, ablation ideas, and expected results.## πΊοΈ GIS Libraries Covered (13)| Priority | Libraries | Coverage ||----------|-----------|----------|| **Tier 1** (0% baseline) | OSMnx, MovingPandas, Rasterio, GDAL, PyProj | Heavy β these are where models fail || **Tier 2** | GeoPandas, Shapely, H3 | Core GIS operations || **Tier 3** | Folium, xarray, PyQGIS, Fiona, PySAL | Real-world workflows |## π Proof-of-Concept Results (0.5B)Trained on CPU with the smaller base model to validate the approach:| Metric | Start β End ||--------|------------|| **Loss** | 1.52 β 0.88 (β42%) || **Token Accuracy** | 69.3% β **79.3%** (+10pp) || **Eval Quality** | **85%** (code + library + CoT + function) |## π¬ Training RecipeBased on published research:| Principle | Source | Applied ||-----------|--------|---------|| QLoRA SFT beats 72B models | [CFD paper](https://arxiv.org/abs/2504.09602) | r=32, all-linear, lr=2e-4 || Qwen2.5-Coder best backbone | [MapCoder-Lite](https://arxiv.org/abs/2509.17489) | Base model selection || Models score 0% on GIS | [GIS Benchmark](https://arxiv.org/abs/2410.04617) | Heavy OSMnx/MovingPandas coverage || CoT boosts +20.9% pass@1 | CFD paper ablation | All examples include CoT || Target all linear layers | [LoRA Without Regret](https://arxiv.org/abs/2410.13732) | `target_modules="all-linear"` |## π Dataset**[RhodWeo/gis-code-instructions](https://huggingface.co/datasets/RhodWeo/gis-code-instructions)** β 70 expert-curated examples with Chain-of-Thought annotations.## LicenseApache 2.0
README.md+58-100