Giter Club home page Giter Club logo

ebarkhordar / voter-behavior-prediction-llm Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 3.38 MB

This project explores the predictive power of large language models (LLMs) on voter behavior using social media data. By integrating demographic information with user-generated content such as tweets, the study compares the performance and biases of different LLMs in forecasting voter preferences. The analysis highlights the importance of data dive

License: MIT License

Jupyter Notebook 95.14% TeX 4.86%
llms nlp social-science vote

voter-behavior-prediction-llm's Introduction

Voter Behavior Prediction Using Large Language Models

Abstract

This article explores how large language models (LLMs) can reflect human preferences and exhibit biases based on the diversity and type of input data. Utilizing survey data linked with tweets, we compare the predictive performance and bias manifestations of LLMs under three different data inclusion strategies: (1) using only demographic information, (2) combining demographic information with tweets, and (3) exclusively using tweets. The study finds that prompts enriched with tweets notably improve the predictive accuracy of models compared to those relying solely on demographic data. More importantly, the inclusion of dynamic, user-generated content like tweets not only reduces the oversimplification of individual identities but also lessens inherent biases, leading to more accurate and representative simulations of voter behavior. These findings underscore the critical role of data variety in LLM-based simulations, suggesting that integrating richer, real-time data sources can effectively diminish biases and enhance the models' ability to simulate complex human characteristics.

Table of Contents

Installation

Prerequisites

  • Python 3.10 or higher
  • A virtual environment tool (e.g., venv, virtualenv, conda)

Setup

  1. Clone the repository and navigate to the project directory:

    git clone https://github.com/your-username/voter-behavior-prediction-LLM.git
    cd voter-behavior-prediction-LLM
  2. Set up a virtual environment and install dependencies:

    # Using conda as an example
    conda create --name myenv python=3.10
    conda activate myenv
    pip install -r requirements.txt
  3. Open the notebooks in Jupyter or run them in Google Colab for optimal performance:

    jupyter notebook notebooks/<notebook_name>.ipynb

Using Google Colab

To use Google Colab, simply upload the notebooks and dataset files (both tweets_data.json and survey.xlsx) to your Google Drive. Modify the path in the notebooks to reflect the dataset's location:

%cd /path/to/voter-behavior-prediction-LLM

Run the notebooks directly in Colab without any installation required. Ensure you place your OpenAI API token in the .env file located in the same directory as tweets_data.json to access the models.

Dataset

This project utilizes survey data and tweets for analysis. Access the survey data in dataset/survey.xlsx. For tweet data, please request access through this Google Drive link. The dataset also uses auxiliary files like utils/city_codes.txt for data transformation.

Notebooks

  • notebooks/survey.ipynb: Main notebook for data preprocessing, prompt creation, results retrieval, and storage.
  • notebooks/analysis.ipynb: Analyzes collected data and model predictions.
  • notebooks/evaluate.ipynb: Evaluates model performance.

Results

Detailed results from various LLMs are stored in the results directory:

  • Davinci-002 results: results/results_davinci-002_20240519162857.json
  • GPT-3.5 Turbo results: results/results_gpt-3.5-turbo-0125_20240519153306.json
  • GPT-4 results: results/results_gpt-4o-2024-05-13_20240519155949.json

Citing This Work

If you find the content of this repository useful in your research, please cite the following paper:

@inproceedings{barkhordar2024assessing,
  title={Assessing the Predictive Power of Social Media Data-Fed Large Language Models on Voter Behavior},
  author={Barkhordar, Ehsan and Atsizelti, Şükrü},
  booktitle={Proceedings of the ACM Conference},
  year={2024},
  doi={10.1145/3630744.3659831}
}

License

This project is distributed under the MIT License. See the LICENSE file for more details.

voter-behavior-prediction-llm's People

Contributors

ebarkhordar avatar

Stargazers

foo1s avatar HI avatar Şükrü Atsızelti avatar  avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.