Views
No views yet
html2text. This benchmark measures the extraction accuracy of content extractors by computing ROUGE-N scores between the extracted results and ground-truth content. The primary evaluation results are presented in the table below:| Extractor | ROUGE-N.f1 |
|---|---|
| DeepSeek-V3* | 0.9098 |
| GPT-5* | 0.9024 |
| MinerU-HTML-v1.1 | 0.9001 |
| Magic-HTML | 0.7138 |
| Readability | 0.6542 |
| Trafilatura | 0.6402 |
| Resiliparse | 0.6290 |
| html2text | 0.6042 |
| BoilerPy3 | 0.5434 |
| GNE | 0.5171 |
| news-please | 0.5032 |
| justText | 0.4782 |
| Goose3 | 0.4371 |
| ReaderLM-v2 | 0.2279 |
huggingface-cli download opendatalab/MinerU-HTML-v1.1-hunyuan0.5B-compact1# Clone the repository
2git clone https://github.com/opendatalab/MinerU-HTML
3cd MinerU-HTML
4
5# Install the package with core dependencies only
6pip install .1# Install VLLM backend dependencies (Default)
2pip install .[vllm]
3
4# Install OpenAI backend dependencies
5pip install .[openai]
6
7# Install all dependencies
8pip install .[all]1from mineru_html import MinerUHTML, MinerUHTMLConfig
2
3
4config = MinerUHTMLConfig(
5 use_fall_back='trafilatura', # optional 'trafilatura','bypass' or 'empty'
6 prompt_version='short_compact', # only support 'short_compact' for v1.1
7 response_format='compact', # only support 'compact' for v1.1
8 early_load=True
9)
10
11# initialize MinerUHTML
12extractor = MinerUHTML(
13 model_path='path/to/your/model',
14 config=config
15)
16
17# process single HTML
18html_content = '<html>...</html>'
19result = extractor.process(html_content)
20print(result[0].main_html)
21
22# process multi HTML
23html_list = ['<html>...</html>', '<html>...</html>']
24results = extractor.process(html_list)
25for result in results:
26 print(result.main_html)
27 print(result.case_id)
28extractor.llm.cleanup()1from mineru_html import MinerUHTML_OpenAI, MinerUHTMLConfig
2
3
4config = MinerUHTMLConfig(
5 use_fall_back='trafilatura',
6 prompt_version='v2', # 'v2' is the best version up to v1.1
7 response_format='json', # only support 'json' for 'v2' prompt version
8 early_load=True
9)
10
11# initialize MinerUHTML_OpenAI
12extractor = MinerUHTML_OpenAI(
13 base_url='https://api.openai.com/v1',
14 sk='your-api-key',
15 model='gpt-4',
16 config=config,
17 retry_times=3
18)
19
20# process HTML
21html_content = '<html>...</html>'
22result = extractor.process(html_content)
23print(result[0].main_html)1from mineru_html import MinerUHTML_Transformers, MinerUHTMLConfig
2
3config = MinerUHTMLConfig(
4 use_fall_back='trafilatura',
5 prompt_version='short_compact', # only support 'short_compact' for v1.1
6 response_format='compact', # only support 'compact' for v1.1
7 early_load=True
8)
9
10# initialize MinerUHTML_Transformers
11extractor = MinerUHTML_Transformers(
12 model_path='path/to/your/model',
13 config=config,
14 model_init_kwargs={
15 'device_map': 'auto',
16 'dtype': 'auto',
17 },
18 model_gen_kwargs={
19 'max_new_tokens': 16 * 1024,
20 }
21)
22
23# process HTML
24html_content = '<html>...</html>'
25result = extractor.process(html_content)
26print(result[0].main_html)simplify_html): Simplifies raw HTML into a structured format, assigning a unique _item_id attribute to each elementbuild_prompt): Constructs LLM prompts based on simplified HTML to guide the model in content classificationinference): Uses LLM to classify each element, marking them as "main" (main content) or "other" (auxiliary content)parse_result): Parses the classification results returned by LLMextract_main_html): Extracts main content from original HTML based on classification resultsMinerUHTMLConfig supports the following configurations:use_fall_back: Fallback type, optional 'trafilatura', 'bypass', or 'empty'early_load: Whether to load the model early (default True)prompt_version: Prompt version, optional 'v0', 'v1', 'v2', 'compact', 'short_compact'. The MinerUHTML and MinerUHTML_Transformers interfaces default to 'short_compact'; the MinerUHTML_OpenAI interface defaults to 'v2'response_format: The output format of the model. Only 'json' or 'compact' are permitted. VLLM/Transformers defaults to 'compact'; OpenAI defaults to 'json'.'compact': Used for local model inference, it returns more concise results (only keeping the key and value in the JSON dictionary). It is recommended to use the 'compact' model for faster inference speed.'v2': Used for OpenAI API inference, it is the result after prompt optimization.MinerUHTMLGeneric:1from mineru_html import MinerUHTMLGeneric, MinerUHTMLConfig
2from mineru_html.inference.factory import create_vllm_backend, create_openai_backend, create_transformers_backend
3
4# Create VLLM backend using factory function
5llm = create_vllm_backend(
6 model_path='path/to/model',
7 response_format='compact',
8 max_context_window=32 * 1024,
9 model_init_kwargs={'tensor_parallel_size': 1}
10)
11
12# Create Transformers backend using factory function
13llm = create_transformers_backend(
14 model_path='path/to/model',
15 max_context_window=32 * 1024,
16 response_format='compact',
17 model_init_kwargs={
18 'device_map': 'auto',
19 'dtype': 'auto',
20 },
21 model_gen_kwargs={
22 'max_new_tokens': 8192,
23 }
24)
25
26# Create OpenAI backend using factory function
27llm = create_openai_backend(
28 base_url='https://api.openai.com/v1',
29 sk='your-api-key',
30 model='gpt-5',
31 max_context_window=128 * 1000,
32 response_format='json'
33)
34
35# Use the created backend
36config = MinerUHTMLConfig()
37extractor = MinerUHTMLGeneric(llm=llm, config=config)1from mineru_html.exceptions import MinerUHTMLError
2
3try:
4 result = extractor.process(html_content)
5except MinerUHTMLError as e:
6 print(f"Processing failed: {e}")
7 print(f"Case ID: {e.case_id}")baselines.txt first.pip install -r baselines.txt1
2BENCHMARK_DATA=benchmark/WebMainBench_100.jsonl
3RESULT_DIR=benchmark_results
4mkdir $RESULT_DIR
5
6# For MinerU-HTML
7EXTRACTORS=(
8"mineru_html_fallback-html-md"
9)
10MODEL_PATH=YOUR_MINERUHTML_MODEL_PATH
11
12for extractor in ${EXTRACTORS[@]}; do
13 python eval_baselines.py --bench $BENCHMARK_DATA --task_dir $RESULT_DIR/$extractor --extractor_name $extractor --model_path $MODEL_PATH --default_config gpu
14done
15
16# For CPU Extractors
17EXTRACTORS=(
18"magichtml-html-md"
19"readability-html-md"
20"trafilatura-html-md"
21"resiliparse-text"
22"trafilatura-md"
23"trafilatura-text"
24"fullpage-html-md"
25"boilerpy3-text"
26"gne-html-md"
27"newsplease-text"
28"justtext-text"
29"boilerpy3-html-md"
30"goose3-text"
31)
32
33for extractor in ${EXTRACTORS[@]}; do
34 python eval_baselines.py --bench $BENCHMARK_DATA --task_dir $RESULT_DIR/$extractor --extractor_name $extractor
35done
36
37# For ReaderLM
38extractor=readerlm-text
39MODEL_PATH=YOUR_READERLM_MODEL_PATH
40
41python eval_baselines.py --bench $BENCHMARK_DATA --task_dir $RESULT_DIR/$extractor --extractor_name $extractor --model_path $MODEL_PATH --default_config gpu1@misc{liu2025drippertokenefficientmainhtml,
2 title={Dripper: Token-Efficient Main HTML Extraction with a Lightweight LM},
3 author={Mengjie Liu and Jiahui Peng and Pei Chu and Jiantao Qiu and Ren Ma and He Zhu and Rui Min and Lindong Lu and Wenchang Ning and Linfeng Hou and Kaiwen Liu and Yuan Qu and Zhenxiang Li and Chao Xu and Zhongying Tu and Wentao Zhang and Conghui He},
4 year={2025},
5 eprint={2511.23119},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2511.23119},
9}1@misc{ma2025aiccparsehtmlfiner,
2 title={AICC: Parse HTML Finer, Make Models Better -- A 7.3T AI-Ready Corpus Built by a Model-Based HTML Parser},
3 author={Ren Ma and Jiantao Qiu and Chao Xu and Pei Chu and Kaiwen Liu and Pengli Ren and Yuan Qu and Jiahui Peng and Linfeng Hou and Mengjie Liu and Lindong Lu and Wenchang Ning and Jia Yu and Rui Min and Jin Shi and Haojiong Chen and Peng Zhang and Wenjian Zhang and Qian Jiang and Zengjie Hu and Guoqiang Yang and Zhenxiang Li and Fukai Shang and Runyuan Ma and Chenlin Su and Zhongying Tu and Wentao Zhang and Dahua Lin and Conghui He},
4 year={2025},
5 eprint={2511.16397},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2511.16397},
9}