Skip to main content

No project description provided

Project description

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 Aopc will 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aopc-0.1.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aopc-0.1.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file aopc-0.1.0.tar.gz.

File metadata

  • Download URL: aopc-0.1.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.2 Darwin/24.0.0

File hashes

Hashes for aopc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6b6ebe5a38bd357632d1afcb11630a178ce35e91d051d8b0dadd8f9ec035966b
MD5 83eae2c412783c28e001541b76ce0cd8
BLAKE2b-256 be7b28d89726af550d71d8fb7e2f8605621696db83ac54c7b3eb4c4b11539a62

See more details on using hashes here.

File details

Details for the file aopc-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: aopc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.2 Darwin/24.0.0

File hashes

Hashes for aopc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6efe7fac0dd8b4a50fd6293c2cab76145c3dc7f6b450645197b04b3f42b5eb81
MD5 f5b3be1ce9dcb5794a72e4817dc5406b
BLAKE2b-256 85b35e7bb92de3ef6b55ac48518a0da20ce8eab18f8c3700be1eda9efbeb0169

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page