Instructions to use QuantFactory/HTML-Pruner-Llama-1B-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use QuantFactory/HTML-Pruner-Llama-1B-GGUF with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("QuantFactory/HTML-Pruner-Llama-1B-GGUF", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use QuantFactory/HTML-Pruner-Llama-1B-GGUF with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf QuantFactory/HTML-Pruner-Llama-1B-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf QuantFactory/HTML-Pruner-Llama-1B-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf QuantFactory/HTML-Pruner-Llama-1B-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf QuantFactory/HTML-Pruner-Llama-1B-GGUF:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf QuantFactory/HTML-Pruner-Llama-1B-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf QuantFactory/HTML-Pruner-Llama-1B-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf QuantFactory/HTML-Pruner-Llama-1B-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf QuantFactory/HTML-Pruner-Llama-1B-GGUF:Q4_K_M
Use Docker
docker model run hf.co/QuantFactory/HTML-Pruner-Llama-1B-GGUF:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use QuantFactory/HTML-Pruner-Llama-1B-GGUF with Ollama:
ollama run hf.co/QuantFactory/HTML-Pruner-Llama-1B-GGUF:Q4_K_M
- Unsloth Studio
How to use QuantFactory/HTML-Pruner-Llama-1B-GGUF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/HTML-Pruner-Llama-1B-GGUF to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/HTML-Pruner-Llama-1B-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for QuantFactory/HTML-Pruner-Llama-1B-GGUF to start chatting
- Pi
How to use QuantFactory/HTML-Pruner-Llama-1B-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf QuantFactory/HTML-Pruner-Llama-1B-GGUF:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "QuantFactory/HTML-Pruner-Llama-1B-GGUF:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use QuantFactory/HTML-Pruner-Llama-1B-GGUF with Docker Model Runner:
docker model run hf.co/QuantFactory/HTML-Pruner-Llama-1B-GGUF:Q4_K_M
- Lemonade
How to use QuantFactory/HTML-Pruner-Llama-1B-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull QuantFactory/HTML-Pruner-Llama-1B-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.HTML-Pruner-Llama-1B-GGUF-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use QuantFactory/HTML-Pruner-Llama-1B-GGUF with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf QuantFactory/HTML-Pruner-Llama-1B-GGUF:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default QuantFactory/HTML-Pruner-Llama-1B-GGUF:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use QuantFactory/HTML-Pruner-Llama-1B-GGUF with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf QuantFactory/HTML-Pruner-Llama-1B-GGUF:Q4_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "QuantFactory/HTML-Pruner-Llama-1B-GGUF:Q4_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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3.2-1B
|
| 8 |
+
license: apache-2.0
|
| 9 |
+
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
[](https://hf.co/QuantFactory)
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
# QuantFactory/HTML-Pruner-Llama-1B-GGUF
|
| 16 |
+
This is quantized version of [zstanjj/HTML-Pruner-Llama-1B](https://huggingface.co/zstanjj/HTML-Pruner-Llama-1B) created using llama.cpp
|
| 17 |
+
|
| 18 |
+
# Original Model Card
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
## ✨ Latest News
|
| 24 |
+
|
| 25 |
+
- [11/06/2024]: Our paper is available on arXiv. You can access it [here](https://arxiv.org/abs/2411.02959).
|
| 26 |
+
- [11/05/2024]: The open-source toolkit and models are released. You can apply HtmlRAG in your own RAG systems now.
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
## Model Information
|
| 30 |
+
|
| 31 |
+
<p align="left">
|
| 32 |
+
• 📝 <a href="https://arxiv.org/abs/2411.02959" target="_blank">Paper</a> • 🤗 <a href="https://huggingface.co/zstanjj/SlimPLM-Query-Rewriting/" target="_blank">Hugging Face</a> • 🧩 <a href="https://github.com/plageon/SlimPLM" target="_blank">Github</a>
|
| 33 |
+
</p>
|
| 34 |
+
|
| 35 |
+
We propose HtmlRAG, which uses HTML instead of plain text as the format of external knowledge in RAG systems. To tackle the long context brought by HTML, we propose **Lossless HTML Cleaning** and **Two-Step Block-Tree-Based HTML Pruning**.
|
| 36 |
+
|
| 37 |
+
- **Lossless HTML Cleaning**: This cleaning process just removes totally irrelevant contents and compress redundant structures, retaining all semantic information in the original HTML. The compressed HTML of lossless HTML cleaning is suitable for RAG systems that have long-context LLMs and are not willing to loss any information before generation.
|
| 38 |
+
|
| 39 |
+
- **Two-Step Block-Tree-Based HTML Pruning**: The block-tree-based HTML pruning consists of two steps, both of which are conducted on the block tree structure. The first pruning step uses a embedding model to calculate scores for blocks, while the second step uses a path generative model. The first step processes the result of lossless HTML cleaning, while the second step processes the result of the first pruning step.
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
🌹 If you use this model, please star our **[GitHub repository](https://github.com/plageon/HTMLRAG)** to support us. Your star means a lot!
|
| 43 |
+
|
| 44 |
+
## 📦 Installation
|
| 45 |
+
|
| 46 |
+
Install the package using pip:
|
| 47 |
+
```bash
|
| 48 |
+
pip install htmlrag
|
| 49 |
+
```
|
| 50 |
+
Or install the package from source:
|
| 51 |
+
```bash
|
| 52 |
+
pip install -e .
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
---
|
| 56 |
+
|
| 57 |
+
## 📖 User Guide
|
| 58 |
+
|
| 59 |
+
### 🧹 HTML Cleaning
|
| 60 |
+
|
| 61 |
+
```python
|
| 62 |
+
from htmlrag import clean_html
|
| 63 |
+
|
| 64 |
+
question = "When was the bellagio in las vegas built?"
|
| 65 |
+
html = """
|
| 66 |
+
<html>
|
| 67 |
+
<head>
|
| 68 |
+
<title>When was the bellagio in las vegas built?</title>
|
| 69 |
+
</head>
|
| 70 |
+
<body>
|
| 71 |
+
<p class="class0">The Bellagio is a luxury hotel and casino located on the Las Vegas Strip in Paradise, Nevada. It was built in 1998.</p>
|
| 72 |
+
</body>
|
| 73 |
+
<div>
|
| 74 |
+
<div>
|
| 75 |
+
<p>Some other text</p>
|
| 76 |
+
<p>Some other text</p>
|
| 77 |
+
</div>
|
| 78 |
+
</div>
|
| 79 |
+
<p class="class1"></p>
|
| 80 |
+
<!-- Some comment -->
|
| 81 |
+
<script type="text/javascript">
|
| 82 |
+
document.write("Hello World!");
|
| 83 |
+
</script>
|
| 84 |
+
</html>
|
| 85 |
+
"""
|
| 86 |
+
|
| 87 |
+
simplified_html = clean_html(html)
|
| 88 |
+
print(simplified_html)
|
| 89 |
+
|
| 90 |
+
# <html>
|
| 91 |
+
# <title>When was the bellagio in las vegas built?</title>
|
| 92 |
+
# <p>The Bellagio is a luxury hotel and casino located on the Las Vegas Strip in Paradise, Nevada. It was built in 1998.</p>
|
| 93 |
+
# <div>
|
| 94 |
+
# <p>Some other text</p>
|
| 95 |
+
# <p>Some other text</p>
|
| 96 |
+
# </div>
|
| 97 |
+
# </html>
|
| 98 |
+
```
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
### 🌲 Build Block Tree
|
| 102 |
+
|
| 103 |
+
```python
|
| 104 |
+
from htmlrag import build_block_tree
|
| 105 |
+
|
| 106 |
+
block_tree, simplified_html = build_block_tree(simplified_html, max_node_words=10)
|
| 107 |
+
for block in block_tree:
|
| 108 |
+
print("Block Content: ", block[0])
|
| 109 |
+
print("Block Path: ", block[1])
|
| 110 |
+
print("Is Leaf: ", block[2])
|
| 111 |
+
print("")
|
| 112 |
+
|
| 113 |
+
# Block Content: <title>When was the bellagio in las vegas built?</title>
|
| 114 |
+
# Block Path: ['html', 'title']
|
| 115 |
+
# Is Leaf: True
|
| 116 |
+
#
|
| 117 |
+
# Block Content: <div>
|
| 118 |
+
# <p>Some other text</p>
|
| 119 |
+
# <p>Some other text</p>
|
| 120 |
+
# </div>
|
| 121 |
+
# Block Path: ['html', 'div']
|
| 122 |
+
# Is Leaf: True
|
| 123 |
+
#
|
| 124 |
+
# Block Content: <p>The Bellagio is a luxury hotel and casino located on the Las Vegas Strip in Paradise, Nevada. It was built in 1998.</p>
|
| 125 |
+
# Block Path: ['html', 'p']
|
| 126 |
+
# Is Leaf: True
|
| 127 |
+
```
|
| 128 |
+
|
| 129 |
+
### ✂️ Prune HTML Blocks with Embedding Model
|
| 130 |
+
|
| 131 |
+
```python
|
| 132 |
+
from htmlrag import EmbedHTMLPruner
|
| 133 |
+
|
| 134 |
+
embed_html_pruner = EmbedHTMLPruner(embed_model="bm25")
|
| 135 |
+
block_rankings = embed_html_pruner.calculate_block_rankings(question, simplified_html, block_tree)
|
| 136 |
+
print(block_rankings)
|
| 137 |
+
|
| 138 |
+
# [0, 2, 1]
|
| 139 |
+
|
| 140 |
+
from transformers import AutoTokenizer
|
| 141 |
+
|
| 142 |
+
chat_tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.1-70B-Instruct")
|
| 143 |
+
|
| 144 |
+
max_context_window = 60
|
| 145 |
+
pruned_html = embed_html_pruner.prune_HTML(simplified_html, block_tree, block_rankings, chat_tokenizer, max_context_window)
|
| 146 |
+
print(pruned_html)
|
| 147 |
+
|
| 148 |
+
# <html>
|
| 149 |
+
# <title>When was the bellagio in las vegas built?</title>
|
| 150 |
+
# <p>The Bellagio is a luxury hotel and casino located on the Las Vegas Strip in Paradise, Nevada. It was built in 1998.</p>
|
| 151 |
+
# </html>
|
| 152 |
+
```
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
### ✂️ Prune HTML Blocks with Generative Model
|
| 156 |
+
|
| 157 |
+
```python
|
| 158 |
+
from htmlrag import GenHTMLPruner
|
| 159 |
+
|
| 160 |
+
ckpt_path = "zstanjj/HTML-Pruner-Llama-1B"
|
| 161 |
+
gen_embed_pruner = GenHTMLPruner(gen_model=ckpt_path, max_node_words=10)
|
| 162 |
+
block_rankings = gen_embed_pruner.calculate_block_rankings(question, pruned_html)
|
| 163 |
+
print(block_rankings)
|
| 164 |
+
|
| 165 |
+
# [1, 0]
|
| 166 |
+
|
| 167 |
+
max_context_window = 32
|
| 168 |
+
pruned_html = gen_embed_pruner.prune_HTML(pruned_html, block_tree, block_rankings, chat_tokenizer, max_context_window)
|
| 169 |
+
print(pruned_html)
|
| 170 |
+
|
| 171 |
+
# <p>The Bellagio is a luxury hotel and casino located on the Las Vegas Strip in Paradise, Nevada. It was built in 1998.</p>
|
| 172 |
+
```
|
| 173 |
+
|
| 174 |
+
## Results
|
| 175 |
+
|
| 176 |
+
- **Results for [HTML-Pruner-Phi-3.8B](https://huggingface.co/zstanjj/HTML-Pruner-Phi-3.8B) and [HTML-Pruner-Llama-1B](https://huggingface.co/zstanjj/HTML-Pruner-Llama-1B) with Llama-3.1-70B-Instruct as chat model**.
|
| 177 |
+
|
| 178 |
+
| Dataset | ASQA | HotpotQA | NQ | TriviaQA | MuSiQue | ELI5 |
|
| 179 |
+
|------------------|-----------|-----------|-----------|-----------|-----------|-----------|
|
| 180 |
+
| Metrics | EM | EM | EM | EM | EM | ROUGE-L |
|
| 181 |
+
| BM25 | 49.50 | 38.25 | 47.00 | 88.00 | 9.50 | 16.15 |
|
| 182 |
+
| BGE | 68.00 | 41.75 | 59.50 | 93.00 | 12.50 | 16.20 |
|
| 183 |
+
| E5-Mistral | 63.00 | 36.75 | 59.50 | 90.75 | 11.00 | 16.17 |
|
| 184 |
+
| LongLLMLingua | 62.50 | 45.00 | 56.75 | 92.50 | 10.25 | 15.84 |
|
| 185 |
+
| JinaAI Reader | 55.25 | 34.25 | 48.25 | 90.00 | 9.25 | 16.06 |
|
| 186 |
+
| HtmlRAG-Phi-3.8B | **68.50** | **46.25** | 60.50 | **93.50** | **13.25** | **16.33** |
|
| 187 |
+
| HtmlRAG-Llama-1B | 66.50 | 45.00 | **60.75** | 93.00 | 10.00 | 16.25 |
|
| 188 |
+
|
| 189 |
+
---
|
| 190 |
+
|
| 191 |
+
## 📜 Citation
|
| 192 |
+
|
| 193 |
+
```bibtex
|
| 194 |
+
@misc{tan2024htmlraghtmlbetterplain,
|
| 195 |
+
title={HtmlRAG: HTML is Better Than Plain Text for Modeling Retrieved Knowledge in RAG Systems},
|
| 196 |
+
author={Jiejun Tan and Zhicheng Dou and Wen Wang and Mang Wang and Weipeng Chen and Ji-Rong Wen},
|
| 197 |
+
year={2024},
|
| 198 |
+
eprint={2411.02959},
|
| 199 |
+
archivePrefix={arXiv},
|
| 200 |
+
primaryClass={cs.IR},
|
| 201 |
+
url={https://arxiv.org/abs/2411.02959},
|
| 202 |
+
}
|
| 203 |
+
```
|
| 204 |
+
|
| 205 |
+
|