[EMNLP 2025 Findings] Mitigating Geospatial Knowledge Hallucination in Large Language Models: Benchmarking and Dynamic Factuality Aligning
This is the official codebase for our EMNLP 2025 Findings paper. It provides a knowledge-graph-inspired benchmark for geospatial knowledge hallucination and a Dynamic Factuality Aligning (DynamicKTO) method to mitigate it.
- 2025-11 Paper presented at EMNLP 2025 in Suzhou, China.
- 2025-07 Paper released on arXiv: 2507.19586.
This work is part of a series of urban foundation models from FIB Lab, Tsinghua University:
| Work | Venue | Focus |
|---|---|---|
| CityGPT | KDD 2025 | Text-based urban spatial cognition (CityInstruction + SWFT + CityEval) |
| This work (GeospatialHallucination) | EMNLP 2025 Findings | Benchmarking & mitigating the geospatial hallucinations of the above LLMs |
| UrbanLLaVA | ICCV 2025 | Multi-modal extension based on CityGPT (spatial reasoning + understanding) |
In short: CityGPT injects city-scale knowledge to empower LLMs' urban spatial cognition; this work systematically benchmarks and eliminates the geospatial hallucinations these models still suffer from; and UrbanLLaVA further extends the line into the multi-modal dimension.
Overview of the benchmark construction and the Dynamic Factuality Aligning method.
LLMs possess rich geospatial knowledge that has been applied to tasks such as mobility prediction and social indicator prediction. However, they frequently produce geospatial hallucinations — incorrect or inconsistent representations of geospatial information (e.g., fake POIs, wrong addresses, non-existent roads) — which compromise their reliability. This work addresses the problem from both the evaluation and the mitigation sides:
- A comprehensive evaluation framework built on structured geospatial knowledge graphs, providing a controlled benchmark that reveals how hallucinations manifest across 20 advanced LLMs.
- Dynamic Factuality Aligning (DynamicKTO), a learning method based on Kahneman-Tversky Optimization (KTO) that dynamically aligns the model with factual geospatial knowledge, improving benchmark performance by over 29.6%.
Inspired by Knowledge Graphs, geospatial hallucinations are classified into three first-level categories:
| Level | Subcategory | Description |
|---|---|---|
| 1. Entity | Entity Fabrication / Entity Omission | The model claims a non-existent or denies an existing POI / AOI / Road |
| 2. Relation | Relation Fabrication / Relation Omission | The model mistakes the locate-at / near / connect relations between entities |
| 3. Attribute | Attribute Confusion | The model confuses the address / category / land use / area / length attributes of an entity |
The benchmark evaluates the three levels across three geospatial elements (POI, AOI, Road) with 14 fine-grained subcategories.
- Benchmark: 14 fine-grained subcategories over 3 levels (Entity / Relation / Attribute) and 3 elements (POI / AOI / Road), covering 13 cities worldwide.
- Evaluation: systematic evaluation across 20 advanced LLMs reveals prevalent geospatial hallucinations, especially on long-tail knowledge.
- Mitigation: Dynamic Factuality Aligning (KTO) improves benchmark accuracy by over 29.6%, enhancing the trustworthiness of LLMs in geospatial knowledge and reasoning tasks.
City Map (pycitysim)
│ 1_KG_construct → factual urban KG (POI / AOI / Road + address + relations)
▼
Factual KG + 2_hallucination_gen → real vs. hallucinated entity names
│
├─ 3_*/4_tag_*_train_* → DPO preference pairs (entity / attribute / relation)
├─ 5_test_* + 6_simplifier → multiple-choice test sets
│
▼
7_dpo2kto + train/DynamicKTO → KTO training (LLaMA-Factory)
eval/inference + eval/stats → LLM responses + hallucination statistics
.
├── config.py # Global configuration (regions, maps, models, paths)
├── assets/ # Figures (framework / benchmark / example)
├── data/ # Data pipeline
│ ├── 1_KG_construct.py # Construct the factual urban KG (POI/AOI/Road layers)
│ ├── 2_hallucination_gen.py# Generate hallucinated entity names with an LLM
│ ├── 3_train_*_construct.py# Build DPO training data (entity / attribute / relation)
│ ├── 4_tag_*_construct.py # Build tagged DPO training data
│ ├── 5_test_*_construct.py # Build multiple-choice test sets
│ ├── 6_simplifier.py # Simplify test sets (drop refusal options)
│ ├── 7_dpo2kto.py # Convert DPO format to KTO format
│ ├── stats.py # Token statistics utility
│ └── train/ train_tagged/ test/ # Output directories (DPO / tagged DPO / test data)
├── eval/
│ ├── inference.py # Query LLM APIs or local vLLM models
│ └── stats.py # Accuracy + hallucination-type statistics
└── train/
└── DynamicKTO/
└── LLaMA-Factory/ # Submodule (KTO training framework)
git clone https://github.com/tsinghua-fib-lab/GeospatialHallucination.git
cd GeospatialHallucination
# initialize the LLaMA-Factory submodule
git submodule update --init --recursive
pip install -r requirements.txtKey dependencies include pycitysim (map data), shapely, pandas, numpy, tenacity, openai, tqdm, and optionally vllm for local inference.
All global settings live in config.py. Before running any script, fill in:
SERVING_IP— server for OSM reverse geocoding (Nominatim).SERVER_IP,LOCAL_MODEL_KEY— local model server.MONGODB_URI— MongoDB that hosts the city maps (used bypycitysim).REGION_EXP— region for the experiment (defaultBeijing; seeMAP_DICTandREGION_BOUNDARYfor the 13 supported cities).MIN_ROAD_LENGTH— minimum road length (meters) to consider.
Also set the relevant environment variables for LLM APIs, e.g. SiliconFlow_API_KEY, DeepInfra_API_KEY or OpenAI_API_KEY.
Set REGION_EXP and MONGODB_URI in config.py, then:
cd data
python 1_KG_construct.pyThis writes <Region>_roads_basic.csv, <Region>_pois_basic.csv, <Region>_aois_basic.csv and <Region>_{pois,aois,roads}.json under resource/.
Update the source file paths and the API_TYPE / API_KEY in the script:
cd data
python 2_hallucination_gen.pyOutputs hallucinated_{poi,aoi,road}_names.txt.
Adjust the source/hallucinated-name paths and CITY in each script:
cd data
python 3_train_entity_construct.py
python 3_train_attribute_construct.py
python 3_train_relation_construct.py
# or the tagged variants
python 4_tag_train_entity_construct.py
python 4_tag_train_attribute_construct.py
python 4_tag_train_relation_construct.pyDPO-format data is written to train/ (or train_tagged/) as dpo_{entity,attribute,relation}.json.
cd data
python 5_test_entity_construct.py # 1.x entity-level questions
# ... plus relation / attribute construction scripts (see data/)
python 6_simplifier.py # remove "Cannot determine"/"Refuse to answer" optionsTest sets are JSON files of multiple-choice questions saved under data/test/.
cd data
python 7_dpo2kto.pyProduces kto_{entity,attribute,relation}.json in train_tagged/.
Use the LLaMA-Factory submodule under train/DynamicKTO/ to run KTO training with the generated KTO datasets.
Set the test set directory and the model list in eval/inference.py, then:
cd eval
# test models served via DeepInfra / Siliconflow / OpenAI APIs or local vLLM
python inference.py
python inference.py --sampled # run on a small sample (first 10 instances)Responses are saved under eval/output/. Compute accuracy and hallucination-type statistics:
python stats.pyThis writes stats.json, testset_stats.json, hallucination_first_level.json, hallucination_second_level.json, hallucination_type.json and an output_stats.xlsx report.
Beijing, Shanghai, Mumbai, Tokyo, London, Paris, Moscow, New York, San Francisco, São Paulo, Nairobi, Cape Town, Sydney.
OpenAI, DeepInfra, Siliconflow, DeepBricks (via OpenAI-compatible API) and local models served through vLLM. The evaluated models include Qwen2, InternLM2.5, Mistral, Mixtral, Llama-3, Gemma-2, DeepSeek, GPT-3.5/4, etc. (see config.py).
If you find this work useful, please cite:
@inproceedings{wang-etal-2025-mitigating,
title = "Mitigating Geospatial Knowledge Hallucination in Large Language Models: Benchmarking and Dynamic Factuality Aligning",
author = "Wang, Shengyuan and Feng, Jie and Liu, Tianhui and Pei, Dan and Li, Yong",
booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2025",
month = nov,
year = "2025",
address = "Suzhou, China",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2025.findings-emnlp.45/",
doi = "10.18653/v1/2025.findings-emnlp.45",
pages = "870--888"
}This project is released under the MIT License. Copyright (c) 2025 FIB Lab, Tsinghua University.

