Skip to content

Repository files navigation

Post2Place — Geospatial Analysis of a Tweet-to-Coordinate Mapping Approach

Research project · The University of Texas at San Antonio (UTSA), Department of Computer Science

Authors: Bryce Hinkley · Javier De La Rosa · Fernando Canseco

Overview

Post2Place predicts the geographic coordinates (latitude/longitude) of a social-media post from its text alone — no profile metadata, no GPS tags. The core challenge is that cross-country language differences are obvious, but intra-country regional linguistic patterns (slang, local references, place names) are subtle and require richer modeling. We use transformer embeddings to capture those patterns and regress them directly to coordinates.

Approach

Dataset (~11M tweets). We unified several geotagged-tweet sources (Twitter CIKM 2010, GeoText 2010, Yachay) into a large-scale corpus, then enhanced it:

  • News-based synthesis ("3DL News"): generated tweets reflecting real-world regional topics from a news dataset.
  • Contextual augmentation: used language models to generate contextually relevant posts by pulling nearby content.

Model. A pre-trained transformer embedding model (encoder with attention + MLP blocks followed by pooling) encodes each post into a latent vector; a linear regression head then maps that vector to [latitude, longitude]. Attention-based spatial priors help the model latch onto regionally meaningful words and phrases.

post text → embedding model (encoder → pooling) → embedding vector → linear layer → [lat, lon]

Results

Mean Haversine distance to the true location — lower is better:

Model Mean Haversine Error (km)
PSOP 1881
UnicodeCNN (Large) 2898
UnicodeCNN (Huge) 2802
Our Approach 754
  • Beats published baselines by ~2–4× on the same evaluation.
  • On in-domain (3DL News) test data: 275 km mean / 58 km median error.
  • Downstream application — PFAS contamination zones: classifying posts originating from high-PFAS EPA regions reached F1 ≈ 0.81 (precision 0.83 / recall 0.79) on the 3DL News set, pointing at a public-health use case for text-based geolocation.

Repository contents

  • ddp_train_stella.py — distributed (PyTorch DDP) training of the embedding → coordinate regression model.
  • generate_embeddings.py, notebooks/ — generate text embeddings (GTE-Qwen2, NV-Embed-v2) and train the linear GeoPredictor head (notebooks/linear_model.ipynb).
  • utils/ — dataset utilities (dataset_utils.py), synthetic-tweet generation via vLLM (llm.py), and map visualization (map_visualization.py).
  • dataset_gen.py — dataset assembly and augmentation.
  • AI-Pract-Project.pdf — presentation slides (methodology, dataset visualizations, results tables, EPA-region confusion matrix).

Setup

conda env create -f environment.yaml && conda activate post2geo
# or:  pip install -r requirements.txt

Set HF_TOKEN in your environment to load the dataset from the Hugging Face Hub.

Notes

Team research project (Hinkley · De La Rosa · Canseco). Code is shared here for portfolio and reference purposes; the full dataset and trained checkpoints are not included.

About

Research: predicting a tweet's geographic coordinates from its text alone using transformer embeddings (UTSA). 754 km mean error, beating published baselines 2-4x.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages