Skip to content

Latest commit

ย 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

MobQA: A Benchmark Dataset for Semantic Understanding of Human Mobility Data through Question Answering

Hikaru Asano1 ย  Hiroki Ouchi2,3 ย  Akira Kasuga3 ย  Ryo Yonetani3

1The University of Tokyo ย  2Nara Institute of Science and Technology ย  3CyberAgent

arXiv paper License


๐Ÿ“– Overview

This repository provides tools and data for building a mobility question answering dataset. The dataset combines trajectory data with question-answer pairs covering factual retrieval, multiple choice, and free-form questions about mobility patterns and behaviors.

๐Ÿ›  Prerequisites

  • macOS: This project has been tested and confirmed to work on macOS
  • uv: Required for Python package management and environment setup
  • OpenAI API: Required when using OpenAI models
  • Google Cloud Platform (GCP): Required when using Gemini models

๐Ÿš€ Setup Guide

1. ๐Ÿ“ฆ Python Environment Setup

First, install dependencies and set up your environment:

# Install dependencies
uv sync

2. ๐Ÿ”‘ Environment Configuration

Configure your environment by creating a .env file with your API keys and project settings.

  1. Copy the example file:

    cp .env.example .env
  2. Open .env in your editor and replace the placeholder values with your actual credentials. Example .env content:

    OPENAI_API_KEY=sk-your_actual_api_key_here
    # The following GCP settings are only required if you plan to use Google Gemini models.
    GCP_PROJECT=your-gcp-project-id
    GCP_LOCATION=your-gcp-region

Required Environment Variables:

  • OPENAI_API_KEY: Your OpenAI API key
  • GCP_PROJECT: Google Cloud Platform project ID
  • GCP_LOCATION: GCP region (e.g., us-central1, asia-northeast1)

3. ๐Ÿ“ Download GeoLife Dataset

Before building the dataset, you need to download the GeoLife dataset:

  1. ๐Ÿ“ฅ Download: Visit Microsoft Research GeoLife and download the GPS trajectory dataset
  2. ๐Ÿ“‚ Extract and Place: Extract the downloaded archive and place the contents in data/geolife/
  3. โœ… Verify: Ensure the directory structure matches the expected format below

Expected directory structure after setup:

data/
โ””โ”€โ”€ geolife/
    โ””โ”€โ”€ Data/
        โ”œโ”€โ”€ 000/
        โ”‚   โ””โ”€โ”€ Trajectory/
        โ”‚       โ”œโ”€โ”€ 20081023025304.plt
        โ”‚       โ””โ”€โ”€ ...
        โ”œโ”€โ”€ 001/
        โ”œโ”€โ”€ 002/
        โ””โ”€โ”€ ... (up to 181)

๐Ÿ—๏ธ Dataset Construction

Building the Complete Dataset

To build the complete dataset, run the following command:

# Build the complete Mobility QA dataset
bash scripts/build_dataset.sh

The script will automatically execute the preprocessing pipeline and generate the final dataset in the mobility_qa_dataset/ directory.

For detailed information about each preprocessing step, see src/mobility_qa/preprocess/README.md.

๐Ÿ“Š Dataset Structure

The final dataset is organized as follows:

mobility_qa_dataset/
โ”œโ”€โ”€ factual_retrieval/
โ”‚   โ”œโ”€โ”€ one_day/                    # ๐Ÿ“… Single-day factual retrieval questions
โ”‚   โ”‚   โ”œโ”€โ”€ place_to_time/          # ๐Ÿ“ "When was the person at location X?"
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ 1/qa.json
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ 2/qa.json
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ””โ”€โ”€ ... (other question types)
โ”‚   โ””โ”€โ”€ weekly/                     # ๐Ÿ“ˆ Weekly pattern questions
โ”œโ”€โ”€ free_form/
โ”‚   โ”œโ”€โ”€ one_day/                    # ๐Ÿ’ญ Single-day open-ended questions
โ”‚   โ””โ”€โ”€ weekly/                     # ๐Ÿ“ Weekly analysis questions
โ””โ”€โ”€ multiple_choice/
    โ”œโ”€โ”€ one_day/                    # โœ… Single-day multiple choice questions
    โ””โ”€โ”€ weekly/                     # ๐Ÿ“‹ Weekly multiple choice questions

Each QA file contains:

  • โ“ Question text
  • ๐Ÿท๏ธ Question type and metadata
  • โœ… Ground truth answers
  • ๐Ÿ›ฃ๏ธ Integrated trajectory data (filtered and normalized)
  • ๐Ÿ‘ค User ID and original day information

๐Ÿค– Demonstrating QA Task

The repository includes three completion scripts for generating answers using large language models.

๐Ÿ“œ Available Scripts

  1. ๐Ÿ” Factual Retrieval: scripts/fact_retrieval.py - Extract specific facts from trajectory data
  2. โœ… Multiple Choice: scripts/multi_choice.py - Answer multiple-choice questions about mobility patterns
  3. ๐Ÿ’ญ Free Form: scripts/free_form.py - Generate open-ended responses with automatic evaluation

๐ŸŽฏ Basic Usage

Run each script with default settings (no annotations, 10 questions per script):

# Run factual retrieval (extracts specific facts)
uv run scripts/fact_retrieval.py

# Run multiple choice (selects from given options)
uv run scripts/multi_choice.py

# Run free form (generates open-ended answers)
uv run scripts/free_form.py

โš™๏ธ Advanced Usage with Parameters

# Specify model and parameters
uv run scripts/fact_retrieval.py \
  --model_name gpt-4o \
  --temperature 0.5 \
  --num_questions 20

