[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-thunlp--ERNIE":3,"tool-thunlp--ERNIE":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 真正成长为懂上",151314,2,"2026-04-11T23:32:58",[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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108322,"2026-04-10T11:39:34",[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},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[52,13,15,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":32,"last_commit_at":59,"category_tags":60,"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":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":67,"readme_en":68,"readme_zh":69,"quickstart_zh":70,"use_case_zh":71,"hero_image_url":72,"owner_login":73,"owner_name":74,"owner_avatar_url":75,"owner_bio":76,"owner_company":77,"owner_location":77,"owner_email":78,"owner_twitter":77,"owner_website":79,"owner_url":80,"languages":81,"stars":86,"forks":87,"last_commit_at":88,"license":89,"difficulty_score":90,"env_os":91,"env_gpu":92,"env_ram":93,"env_deps":94,"category_tags":103,"github_topics":77,"view_count":32,"oss_zip_url":77,"oss_zip_packed_at":77,"status":17,"created_at":104,"updated_at":105,"faqs":106,"releases":146},6835,"thunlp\u002FERNIE","ERNIE","Source code and dataset for ACL 2019 paper \"ERNIE: Enhanced Language Representation with Informative Entities\"","ERNIE 是一款开源的自然语言处理工具，旨在通过将知识图谱中的实体信息融入预训练语言模型，显著提升机器对文本的理解能力。它主要解决了传统模型（如 BERT）在处理依赖背景知识的任务时表现不足的问题，让 AI 不仅能读懂字面意思，还能理解词语背后蕴含的丰富实体关系。\n\n这款工具特别适合人工智能研究人员和开发者使用，尤其是那些正在从事实体类型识别、关系分类等知识驱动型任务的技术团队。ERNIE 的核心亮点在于其独特的“增强表示”机制：它利用维基百科等大规模语料构建知识嵌入，在预训练阶段就让模型学习到实体间的深层关联。实验数据显示，在 FIGER、FewRel 等多个权威数据集上，ERNIE 的准确率和 F1 分数均优于原生 BERT 模型。\n\n项目提供了完整的源代码、数据集以及详细的微调指令，支持基于 PyTorch 环境进行复现和二次开发。虽然部署过程涉及数据预处理和模型训练等技术环节，需要一定的编程基础，但其开放的架构为探索知识与语言融合的研究方向提供了宝贵资源。无论是希望优化现有 NLP 系统的工程师，还是致力于前沿算法探索的学者，ERNIE 都是一个值得尝试的高效 toolkit","ERNIE 是一款开源的自然语言处理工具，旨在通过将知识图谱中的实体信息融入预训练语言模型，显著提升机器对文本的理解能力。它主要解决了传统模型（如 BERT）在处理依赖背景知识的任务时表现不足的问题，让 AI 不仅能读懂字面意思，还能理解词语背后蕴含的丰富实体关系。\n\n这款工具特别适合人工智能研究人员和开发者使用，尤其是那些正在从事实体类型识别、关系分类等知识驱动型任务的技术团队。ERNIE 的核心亮点在于其独特的“增强表示”机制：它利用维基百科等大规模语料构建知识嵌入，在预训练阶段就让模型学习到实体间的深层关联。实验数据显示，在 FIGER、FewRel 等多个权威数据集上，ERNIE 的准确率和 F1 分数均优于原生 BERT 模型。\n\n项目提供了完整的源代码、数据集以及详细的微调指令，支持基于 PyTorch 环境进行复现和二次开发。虽然部署过程涉及数据预处理和模型训练等技术环节，需要一定的编程基础，但其开放的架构为探索知识与语言融合的研究方向提供了宝贵资源。无论是希望优化现有 NLP 系统的工程师，还是致力于前沿算法探索的学者，ERNIE 都是一个值得尝试的高效 toolkit。","# ERNIE (sub-project of OpenSKL)\n\nERNIE is a sub-project of OpenSKL, providing an open-sourced toolkit (**E**nhanced language **R**epresentatio**N** with **I**nformative **E**ntities) for augmenting pre-trained language models with knowledge graph representations.\n\n## Overview\n\nERNIE contains the source code and dataset for \"[ERNIE: Enhanced Language Representation with Informative Entities](https:\u002F\u002Farxiv.org\u002Fabs\u002F1905.07129)\", and is an effective and efficient toolkit for augmenting pre-trained language models with knowledge graph representations.\n\n## Models\nWe provide our knowledge-enhanced pre-trained language model ERNIE in this toolkit. We also provide the detailed commands to fine-tune ERNIE for different downstream tasks.\n\n## Evaluation\n\nWe validate the effectiveness of ERNIE on entity typing and relation classification tasks through fine-tuning.\n\n### Settings\nWe use the following datasets: FIGER and OpenEntity for entity typing, FewRel and TACRED for relation classification. We will fine-tune the models (BERT and ERNIE) first, and then evaluate their accuracies and F1 scores.\n\n### Results\n\nHere we report the main results on the above datasets. From this table, we observe that ERNIE effectively improves the performance of BERT on these knowledge-driven tasks.\n\n|       | FIGER | OpenEntity | FewRel | TACRED |\n|-------|-------|------------|--------|--------|\n|       | Acc.  | F1         | F1     | F1     |\n| BERT  | 52.04 | 73.56      | 84.89  | 66.00  |\n| ERNIE | 57.19 | 75.56      | 88.32  | 67.97  |\n\n\n## Usage\n\n### Requirements:\n\n* Pytorch>=0.4.1\n* Python3\n* tqdm\n* boto3\n* requests\n* apex (If you want to use fp16, you should make sure the commit is `79ad5a88e91434312b43b4a89d66226be5f2cc98`.)\n\n### Prepare Pre-train Data\n\nRun the following command to create training instances.\n\n```shell\n  # Download Wikidump\n  wget https:\u002F\u002Fdumps.wikimedia.org\u002Fenwiki\u002Flatest\u002Fenwiki-latest-pages-articles.xml.bz2\n  # Download anchor2id\n  wget -c https:\u002F\u002Fcloud.tsinghua.edu.cn\u002Ff\u002F6318808dded94818b3a1\u002F?dl=1 -O anchor2id.txt\n  # WikiExtractor\n  python3 pretrain_data\u002FWikiExtractor.py enwiki-latest-pages-articles.xml.bz2 -o pretrain_data\u002Foutput -l --min_text_length 100 --filter_disambig_pages -it abbr,b,big --processes 4\n  # Modify anchors with 4 processes\n  python3 pretrain_data\u002Fextract.py 4\n  # Preprocess with 4 processes\n  python3 pretrain_data\u002Fcreate_ids.py 4\n  # create instances\n  python3 pretrain_data\u002Fcreate_insts.py 4\n  # merge\n  python3 code\u002Fmerge.py\n```\n\nIf you want to get anchor2id by yourself, run the following code(this will take about half a day) after `python3 pretrain_data\u002Fextract.py 4`\n```shell\n  # extract anchors\n  python3 pretrain_data\u002Futils.py get_anchors\n  # query Mediawiki api using anchor link to get wikibase item id. For more details, see https:\u002F\u002Fen.wikipedia.org\u002Fw\u002Fapi.php?action=help.\n  python3 pretrain_data\u002Fcreate_anchors.py 256 \n  # aggregate anchors \n  python3 pretrain_data\u002Futils.py agg_anchors\n```\n\nRun the following command to pretrain:\n\n```\n  python3 code\u002Frun_pretrain.py --do_train --data_dir pretrain_data\u002Fmerge --bert_model bert_base --output_dir pretrain_out\u002F --task_name pretrain --fp16 --max_seq_length 256\n```\n\nWe use 8 NVIDIA-2080Ti to pre-train our model and there are 32 instances in each GPU. It takes nearly one day to finish the training (1 epoch is enough).\n\n### Pre-trained Model\n\nDownload pre-trained knowledge embedding from [Google Drive](https:\u002F\u002Fdrive.google.com\u002Fopen?id=14VNvGMtYWxuqT-PWDa8sD0e7hO486i8Y)\u002F[Tsinghua Cloud](https:\u002F\u002Fcloud.tsinghua.edu.cn\u002Ff\u002F229e8cccedc2419f987e\u002F) and extract it.\n\n```shell\ntar -xvzf kg_embed.tar.gz\n```\n\nDownload pre-trained ERNIE from [Google Drive](https:\u002F\u002Fdrive.google.com\u002Fopen?id=1DVGADbyEgjjpsUlmQaqN6i043SZvHPu5)\u002F[Tsinghua Cloud](https:\u002F\u002Fcloud.tsinghua.edu.cn\u002Ff\u002Fa763616323f946fd8ff6\u002F) and extract it.\n\n```shell\ntar -xvzf ernie_base.tar.gz\n```\n\nNote that the extraction may be not completed in Windows.\n\n### Fine-tuning\n\nAs most datasets except FewRel don't have entity annotations, we use [TAGME](\u003Chttps:\u002F\u002Ftagme.d4science.org\u002Ftagme\u002F>) to extract the entity mentions in the sentences and link them to their corresponding entitoes in KGs. We provide the annotated datasets [Google Drive](https:\u002F\u002Fdrive.google.com\u002Fopen?id=1HlWw7Q6-dFSm9jNSCh4VaBf1PlGqt9im)\u002F[Tsinghua Cloud](https:\u002F\u002Fcloud.tsinghua.edu.cn\u002Ff\u002F6ec98dbd931b4da9a7f0\u002F).\n\n```shell\ntar -xvzf data.tar.gz\n```\n\nIn the root directory of the project, run the following codes to fine-tune ERNIE on different datasets.\n\n**FewRel:**\n\n```bash\npython3 code\u002Frun_fewrel.py   --do_train   --do_lower_case   --data_dir data\u002Ffewrel\u002F   --ernie_model ernie_base   --max_seq_length 256   --train_batch_size 32   --learning_rate 2e-5   --num_train_epochs 10   --output_dir output_fewrel   --fp16   --loss_scale 128\n# evaluate\npython3 code\u002Feval_fewrel.py   --do_eval   --do_lower_case   --data_dir data\u002Ffewrel\u002F   --ernie_model ernie_base   --max_seq_length 256   --train_batch_size 32   --learning_rate 2e-5   --num_train_epochs 10   --output_dir output_fewrel   --fp16   --loss_scale 128\n```\n\n**TACRED:**\n\n```bash\npython3 code\u002Frun_tacred.py   --do_train   --do_lower_case   --data_dir data\u002Ftacred   --ernie_model ernie_base   --max_seq_length 256   --train_batch_size 32   --learning_rate 2e-5   --num_train_epochs 4.0   --output_dir output_tacred   --fp16   --loss_scale 128 --threshold 0.4\n# evaluate\npython3 code\u002Feval_tacred.py   --do_eval   --do_lower_case   --data_dir data\u002Ftacred   --ernie_model ernie_base   --max_seq_length 256   --train_batch_size 32   --learning_rate 2e-5   --num_train_epochs 4.0   --output_dir output_tacred   --fp16   --loss_scale 128 --threshold 0.4\n```\n\n**FIGER:**\n\n```bash\npython3 code\u002Frun_typing.py    --do_train   --do_lower_case   --data_dir data\u002FFIGER   --ernie_model ernie_base   --max_seq_length 256   --train_batch_size 2048   --learning_rate 2e-5   --num_train_epochs 3.0   --output_dir output_figer  --gradient_accumulation_steps 32 --threshold 0.3 --fp16 --loss_scale 128 --warmup_proportion 0.2\n# evaluate\npython3 code\u002Feval_figer.py    --do_eval   --do_lower_case   --data_dir data\u002FFIGER   --ernie_model ernie_base   --max_seq_length 256   --train_batch_size 2048   --learning_rate 2e-5   --num_train_epochs 3.0   --output_dir output_figer  --gradient_accumulation_steps 32 --threshold 0.3 --fp16 --loss_scale 128 --warmup_proportion 0.2\n```\n\n**OpenEntity:**\n\n```bash\npython3 code\u002Frun_typing.py    --do_train   --do_lower_case   --data_dir data\u002FOpenEntity   --ernie_model ernie_base   --max_seq_length 128   --train_batch_size 16   --learning_rate 2e-5   --num_train_epochs 10.0   --output_dir output_open --threshold 0.3 --fp16 --loss_scale 128\n# evaluate\npython3 code\u002Feval_typing.py   --do_eval   --do_lower_case   --data_dir data\u002FOpenEntity   --ernie_model ernie_base   --max_seq_length 128   --train_batch_size 16   --learning_rate 2e-5   --num_train_epochs 10.0   --output_dir output_open --threshold 0.3 --fp16 --loss_scale 128\n```\n\nSome code is modified from the **pytorch-pretrained-BERT**. You can find the explanation of most parameters in [pytorch-pretrained-BERT](\u003Chttps:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fpytorch-pretrained-BERT>). \n\nAs the annotations given by TAGME have confidence score, we use `--threshlod` to set the lowest confidence score and choose the annotations whose scores are higher than `--threshold`. In this experiment, the value is usually `0.3` or `0.4`.\n\nThe script for the evaluation of relation classification just gives the accuracy score. For the macro\u002Fmicro metrics, you should use `code\u002Fscore.py` which is from [tacred repo](\u003Chttps:\u002F\u002Fgithub.com\u002Fyuhaozhang\u002Ftacred-relation>).\n\n```shell\npython3 code\u002Fscore.py gold_file pred_file\n```\n\nYou can find `gold_file` and `pred_file` on each checkpoint in the output folder (`--output_dir`).\n\n### New Tasks\n\nIf you want to use ERNIE in new tasks, you should follow these steps:\n\n* Use an entity-linking tool like TAGME to extract the entities in the text\n* Look for the Wikidata ID of the extracted entities\n* Take the text and entities sequence as input data\n\nHere is a quick-start example (`code\u002Fexample.py`) using ERNIE for Masked Language Model. We show how to annotate the given sentence with TAGME and build the input data for ERNIE. Note that it will take some time (around 5 mins) to load the model.\n\n```shell\n# If you haven't installed tagme\npip install tagme\n# Run example\npython3 code\u002Fexample.py\n```\n\n## Citation\n\nIf you use the code, please cite this paper:\n\n```\n@inproceedings{zhang2019ernie,\n  title={{ERNIE}: Enhanced Language Representation with Informative Entities},\n  author={Zhang, Zhengyan and Han, Xu and Liu, Zhiyuan and Jiang, Xin and Sun, Maosong and Liu, Qun},\n  booktitle={Proceedings of ACL 2019},\n  year={2019}\n}\n```\n******************\n## About OpenSKL\nOpenSKL project aims to harness the power of both structured knowledge and natural languages via representation learning. All sub-projects of OpenSKL, under the categories of **Algorithm**, **Resource** and **Application**, are as follows.\n\n- **Algorithm**: \n  - [OpenKE](https:\u002F\u002Fwww.github.com\u002Fthunlp\u002FOpenKE)\n    - An effective and efficient toolkit for representing structured knowledge in large-scale knowledge graphs as embeddings, with \u003Ca href=\"https:\u002F\u002Fojs.aaai.org\u002Findex.php\u002FAAAI\u002Farticle\u002Fview\u002F9491\u002F9350\"> TransR\u003C\u002Fa> and  \u003Ca href=\"https:\u002F\u002Faclanthology.org\u002FD15-1082.pdf\">PTransE\u003C\u002Fa> as key features to handle complex relations and relational paths.\n    - This toolkit also includes three repositories:\n       - [KB2E](https:\u002F\u002Fwww.github.com\u002Fthunlp\u002FKB2E)\n       - [TensorFlow-Transx](https:\u002F\u002Fwww.github.com\u002Fthunlp\u002FTensorFlow-Transx)\n       - [Fast-TransX](https:\u002F\u002Fwww.github.com\u002Fthunlp\u002FFast-TransX)\n  - [ERNIE](https:\u002F\u002Fgithub.com\u002Fthunlp\u002FERNIE)\n    - An effective and efficient toolkit for augmenting pre-trained language models with knowledge graph representations.\n  - [OpenNE](https:\u002F\u002Fwww.github.com\u002Fthunlp\u002FOpenNE)\n    - An effective and efficient toolkit for representing nodes in large-scale graphs as embeddings, with [TADW](https:\u002F\u002Fwww.ijcai.org\u002FProceedings\u002F15\u002FPapers\u002F299.pdf) as key features to incorporate text attributes of nodes.\n  - [OpenNRE](https:\u002F\u002Fwww.github.com\u002Fthunlp\u002FOpenNRE)\n    - An effective and efficient toolkit for implementing neural networks for extracting structured knowledge from text, with [ATT](https:\u002F\u002Faclanthology.org\u002FP16-1200.pdf) as key features to consider relation-associated text information.\n    - This toolkit also includes two repositories:\n      - [JointNRE](https:\u002F\u002Fwww.github.com\u002Fthunlp\u002FJointNRE)\n      - [NRE](https:\u002F\u002Fgithub.com\u002Fthunlp\u002FNRE)\n- **Resource**:\n  - The embeddings of large-scale knowledge graphs pre-trained by OpenKE, covering three typical large-scale knowledge graphs: Wikidata, Freebase, and XLORE. The embeddings are free to use under the [MIT license](https:\u002F\u002Fopensource.org\u002Flicense\u002Fmit\u002F), and please click the following link to submit [download requests](http:\u002F\u002F139.129.163.161\u002Fdownload\u002Fwikidata).\n  - OpenKE-Wikidata\n    - Wikidata is a free and collaborative database, collecting structured data to provide support for Wikipedia. The original Wikidata contains 20,982,733 entities, 594 relations and 68,904,773 triplets. In particular, Wikidata-5M is the core subgraph of Wikidata, containing  5,040,986 high-frequency entities from Wikidata with their corresponding 927 relations and 24,267,796 triplets.\n    - [TransE version](http:\u002F\u002F139.129.163.161\u002Fdownload\u002Fwikidata): Knowledge embeddings of Wikidata pre-trained by OpenKE. \n    - [TransR version](http:\u002F\u002F139.129.163.161\u002Fdownload\u002Fwikidata) of Wikidata-5M: Knowledge embeddings of Wikidata-5M pre-trained by OpenKE.\n  - OpenKE-Freebase\n    - Freebase was a large collaborative knowledge base consisting of data composed mainly by its community members. It was an online collection of structured data harvested from many sources. Freebase contains 86,054,151 entities, 14,824 relations and 338,586,276 triplets.\n    - [TransE version](http:\u002F\u002F139.129.163.161\u002Fdownload\u002Fwikidata): Knowledge embeddings of Freebase pre-trained by OpenKE. \n  - OpenKE-XLORE\n    - XLORE is one of the most popular Chinese knowledge graphs developed by THUKEG. XLORE contains 10,572,209 entities, 138,581 relations and 35,954,249 triplets.\n    - [TransE version](http:\u002F\u002F139.129.163.161\u002Fdownload\u002Fwikidata): Knowledge embeddings of XLORE pre-trained by OpenKE.\n- **Application**:   \n    - [Knowledge-Plugin](https:\u002F\u002Fgithub.com\u002FTHUNLP\u002FKnowledge-Plugin)\n      - An effective and efficient toolkit of plug-and-play knowledge injection for pre-trained language models. Knowledge-Plugin is general for all kinds of knowledge graph embeddings mentioned above. In the toolkit, we plug the TransR version of Wikidata-5M into BERT as an example of applications. With the TransR embedding, we enhance the knowledge ability of BERT without fine-tuning the original model, e.g., up to 8% improvement on question answering.\n","# ERNIE（OpenSKL的子项目）\n\nERNIE是OpenSKL的一个子项目，提供了一个开源工具包（**E**nhanced language **R**epresentatio**N** with **I**nformative **E**ntities），用于将知识图谱表示增强到预训练语言模型中。\n\n## 概述\n\nERNIE包含了论文“[ERNIE: 基于信息实体的增强语言表示](https:\u002F\u002Farxiv.org\u002Fabs\u002F1905.07129)”的源代码和数据集，是一个高效且实用的工具包，能够将知识图谱表示有效地融入预训练语言模型中。\n\n## 模型\n\n我们在这个工具包中提供了基于知识增强的预训练语言模型ERNIE。同时，我们也提供了针对不同下游任务微调ERNIE的详细命令。\n\n## 评估\n\n我们通过微调ERNIE，在实体分类和关系分类任务上验证了其有效性。\n\n### 设置\n\n我们使用以下数据集：FIGER和OpenEntity用于实体分类，FewRel和TACRED用于关系分类。我们将首先对BERT和ERNIE模型进行微调，然后评估它们的准确率和F1分数。\n\n### 结果\n\n以下是我们在上述数据集上的主要结果。从表格中可以看出，ERNIE显著提升了BERT在这些知识驱动任务上的性能。\n\n|       | FIGER | OpenEntity | FewRel | TACRED |\n|-------|-------|------------|--------|--------|\n|       | Acc.  | F1         | F1     | F1     |\n| BERT  | 52.04 | 73.56      | 84.89  | 66.00  |\n| ERNIE | 57.19 | 75.56      | 88.32  | 67.97  |\n\n## 使用方法\n\n### 需求：\n\n* Pytorch>=0.4.1\n* Python3\n* tqdm\n* boto3\n* requests\n* apex（如果要使用fp16，需确保commit为`79ad5a88e91434312b43b4a89d66226be5f2cc98`。）\n\n### 准备预训练数据\n\n运行以下命令以创建训练实例。\n\n```shell\n  # 下载维基转储文件\n  wget https:\u002F\u002Fdumps.wikimedia.org\u002Fenwiki\u002Flatest\u002Fenwiki-latest-pages-articles.xml.bz2\n  # 下载anchor2id\n  wget -c https:\u002F\u002Fcloud.tsinghua.edu.cn\u002Ff\u002F6318808dded94818b3a1\u002F?dl=1 -O anchor2id.txt\n  # 使用WikiExtractor提取文本\n  python3 pretrain_data\u002FWikiExtractor.py enwiki-latest-pages-articles.xml.bz2 -o pretrain_data\u002Foutput -l --min_text_length 100 --filter_disambig_pages -it abbr,b,big --processes 4\n  # 使用4个进程处理锚点\n  python3 pretrain_data\u002Fextract.py 4\n  # 使用4个进程进行预处理\n  python3 pretrain_data\u002Fcreate_ids.py 4\n  # 创建训练实例\n  python3 pretrain_data\u002Fcreate_insts.py 4\n  # 合并数据\n  python3 code\u002Fmerge.py\n```\n\n如果你想自己获取anchor2id，可以在`python3 pretrain_data\u002Fextract.py 4`之后运行以下代码（这大约需要半天时间）：\n```shell\n  # 提取锚点\n  python3 pretrain_data\u002Futils.py get_anchors\n  # 使用锚点链接查询MediaWiki API以获取维基数据项目ID。更多详情请参阅https:\u002F\u002Fen.wikipedia.org\u002Fw\u002Fapi.php?action=help。\n  python3 pretrain_data\u002Fcreate_anchors.py 256 \n  # 聚合锚点\n  python3 pretrain_data\u002Futils.py agg_anchors\n```\n\n运行以下命令进行预训练：\n\n```\n  python3 code\u002Frun_pretrain.py --do_train --data_dir pretrain_data\u002Fmerge --bert_model bert_base --output_dir pretrain_out\u002F --task_name pretrain --fp16 --max_seq_length 256\n```\n\n我们使用8块NVIDIA-2080Ti显卡来预训练模型，每张显卡有32个实例。整个训练过程大约需要一天时间（完成1个epoch即可）。\n\n### 预训练模型\n\n从[Google Drive](https:\u002F\u002Fdrive.google.com\u002Fopen?id=14VNvGMtYWxuqT-PWDa8sD0e7hO486i8Y)\u002F[清华大学云](https:\u002F\u002Fcloud.tsinghua.edu.cn\u002Ff\u002F229e8cccedc2419f987e\u002F)下载预训练的知识嵌入，并解压：\n```shell\ntar -xvzf kg_embed.tar.gz\n```\n\n从[Google Drive](https:\u002F\u002Fdrive.google.com\u002Fopen?id=1DVGADbyEgjjpsUlmQaqN6i043SZvHPu5)\u002F[清华大学云](https:\u002F\u002Fcloud.tsinghua.edu.cn\u002Ff\u002Fa763616323f946fd8ff6\u002F)下载预训练的ERNIE模型，并解压：\n```shell\ntar -xvzf ernie_base.tar.gz\n```\n\n请注意，在Windows系统下解压可能会失败。\n\n### 微调\n\n由于除了FewRel之外的大多数数据集都没有实体标注，我们使用[TAGME](\u003Chttps:\u002F\u002Ftagme.d4science.org\u002Ftagme\u002F>)来提取句子中的实体提及，并将其链接到知识图谱中的相应实体。我们提供了标注好的数据集，可以从[Google Drive](https:\u002F\u002Fdrive.google.com\u002Fopen?id=1HlWw7Q6-dFSm9jNSCh4VaBf1PlGqt9im)\u002F[清华大学云](https:\u002F\u002Fcloud.tsinghua.edu.cn\u002Ff\u002F6ec98dbd931b4da9a7f0\u002F)下载。\n```shell\ntar -xvzf data.tar.gz\n```\n\n在项目的根目录下，运行以下代码以在不同数据集上微调ERNIE。\n\n**FewRel：**\n\n```bash\npython3 code\u002Frun_fewrel.py   --do_train   --do_lower_case   --data_dir data\u002Ffewrel\u002F   --ernie_model ernie_base   --max_seq_length 256   --train_batch_size 32   --learning_rate 2e-5   --num_train_epochs 10   --output_dir output_fewrel   --fp16   --loss_scale 128\n# 评估\npython3 code\u002Feval_fewrel.py   --do_eval   --do_lower_case   --data_dir data\u002Ffewrel\u002F   --ernie_model ernie_base   --max_seq_length 256   --train_batch_size 32   --learning_rate 2e-5   --num_train_epochs 10   --output_dir output_fewrel   --fp16   --loss_scale 128\n```\n\n**TACRED：**\n\n```bash\npython3 code\u002Frun_tacred.py   --do_train   --do_lower_case   --data_dir data\u002Ftacred   --ernie_model ernie_base   --max_seq_length 256   --train_batch_size 32   --learning_rate 2e-5   --num_train_epochs 4.0   --output_dir output_tacred   --fp16   --loss_scale 128 --threshold 0.4\n# 评估\npython3 code\u002Feval_tacred.py   --do_eval   --do_lower_case   --data_dir data\u002Ftacred   --ernie_model ernie_base   --max_seq_length 256   --train_batch_size 32   --learning_rate 2e-5   --num_train_epochs 4.0   --output_dir output_tacred   --fp16   --loss_scale 128 --threshold 0.4\n```\n\n**FIGER：**\n\n```bash\npython3 code\u002Frun_typing.py    --do_train   --do_lower_case   --data_dir data\u002FFIGER   --ernie_model ernie_base   --max_seq_length 256   --train_batch_size 2048   --learning_rate 2e-5   --num_train_epochs 3.0   --output_dir output_figer  --gradient_accumulation_steps 32 --threshold 0.3 --fp16 --loss_scale 128 --warmup_proportion 0.2\n# 评估\npython3 code\u002Feval_figer.py    --do_eval   --do_lower_case   --data_dir data\u002FFIGER   --ernie_model ernie_base   --max_seq_length 256   --train_batch_size 2048   --learning_rate 2e-5   --num_train_epochs 3.0   --output_dir output_figer  --gradient_accumulation_steps 32 --threshold 0.3 --fp16 --loss_scale 128 --warmup_proportion 0.2\n```\n\n**OpenEntity：**\n\n```bash\npython3 code\u002Frun_typing.py    --do_train   --do_lower_case   --data_dir data\u002FOpenEntity   --ernie_model ernie_base   --max_seq_length 128   --train_batch_size 16   --learning_rate 2e-5   --num_train_epochs 10.0   --output_dir output_open --threshold 0.3 --fp16 --loss_scale 128\n\n# 评估\npython3 code\u002Feval_typing.py   --do_eval   --do_lower_case   --data_dir data\u002FOpenEntity   --ernie_model ernie_base   --max_seq_length 128   --train_batch_size 16   --learning_rate 2e-5   --num_train_epochs 10.0   --output_dir output_open --threshold 0.3 --fp16 --loss_scale 128\n```\n\n部分代码改编自 **pytorch-pretrained-BERT**。大多数参数的解释可以在 [pytorch-pretrained-BERT](\u003Chttps:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fpytorch-pretrained-BERT>) 中找到。\n\n由于 TAGME 提供的标注带有置信度分数，我们使用 `--threshlod` 来设置最低置信度阈值，只选择置信度高于该阈值的标注。在本实验中，该值通常设为 `0.3` 或 `0.4`。\n\n用于关系分类评估的脚本仅输出准确率。若需计算宏平均和微平均指标，应使用来自 [tacred repo](\u003Chttps:\u002F\u002Fgithub.com\u002Fyuhaozhang\u002Ftacred-relation>) 的 `code\u002Fscore.py` 脚本。\n\n```shell\npython3 code\u002Fscore.py gold_file pred_file\n```\n\n`gold_file` 和 `pred_file` 可以在输出文件夹（`--output_dir`）中的每个检查点下找到。\n\n### 新任务\n\n若想在新任务中使用 ERNIE，应遵循以下步骤：\n\n* 使用如 TAGME 这样的实体链接工具提取文本中的实体。\n* 查找提取出的实体对应的 Wikidata ID。\n* 将文本和实体序列作为输入数据。\n\n以下是一个快速入门示例（`code\u002Fexample.py`），演示如何使用 ERNIE 进行掩码语言模型任务。我们展示了如何使用 TAGME 对给定句子进行标注，并构建 ERNIE 的输入数据。请注意，加载模型需要一些时间（约 5 分钟）。\n\n```shell\n# 如果尚未安装 tagme\npip install tagme\n# 运行示例\npython3 code\u002Fexample.py\n```\n\n## 引用\n如果您使用了这些代码，请引用以下论文：\n\n```\n@inproceedings{zhang2019ernie,\n  title={{ERNIE}: Enhanced Language Representation with Informative Entities},\n  author={Zhang, Zhengyan and Han, Xu and Liu, Zhiyuan and Jiang, Xin and Sun, Maosong and Liu, Qun},\n  booktitle={Proceedings of ACL 2019},\n  year={2019}\n}\n```\n******************\n## 关于 OpenSKL\nOpenSKL 项目旨在通过表示学习，同时利用结构化知识和自然语言的力量。OpenSKL 的所有子项目分为 **算法**、**资源** 和 **应用** 三大类，具体如下。\n\n- **算法**：\n  - [OpenKE](https:\u002F\u002Fwww.github.com\u002Fthunlp\u002FOpenKE)\n    - 一个高效且实用的工具包，用于将大规模知识图谱中的结构化知识表示为嵌入向量，其核心功能包括 \u003Ca href=\"https:\u002F\u002Fojs.aaai.org\u002Findex.php\u002FAAAI\u002Farticle\u002Fview\u002F9491\u002F9350\"> TransR\u003C\u002Fa> 和  \u003Ca href=\"https:\u002F\u002Faclanthology.org\u002FD15-1082.pdf\">PTransE\u003C\u002Fa>,能够有效处理复杂的关系和关系路径。\n    - 该工具包还包括三个仓库：\n       - [KB2E](https:\u002F\u002Fwww.github.com\u002Fthunlp\u002FKB2E)\n       - [TensorFlow-Transx](https:\u002F\u002Fwww.github.com\u002Fthunlp\u002FTensorFlow-Transx)\n       - [Fast-TransX](https:\u002F\u002Fwww.github.com\u002Fthunlp\u002FFast-TransX)\n  - [ERNIE](https:\u002F\u002Fgithub.com\u002Fthunlp\u002FERNIE)\n    - 一个高效且实用的工具包，用于将知识图谱表示融入预训练的语言模型中。\n  - [OpenNE](https:\u002F\u002Fwww.github.com\u002Fthunlp\u002FOpenNE)\n    - 一个高效且实用的工具包，用于将大规模图中的节点表示为嵌入向量，其核心功能是 [TADW](https:\u002F\u002Fwww.ijcai.org\u002FProceedings\u002F15\u002FPapers\u002F299.pdf)，能够结合节点的文本属性。\n  - [OpenNRE](https:\u002F\u002Fwww.github.com\u002Fthunlp\u002FOpenNRE)\n    - 一个高效且实用的工具包，用于实现从文本中提取结构化知识的神经网络模型，其核心功能是 [ATT](https:\u002F\u002Faclanthology.org\u002FP16-1200.pdf)，能够充分考虑与关系相关的信息。\n    - 该工具包还包括两个仓库：\n      - [JointNRE](https:\u002F\u002Fwww.github.com\u002Fthunlp\u002FJointNRE)\n      - [NRE](https:\u002F\u002Fgithub.com\u002Fthunlp\u002FNRE)\n- **资源**：\n  - OpenKE 预训练的大规模知识图谱嵌入，涵盖三种典型的大型知识图谱：Wikidata、Freebase 和 XLORE。这些嵌入可在 [MIT 许可证](https:\u002F\u002Fopensource.org\u002Flicense\u002Fmit\u002F) 下免费使用，您可以通过以下链接提交 [下载请求](http:\u002F\u002F139.129.163.161\u002Fdownload\u002Fwikidata)。\n  - OpenKE-Wikidata\n    - Wikidata 是一个免费的协作式数据库，收集结构化数据以支持维基百科。原始 Wikidata 包含 20,982,733 个实体、594 种关系和 68,904,773 组三元组。其中，Wikidata-5M 是 Wikidata 的核心子图，包含 5,040,986 个高频实体及其对应的 927 种关系和 24,267,796 组三元组。\n    - [TransE 版本](http:\u002F\u002F139.129.163.161\u002Fdownload\u002Fwikidata)：由 OpenKE 预训练的 Wikidata 知识嵌入。\n    - [TransR 版本](http:\u002F\u002F139.129.163.161\u002Fdownload\u002Fwikidata) 的 Wikidata-5M：由 OpenKE 预训练的 Wikidata-5M 知识嵌入。\n  - OpenKE-Freebase\n    - Freebase 是一个大型协作式知识库，主要由社区成员贡献数据组成。它是一个汇集了多源结构化数据的在线平台。Freebase 包含 86,054,151 个实体、14,824 种关系和 338,586,276 组三元组。\n    - [TransE 版本](http:\u002F\u002F139.129.163.161\u002Fdownload\u002Fwikidata)：由 OpenKE 预训练的 Freebase 知识嵌入。\n  - OpenKE-XLORE\n    - XLORE 是 THUKEG 开发的最受欢迎的中文知识图谱之一。XLORE 包含 10,572,209 个实体、138,581 种关系和 35,954,249 组三元组。\n    - [TransE 版本](http:\u002F\u002F139.129.163.161\u002Fdownload\u002Fwikidata)：由 OpenKE 预训练的 XLORE 知识嵌入。\n- **应用**：   \n    - [Knowledge-Plugin](https:\u002F\u002Fgithub.com\u002FTHUNLP\u002FKnowledge-Plugin)\n      - 一个高效且实用的即插即用知识注入工具包，适用于预训练的语言模型。Knowledge-Plugin 通用性强，可应用于上述各类知识图谱嵌入。在该工具包中，我们以将 Wikidata-5M 的 TransR 嵌入插入 BERT 为例，展示其应用效果。借助 TransR 嵌入，我们无需对原模型进行微调即可增强 BERT 的知识能力，例如在问答任务上提升高达 8%。","# ERNIE 快速上手指南\n\nERNIE 是 OpenSKL 项目的子项目，旨在通过知识图谱表示来增强预训练语言模型。本指南将帮助你快速配置环境、下载模型并运行微调任务。\n\n## 环境准备\n\n在开始之前，请确保你的系统满足以下要求：\n\n*   **操作系统**: Linux (推荐) 或 macOS (Windows 下解压可能存在问题)\n*   **Python**: Python 3\n*   **深度学习框架**: PyTorch >= 0.4.1\n*   **混合精度训练 (可选)**: 若需使用 FP16 加速，需安装 `apex`，并确保 commit 版本为 `79ad5a88e91434312b43b4a89d66226be5f2cc98`。\n\n**依赖安装：**\n```bash\npip install tqdm boto3 requests\n# 如需开启 fp16，请按需安装特定版本的 apex\n```\n\n## 安装与模型下载\n\nERNIE 提供了预训练好的模型权重和知识嵌入，建议直接下载使用，无需从头预训练。国内用户推荐使用**清华云盘**镜像加速下载。\n\n### 1. 下载知识嵌入 (Knowledge Embedding)\n```bash\n# 使用清华云盘下载\nwget https:\u002F\u002Fcloud.tsinghua.edu.cn\u002Ff\u002F229e8cccedc2419f987e\u002F -O kg_embed.tar.gz\ntar -xvzf kg_embed.tar.gz\n```\n\n### 2. 下载预训练 ERNIE 模型\n```bash\n# 使用清华云盘下载\nwget https:\u002F\u002Fcloud.tsinghua.edu.cn\u002Ff\u002Fa763616323f946fd8ff6\u002F -O ernie_base.tar.gz\ntar -xvzf ernie_base.tar.gz\n```\n\n### 3. 下载微调数据集 (含实体标注)\n由于大多数数据集缺乏实体标注，项目提供了基于 TAGME 工具标注好的数据。\n```bash\n# 使用清华云盘下载\nwget https:\u002F\u002Fcloud.tsinghua.edu.cn\u002Ff\u002F6ec98dbd931b4da9a7f0\u002F -O data.tar.gz\ntar -xvzf data.tar.gz\n```\n\n## 基本使用\n\n以下展示如何在 **FewRel** (关系分类) 和 **FIGER** (实体类型分类) 数据集上对 ERNIE 进行微调和评估。请确保在项目根目录下运行以下命令。\n\n> **注意**：示例命令开启了 `--fp16` 混合精度训练以加速，如未安装 apex 请移除该参数。\n\n### 场景一：关系分类 (FewRel)\n\n**训练：**\n```bash\npython3 code\u002Frun_fewrel.py   --do_train   --do_lower_case   --data_dir data\u002Ffewrel\u002F   --ernie_model ernie_base   --max_seq_length 256   --train_batch_size 32   --learning_rate 2e-5   --num_train_epochs 10   --output_dir output_fewrel   --fp16   --loss_scale 128\n```\n\n**评估：**\n```bash\npython3 code\u002Feval_fewrel.py   --do_eval   --do_lower_case   --data_dir data\u002Ffewrel\u002F   --ernie_model ernie_base   --max_seq_length 256   --train_batch_size 32   --learning_rate 2e-5   --num_train_epochs 10   --output_dir output_fewrel   --fp16   --loss_scale 128\n```\n\n### 场景二：实体类型分类 (FIGER)\n\n**训练：**\n```bash\npython3 code\u002Frun_typing.py    --do_train   --do_lower_case   --data_dir data\u002FFIGER   --ernie_model ernie_base   --max_seq_length 256   --train_batch_size 2048   --learning_rate 2e-5   --num_train_epochs 3.0   --output_dir output_figer  --gradient_accumulation_steps 32 --threshold 0.3 --fp16 --loss_scale 128 --warmup_proportion 0.2\n```\n\n**评估：**\n```bash\npython3 code\u002Feval_figer.py    --do_eval   --do_lower_case   --data_dir data\u002FFIGER   --ernie_model ernie_base   --max_seq_length 256   --train_batch_size 2048   --learning_rate 2e-5   --num_train_epochs 3.0   --output_dir output_figer  --gradient_accumulation_steps 32 --threshold 0.3 --fp16 --loss_scale 128 --warmup_proportion 0.2\n```\n\n### 自定义新任务\n\n若要在自己的数据上使用 ERNIE，需遵循以下步骤构建输入：\n1.  使用实体链接工具（如 [TAGME](https:\u002F\u002Ftagme.d4science.org\u002Ftagme\u002F)）提取文本中的实体提及。\n2.  查找这些实体对应的 Wikidata ID。\n3.  将文本序列和实体序列作为模型输入。\n\n你可以参考官方提供的示例脚本 `code\u002Fexample.py` 来了解如何自动标注并构建输入数据：\n\n```bash\n# 安装 tagme (如果尚未安装)\npip install tagme\n\n# 运行示例 (首次加载模型约需 5 分钟)\npython3 code\u002Fexample.py\n```\n\n**参数说明提示**：\n*   `--threshold`: 用于设定实体链接的置信度阈值（通常为 0.3 或 0.4），低于此分数的标注将被过滤。\n*   更多通用参数（如 learning_rate, batch_size 等）可参考 [pytorch-pretrained-BERT](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fpytorch-pretrained-BERT) 文档。","某金融科技公司正在构建智能风控系统，需要从海量新闻和报告中自动识别企业实体并判断其间的担保、投资等复杂关系。\n\n### 没有 ERNIE 时\n- 模型仅依赖纯文本上下文，遇到“苹果”一词时无法区分是指科技公司还是水果，导致实体类型识别错误率高。\n- 在处理“母公司 - 子公司”或“担保人 - 被担保人”等隐含关系时，因缺乏外部知识库支撑，分类准确率难以突破瓶颈。\n- 为了提升效果，团队需耗费数周人工标注大量领域数据，且模型对未登录的新实体泛化能力极差。\n- 面对长尾领域的专业术语，通用预训练模型（如 BERT）表现平平，F1 分数停滞在 66% 左右，无法满足上线标准。\n\n### 使用 ERNIE 后\n- ERNIE 融入知识图谱表示，能利用实体信息消歧，准确将上下文中的“苹果”锁定为企业实体，显著降低误判。\n- 借助内置的知识增强机制，模型在关系分类任务上直接“读懂”实体间潜在逻辑，FewRel 数据集上的 F1 值提升至 88.32%。\n- 减少了对大规模人工标注数据的依赖，通过微调即可让模型具备较强的少样本学习能力，快速适配新业务场景。\n- 在 TACRED 等知识驱动型任务中，性能全面超越基线模型，将关系抽取的 F1 分数从 66.00% 提升至 67.97%，达到生产级精度。\n\nERNIE 通过将知识图谱与语言模型深度融合，解决了传统模型“懂文字不懂常识”的痛点，让机器真正具备了理解实体关系的智慧。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fthunlp_ERNIE_0bcbe111.png","thunlp","THUNLP","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fthunlp_13da7b2e.png","Natural Language Processing Lab at Tsinghua University",null,"thunlp@gmail.com","http:\u002F\u002Fnlp.csai.tsinghua.edu.cn","https:\u002F\u002Fgithub.com\u002Fthunlp",[82],{"name":83,"color":84,"percentage":85},"Python","#3572A5",100,1419,265,"2026-03-31T07:02:42","MIT",4,"Linux, macOS","需要 NVIDIA GPU（官方测试使用 8 张 NVIDIA 2080Ti），支持 FP16 混合精度训练（需安装特定版本的 apex）","未说明",{"notes":95,"python":96,"dependencies":97},"1. Windows 系统下解压预训练模型文件可能无法完成，建议在 Linux\u002FmacOS 环境下运行。\n2. 若使用 FP16 加速，必须安装指定 commit ID 的 apex 库。\n3. 预处理数据步骤繁琐，涉及下载维基百科转储、提取锚点及调用 MediaWiki API，耗时较长（获取 anchor2id 约需半天）。\n4. 官方预训练使用 8 卡环境，单卡显存需求较高；微调时部分任务（如 FIGER）使用了较大的梯度累积步数以适应显存限制。","Python 3",[98,99,100,101,102],"Pytorch>=0.4.1","tqdm","boto3","requests","apex (commit 79ad5a88e91434312b43b4a89d66226be5f2cc98)",[35,14],"2026-03-27T02:49:30.150509","2026-04-12T17:23:41.403921",[107,112,117,122,127,132,137,141],{"id":108,"question_zh":109,"answer_zh":110,"source_url":111},30829,"如何获取 kg_embed.zip 中实体向量对应的实体名称？","entity_map.txt 文件中包含了实验中涉及到的部分实体名称。如果您需要获取所有实体的名称，可以使用 Wikidata 官方数据（网页端格式为 https:\u002F\u002Fwww.wikidata.org\u002Fwiki\u002FQxxx，其中 Qxxx 是实体 ID）进行匹配。","https:\u002F\u002Fgithub.com\u002Fthunlp\u002FERNIE\u002Fissues\u002F11",{"id":113,"question_zh":114,"answer_zh":115,"source_url":116},30830,"train.csv 中实体列的格式 [['Q8029103', 139, 143, 0.5]] 中各个数字代表什么含义？","其中 'Q8029103' 是实体标识符。后面的数字分别代表：开始位置 (begin)、结束位置 (end) 以及置信度分数 (score)。这些值通常由 TagMe 工具返回。具体的数据准备细节可以参考代码目录下的 `code\u002Fexample.py` 文件。","https:\u002F\u002Fgithub.com\u002Fthunlp\u002FERNIE\u002Fissues\u002F23",{"id":118,"question_zh":119,"answer_zh":120,"source_url":121},30831,"在 TACRED 和 OpenEntity 数据集上复现论文结果时，F1 分数偏低怎么办？","请尝试将优化器更改为 AdamW，并使用以下参数运行：\n对于 TACRED:\npython3 code\u002Frun_tacred_new.py --do_train --do_eval --data_dir data\u002Ftacred --model ernie_base --train_batch_size 32 --learning_rate 2e-5 --num_train_epochs 4 --max_seq_length 256 --do_lower_case --output_dir output_tacred_new --loss_scale 128 --threshold 0.4\n\n对于 OpenEntity:\n使用与 TACRED 相同的参数，但将 --train_batch_size 改为 16。\n此外，确保代码和 README.md 已更新到最新版本。","https:\u002F\u002Fgithub.com\u002Fthunlp\u002FERNIE\u002Fissues\u002F52",{"id":123,"question_zh":124,"answer_zh":125,"source_url":126},30832,"预训练 TransE KGembedding 时，是如何从 Wikidata 中采样实体和边的？","实体的采样基于预训练语料库。关于边的采样策略，项目保留了那些头实体和尾实体都出现在预训练语料库中的边（事实三元组）。","https:\u002F\u002Fgithub.com\u002Fthunlp\u002FERNIE\u002Fissues\u002F44",{"id":128,"question_zh":129,"answer_zh":130,"source_url":131},30833,"使用 TagMe 标注大规模语料库（如 Wikipedia）速度太慢，是否有本地版本或加速方法？","对于大多数实体提及无法链接的情况（例如不在开篇段落的超链接），处理策略是直接丢弃这些句子。如果锚点链接的覆盖率较低，通常也会选择丢弃该句子以保证数据质量。","https:\u002F\u002Fgithub.com\u002Fthunlp\u002FERNIE\u002Fissues\u002F31",{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},30834,"执行 pretrain_data\u002Fcreate_ids.py 脚本后生成的 raw 文件夹为空，如何解决？","这通常是因为缺少 NLTK 的数据包。请先在 Python 环境中执行以下命令下载所需资源：\nimport nltk\nnltk.download('punkt')\n\n下载完成后，再重新执行 README 中的指令，程序即可正常运行。","https:\u002F\u002Fgithub.com\u002Fthunlp\u002FERNIE\u002Fissues\u002F91",{"id":138,"question_zh":139,"answer_zh":140,"source_url":111},30835,"entity2id.txt 和 entity_map.txt 中的实体数量不一致是什么原因？","entity2id.txt 包含所有实体的映射（约 500 万行），而 entity_map.txt 仅包含实验中实际涉及到的部分实体（约 34 万行）。如果需要完整列表，需结合 Wikidata 官方数据获取。",{"id":142,"question_zh":143,"answer_zh":144,"source_url":145},30836,"是否计划发布 Wikipedia 预训练数据和对应的 Wikidata 嵌入？","Wikipedia 语料库中包含来自锚点的人工标注对齐信息。关于预处理代码的发布，维护者指出可以利用这些锚点信息来构建训练数据，具体实现可参考项目代码中关于数据预处理的部分。","https:\u002F\u002Fgithub.com\u002Fthunlp\u002FERNIE\u002Fissues\u002F3",[]]