Skip to main content

obvs: A Python Library for Analyzing and Interpreting Language Models

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.

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.

Installation

To install the obvs library, you can use pip:

pip install obvs

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:

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.

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 tutorials, documentation, and PyPI.

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 – obvslib@protonmail.com

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

Contributing

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

Metadata

Release files for obvs 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for obvs 0.1.2
File Size Uploaded
obvs-0.1.2.tar.gz 18.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for obvs 0.1.2
File Interpreter ABI Platform
obvs-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 36.8 kB

Release files / obvs-0.1.2.tar.gz

Download URL obvs-0.1.2.tar.gz
Size 18.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e54767341a2653deb11efa7fb15e9f9a94a84d70a98647233b9838f00b796dd5
BLAKE2b-256 checksum
How to use checksums
a332a14f654adadb996f73ff3348e976ec737d14a921b484cffa94b7f9007022
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.7 Darwin/22.6.0

Release files / obvs-0.1.2-py3-none-any.whl

Download URL obvs-0.1.2-py3-none-any.whl
Size 18.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c746dca5112e9c8b018031ddc82a6bb7a7bfa9fed477fa4f284a939820bbd257
BLAKE2b-256 checksum
How to use checksums
d357f67f989d293780b60a2445abd4fe14020d781e83305c316a35f9e2aff78a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.7 Darwin/22.6.0

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page