# Include all annotation types (mobility_mode, poi, reason)
uv run scripts/multi_choice.py \
  --with_annotation

# Run free form with evaluation model
uv run scripts/free_form.py \
  --model_name gpt-4o-mini \
  --evaluation_model_name gpt-4o \
  --with_annotation

๐Ÿ”ง Parameter Options

Parameter Type Default Description
--model_name str gpt-4o-mini ๐Ÿค– LLM model name to use
--temperature float 0.0 ๐ŸŒก๏ธ Temperature for generation (0.0-1.0)
--num_questions int 10 ๐Ÿ”ข Number of questions to process
--with_annotation flag False ๐Ÿ“ Include all annotation types (mobility_mode, poi, reason)
--evaluation_model_name str gpt-4o ๐ŸŽฏ Model for evaluation (free_form only)
--max_retries int 5 ๐Ÿ”„ Maximum number of retries for failed requests
--initial_wait_time int 30 โฐ Initial wait time for retries (seconds)
--seed int 42 ๐ŸŽฒ Random seed for reproducibility

๐Ÿ“‹ Annotation Modes

Mode Description Trajectory Format Use Case
Default (no flag) ๐Ÿšถ Basic trajectory only [day, time, x, y] Quick testing, basic analysis
--with_annotation ๐Ÿ“Š All annotations included [day, time, x, y, mobility_mode, poi, reason] Comprehensive analysis, research

๐Ÿ’ก Example Commands

# Basic usage with default settings (no annotations, 10 questions)
uv run scripts/fact_retrieval.py

# Process more questions with a different model
uv run scripts/multi_choice.py \
  --model_name gpt-4 \
  --num_questions 50

# Include all annotations for comprehensive analysis
uv run scripts/free_form.py \
  --with_annotation \
  --temperature 0.3

# Large-scale evaluation with custom retry settings
uv run scripts/fact_retrieval.py \
  --with_annotation \
  --model_name gpt-4 \
  --num_questions 100 \
  --max_retries 10 \
  --initial_wait_time 60 \
  --seed 123

# Reproducible experiments with specific seed
uv run scripts/multi_choice.py \
  --model_name gpt-4 \
  --seed 12345

๐Ÿ“‹ Detailed Information

๐Ÿ“„ Data Format

QA File Structure

{
  "question": "When was the person at (10.54, 3.78)?",
  "question_type": "place_to_time",
  "original_days": [6],
  "user_id": 115,
  "answer": ["01:30"],
  "trajectory": [
    ["day", "time", "x", "y"],
    [1, "02:19:16", -0.15, 0.4],
    [1, "02:20:01", -0.17, 0.33],
    ...
  ]
}

Trajectory Data Format

The trajectory data in each QA file follows a consistent format with different annotation levels:

๐Ÿšถ Basic Trajectory Format

Used in factual_retrieval and multiple_choice datasets:

[
  ["day", "time", "x", "y"],
  [1, "00:00:00", -0.05, -3.52],
  [1, "00:01:00", -0.04, -3.78],
  ...
]
  • day: Normalized day number (starts from 1)
  • time: Time in HH:MM:SS format
  • x, y: Normalized spatial coordinates in kilometers, relative to a reference point, with precision up to two decimal places.
๐Ÿ“Š Semantic Trajectory Format

Used in free_form dataset with additional annotations in Japanese:

[
  ["day", "time", "x", "y", "mobility_mode", "reason", "poi"],
  [1, "00:00:00", -0.05, -3.52, "ใƒใ‚น", "่ทๅ ดใธใฎ็งปๅ‹•", "้€šๅ‹ค้€”ไธญใฎใƒใ‚นๅœ"],
  [1, "00:01:00", -0.04, -3.78, "ใƒใ‚น", "่ทๅ ดใธใฎ็งปๅ‹•", NaN],
  ...
]
  • mobility_mode: Transportation mode (e.g., "ใƒใ‚น", "ๅพ’ๆญฉ", "่ปŠ")
  • reason: Purpose of movement (e.g., "่ทๅ ดใธใฎ็งปๅ‹•", "ไฝ™ๆš‡", "่ฒทใ„็‰ฉ")
  • poi: Point of interest category (e.g., "่‡ชๅฎ…", "ใ‚ชใƒ•ใ‚ฃใ‚น", "ใƒฌใ‚นใƒˆใƒฉใƒณ")
๐Ÿ“… Data Normalization Notes
  • Day numbers are normalized to start from 1 based on original_days field
  • Spatial coordinates (x, y) are normalized and may not represent actual GPS coordinates
  • Time format is consistent across all trajectory points

Acknowledgments

This dataset is built upon the GeoLife GPS Trajectory Dataset. We have processed and transformed the original GeoLife data to create question-answer pairs for mobility analysis tasks, including additional semantic annotations.

If you use this dataset, please cite the original GeoLife papers

@inproceedings{zheng2010geolife,
  title={GeoLife: A collaborative social networking service among user, location and trajectory},
  author={Zheng, Yu and Xie, Xing and Ma, Wei-Ying},
  booktitle={IEEE Data Eng. Bull.},
  volume={33},
  number={2},
  pages={32--39},
  year={2010}
}

๐Ÿ“œ License

This project is licensed under the MIT License.

๐Ÿ“š Citation

@article{asano2025mobqa,
  title         = "{MobQA}: A benchmark dataset for semantic understanding of
                   human mobility data through question answering",
  author        = "Hikaru, Asano and Hiroki, Ouchi and Akira, Kasuga and Ryo,
                   Yonetani",
  journal       = "arXiv preprint arXiv:2508.11163",
  year          =  2025,
}

About

No description, website, or topics provided.

Resources

Stars

8 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages