Contributing
We welcome contributions to the LLM Samplers project! Here’s how you can help:
Development Setup
Fork the repository on GitHub.
Clone your fork locally:
git clone https://github.com/your-username/llm-samplers.git cd llm-samplers
Create a virtual environment and install development dependencies:
python -m venv .venv source .venv/bin/activate # On Unix/macOS # or .venv\Scripts\activate # On Windows pip install -e ".[dev]"
Set up pre-commit hooks:
pre-commit install
Code Style
This project uses Ruff for linting and formatting. Before submitting a pull request:
# Check for issues
ruff check .
# Format your code
ruff format .
All code should follow the project’s style guidelines, which are enforced by Ruff.
Writing Tests
We use pytest for testing. Please include tests for any new features or bug fixes:
Add test files in the
tests/directoryRun the tests:
python -m pytest tests/ # For more verbose output python -m pytest tests/ -v
Pull Request Process
Update the documentation if necessary.
Make sure all tests pass.
Update the README.md if needed.
Submit a pull request with a clear description of the changes.
Creating a New Sampler
If you’re implementing a new sampling technique:
Create a new file in
src/llm_samplers/named after your sampler (e.g.,my_sampler.py)Extend the base
Samplerclass frombase.pyImplement the required methods: -
__init__: Initialize your sampler with appropriate parameters -adjust_logits: The main method that modifies the logits - Any additional helper methods you needAdd your sampler to
__init__.pyCreate tests in the
tests/directoryUpdate documentation to include your new sampler
Documentation
To build the documentation locally:
cd docs
pip install -r requirements.txt
sphinx-build -b html source _build/html
Then open _build/html/index.html in your browser to view the documentation.