Installation
uv pip install hard-negatives
Usage
Mines hard negatives from existing query document pair datasets.
# 1. prepare (one node, CPU): dedup pairs, add content hashes, write --num_shards small parquet files
sbatch examples/prepare.sbatch --input_path "/data/pairs/*.parquet" --query_column anchor --document_column positive --num_shards 1024
# 2. embed (Slurm array, one task per node, one Qwen3-Embedding-4B actor per GPU): query and doc embeddings per pair
sbatch examples/embed.sbatch --query_column anchor --document_column positive
# 3. search (Slurm array, one task per node, all GPUs): exact top-K negatives per pair, positives and duplicates masked
sbatch examples/search.sbatch --query_column anchor --document_column positive
# 4. training dataset (one node, CPU): anchor, positive, negative_1..N after the NV-Retriever 95% filter
sbatch examples/nv_retriever.sbatch --query_column anchor --document_column positive
Contributing
uvx ruff format
uvx ruff check --select I --fix .
@software{shippole2026hardnegatives,
title = {Hard Negatives: A Python Library for Mining Hard Negative Examples},
author = {Shippole, Enrico and Chaffin, Antoine and Aarsen, Tom},
year = {2026},
url = {https://github.com/teraflop-ai/hard-negatives},
version = {1.0.0},
note = {Python package available on PyPI at \url{https://pypi.org/project/hard-negatives/}}
}
Metadata
Release files for hard-negatives 0.1.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hard_negatives-0.1.10.tar.gz | 9.3 kB | Without provenance | Details for hard_negatives-0.1.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hard_negatives-0.1.10-py3-none-any.whl | Python 3 | none | any | Details for hard_negatives-0.1.10-py3-none-any.whl |
Total release size: 20.1 kB
Release files / hard_negatives-0.1.10.tar.gz
| Download URL | hard_negatives-0.1.10.tar.gz |
|---|---|
| Size | 9.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1168dc47478f0d3d418dd61b45235f958dcbfb766ce2c906f582d3841f896a0f
|
|
BLAKE2b-256 checksum How to use checksums |
687ab0abf4fdaa1fcada2968556db963c2b32a1007dbea91ca6467c62c6f582c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / hard_negatives-0.1.10-py3-none-any.whl
| Download URL | hard_negatives-0.1.10-py3-none-any.whl |
|---|---|
| Size | 10.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8a81b94691e7742bd479103e6fea893652fa9a2832cbfcb00278b6c761d34e2d
|
|
BLAKE2b-256 checksum How to use checksums |
dabba8c99b4cb8780acaec3061a55a653a32cee498573ac78562aa23ca8aa3ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for hard-negatives 0.1.10
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.