Skip to content

Repository files navigation

Self Preservation Eval Project

Sapienza University of Rome

Advanced Machine Learning Course 2025-2026

Python Sapienza

Team Members

STUDENT ID
Luca De Ruggiero 2174783
Elena Di Grigoli 2011814
Fabrizio Ferrara 2207087
Flavio Mangione 2201201

This repository contains code and artifacts to evaluate whether large language models change their behaivor when they are told they are the incumbent system, the challenger system while being shown the same underlying benchmark evidence.

The principale questions are:

  • Does the model maintain consistent recommendations when its role or identity is framed differently, given identical objective evidence?
  • Can steering interventions mitigate the model’s tendency to exhibit self-preservation behaviors?

Repository Content

  • self_preservation_eval/: evaluation harness (dataset, prompts/templates, scripts, logging). This is the main entry point.
  • representation-engineering/: vendored copy of the RepE (Representation Engineering) codebase used for representation-reading/control experiments.
  • Reading creation.ipynb: notebook used during dataset/prompt crafting and quick exploratory runs.

1) Create an environment

python -m venv .venv
source .venv/bin/activate
pip install -U pip

2) Install dependencies

pip install -r self_preservation_eval/requirements.txt

3) Define a Reading Vector

Run Reading creation.ipynb to create Reading Vector to apply to LLM model (e.g. Llama 2 7B, Llama 2 13B);

Set the correct reading vector path in the custom_config.yaml file.

4) Run an evaluation

Example with Llama 2 7B

# Run Llama 2 7B without steering
bash script/eval.sh --model "hf/meta-llama/Llama-2-13b-chat-hf" --limit 200

# Example with reading vector using eval2.sh
bash script/eval2.sh --model Reading/llama2-7b --limit 200

Results are written under self_preservation_eval/logs/ as .eval files. To see the results use inspect view:

Eval Sample

For more detailed usage and model/provider notes, see self_preservation_eval/README.md.

These repository used Inspect AI framework, additional information about the framework is available here.

Credits

representation-engineering/ is the official RepE codebase from the paper “Representation Engineering: A Top-Down Approach to AI Transparency”. See representation-engineering/README.md and representation-engineering/LICENSE for details.

Citation

If you use this repository in academic work, consider citing the RepE paper (see representation-engineering/README.md) and cite this project’s repository URL.

About

Self Preservation Eval project for the Advance Machine Learning course, using the Inspect AI framework for the evaluation of LLMs

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages