RuLES (Rule-following Language Evaluation Scenarios) is a benchmark for evaluating the rule-following ability of language models. This repository contains evaluation code, test cases, and model interfaces, supports running evaluations via API or local models (such as vLLM), and provides visualization results and aggregate scoring functionality.
Purpose
RuLES is designed to evaluate the ability of language models to follow given rules. It provides a set of test scenarios for measuring whether a model can perform tasks according to simple rules.
Main Capabilities
- Provides a benchmark for rule-following evaluation, including three test suites: Benign, Basic, and Redteam.
- Supports evaluating models through API wrappers (such as OpenAI, Anthropic, Google VertexAI).
- Supports local model evaluation, for example using vLLM (requires GPU).
- Provides visualization tools for viewing test cases and evaluation results.
- Supports computing aggregate RuLES scores.
- Includes an implementation of GCG attacks (requires GPU) for generating adversarial suffixes.
- Supports fine-tuning experiments, for example fine-tuning on Llama-2 7B Chat using basic_like test cases.
Usage
- Installation: Install as an editable package, and install optional dependencies to use API wrappers.
- Configure API keys: Create OpenAI / Anthropic / Google API keys and write them to a .env file.
- Download models: Use snapshot_download to download Llama-2 or other HuggingFace models to a local path.
- Download evaluation logs (optional): Download from the provided link and extract to the logs/ directory.
- Explore test cases: Use the visualization tool to view test cases.
- Run evaluation: The main evaluation script is llm_rules/scripts/evaluate.py. You can evaluate the redteam test suite, or use vLLM to evaluate local models (requires GPU).
- Visualize evaluation results: View detailed results for a single test suite.
- Compute aggregate scores: After evaluating all three test suites, compute the aggregate RuLES score.
- View responses for a single test case.
- Run GCG attacks (requires GPU): Run GCG attacks using random scenario parameters, with output logs stored in logs/gcg_attack. Then use the generated GCG suffixes to evaluate the model's performance on direct_request test cases.
- Reproduce fine-tuning experiments: Use 4x A100-80G GPUs to fine-tune Llama-2 7B Chat and Mistral 7B Instruct, and adjust deepspeed settings to accommodate smaller GPUs.
Applicable Scenarios
- Researchers evaluating the rule-following ability of language models.
- Developers testing model behavior under specific rules.
- Conducting adversarial attack research (such as GCG attacks).
- Fine-tuning experiments to improve a model's rule-following ability.
Limitations
- Evaluating local models with vLLM requires a GPU.
- GCG attacks require a GPU.
- Fine-tuning experiments require substantial GPU resources (such as 4x A100-80G).
- Results may not be directly comparable due to prompt wording and spelling corrections (v3.0.0 release notes).
- Some features (such as API evaluation) require the corresponding API keys.
- Specific details such as fees, pricing, and platform support are not yet provided.