Multi-Class Content Ranking using Seq-to-Seq Models
This repository contains code for a multi-class HTML content ranking model using BiLSTM-CRF, as described in the paper "A High-Speed Multi-Class Content Ranking using Seq-to-Seq Models".
Overview
The model classifies HTML content into 6 classes indicating importance:
- Title
- Main content
- Related parts
- Other topics
- Headers and footers
- Useless parts
The model uses only structural HTML features and is language agnostic.
Abstract
Content Ranking is an important task in many applications, such as documents ranking, text retrieval, text summarization and other natural language processing (NLP) procedures. Existing approaches define content ranking as a binary classification boilerplate removal, in which a text is either boilerplate or main-content. While boilerplate removal provides a basic mean for text ranking, in many applications, more importance levels are required to distinguish between different parts of an HTML document.
Based on a new dataset of segmented and labeled HTML documents, in this paper we introduce a high-speed multi-class sequence-to-sequence text classification model for determining the importance level of a text within six levels. As we use only HTML’s structural features in the training process, our model is language-agnostic and also it can be fine-tuned on a small dataset of web pages of other languages.
The involved feature extraction uses an optimized algorithm in terms of speed, which makes the end-to-end inference on an html page in about and less than 25ms, which is a huge benefit in terms of scalability of the model. Besides, our model achieves the 83 percent score in accuracy and 74 percent score in average 6 classes f1 score, which is a prominent result.
Dataset
The dataset used for this project can be found at ZDA Dataset. It contains 1602 labeled HTML documents across 6 classes:
- Title
- Main content
- Related parts
- Other topics
- Headers and footers
- Useless parts
Results
The model achieves 83% accuracy and 74% average F1 score on the test set.
Confusion Matrix
The confusion matrix shows the model confuses classes with adjacent importance levels:
Example Output
The model generalizes well to new HTML pages:
Usage
See the examples for scripts showing end-to-end usage.
Basic usage:
from content_ranker import predict
model = predict.load_model("path/to/model.pt")
html_string = load_html(...)
features = extract_features(html_string)
tags = model.predict(features)
Repository Structure
.
├── Dockerfile
├── examples/ - Example scripts showing usage
├── main.py - Main entry point
├── pyproject.toml - pypi config
├── README.md
├── requirements.txt - Python requirements
├── src/ - Source code
│ └── content_ranker/ - Package containing model code
│ ├── features/ - Feature extraction
│ ├── models/ - PyTorch model definitions
│ ├── resources/ - Resources like pretrained models
│ └── utils/ - Utility functions
└── tests/ - Tests
Citation
Please cite the paper if you use this repository:
@article{ashourisefat-raziei-2023-content-ranker,
title={A High-Speed Multi-Class Content Ranking using Seq-to-Seq Models},
author={AshouriSefat, Soroush and Kazemi, Reza and Alikhany, Morteza and Raziei, Mohammad and Amini, Arash},
journal={IEEE Access},
volume={9},
pages={XXXXX--XXXXX},
year={2023},
publisher={IEEE}
}
Contact
For any questions, feel free to open an issue or contact us at soroush_ashourisefat@ee.sharif.edu or mohammadraziei1375@gmail.com .
Metadata
Release files for content-ranker 0.0.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 | Provenance | |
|---|---|---|---|---|
| content_ranker-0.0.0.tar.gz | 34.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| content_ranker-0.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 48.6 kB
Release files / content_ranker-0.0.0.tar.gz
| Download URL | content_ranker-0.0.0.tar.gz |
|---|---|
| Size | 34.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ee51bb28e8bb1ebf6afce5cd41a734a5a8a25591608a1595f6a9ef6e87349db
|
|
BLAKE2b-256 checksum How to use checksums |
c02f7bd9d1c67b142698733f24c5233f81dca716f49607be04965fef3ce2ba2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / content_ranker-0.0.0-py3-none-any.whl
| Download URL | content_ranker-0.0.0-py3-none-any.whl |
|---|---|
| Size | 14.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eb478f2aba463c17ce4b9e51ce248278e6fbc36046213fd86718b3eb0032b3e9
|
|
BLAKE2b-256 checksum How to use checksums |
27febc07a86d20d8e34b51f49c4655c38f1b889f15fde6e791f6f57b54d6137c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Security for content-ranker 0.0.0
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.