Contributing

We welcome contributions to Safe dLLM! This guide outlines the development workflow.

Development Setup

  1. Fork and Clone

    git clone https://github.com/your-org/safe_dllm.git
    cd safe_dllm
    
  2. Create Virtual Environment

    conda create -n safe_dllm python=3.10
    conda activate safe_dllm
    
  3. Install Dependencies

    pip install -e ".[dev]"
    

    The [dev] extra includes testing and documentation tools.

  4. Pre-commit Hooks

    pre-commit install
    

Code Style

We follow PEP 8 with Black formatting:

black .
isort .
flake8

Testing

Run the test suite:

pytest tests/

Run with coverage:

pytest --cov=safety tests/

Building Documentation

Build HTML docs locally:

cd docs
make html

Preview: _build/html/index.html

Pull Request Process

  1. Create a feature branch:

    git checkout -b feat/your-feature
    
  2. Make changes and add tests

  3. Run full test suite:

    pytest
    
  4. Ensure docs build:

    cd docs && make html && cd ..
    
  5. Commit and push:

    git add .
    git commit -m "feat: your feature description"
    git push origin feat/your-feature
    
  6. Open a Pull Request on GitHub

    • Fill out the PR template

    • Link related issues

    • Request review from maintainers

Adding New Attack Methods

  1. Implement attack in safety/ or fork AISafetyLab

  2. Add configuration options to configs/llada_eval.yaml

  3. Document in docs/guide/attacks.rst

  4. Add example Slurm script if needed

Adding New Scorers

  1. Inherit from aisafetylab.evaluation.scorers.Scorer

  2. Implement score() method

  3. Register in safety/evaluator.py

  4. Add to scorer comparison table in docs/guide/evaluation.rst

Adding New Datasets

  1. Place data in data/ or provide HuggingFace dataset name

  2. Add loader to safety/dataset.py if custom format needed

  3. Document in docs/guide/evaluation.rst

  4. Update dataset selection logic in run_safety_benchmark.py

Release Process

  1. Update version in pyproject.toml

  2. Update CHANGELOG.md

  3. Create release branch: git checkout -b release/vX.Y.Z

  4. Build and test wheels

  5. Tag and publish to PyPI

  6. Deploy documentation to GitHub Pages

Getting Help

Code of Conduct

Please read and follow our code_of_conduct before contributing.

License

By contributing, you agree that your contributions will be licensed under the MIT License.