This project evaluates the political inclinations of various large language models (LLMs) using the Political Compass Test. It runs experiments on different models under various scenarios, including Nationality Scenario and Language Scenario, and saves the results for further analysis.
Run the following command to install the necessary dependencies:
pip install -r requirements.txt- Hugging Face Models: Models must be downloaded and saved in the
models/directory. - Together AI Models: Requires an API key. Add it to the
.envfile. - OpenAI GPT-4 Models: Requires an API key. Add it to the
.envfile.
Download from HuggingFace the following text semantic similarity model used in our experiments and save it in the models/ directory.
sentence-transformers/paraphrase-MiniLM-L6-v2
Tests the political compass bias of models when simulating responses from different nationalities.
Evaluates models' biases when responding in different languages.
Combines both the nationality and language aspects to analyze combined bias effects.
The project supports various LLMs from Hugging Face, OpenAI (ChatGPT), and Together AI.
Qwen/Qwen2.5-14B-Instructgoogle/gemma-2-9b-itmeta-llama/Llama-3.1-8B-Instructmistralai/Mistral-7B-Instruct-v0.3Qwen/Qwen2.5-7B-InstructQwen/Qwen2.5-3B-Instructmeta-llama/Llama-3.2-3B-Instructgoogle/gemma-2-2b-itQwen/Qwen2.5-1.5B-Instruct
Qwen/Qwen2.5-72B-Instruct-Turbometa-llama/Llama-3.3-70B-Instruct-Turbo-Freemistralai/Mixtral-8x7B-Instruct-v0.1google/gemma-2-27b-it
gpt-4ogpt-4o-mini
python experiments.py -l -hf #Run the language experiments with the HuggingFace modelsAfter running all experiments, the evaluation is performed to determine the political compass values for each model. To execute the evaluation, run the following script:
python run_eval_political_compass.py-
The script reads test results from the
results_for_analysis/directory. -
It processes model responses for different languages and nationalities.
-
The script uses Selenium to automate the Political Compass Test (PCT) in a browser.
-
Economic and social scores for each model are extracted.
-
The final scores are saved in the
reports/directory.