Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create CODE_OF_CONDUCT.md #61

Merged
merged 2 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[email protected].
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
88 changes: 88 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Contributing to `obvs`

Welcome to the `obvs` library! We appreciate your interest in contributing to the project. This document provides guidelines and information to help you contribute effectively.

## Table of Contents

- [Welcome Note](#welcome-note)
- [Links to Resources](#links-to-resources)
- [Templates](#templates)
- [Test Location](#test-location)
- [Submit Changes](#submit-changes)
- [Development Environment Details](#development-environment-details)
- [How To Contribute](#how-to-contribute)
- [How to Make a Bug Report](#how-to-make-a-bug-report)
- [How to Fix a Bug](#how-to-fix-a-bug)
- [How to Suggest Enhancements](#how-to-suggest-enhancements)
- [Coding Conventions and Style Guide](#coding-conventions-and-style-guide)
- [Code of Conduct](#code-of-conduct)
- [Acknowledgements](#acknowledgements)
- [Project Owner and Contributors Information](#project-owner-and-contributors-information)
- [Where to Get Help](#where-to-get-help)

## Welcome Note

Thank you for considering contributing to the `obvs` library! Your contributions, whether they are bug reports, feature suggestions, or code improvements, are greatly appreciated. By contributing, you help make `obvs` a better tool for analyzing and interpreting language models.

## Links to Resources

### Templates

- [Bug Report Template](link-to-bug-report-template)
- [Feature Request Template](link-to-feature-request-template)
- [Pull Request Template](link-to-pull-request-template)

### Test Location

Please place your tests in the `tests/` directory and ensure they follow the naming convention `test_*.py`.

### Submit Changes

To submit your changes, please follow the steps outlined in the [How To Contribute](#how-to-contribute) section.

### Development Environment Details

To set up the development environment for `obvs`, please refer to the [Development Setup](https://github.com/obvslib/obvs?tab=readme-ov-file#development-setup) section in the README.

## How To Contribute

### How to Make a Bug Report

If you encounter a bug while using `obvs`, please [open an issue](https://github.com/obvslib/obvs/issues) on the GitHub repository. Provide a clear and descriptive title, along with a detailed description of the problem, steps to reproduce it, and any relevant code snippets or error messages.

### How to Fix a Bug

If you would like to fix a bug, follow these steps:

1. Check the [issue tracker](https://github.com/obvslib/obvs/issues) to see if the bug has already been reported. If not, [open a new issue](https://github.com/obvslib/obvs/issues/new) describing the bug.
2. Fork the repository and create a new branch for your bug fix.
3. Make the necessary changes to fix the bug.
4. Write tests to verify the bug fix and ensure it doesn't introduce new issues.
5. Commit your changes and push them to your forked repository.
6. [Submit a pull request](https://github.com/obvslib/obvs/compare) to the main repository, referencing the related issue.

### How to Suggest Enhancements

If you have an idea for an enhancement or a new feature for `obvs`, please [open an issue](https://github.com/obvslib/obvs/issues/new) on the GitHub repository. Provide a clear and descriptive title, along with a detailed description of the enhancement, its benefits, and any relevant examples or use cases.

## Coding Conventions and Style Guide

When contributing code to `obvs`, please adhere to the following coding conventions and style guide:

- Use meaningful variable and function names.
- Follow the [PEP 8](https://www.python.org/dev/peps/pep-0008/) style guide for Python code.
- Write docstrings for functions and classes following the [NumPy docstring format](https://numpydoc.readthedocs.io/en/latest/format.html).
- Use type hints to improve code readability and maintainability.
- Keep lines of code under 80 characters in length.

## Code of Conduct

Please note that the `obvs` project follows a `CODE_OF_CONDUCT`. By participating in this project, you are expected to uphold this code. Please report any unacceptable behavior to the project maintainers.

## Acknowledgements

We would like to express our gratitude to all the contributors who have helped improve the `obvs` library. Your contributions are greatly appreciated!

## Where to Get Help

If you have any questions or need assistance with contributing to `obvs`, please [open an issue](https://github.com/obvslib/obvs/issues/new) on the GitHub repository. You can also reach out to the project maintainers or join our [github discussions](https://github.com/obvslib/obvs/discussions) for further help and discussion.
111 changes: 94 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,100 @@
# obvs
# obvs: A Python Library for Analyzing and Interpreting Language Models

[![CI](https://github.com/obvslib/obvs/actions/workflows/main.yaml/badge.svg)](https://github.com/obvslib/obvs/actions/workflows/main.yaml)
The `obvs` library is a powerful Python package that provides a comprehensive set of tools and utilities for analyzing and interpreting language models using the patchscope framework. It offers a range of functionalities to probe and understand the internal representations and behaviors of language models at different layers and positions.

Making Transformers Obvious
With `obvs`, you can easily investigate how language models process and generate text, gain insights into their inner workings, and visualize the results using various techniques such as heatmaps and plots. Whether you are a researcher, data scientist, or language model enthusiast, `obvs` empowers you to conduct interpretability experiments and reproduce standard results with ease.

## Project cheatsheet
## Installation

- **pre-commit:** `pre-commit run --all-files`
- **pytest:** `pytest` or `pytest -s`
- **coverage:** `coverage run -m pytest` or `coverage html`
- **poetry sync:** `poetry install --no-root --sync`
- **updating requirements:** see [docs/updating_requirements.md](docs/updating_requirements.md)
To install the `obvs` library, you can use pip:

## Initial project setup
```
pip install obvs
```

1. See [docs/getting_started.md](docs/getting_started.md) or [docs/quickstart.md](docs/quickstart.md)
for how to get up & running.
2. Check [docs/project_specific_setup.md](docs/project_specific_setup.md) for project specific setup.
3. See [docs/using_poetry.md](docs/using_poetry.md) for how to update Python requirements using
[Poetry](https://python-poetry.org/).
4. See [docs/detect_secrets.md](docs/detect_secrets.md) for more on creating a `.secrets.baseline`
file using [detect-secrets](https://github.com/Yelp/detect-secrets).
Make sure you have Python >=3.10 installed on your system.

## Entity Resolution Example.

Here's a simple example demonstrating how to use the `TokenIdentity` lens from the `obvs` library:

```python
from obvs.lenses import TokenIdentity

token_identity = TokenIdentity(source_prompt="The quick brown fox", model_name="gpt2", source_phrase="quick brown")
token_identity.run().compute_surprisal("fox").visualize()
```

This code snippet creates an instance of the `TokenIdentity` lens, specifying the source prompt, model name, and source phrase. It then runs the lens analysis, computes the surprisal for the word "fox", and visualizes the results.

## Activation Patching Example.

"The Collosseum is in the city of Paris" activation patching example.

```python
from obvs.patchscope import Patchscope, SourceContext, TargetContext

MODEL="gpt2"
source=SourceContext(
model_name=MODEL,
prompt="The Eiffel Tower is in the city of",
layer=10,
position=9,
)

target=TargetContext(
model_name=MODEL,
prompt="The Colosseum is in the city of",
layer=10,
position=9,
max_new_tokens=1
)

patchscope=Patchscope(source, target)
patchscope.run()

print(patchscope.full_output())
```

For more examples and usage, please refer to the [documentation](https://obvs.rtfd.io/) and [PyPI](https://pypi.org/project/obvs/).

## Development setup

To set up the development environment for `obvs`, follow these steps:

1. Clone the repository:

```
git clone https://github.com/yourname/obvs.git
```

2. Install the development dependencies:

```
poetry install --no-root --sync
```

3. Run the test suite:
```
pytest tests/
```

Make sure you have Python 3.10 or above and the required dependencies installed.

## Release History

- 0.1.1
- Initial release of the `obvs` library
- Includes `patchscope`, `patchscope_base`, `lenses`, `logging`, and `metrics` modules
- Provides a collection of scripts for reproducing standard results

## Meta

For assistance, reach out to Jamie Coombes – www.linkedin.com/in/
jamiecoombes – [email protected]

Distributed under the MIT license. See `LICENSE` for more information.

## Contributing

We welcome contributions to the `obvs` library! See `CONTRIBUTING` for more information.
Loading