Aopc
The Aopc package provides a framework for evaluating model faithfulness using the Area Over the Perturbation Curve (AOPC) metric. It supports Hugging Face models and datasets, specifically tailored for sequence label classification tasks.
Installation
Install the package via pip:
pip install aopc
Key Features
- Support for Hugging Face models and datasets: Utilize pre-trained models and standard datasets seamlessly.
- AOPC Evaluation: Calculate AOPC metrics for attributions.
- Beam Size Suggestion: Automatically estimate optimal beam sizes for normalized AOPC using our approximation method.
Quick Start
Initialize the Aopc Class
Start by configuring Aopc with a Hugging Face model, such as prajjwal1/bert-tiny:
from aopc import Aopc
aopc = Aopc(model_id="prajjwal1/bert-tiny")
Evaluate Dataset
Load your dataset with Hugging Face's datasets library and evaluate it with Aopc:
Note: If the dataset has not been tokenized
Aopcwill take care of it.
import datasets
# Load dataset
dset = datasets.load_dataset("stanfordnlp/imdb")
# Evaluate dataset without normalization
new_dset = aopc.evaluate(dset)
Note: Aopc.evaluate() allow either a dictionary, datasets.Dataset or datasets.DatasetDict as input.
Normalized AOPC with Exact Bounds
Estimate
new_dset = aopc.evaluate(dset, normalization="exact")
Normalized AOPC with Approximated Bounds
Calculate the suggested beam size for normalized AOPC approximation:
# Estimate Beam Size
beam_size = aopc.get_suggested_beam_size(dset)
# Approximate normalization
new_dset = aopc.evaluate_dset(dset, normalization="approx", beam_size=beam_size)
License
This project is licensed under the MIT License.
Release files for aopc 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aopc-0.1.0.tar.gz | 9.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aopc-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:20.0 kB
Release files / aopc-0.1.0.tar.gz
| Download URL | aopc-0.1.0.tar.gz |
|---|---|
| Size | 9.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6b6ebe5a38bd357632d1afcb11630a178ce35e91d051d8b0dadd8f9ec035966b
|
|
BLAKE2b-256 checksum How to use checksums |
be7b28d89726af550d71d8fb7e2f8605621696db83ac54c7b3eb4c4b11539a62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.2 Darwin/24.0.0
|
Release files / aopc-0.1.0-py3-none-any.whl
| Download URL | aopc-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6efe7fac0dd8b4a50fd6293c2cab76145c3dc7f6b450645197b04b3f42b5eb81
|
|
BLAKE2b-256 checksum How to use checksums |
85b35e7bb92de3ef6b55ac48518a0da20ce8eab18f8c3700be1eda9efbeb0169
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.2 Darwin/24.0.0
|