htmlsift
Web main-content extraction: HTML in, clean text / HTML / markdown out. Trained on WebMainBench, scores each rendered line of a page as main content or boilerplate (nav, ads, cookie banners, and footers) and returns just the content.
Apache-2.0. Full documentation, diagrams, and benchmarks: https://github.com/koivualeksi/htmlsift
Results
| model | desc | WMB test F1 | seeds | CPU (pages/s) | GPU (pages/s) | install |
|---|---|---|---|---|---|---|
base |
311M, 10 layers | 0.9311 | 3 | 0.4 | 24.6 | htmlsift[full] |
| unpublished | 97M, 6 layers, int8 QAT | 0.9256 | 3 | 0.9 | 30.2 | — |
mini |
int8 embedding table | 0.9010 | 3 | 27.7 | — | htmlsift |
GPU = RTX 4090, CPU = Ryzen 5 3600 single thread; WMB test = 544 pages (one of the 545 has
no gold reference). On WMB (in-domain), mini scores ~15 F1 points above trafilatura at
comparable CPU speed.
Cross-benchmark accuracy (zero-shot)
Trained on WMB, scored on benchmarks the model never saw. Each column uses that benchmark's own metric.
| model | WMB (ROUGE-5) | WCXB (word-F1) | DAnIEL (ROUGE-L) |
|---|---|---|---|
base |
0.9311 | 0.8633 | 0.9175 |
mini |
0.9010 | 0.8474 | 0.8797 |
| trafilatura | 0.7525 | 0.8584 | 0.8265 |
| readability | 0.8016 | 0.7653 | 0.8925 |
| resiliparse | 0.7135 | 0.7909 | 0.7094 |
Model rows are 3-seed test means; heuristics are single deterministic runs. "Main content" is a labeling policy: htmlsift leads in-domain and stays competitive off-policy — retrain on your own labels if your definition differs. Details in the research repo.
Install
pip install htmlsift # default: the mini model (CPU, ONNX)
pip install htmlsift[full] # adds the base 311M model (torch; GPU-capable)
htmlsift— theminimodel only; few dependencies (onnxruntime + tokenizers + lxml + numpy + huggingface-hub). First use downloads ~230 MB of model files.htmlsift[full]— addstorch+transformersto runbase. First use ofbasedownloads ~1 GB.
Requires Python 3.10+. Model files download from the Hugging Face Hub on first use and are
cached; run htmlsift download <mode> to prefetch, or set HF_HUB_OFFLINE=1 to run from
cache only.
Usage
from htmlsift import Extractor
ex = Extractor() # defaults to "mini"
ex.extract(html) # -> str (plain text)
ex.extract(html, output="html") # structure, links, images kept
ex.extract(html, output="markdown") # clean markdown: [text](url), 
ex.extract(html, with_blocks=True) # -> (blocks, probs)
import htmlsift
htmlsift.extract(html) # module-level convenience
The larger model, from htmlsift[full]:
ex = Extractor("base") # 311M encoder; GPU when present, else CPU (with a warning)
ex = Extractor("base", device="cuda") # require the GPU
mini is CPU-only; only base runs on the GPU.
Output modes
output |
what you get |
|---|---|
text (default) |
selected content as plain text |
html |
selected DOM, with structure / links / images kept |
markdown |
clean markdown, links and images preserved |
License
Apache-2.0. Model weights are distributed from the Hugging Face Hub, also under Apache-2.0, and are trained on WebMainBench (Apache-2.0); please attribute WebMainBench when you use them.
Metadata
Release files for htmlsift 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| htmlsift-0.1.1.tar.gz | 46.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| htmlsift-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 76.5 kB
Release files / htmlsift-0.1.1.tar.gz
| Download URL | htmlsift-0.1.1.tar.gz |
|---|---|
| Size | 46.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad953d1491d71a2f928e86a43c161aa2f8f9f0645cd762515f6610a4be95544a
|
|
BLAKE2b-256 checksum How to use checksums |
04e8112646c3fe75eed8ebbfd0a66f5827dd2bfe0af3eff1d405cf85305d98ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.
Transparency logRelease files / htmlsift-0.1.1-py3-none-any.whl
| Download URL | htmlsift-0.1.1-py3-none-any.whl |
|---|---|
| Size | 30.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7abee55d60bf99334f3d9ef03bf694720d4d93ca0c9f17f11e2359459227e7bd
|
|
BLAKE2b-256 checksum How to use checksums |
9af4bfc1b453d93d99369c84d26611c66c318fd34006dedeacda6921106fc0ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.
Transparency log