Predicting the geolocation of tweets using transformer models on customized data

Kateryna Lutsai, Christoph LampertJournal of Spatial Information Science 2025

TL;DR

This paper introduces a novel approach for predicting the geographic location of tweets using transformer models, specifically BERT, fine-tuned on a customized Twitter dataset. By leveraging both tweet content and metadata, the method achieves impressive accuracy, with median errors under 30 km globally and under 15 km in the US, offering a flexible and robust solution for large-scale geo-tagging.

What Problem Does This Paper Address?

Geolocating short text, like tweets, is crucial for various applications, from understanding social dynamics and public health trends to informing business strategies. However, accurately pinpointing the origin of a tweet is challenging due to the limited nature of the text and the scarcity of explicit geo-tags (only ~1-2% of tweets are geo-tagged). Existing methods often rely on user network analysis or specific location-indicative words, which can be limiting. This research aims to develop a flexible and accurate method for tweet geolocation prediction using advanced NLP models that can handle diverse textual data and provide precise coordinate estimates.

Methods

The core of this research lies in fine-tuning pre-trained Bidirectional Encoder Representations from Transformers (BERT) models for geolocation prediction. The authors propose a regression-based approach, predicting coordinate pairs (longitude, latitude) and employing two-dimensional Gaussian Mixture Models (GMMs) to represent uncertainty and multiple potential locations. Key innovations include:

  • Multitask Learning: The model utilizes both "Key Features" (tweet text and user metadata like screen name, description, and location) and "Minor Features" (geo-tagged 'place' metadata) in a multitask learning setup. This allows the model to learn from both explicit geo-information and implicit textual cues.
  • Custom Loss Functions: For GMM-based predictions, custom loss functions were developed to handle the probabilistic output, including a lower-bounded SoftPlus function to ensure covariance parameters remain positive and prevent issues with negative log-likelihood.
  • Model Architecture: The approach involves adding linear regression wrapper layers on top of the BERT base model to output the desired geospatial or probabilistic parameters. Different configurations (SOP, MOP, GSOP, GMOP, PSOP, PMOP) were explored based on the number of prediction outcomes and output type.

Datasets

The research primarily utilizes a large, custom-collected Twitter dataset spanning from 2020-2022. This dataset consists of tweets with defined 'coordinates' and 'place' objects.

  • Training and Development Data: Approximately 150 million geo-tagged tweets were collected. This dataset was filtered to remove bot users (posting >20 messages/day) for evaluation purposes, though training included both real and bot users.
  • Ablation Study Data: A subset focusing on three countries (Great Britain, France, and Canada) was used to specifically address language ambiguity challenges.

Key Insights and Ideas

  • Metadata is Key: The study strongly suggests that incorporating tweet metadata (user profiles, 'place' field) significantly enhances geolocation accuracy compared to relying solely on tweet text.
  • Probabilistic Predictions Outperform Single Points: Predicting a probability distribution (GMMs) rather than a single coordinate point generally leads to better performance, especially in handling ambiguity.
  • Multitask Learning for Robustness: Splitting features into Key and Minor groups for multitask learning proved more effective than concatenating all features into a single input, suggesting that specialized handling of different feature types improves model attention and accuracy.
  • Language Ambiguity is a Challenge: The ablation study highlighted that models struggle with multilingual territories, emphasizing the need for robust handling of language variations.

Key Results

  • High Accuracy: The best models achieved a median error of fewer than 30 km on a worldwide level and fewer than 15 km on US-level datasets.
  • PMOP Model Superiority: The Probabilistic Multiple Outcomes Prediction (PMOP) model, particularly with 5 outcomes and using NON-GEO as the Key Feature and GEO-ONLY as the Minor Feature, demonstrated the most accurate results.
  • Computational Efficiency: The research achieved a processing speed of 14.9 tweets/second for combined geospatial and probabilistic computations on their hardware (NVIDIA GeForce GTX 1080 Ti).
  • Ablation Study Findings: In the country-specific ablation study, Great Britain showed the lowest mean and median error distances, while France had the highest median SAE despite having the least data. Canada, with the largest area, had the highest mean SAE.

Limitations and Future Work

  • Data Availability: The study acknowledges the limitation of not being able to incorporate profile background images due to resource intensity and privacy concerns.
  • Computational Resources: While BERT is efficient, processing large-scale Twitter data still requires significant computational resources.
  • Future Work: The authors suggest exploring other projection methods beyond Plate Carrée and applying the developed techniques to other state-of-the-art NLP models. They also mention the potential for real-time user location monitoring and extending the framework to other prediction outputs.

Summary updated

Abstract

This research is aimed to solve the tweet/user geolocation prediction task and provide a flexible methodology for the geo-tagging of textual big data. The suggested approach implements neural networks for natural language processing (NLP) to estimate the location as coordinate pairs (longitude, latitude) and two-dimensional Gaussian Mixture Models (GMMs). The scope of proposed models has been finetuned on a Twitter dataset using pretrained Bidirectional Encoder Representations from Transformers (BERT) as base models. Performance metrics show a median error of fewer than 30 km on a worldwide-level, and fewer than 15 km on the US-level datasets for the models trained and evaluated on text features of tweets' content and metadata context. Our source code and data are available at https://github.com/K4TEL/geo-twitter.git.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
Worldwide Twitter dataset (300,000 tweets)PMOP (5 outcomes)Med SAE29.4 kmsplit: val
Source quote
L486: 29.4
Worldwide Twitter dataset (300,000 tweets)GMOP (5 outcomes)Med SAE35.6 kmFive-outcome geospatial multiple-outcome model; evaluated with VF=NG. The results are i…
Source quote
L597: 35.6
Worldwide Twitter dataset (300,000 tweets)PSOP (1 outcome)Med SAE32.1 kmOne-outcome probabilistic model; evaluated with VF=NG. The results are in the NG+GO tra…
Source quote
L447: 32.1
Worldwide Twitter dataset (300,000 tweets)GSOP (1 outcome)Med SAE36.6 kmOne-outcome geospatial model; evaluated with VF=NG. The results are in the NG+GO traini…
Source quote
L578: 36.6
BibTeX
@article{lutsai2025predicting,
  author = {Kateryna Lutsai and Christoph Lampert},
  title = {{Predicting the geolocation of tweets using transformer models on customized data}},
  journal = {Journal of Spatial Information Science},
  year = {2025},
  url = {https://openreview.net/forum?id=fYcbbjJwbb},
}
Figure