[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-dbiir--UER-py":3,"tool-dbiir--UER-py":61},[4,18,26,36,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",144730,2,"2026-04-07T23:26:32",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107888,"2026-04-06T11:32:50",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":10,"last_commit_at":59,"category_tags":60,"status":17},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,"2026-04-06T11:19:32",[35,15,13,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":66,"readme_en":67,"readme_zh":68,"quickstart_zh":69,"use_case_zh":70,"hero_image_url":71,"owner_login":72,"owner_name":73,"owner_avatar_url":74,"owner_bio":75,"owner_company":76,"owner_location":76,"owner_email":76,"owner_twitter":76,"owner_website":77,"owner_url":78,"languages":79,"stars":84,"forks":85,"last_commit_at":86,"license":87,"difficulty_score":10,"env_os":88,"env_gpu":89,"env_ram":88,"env_deps":90,"category_tags":105,"github_topics":108,"view_count":32,"oss_zip_url":76,"oss_zip_packed_at":76,"status":17,"created_at":129,"updated_at":130,"faqs":131,"releases":171},5489,"dbiir\u002FUER-py","UER-py","Open Source Pre-training Model Framework in PyTorch & Pre-trained Model Zoo","UER-py 是一个基于 PyTorch 构建的开源预训练模型框架，旨在为自然语言处理（NLP）任务提供从通用语料预训练到下游任务微调的一站式解决方案。它有效解决了研究人员在复现经典模型（如 BERT、GPT-2、T5 等）时面临的代码分散、架构不统一及难以扩展等痛点，确保了实验结果的高度可复现性。\n\n这款工具特别适合 NLP 领域的研究人员、算法工程师以及希望深入探索预训练技术的开发者使用。对于需要处理中等规模文本模型（参数量小于十亿）的用户，UER-py 依然是比其多模态继任者更轻量、专注的选择。\n\nUER-py 的核心亮点在于其卓越的“模块化”设计。它将模型拆解为嵌入层、编码器、解码器等独立组件，用户像搭积木一样自由组合这些模块，从而以极低的成本构建自定义预训练模型。此外，它不仅支持 CPU、单卡及分布式等多种训练模式，还维护了一个丰富的“模型动物园”，提供了多种特性的预训练模型供直接调用。凭借在各类 NLP 竞赛中验证过的优异表现，UER-py 能帮助用户快速搭建分类、机器阅读理解等应用，是进行预训练技术研究与落地的得力助手。","[**English**](https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py) | [**中文**](https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fblob\u002Fmaster\u002FREADME_ZH.md)\n\n[![Build Status](https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Factions\u002Fworkflows\u002Fgithub-actions.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Factions\u002Fworkflows\u002Fgithub-actions.yml)\n[![codebeat badge](https:\u002F\u002Fcodebeat.co\u002Fbadges\u002Ff75fab90-6d00-44b4-bb42-d19067400243)](https:\u002F\u002Fcodebeat.co\u002Fprojects\u002Fgithub-com-dbiir-uer-py-master)\n![](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-MIT-000000.svg)\n[![arXiv](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FarXiv-1909.05658-\u003Ccolor>.svg)](https:\u002F\u002Farxiv.org\u002Fabs\u002F1909.05658)\n\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdbiir_UER-py_readme_1179b95c4ca4.jpg\" width=\"390\" hegiht=\"390\" align=left \u002F>\n\nPre-training has become an essential part for NLP tasks. UER-py (Universal Encoder Representations) is a toolkit for pre-training on general-domain corpus and fine-tuning on downstream task. UER-py maintains model modularity and supports research extensibility. It facilitates the use of existing pre-training models, and provides interfaces for users to further extend upon. With UER-py, we build a model zoo which contains pre-trained models of different properties. **See the [UER-py project Wiki](https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fwiki) for full documentation**.\n\n\u003Cbr\u002F>\n\u003Cbr\u002F>\n\n\n**🚀** We have open-sourced the [TencentPretrain](https:\u002F\u002Fgithub.com\u002FTencent\u002FTencentPretrain), a refactored new version of UER-py. TencentPretrain supports multi-modal models and enables training of large models. If you are interested in text models of medium size (with parameter sizes of less than one billion), we recommend continuing to use the UER-py project.\n\n\n\u003Cbr\u002F>\n\nTable of Contents\n=================\n  * [Features](#features)\n  * [Requirements](#requirements)\n  * [Quickstart](#quickstart)\n  * [Pre-training data](#pre-training-data)\n  * [Downstream datasets](#downstream-datasets)\n  * [Modelzoo](#modelzoo)\n  * [Instructions](#instructions)\n  * [Competition solutions](#competition-solutions)\n  * [Citation](#citation)\n  * [Contact information](#contact-information)\n\n\n\u003Cbr\u002F>\n\n## Features\nUER-py has the following features:\n- __Reproducibility__ UER-py has been tested on many datasets and should match the performances of the original pre-training model implementations such as BERT, GPT-2, ELMo, and T5.\n- __Model modularity__ UER-py is divided into the following components: embedding, encoder, target embedding (optional), decoder (optional), and target. Ample modules are implemented in each component. Clear and robust interface allows users to combine modules to construct pre-training models with as few restrictions as possible.\n- __Model training__ UER-py supports CPU mode, single GPU mode and distributed training mode.\n- __Model zoo__ With the help of UER-py, we pre-train and release models of different properties. Proper selection of pre-trained models is important to the performances of downstream tasks.\n- __SOTA results__ UER-py supports comprehensive downstream tasks (e.g. classification and machine reading comprehension) and provides winning solutions of many NLP competitions.\n- __Abundant functions__ UER-py provides abundant functions related with pre-training, such as feature extractor and text generation.\n\n\n\u003Cbr\u002F>\n\n## Requirements\n* Python >= 3.6\n* torch >= 1.1\n* six >= 1.12.0\n* argparse\n* packaging\n* regex\n* For the pre-trained model conversion (related with TensorFlow) you will need TensorFlow\n* For the tokenization with sentencepiece model you will need [SentencePiece](https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fsentencepiece)\n* For developing a stacking model you will need LightGBM and [BayesianOptimization](https:\u002F\u002Fgithub.com\u002Ffmfn\u002FBayesianOptimization)\n* For the pre-training with whole word masking you will need word segmentation tool such as [jieba](https:\u002F\u002Fgithub.com\u002Ffxsjy\u002Fjieba)\n* For the use of CRF in sequence labeling downstream task you will need [pytorch-crf](https:\u002F\u002Fgithub.com\u002Fkmkurn\u002Fpytorch-crf)\n\n\n\u003Cbr\u002F>\n\n## Quickstart\nThis section uses several commonly-used examples to demonstrate how to use UER-py. More details are discussed in Instructions section. We firstly use BERT (a text pre-training model) on book review sentiment classification dataset. We pre-train model on book review corpus and then fine-tune it on book review sentiment classification dataset. There are three input files: book review corpus, book review sentiment classification dataset, and vocabulary. All files are encoded in UTF-8 and included in this project.\n\nThe format of the corpus for BERT is as follows (one sentence per line and documents are delimited by empty lines)：\n```\ndoc1-sent1\ndoc1-sent2\ndoc1-sent3\n\ndoc2-sent1\n\ndoc3-sent1\ndoc3-sent2\n```\nThe book review corpus is obtained from book review classification dataset. We remove labels and split a review into two parts from the middle to construct a document with two sentences (see *book_review_bert.txt* in *corpora* folder). \n\nThe format of the classification dataset is as follows:\n```\nlabel    text_a\n1        instance1\n0        instance2\n1        instance3\n```\nLabel and instance are separated by \\t . The first row is a list of column names. The label ID should be an integer between (and including) 0 and n-1 for n-way classification.\n\nWe use Google's Chinese vocabulary file *models\u002Fgoogle_zh_vocab.txt*, which contains 21128 Chinese characters.\n\nWe firstly pre-process the book review corpus. In the pre-processing stage, the corpus needs to be processed into the format required by the specified pre-training model (*--data_processor*):\n```\npython3 preprocess.py --corpus_path corpora\u002Fbook_review_bert.txt --vocab_path models\u002Fgoogle_zh_vocab.txt \\\n                      --dataset_path dataset.pt --processes_num 8 --data_processor bert\n```\nNotice that *six>=1.12.0* is required.\n\n\nPre-processing is time-consuming. Using multiple processes can largely accelerate the pre-processing speed (*--processes_num*). BERT tokenizer is used in default (*--tokenizer bert*). After pre-processing, the raw text is converted to *dataset.pt*, which is the input of *pretrain.py*. Then we download Google's pre-trained Chinese BERT model [*google_zh_model.bin*](https:\u002F\u002Fshare.weiyun.com\u002FFR4rPxc4) (in UER format and the original model is from [here](https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fbert)), and put it in *models* folder. We load the pre-trained Chinese BERT model and further pre-train it on book review corpus. Pre-training model is usually composed of embedding, encoder, and target layers. To build a pre-training model, we should provide related information. Configuration file (*--config_path*) specifies the modules and hyper-parameters used by pre-training models. More details can be found in *models\u002Fbert\u002Fbase_config.json*. Suppose we have a machine with 8 GPUs:\n```\npython3 pretrain.py --dataset_path dataset.pt --vocab_path models\u002Fgoogle_zh_vocab.txt \\\n                    --pretrained_model_path models\u002Fgoogle_zh_model.bin \\\n                    --config_path models\u002Fbert\u002Fbase_config.json \\\n                    --output_model_path models\u002Fbook_review_model.bin \\\n                    --world_size 8 --gpu_ranks 0 1 2 3 4 5 6 7 \\\n                    --total_steps 5000 --save_checkpoint_steps 1000 --batch_size 32\n\nmv models\u002Fbook_review_model.bin-5000 models\u002Fbook_review_model.bin\n```\nNotice that the model trained by *pretrain.py* is attacted with the suffix which records the training step (*--total_steps*). We could remove the suffix for ease of use.\n\nThen we fine-tune the pre-trained model on downstream classification dataset. We use embedding and encoder layers of [*book_review_model.bin*](https:\u002F\u002Fshare.weiyun.com\u002FPnxMrRwZ), which is the output of *pretrain.py*:\n```\npython3 finetune\u002Frun_classifier.py --pretrained_model_path models\u002Fbook_review_model.bin \\\n                                   --vocab_path models\u002Fgoogle_zh_vocab.txt \\\n                                   --config_path models\u002Fbert\u002Fbase_config.json \\\n                                   --train_path datasets\u002Fbook_review\u002Ftrain.tsv \\\n                                   --dev_path datasets\u002Fbook_review\u002Fdev.tsv \\\n                                   --test_path datasets\u002Fbook_review\u002Ftest.tsv \\\n                                   --epochs_num 3 --batch_size 32\n``` \nThe default path of the fine-tuned classifier model is *models\u002Ffinetuned_model.bin* . It is noticeable that the actual batch size of pre-training is *--batch_size* times *--world_size* ; The actual batch size of downstream task (e.g. classification) is *--batch_size* . \nThen we do inference with the fine-tuned model. \n```\npython3 inference\u002Frun_classifier_infer.py --load_model_path models\u002Ffinetuned_model.bin \\\n                                          --vocab_path models\u002Fgoogle_zh_vocab.txt \\\n                                          --config_path models\u002Fbert\u002Fbase_config.json \\\n                                          --test_path datasets\u002Fbook_review\u002Ftest_nolabel.tsv \\\n                                          --prediction_path datasets\u002Fbook_review\u002Fprediction.tsv \\\n                                          --labels_num 2\n```\n*--test_path* specifies the path of the file to be predicted. The file should contain text_a column.\n*--prediction_path* specifies the path of the file with prediction results.\nWe need to explicitly specify the number of labels by *--labels_num*. The above dataset is a two-way classification dataset.\n\n\u003Cbr>\n\nThe above content provides basic ways of using UER-py to pre-process, pre-train, fine-tune, and do inference. More use cases can be found in complete :arrow_right: [__quickstart__](https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fwiki\u002FQuickstart) :arrow_left: . The complete quickstart contains abundant use cases, covering most of the pre-training related application scenarios. It is recommended that users read the complete quickstart in order to use the project reasonably.\n\n\u003Cbr\u002F>\n\n## Pre-training data\nThis section provides links to a range of :arrow_right: [__pre-training data__](https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fwiki\u002FPretraining-data) :arrow_left: . UER can load these pre-training data directly.\n\n\u003Cbr\u002F>\n\n## Downstream datasets\nThis section provides links to a range of :arrow_right: [__downstream datasets__](https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fwiki\u002FDownstream-datasets) :arrow_left: . UER can load these datasets directly.\n\n\u003Cbr\u002F>\n\n## Modelzoo\nWith the help of UER, we pre-trained models of different properties (e.g. models based on different corpora, encoders, and targets). Detailed introduction of pre-trained models and their download links can be found in :arrow_right: [__modelzoo__](https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fwiki\u002FModelzoo) :arrow_left: . All pre-trained models can be loaded by UER directly.\n\n\u003Cbr\u002F>\n\n## Instructions\nUER-py is organized as follows：\n```\nUER-py\u002F\n    |--uer\u002F\n    |    |--embeddings\u002F # contains modules of embedding component\n    |    |--encoders\u002F # contains modules of encoder component such as RNN, CNN, Transformer\n    |    |--decoders\u002F # contains modules of decoder component\n    |    |--targets\u002F # contains modules of target component such as language modeling, masked language modeling\n    |    |--layers\u002F # contains frequently-used NN layers\n    |    |--models\u002F # contains model.py, which combines modules of different components\n    |    |--utils\u002F # contains frequently-used utilities\n    |    |--model_builder.py\n    |    |--model_loader.py\n    |    |--model_saver.py\n    |    |--opts.py\n    |    |--trainer.py\n    |\n    |--corpora\u002F # contains pre-training data\n    |--datasets\u002F # contains downstream tasks\n    |--models\u002F # contains pre-trained models, vocabularies, and configuration files\n    |--scripts\u002F # contains useful scripts for pre-training models\n    |--finetune\u002F # contains fine-tuning scripts for downstream tasks\n    |--inference\u002F # contains inference scripts for downstream tasks\n    |\n    |--preprocess.py\n    |--pretrain.py\n    |--README.md\n    |--README_ZH.md\n    |--requirements.txt\n    |--LICENSE\n\n```\n\nThe code is organized based on components (e.g. embeddings, encoders). Users can use and extend upon it with little efforts.\n\nComprehensive examples of using UER can be found in :arrow_right: [__instructions__](https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fwiki\u002FInstructions) :arrow_left: , which help users quickly implement pre-training models such as BERT, GPT-2, ELMo, T5 and fine-tune pre-trained models on a range of downstream tasks.\n\n\u003Cbr\u002F>\n\n## Competition solutions\nUER-py has been used in winning solutions of many NLP competitions. In this section, we provide some examples of using UER-py to achieve SOTA results on NLP competitions, such as CLUE. See :arrow_right: [__competition solutions__](https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fwiki\u002FCompetition-solutions) :arrow_left: for more detailed information.\n\n\u003Cbr\u002F>\n\n## Citation\n#### If you are using the work (e.g. pre-trained models) in UER-py for academic work, please cite the [system paper](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1909.05658.pdf) published in EMNLP 2019:\n```\n@article{zhao2019uer,\n  title={UER: An Open-Source Toolkit for Pre-training Models},\n  author={Zhao, Zhe and Chen, Hui and Zhang, Jinbin and Zhao, Xin and Liu, Tao and Lu, Wei and Chen, Xi and Deng, Haotang and Ju, Qi and Du, Xiaoyong},\n  journal={EMNLP-IJCNLP 2019},\n  pages={241},\n  year={2019}\n}\n```\n\n\u003Cbr\u002F>\n\n## Contact information\nFor communication related to this project, please contact Zhe Zhao (helloworld@alu.ruc.edu.cn; nlpzhezhao@tencent.com) or Yudong Li (liyudong123@hotmail.com) or Cheng Hou (chenghoubupt@bupt.edu.cn) or Wenhang Shi (wenhangshi@ruc.edu.cn).\n\nThis work is instructed by my enterprise mentors __Qi Ju__, __Xuefeng Yang__, __Haotang Deng__ and school mentors __Tao Liu__, __Xiaoyong Du__.\n\nWe also got a lot of help from Weijie Liu, Lusheng Zhang, Jianwei Cui, Xiayu Li, Weiquan Mao, Xin Zhao, Hui Chen, Jinbin Zhang, Zhiruo Wang, Peng Zhou, Haixiao Liu, and Weijian Wu. \n","[**English**](https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py) | [**中文**](https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fblob\u002Fmaster\u002FREADME_ZH.md)\n\n[![Build Status](https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Factions\u002Fworkflows\u002Fgithub-actions.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Factions\u002Fworkflows\u002Fgithub-actions.yml)\n[![codebeat badge](https:\u002F\u002Fcodebeat.co\u002Fbadges\u002Ff75fab90-6d00-44b4-bb42-d19067400243)](https:\u002F\u002Fcodebeat.co\u002Fprojects\u002Fgithub-com-dbiir-uer-py-master)\n![](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-MIT-000000.svg)\n[![arXiv](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FarXiv-1909.05658-\u003Ccolor>.svg)](https:\u002F\u002Farxiv.org\u002Fabs\u002F1909.05658)\n\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdbiir_UER-py_readme_1179b95c4ca4.jpg\" width=\"390\" hegiht=\"390\" align=left \u002F>\n\n预训练已成为自然语言处理任务中不可或缺的一部分。UER-py（通用编码器表示）是一个用于在通用领域语料库上进行预训练，并在下游任务上进行微调的工具包。UER-py 保持了模型的模块化设计，支持研究的可扩展性。它既便于用户使用现有的预训练模型，也提供了接口供用户进一步扩展。借助 UER-py，我们构建了一个包含多种不同特性的预训练模型库。**完整的文档请参阅 [UER-py 项目 Wiki](https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fwiki)**。\n\n\u003Cbr\u002F>\n\u003Cbr\u002F>\n\n\n**🚀** 我们已开源了 [TencentPretrain](https:\u002F\u002Fgithub.com\u002FTencent\u002FTencentPretrain)，它是 UER-py 的重构新版本。TencentPretrain 支持多模态模型，并能够训练大规模模型。如果您对中等规模的文本模型（参数量少于十亿）感兴趣，我们建议您继续使用 UER-py 项目。\n\n\n\u003Cbr\u002F>\n\n目录\n=================\n  * [功能特性](#features)\n  * [系统要求](#requirements)\n  * [快速入门](#quickstart)\n  * [预训练数据](#pre-training-data)\n  * [下游数据集](#downstream-datasets)\n  * [模型库](#modelzoo)\n  * [使用说明](#instructions)\n  * [竞赛解决方案](#competition-solutions)\n  * [引用](#citation)\n  * [联系方式](#contact-information)\n\n\n\u003Cbr\u002F>\n\n## 功能特性\nUER-py 具有以下特点：\n- __可复现性__ UER-py 已在多个数据集上进行了测试，其性能应与原始预训练模型实现（如 BERT、GPT-2、ELMo 和 T5）相匹配。\n- __模型模块化__ UER-py 分为以下几个组件：嵌入层、编码器、目标嵌入层（可选）、解码器（可选）和目标。每个组件都实现了丰富的模块，清晰且健壮的接口使用户能够自由组合这些模块，以构建几乎不受限制的预训练模型。\n- __模型训练__ UER-py 支持 CPU 模式、单 GPU 模式以及分布式训练模式。\n- __模型库__ 借助 UER-py，我们预训练并发布了多种不同特性的模型。合理选择预训练模型对于下游任务的性能至关重要。\n- __SOTA 结果__ UER-py 支持全面的下游任务（例如分类和机器阅读理解），并提供了多项 NLP 竞赛的优胜方案。\n- __丰富功能__ UER-py 提供了与预训练相关的丰富功能，如特征提取器和文本生成等。\n\n\n\u003Cbr\u002F>\n\n## 系统要求\n* Python >= 3.6\n* torch >= 1.1\n* six >= 1.12.0\n* argparse\n* packaging\n* regex\n* 进行预训练模型转换（与 TensorFlow 相关）时，需要 TensorFlow\n* 使用 sentencepiece 模型进行分词时，需要 [SentencePiece](https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fsentencepiece)\n* 开发堆叠模型时，需要 LightGBM 和 [BayesianOptimization](https:\u002F\u002Fgithub.com\u002Ffmfn\u002FBayesianOptimization)\n* 进行全词掩码的预训练时，需要像 [jieba](https:\u002F\u002Fgithub.com\u002Ffxsjy\u002Fjieba) 这样的分词工具\n* 在序列标注类下游任务中使用 CRF 时，需要 [pytorch-crf](https:\u002F\u002Fgithub.com\u002Fkmkurn\u002Fpytorch-crf)\n\n\n\u003Cbr\u002F>\n\n## 快速入门\n本节通过几个常用示例展示如何使用 UER-py。更多详细内容请参阅“使用说明”部分。我们首先在书评情感分类数据集上使用 BERT（一种文本预训练模型）。先在书评语料库上对模型进行预训练，然后再在书评情感分类数据集上进行微调。输入文件共有三个：书评语料库、书评情感分类数据集和词汇表。所有文件均采用 UTF-8 编码，并包含在本项目中。\n\nBERT 语料库的格式如下（每行为一句话，文档之间用空行分隔）：\n```\ndoc1-sent1\ndoc1-sent2\ndoc1-sent3\n\ndoc2-sent1\n\ndoc3-sent1\ndoc3-sent2\n```\n书评语料库是从书评分类数据集中提取的。我们去除了标签，并从中间将每篇书评分成两部分，以构建一个包含两句话的文档（详见 `corpora` 文件夹中的 `book_review_bert.txt`）。\n\n分类数据集的格式如下：\n```\nlabel    text_a\n1        instance1\n0        instance2\n1        instance3\n```\n标签和实例之间用制表符 `\\t` 分隔。第一行为列名列表。对于 n 分类问题，标签 ID 应为 0 到 n-1 之间的整数（包括 0 和 n-1）。\n\n我们使用 Google 的中文词汇表文件 `models\u002Fgoogle_zh_vocab.txt`，其中包含 21128 个汉字。\n\n首先对书评语料库进行预处理。在预处理阶段，需要将语料库处理成指定预训练模型所需的格式（`--data_processor`）：\n```\npython3 preprocess.py --corpus_path corpora\u002Fbook_review_bert.txt --vocab_path models\u002Fgoogle_zh_vocab.txt \\\n                      --dataset_path dataset.pt --processes_num 8 --data_processor bert\n```\n请注意，需要安装 `six>=1.12.0`。\n\n预处理过程较为耗时。使用多进程可以显著加快预处理速度（`--processes_num`）。默认使用 BERT 分词器（`--tokenizer bert`）。预处理完成后，原始文本会被转换为 `dataset.pt`，这是 `pretrain.py` 的输入。然后我们下载 Google 预训练的中文 BERT 模型 [`google_zh_model.bin`](https:\u002F\u002Fshare.weiyun.com\u002FFR4rPxc4)（UER 格式，原始模型来自 [这里](https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fbert)），并将其放入 `models` 文件夹中。加载预训练的中文 BERT 模型后，我们继续在书评语料库上对其进行进一步预训练。预训练模型通常由嵌入层、编码器和目标层组成。为了构建预训练模型，我们需要提供相关信息。配置文件（`--config_path`）指定了预训练模型使用的模块和超参数。更多细节请参阅 `models\u002Fbert\u002Fbase_config.json`。假设我们有一台配备 8 块 GPU 的机器：\n```\npython3 pretrain.py --dataset_path dataset.pt --vocab_path models\u002Fgoogle_zh_vocab.txt \\\n                    --pretrained_model_path models\u002Fgoogle_zh_model.bin \\\n                    --config_path models\u002Fbert\u002Fbase_config.json \\\n                    --output_model_path models\u002Fbook_review_model.bin \\\n                    --world_size 8 --gpu_ranks 0 1 2 3 4 5 6 7 \\\n                    --total_steps 5000 --save_checkpoint_steps 1000 --batch_size 32\n\nmv models\u002Fbook_review_model.bin-5000 models\u002Fbook_review_model.bin\n```\n请注意，`pretrain.py` 训练得到的模型会附加一个记录训练步数的后缀（`--total_steps`）。我们可以去掉后缀以便于使用。\n\n接下来，我们在下游分类数据集上对预训练模型进行微调。我们使用 `pretrain.py` 输出的 [`book_review_model.bin`](https:\u002F\u002Fshare.weiyun.com\u002FPnxMrRwZ) 中的嵌入层和编码器：\n```\npython3 finetune\u002Frun_classifier.py --pretrained_model_path models\u002Fbook_review_model.bin \\\n                                   --vocab_path models\u002Fgoogle_zh_vocab.txt \\\n                                   --config_path models\u002Fbert\u002Fbase_config.json \\\n                                   --train_path datasets\u002Fbook_review\u002Ftrain.tsv \\\n                                   --dev_path datasets\u002Fbook_review\u002Fdev.tsv \\\n                                   --test_path datasets\u002Fbook_review\u002Ftest.tsv \\\n                                   --epochs_num 3 --batch_size 32\n``` \n微调后的分类模型默认保存路径为 `models\u002Ffinetuned_model.bin`。需要注意的是，预训练任务的实际批量大小是 `--batch_size` 乘以 `--world_size`；而下游任务（如分类）的实际批量大小则为 `--batch_size`。\n\n随后，我们使用微调后的模型进行推理。\n```\npython3 inference\u002Frun_classifier_infer.py --load_model_path models\u002Ffinetuned_model.bin \\\n                                          --vocab_path models\u002Fgoogle_zh_vocab.txt \\\n                                          --config_path models\u002Fbert\u002Fbase_config.json \\\n                                          --test_path datasets\u002Fbook_review\u002Ftest_nolabel.tsv \\\n                                          --prediction_path datasets\u002Fbook_review\u002Fprediction.tsv \\\n                                          --labels_num 2\n```\n`--test_path` 指定待预测文件的路径，该文件应包含 `text_a` 列。`--prediction_path` 指定包含预测结果的文件路径。我们需要通过 `--labels_num` 显式指定标签数量。上述数据集为二分类数据集。\n\n\u003Cbr>\n\n以上内容提供了使用 UER-py 进行预处理、预训练、微调和推理的基本方法。更多用法案例请参阅完整的 :arrow_right: [__快速入门__](https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fwiki\u002FQuickstart) :arrow_left: 。完整版快速入门包含了丰富的用例，覆盖了大多数与预训练相关的应用场景。建议用户阅读完整版快速入门，以便合理使用该项目。\n\n\u003Cbr\u002F>\n\n## 预训练数据\n本节提供了一系列 :arrow_right: [__预训练数据__](https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fwiki\u002FPretraining-data) :arrow_left: 的链接。UER 可以直接加载这些预训练数据。\n\n\u003Cbr\u002F>\n\n## 下游数据集\n本节提供了一系列 :arrow_right: [__下游数据集__](https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fwiki\u002FDownstream-datasets) :arrow_left: 的链接。UER 可以直接加载这些数据集。\n\n\u003Cbr\u002F>\n\n## 模型库\n借助 UER，我们预训练了多种不同特性的模型（例如基于不同语料库、编码器和目标的模型）。关于这些预训练模型的详细介绍及其下载链接，请参阅 :arrow_right: [__模型库__](https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fwiki\u002FModelzoo) :arrow_left: 。所有预训练模型均可被 UER 直接加载。\n\n\u003Cbr\u002F>\n\n## 使用说明\nUER-py 的目录结构如下：\n```\nUER-py\u002F\n    |--uer\u002F\n    |    |--embeddings\u002F # 包含嵌入组件的模块\n    |    |--encoders\u002F # 包含编码器组件的模块，如 RNN、CNN、Transformer\n    |    |--decoders\u002F # 包含解码器组件的模块\n    |    |--targets\u002F # 包含目标组件的模块，如语言模型、掩码语言模型\n    |    |--layers\u002F # 包含常用的神经网络层\n    |    |--models\u002F # 包含 model.py，用于组合不同组件的模块\n    |    |--utils\u002F # 包含常用的工具函数\n    |    |--model_builder.py\n    |    |--model_loader.py\n    |    |--model_saver.py\n    |    |--opts.py\n    |    |--trainer.py\n    |\n    |--corpora\u002F # 包含预训练数据\n    |--datasets\u002F # 包含下游任务数据集\n    |--models\u002F # 包含预训练模型、词汇表和配置文件\n    |--scripts\u002F # 包含用于预训练模型的实用脚本\n    |--finetune\u002F # 包含下游任务微调脚本\n    |--inference\u002F # 包含下游任务推理脚本\n    |\n    |--preprocess.py\n    |--pretrain.py\n    |--README.md\n    |--README_ZH.md\n    |--requirements.txt\n    |--LICENSE\n\n```\n\n代码按照组件划分（例如嵌入、编码器等），用户可以轻松使用并进行扩展。\n\n关于 UER 的全面使用示例，请参阅 :arrow_right: [__使用说明__](https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fwiki\u002FInstructions) :arrow_left: ，这些示例可以帮助用户快速实现 BERT、GPT-2、ELMo、T5 等预训练模型，并在多种下游任务上对预训练模型进行微调。\n\n\u003Cbr\u002F>\n\n## 竞赛解决方案\nUER-py 已被用于多项 NLP 竞赛的获奖方案中。在本节中，我们提供了一些使用 UER-py 在 CLUE 等 NLP 竞赛中取得 SOTA 结果的案例。更多详细信息请参阅 :arrow_right: [__竞赛解决方案__](https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fwiki\u002FCompetition-solutions) :arrow_left: 。\n\n\u003Cbr\u002F>\n\n## 引用\n#### 如果您在学术研究中使用了 UER-py 中的工作（例如预训练模型），请引用发表于 EMNLP 2019 的 __系统论文__：\n```\n@article{zhao2019uer,\n  title={UER: An Open-Source Toolkit for Pre-training Models},\n  author={Zhao, Zhe and Chen, Hui and Zhang, Jinbin and Zhao, Xin and Liu, Tao and Lu, Wei and Chen, Xi and Deng, Haotang and Ju, Qi and Du, Xiaoyong},\n  journal={EMNLP-IJCNLP 2019},\n  pages={241},\n  year={2019}\n}\n```\n\n\u003Cbr\u002F>\n\n## 联系方式\n有关本项目的沟通，请联系赵哲 (helloworld@alu.ruc.edu.cn; nlpzhezhao@tencent.com) 或李宇东 (liyudong123@hotmail.com) 或侯成 (chenghoubupt@bupt.edu.cn) 或史文航 (wenhangshi@ruc.edu.cn)。\n\n本工作由企业导师 __鞠琪__、__杨雪峰__、__邓浩堂__ 和学校导师 __刘涛__、__杜晓勇__ 指导完成。\n\n同时，我们也得到了刘伟杰、张鲁胜、崔建伟、李夏宇、毛伟权、赵欣、陈辉、张金彬、王志若、周鹏、刘海啸以及吴伟健等人的大力支持。","# UER-py 快速上手指南\n\nUER-py (Universal Encoder Representations) 是一个用于通用领域语料预训练及下游任务微调的 NLP 工具包。它支持模块化模型构建，兼容 BERT、GPT-2、ELMo、T5 等主流架构，并提供丰富的预训练模型库。\n\n## 环境准备\n\n### 系统要求\n*   **Python**: >= 3.6\n*   **PyTorch**: >= 1.1\n*   **操作系统**: Linux \u002F macOS \u002F Windows\n\n### 前置依赖\n安装基础依赖包：\n```bash\npip install torch>=1.1 six>=1.12.0 argparse packaging regex\n```\n\n**可选依赖（按需安装）：**\n*   **TensorFlow**: 用于转换 TensorFlow 格式的预训练模型。\n*   **SentencePiece**: 用于使用 SentencePiece 模型进行分词。\n    ```bash\n    # 建议从源码编译或使用 pip 安装\n    pip install sentencepiece\n    ```\n*   **jieba**: 用于全词掩码（Whole Word Masking）预训练时的中文分词。\n    ```bash\n    pip install jieba\n    ```\n*   **pytorch-crf**: 用于序列标注任务中的 CRF 层。\n    ```bash\n    pip install pytorch-crf\n    ```\n*   **LightGBM & BayesianOptimization**: 用于开发堆叠模型。\n\n## 安装步骤\n\n1.  **克隆项目代码**\n    ```bash\n    git clone https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py.git\n    cd UER-py\n    ```\n\n2.  **验证环境**\n    确保 `python3` 可正常运行，且上述依赖已正确安装。项目无需额外的 `setup.py` 安装步骤，直接在根目录运行脚本即可。\n\n## 基本使用\n\n以下示例演示如何使用 UER-py 完成 **数据预处理 -> 模型预训练 -> 下游任务微调 -> 推理** 的全流程。本例基于书评情感分类任务，使用 BERT 架构。\n\n### 1. 数据预处理\n将原始文本语料转换为模型所需的 `.pt` 格式。\n*假设已有语料文件 `corpora\u002Fbook_review_bert.txt` 和词表 `models\u002Fgoogle_zh_vocab.txt`。*\n\n```bash\npython3 preprocess.py --corpus_path corpora\u002Fbook_review_bert.txt --vocab_path models\u002Fgoogle_zh_vocab.txt \\\n                      --dataset_path dataset.pt --processes_num 8 --data_processor bert\n```\n> **提示**: `--processes_num` 指定并行进程数，可显著加速处理过程。\n\n### 2. 模型预训练 (或继续预训练)\n加载现有的中文 BERT 模型并在书评语料上继续预训练。\n*需先下载 Google 中文 BERT 模型 (`google_zh_model.bin`) 并放入 `models\u002F` 目录。*\n\n```bash\npython3 pretrain.py --dataset_path dataset.pt --vocab_path models\u002Fgoogle_zh_vocab.txt \\\n                    --pretrained_model_path models\u002Fgoogle_zh_model.bin \\\n                    --config_path models\u002Fbert\u002Fbase_config.json \\\n                    --output_model_path models\u002Fbook_review_model.bin \\\n                    --world_size 8 --gpu_ranks 0 1 2 3 4 5 6 7 \\\n                    --total_steps 5000 --save_checkpoint_steps 1000 --batch_size 32\n```\n> **注意**: \n> *   `--world_size` 为 GPU 数量，实际预训练 batch size = `batch_size` × `world_size`。\n> *   生成的模型文件名会附带步数后缀（如 `book_review_model.bin-5000`），使用时可重命名去除后缀。\n\n```bash\nmv models\u002Fbook_review_model.bin-5000 models\u002Fbook_review_model.bin\n```\n\n### 3. 下游任务微调\n使用预训练好的模型在标注数据集上进行情感分类微调。\n*数据格式要求：第一行为表头，列之间用 `\\t` 分隔（label, text_a）。*\n\n```bash\npython3 finetune\u002Frun_classifier.py --pretrained_model_path models\u002Fbook_review_model.bin \\\n                                   --vocab_path models\u002Fgoogle_zh_vocab.txt \\\n                                   --config_path models\u002Fbert\u002Fbase_config.json \\\n                                   --train_path datasets\u002Fbook_review\u002Ftrain.tsv \\\n                                   --dev_path datasets\u002Fbook_review\u002Fdev.tsv \\\n                                   --test_path datasets\u002Fbook_review\u002Ftest.tsv \\\n                                   --epochs_num 3 --batch_size 32\n```\n微调后的模型默认保存为 `models\u002Ffinetuned_model.bin`。\n\n### 4. 模型推理\n使用微调后的模型对无标签数据进行预测。\n\n```bash\npython3 inference\u002Frun_classifier_infer.py --load_model_path models\u002Ffinetuned_model.bin \\\n                                          --vocab_path models\u002Fgoogle_zh_vocab.txt \\\n                                          --config_path models\u002Fbert\u002Fbase_config.json \\\n                                          --test_path datasets\u002Fbook_review\u002Ftest_nolabel.tsv \\\n                                          --prediction_path datasets\u002Fbook_review\u002Fprediction.tsv \\\n                                          --labels_num 2\n```\n> **参数说明**:\n> *   `--test_path`: 待预测文件路径（需包含 `text_a` 列）。\n> *   `--prediction_path`: 预测结果输出路径。\n> *   `--labels_num`: 明确指定分类类别数量（本例为 2 类）。\n\n---\n*更多高级用法、模型配置详解及完整案例，请参考项目官方 Wiki。*","某金融科技公司的算法团队需要基于中文财经新闻构建一个情感分析模型，以辅助量化交易决策。\n\n### 没有 UER-py 时\n- **重复造轮子成本高**：团队需从零编写 BERT 或 GPT 的预训练代码，处理复杂的掩码机制和注意力逻辑，耗时数周且容易引入 Bug。\n- **模型复现困难**：难以确保自研代码与官方论文实现的性能一致，导致基线模型效果不稳定，无法准确评估改进点。\n- **架构扩展僵化**：若想尝试混合编码器或自定义目标函数，必须深度修改底层源码，耦合度高，实验迭代周期极长。\n- **资源适配繁琐**：在单机多卡或分布式集群上切换训练模式时，需手动重写数据并行逻辑，运维负担重。\n\n### 使用 UER-py 后\n- **开箱即用高效启动**：直接调用 UER-py 内置的模块化组件（如 Embedding、Encoder），几行配置即可复现 SOTA 预训练模型，将开发周期从数周缩短至几天。\n- **性能基准可靠**：依托其经过验证的可复现性，团队快速建立了与原始论文一致的强力基线，确保后续优化方向准确无误。\n- **灵活定制架构**：利用清晰的模块接口，研究人员像搭积木一样自由组合不同组件，轻松实现自定义预训练任务，大幅加速算法创新。\n- **训练模式无缝切换**：通过简单参数调整，即可在 CPU 调试、单 GPU 验证及多卡分布式训练之间平滑迁移，显著提升算力利用率。\n\nUER-py 通过高度模块化的设计和可靠的预训练模型库，让团队从繁琐的基础设施构建中解放出来，专注于核心算法的创新与业务价值落地。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdbiir_UER-py_1179b95c.jpg","dbiir","DBIIR @ RUC","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fdbiir_bd824eb6.png","Database & Intelligent Information Retrieval Lab. @ Renmin Univ. of China",null,"http:\u002F\u002Fiir.ruc.edu.cn","https:\u002F\u002Fgithub.com\u002Fdbiir",[80],{"name":81,"color":82,"percentage":83},"Python","#3572A5",100,3105,521,"2026-04-02T08:38:46","Apache-2.0","未说明","非必需。支持 CPU、单 GPU 及分布式训练模式。具体显卡型号、显存大小及 CUDA 版本未在文档中明确指定，但示例中提到可使用 8 卡机器进行训练。",{"notes":91,"python":92,"dependencies":93},"该工具支持模块化构建预训练模型（如 BERT, GPT-2, ELMo, T5）。若需进行大规模多模态训练或参数量超过 10 亿的模型，建议改用其重构版本 TencentPretrain。预处理阶段支持多进程加速。部分功能（如 TensorFlow 模型转换、SentencePiece 分词、全词掩码、CRF 序列标注）需要安装额外的可选依赖库。",">=3.6",[94,95,96,97,98,99,100,101,102,103,104],"torch>=1.1","six>=1.12.0","argparse","packaging","regex","tensorflow (可选，用于模型转换)","sentencepiece (可选，用于分词)","lightgbm (可选，用于堆叠模型)","bayesianoptimization (可选，用于堆叠模型)","jieba (可选，用于全词掩码预训练)","pytorch-crf (可选，用于序列标注任务)",[35,14,15,106,107,13],"音频","视频",[109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128],"bert","pre-training","fine-tuning","gpt","chinese","natural-language-processing","pytorch","elmo","classification","ner","t5","unilm","roberta","albert","clue","gpt-2","model-zoo","bart","pegasus","xlm-roberta","2026-03-27T02:49:30.150509","2026-04-08T19:21:05.618841",[132,137,142,147,152,157,162,167],{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},24919,"如何使用 UER 进行“句子对语义相似度”或“文本对分类”任务（如判断两句话意思是否相同）？","UER 支持多种方案：\n1. **监督微调（推荐）**：使用 `run_classifier.py` 脚本。数据集文件需包含 3 列，用制表符分隔：`label`, `text_a`, `text_b`。可参考 LCQMC 数据集的示例。\n2. **问答匹配**：如果是一个 text_a 对应多个 text_b 的场景，可使用 `run_dbqa.py`。\n3. **无监督方法**：使用 `scripts\u002Fextract_features.py` 抽取句子特征向量，然后计算余弦相似度。维护者提到后续会加入 BERT-whitening 方法以提升效果。","https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fissues\u002F97",{"id":138,"question_zh":139,"answer_zh":140,"source_url":141},24920,"预训练（pretrain）时程序卡在'Worker is training...'不动，可能是什么原因？","这通常是输入语料文件（txt）格式不正确导致的。请检查文件格式是否符合要求，可以参考项目自带的示例文件 `corpora\u002FCLUECorpusSmall_5000_lines_bert.txt` 来确认正确的格式标准。","https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fissues\u002F196",{"id":143,"question_zh":144,"answer_zh":145,"source_url":146},24921,"微调 Pegasus 模型时报错，或者提示字典\u002F分词符不匹配，如何解决？","这是因为使用了错误的词典文件。微调 Pegasus 模型时，必须使用对应的专用词典，例如 `models\u002Fgoogle_zh_vocab.txt`。请确保在配置中指定了正确的词典路径，并注意处理特殊的分词符号（如 @@）。","https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fissues\u002F207",{"id":148,"question_zh":149,"answer_zh":150,"source_url":151},24922,"运行 HuggingFace 到 UER 的模型转换脚本（convert_bert_from_huggingface_to_uer.py）时报 KeyError: 'bert.pooler.dense.weight' 或其他键缺失错误，怎么办？","出现此类 KeyError 通常是因为转换脚本默认针对特定任务（如分类），而源模型（特别是仅预训练的模型）中不包含对应的权重（如 pooler 层）。\n解决方案：在运行转换脚本时，添加参数 `--target mlm`，明确指定转换目标为掩码语言模型（MLM），这样脚本就不会尝试加载分类相关的权重。","https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fissues\u002F140",{"id":153,"question_zh":154,"answer_zh":155,"source_url":156},24923,"多卡训练时显存负载不均衡，且第一张卡显存占用随卡数增加而变大，是参数设置问题吗？","这可能是由于使用的 UER 版本较旧或分布式训练参数配置问题。此外，有用户反馈该问题可能与特定的 PyTorch 版本有关（维护者测试环境为 1.8）。建议尝试更新到最新版的 UER，或检查分布式启动命令是否正确。如果问题依旧，可能需要排查是否为特定版本的 Bug。","https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fissues\u002F246",{"id":158,"question_zh":159,"answer_zh":160,"source_url":161},24924,"运行 T5 模型转换脚本（convert_t5_from_uer_to_huggingface.py）时报 KeyError: 'decoder.self_pos_emb...'，如何解决？","这是因为代码更新后，模型权重的命名规则发生了变化，导致旧版训练的模型权重名称与新版转换脚本不匹配。\n解决方法：手动修改转换脚本，在涉及 decoder 的键名前加上 `target.` 前缀（例如将 `decoder.xxx` 改为 `target.decoder.xxx`），以对齐新的命名规范。","https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fissues\u002F339",{"id":163,"question_zh":164,"answer_zh":165,"source_url":166},24925,"进行 K 折交叉验证（run_classifier_cv.py）微调时，每跑一个 fold 显存就增加，最终导致 CUDA Out of Memory，怎么解决？","这是一个已知的内存泄漏问题，可能与 PyTorch 版本有关（维护者在 1.8 版本下测试正常）。\n临时解决方案：在每个 fold 运行结束后，尝试手动清理缓存或重启进程。\n长期方案：建议检查 PyTorch 版本，或向社区提交 Pull Request 修复代码中的显存释放逻辑。","https:\u002F\u002Fgithub.com\u002Fdbiir\u002FUER-py\u002Fissues\u002F167",{"id":168,"question_zh":169,"answer_zh":170,"source_url":156},24926,"预训练时报错提示找不到 bpe tokenizer 或 '--merges_path' 参数不存在，该如何处理？","旧版本的 UER 可能不支持 BPE 分词相关参数。请升级到最新版本的 UER，新版本已经提供了对 BPE 的支持以及 `--merges_path` 参数。预训练命令的具体用法请参考官方 Wiki 中的 'Pretraining-model-examples' 页面。",[]]