PEFT
Safetensors
Chinese
English
url-classification
list-page-detection
detail-page-detection
qwen
fine-tuning
lora
url-parser
Run this model with HF Jobs
Run windlx/url-classifier-lora on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/windlx/url-classifier-lora. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/windlx/url-classifier-lora on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use windlx/url-classifier-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use windlx/url-classifier-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-1.5B") model = PeftModel.from_pretrained(base_model, "windlx/url-classifier-lora") - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse files123456789101112131415161718192021MIT License
Copyright (c) 2026 xiu xiu
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188---license: mitlanguage:- zh- endatasets:- IowaCat/page_type_inference_datasetmetrics:- accuracy: 0.99pipeline_tag: text-generationtags:- url-classification- list-page-detection- detail-page-detection- qwen- fine-tuning- lora- url-parserwidget:- text: "https://example.com/product/12345"- text: "https://example.com/category/electronics"---
# URL Page Type Classifier
<div align="center">

</div>
## 📋 概述
基于 Qwen2.5-1.5B + LoRA 微调的URL类型分类模型,用于判断URL是列表页还是详情页。
## 🏗️ 模型架构
| 项目 | 详情 ||------|------|| **基础模型** | Qwen/Qwen2.5-1.5B || **微调方法** | LoRA (r=16, alpha=32) || **参数量** | 1.5B || **可训练参数** | ~18M (1.18%) |
## 📊 训练数据
- **数据集**: IowaCat/page_type_inference_dataset- **训练样本**: 10,000条URL (5000列表页 + 5000详情页)- **数据来源**: HuggingFace Datasets
### 数据分布
| 类型 | 数量 | 比例 ||------|------|------|| 列表页 (List Page) | 5,000 | 50% || 详情页 (Detail Page) | 5,000 | 50% |
## ⚙️ 训练配置
```python{ "base_model": "Qwen/Qwen2.5-1.5B", "lora_rank": 16, "lora_alpha": 32, "lora_dropout": 0.05, "num_train_epochs": 3, "per_device_train_batch_size": 2, "gradient_accumulation_steps": 8, "learning_rate": 2e-4, "fp16": true, "optimizer": "adamw_torch", "lr_scheduler_type": "cosine"}```
## 📈 性能评估
### 测试结果
| 测试集 | 样本数 | 准确率 ||--------|--------|--------|| 验证集 | 100 | **99%** |
### 示例预测
| URL | 预测结果 ||-----|----------|| `https://example.com/products/category` | 列表页 (List Page) || `https://example.com/product/12345` | 详情页 (Detail Page) || `https://example.com/search?q=test` | 列表页 (List Page) || `https://example.com/item/abc123` | 详情页 (Detail Page) || `https://example.com/list/all` | 列表页 (List Page) |
## 🚀 快速开始
### 安装依赖
```bashpip install transformers peft torch```
### 推理代码
```pythonfrom transformers import AutoTokenizer, AutoModelForCausalLM
model_name = "windlx/url-classifier-model"tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True)
# 要分类的URLurl = "https://example.com/product/12345"
# 构建提示prompt = f"""请判断以下URL是列表页还是详情页。
URL: {url}类型: """
# 推理inputs = tokenizer(prompt, return_tensors="pt")outputs = model.generate(**inputs, max_new_tokens=10, do_sample=False)response = tokenizer.decode(outputs[0], skip_special_tokens=True)
# 提取结果if "详情页" in response or "Detail Page" in response: result = "详情页 (Detail Page)"else: result = "列表页 (List Page)"
print(f"URL: {url}")print(f"类型: {result}")```
### 使用 GPU
```python# 自动使用GPUmodel = AutoModelForCausalLM.from_pretrained( model_name, trust_remote_code=True, device_map="auto", torch_dtype="auto")```
### 使用 CPU
```python# 强制使用CPUmodel = AutoModelForCausalLM.from_pretrained( model_name, trust_remote_code=True, device_map="cpu", torch_dtype="float32")```
## ⚠️ 局限性
1. **仅基于URL字符串** - 不访问实际网页内容2. **依赖URL路径规范** - 对于URL路径不规范的网站,准确率可能较低3. **仅支持中英文** - 主要针对中文URL优化
## 📝 使用场景
- 🔍 **搜索引擎优化 (SEO)** - 识别网站页面结构- 🕷️ **网页爬虫** - 判断链接类型,优化爬取策略- 📊 **网站分析** - 统计列表页和详情页比例- 🔗 **链接分类** - 大规模URL分类处理
## 📁 相关链接
- **GitHub仓库**: https://github.com/xiuxiu/url-classifier- **HuggingFace模型**: https://huggingface.co/windlx/url-classifier-model- **训练数据集**: https://huggingface.co/datasets/IowaCat/page_type_inference_dataset
## 🙏 致谢
- [Qwen](https://github.com/QwenLM/Qwen2) - 提供基础模型- [LoRA](https://github.com/microsoft/LoRA) - 高效微调方法- [HuggingFace](https://huggingface.co/) - 模型托管平台
## 📄 许可
[LICENSE](LICENSE) - MIT LicenseLICENSEAdded+21
README.mdAdded+188