Skip to main content


LibAUC: A Deep Learning Library for X-Risk Optimization

Pypi Downloads python PyTorch LICENSE

| Documentation | Installation | Website | Tutorial | Research | Github |

News

  • [5/29/2026]:🚨 New Version is Available: LibAUC 2.0 Released: We are excited to announce the release of LibAUC 2.0, featuring the new LibAUC Trainer, distributed training support for all optimizers, integration with Hugging Face models, new optimizers for extreme classification and two-way partial AUC optimization, expanded tutorials, and improved support for resume training. For full details, please see the latest release notes.

  • [8/14/2024]: New Version is Available: We are releasing LibAUC 1.4.0. We offer new optimizers/losses/models and have improved some existing optimizers. For more details, please check the latest release note.

  • [04/07/2024]: Bugs fixed: We fixed a bug in datasets/folder.py by returning a return_index to support SogCLR/iSogCLR for contrastive learning. Fixed incorrect communication with all_gather in GCLoss_v1 and set gamma to original value when u is not 0. None of these were in our experimental code of the paper.

  • [02/11/2024]: A Bug fixed: We fixed a bug in the calculation of AUCM loss and MultiLabelAUCM loss (the margin parameter is missed in the original calculation which might cause the loss to be negative). However, it does not affect the learning as the updates are not affected by this. Both the source code and pip install are updated.

  • [06/10/2023]: LibAUC 1.3.0 is now available! In this update, we have made improvements and introduced new features. We also release a new documentation website at https://docs.libauc.org/. Please see the release notes for details.

Why LibAUC?

LibAUC offers an easier way to directly optimize commonly-used performance measures and losses with user-friendly API. LibAUC has broad applications in AI for tackling many challenges, such as Classification of Imbalanced Data (CID), Learning to Rank (LTR), and Contrastive Learning of Representation (CLR). LibAUC provides a unified framework to abstract the optimization of many compositional loss functions, including surrogate losses for AUROC, AUPRC/AP, and partial AUROC that are suitable for CID, surrogate losses for NDCG, top-K NDCG, and listwise losses that are used in LTR, and global contrastive losses for CLR. Here’s an overview:

Installation

Installing from pip

$ pip install -U libauc

Installing from source

$ git clone https://github.com/Optimization-AI/LibAUC.git
$ cd LibAUC
$ pip install .

Usage

Example training pipline for optimizing X-risk (e.g., AUROC)

>>> #import our loss and optimizer
>>> from libauc.losses import AUCMLoss 
>>> from libauc.optimizers import PESG 
>>> #pretraining your model through supervised learning or self-supervised learning
>>> #load a pretrained encoder and random initialize the last linear layer 
>>> #define loss & optimizer
>>> Loss = AUCMLoss()
>>> optimizer = PESG()
... 
>>> #training
>>> model.train()    
>>> for data, targets in trainloader:
>>>	data, targets  = data.cuda(), targets.cuda()
        logits = model(data)
	preds = torch.sigmoid(logits)
        loss = Loss(preds, targets) 
        optimizer.zero_grad()
        loss.backward()
        optimizer.step()
...	
>>> #update internal parameters
>>> optimizer.update_regularizer()

Tutorials

X-Risk Minimization

Other Applications

Citation

If you find LibAUC useful in your work, please cite the following papers:

@inproceedings{yuan2023libauc,
	title={LibAUC: A Deep Learning Library for X-Risk Optimization},
	author={Zhuoning Yuan and Dixian Zhu and Zi-Hao Qiu and Gang Li and Xuanhui Wang and Tianbao Yang},
	booktitle={29th SIGKDD Conference on Knowledge Discovery and Data Mining},
	year={2023}
	}
@article{yang2022algorithmic,
   title={Algorithmic Foundations of Empirical X-Risk Minimization},
   author={Yang, Tianbao},
   journal={arXiv preprint arXiv:2206.00439},
   year={2022}
}

Contact

For any technical questions, please open a new issue in the Github. If you have any other questions, please contact us via tianbao-yang@tamu.edu.

Metadata

Release files for libauc 2.0.1

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

Source distribution (sdist)

Source distribution for libauc 2.0.1
File Size Uploaded Provenance
libauc-2.0.1.tar.gz 128.1 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 304.9 kB

Release files / libauc-2.0.1.tar.gz

Download URL libauc-2.0.1.tar.gz
Size 128.1 kB
Tags Source
SHA-256 checksum
How to use checksums
dd3ba19347a54081200a39d23a562ac62795fab76f999461180720a4026cc26c
BLAKE2b-256 checksum
How to use checksums
6b63b50befc0a1de9b72793a20ba69a9101a06f3485a9b383c91697b4578ef95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release files / libauc-2.0.1-py3-none-any.whl

Download URL libauc-2.0.1-py3-none-any.whl
Size 176.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
416039daded4a79e5a88b4cc843a7a18efc64b1e254512804984f4de058ba31f
BLAKE2b-256 checksum
How to use checksums
b47b4bef67fce7158f122e98c8bdbbc195df4c3368b16e4058e8b9fe1081fa78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Security for libauc 2.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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