Craw4LLM 使用教程
Crawl4LLM 项目地址: https://gitcode.com/gh_mirrors/cr/Crawl4LLM
1. 项目的目录结构及介绍
Craw4LLM 项目是一个用于大规模语言模型预训练的网页爬虫工具。项目的目录结构如下:
Craw4LLM/
├── .gitignore
├── LICENSE
├── README.md
├── access_data.py
├── corpus_interface.py
├── crawl.py
├── crawler.py
├── document_rater.py
├── fetch_docs.py
├── normalizer.py
├── seed.txt
├── utils.py
├── wandb_logger.py
└── configs/
README.md
: 项目说明文件,包含项目的基本信息和如何使用。.gitignore
: Git 忽略文件,指定在 Git 版本控制中应该忽略的文件。LICENSE
: 项目许可证文件,本项目采用 MIT 许可证。access_data.py
: 数据访问相关的 Python 脚本。corpus_interface.py
: 与语料库交互的接口。crawl.py
: 爬虫启动脚本,用于执行爬虫任务。crawler.py
: 爬虫核心逻辑实现。document_rater.py
: 文档评分相关的 Python 脚本。fetch_docs.py
: 用于获取文档内容的 Python 脚本。normalizer.py
: 文本归一化处理。seed.txt
: 爬虫起始种子文件。utils.py
: 工具函数库。wandb_logger.py
: Weights & Biases 日志记录。configs/
: 配置文件目录,包含不同的爬虫配置。
2. 项目的启动文件介绍
项目的启动文件是 crawl.py
。该文件包含了运行爬虫所需的主函数。使用以下命令运行爬虫:
python crawl.py crawl --config <path_to_your_config_file>
其中 <path_to_your_config_file>
是指向配置文件的路径,配置文件定义了爬虫的运行参数。
3. 项目的配置文件介绍
配置文件位于 configs/
目录下,是一个 YAML 格式的文件。以下是配置文件的基本结构和参数说明:
cw22_root_path: <path_to_clueweb22_a>
seed_docs_file: seed.txt
output_dir: crawl_results/seed_10k_crawl_20m_dclm_fasttext
num_selected_docs_per_iter: 10000
num_workers: 16
save_state_every: -1
max_num_docs: 20000000
selection_method: dclm_fasttext_score
order: desc
wandb: true
wandb_project: crawler
wandb_run_name: seed_10k_crawl_20m_dclm_fasttext
rating_methods:
- type: length
- type: fasttext_score
rater_name: dclm_fasttext_score
model_path: fasttext_scorers/openhermes_reddit_eli5_vs_rw_v2_bigram_200k_train.bin
cw22_root_path
: ClueWeb22 数据集的根路径。seed_docs_file
: 种子文档文件的路径。output_dir
: 爬虫结果的输出目录。num_selected_docs_per_iter
: 每次迭代选择的文档数量。num_workers
: 爬虫的工作线程数。save_state_every
: 多少步骤保存一次爬虫状态,-1 表示不保存。max_num_docs
: 爬虫最大的文档数量。selection_method
: 选择文档的方法。order
: 排序的顺序,desc 表示降序,asc 表示升序。wandb
: 是否启用 Weights & Biases 日志记录。wandb_project
: Weights & Biases 项目名。wandb_run_name
: Weights & Biases 运行名。rating_methods
: 评分方法列表。rater_name
: 最终评分器名称。model_path
: fastText 模型的路径。
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考