[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-guillaumegenthial--tf_ner":3,"tool-guillaumegenthial--tf_ner":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},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,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},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 真正成长为懂上",140436,2,"2026-04-05T23:32:43",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":78,"owner_location":79,"owner_email":78,"owner_twitter":78,"owner_website":80,"owner_url":81,"languages":82,"stars":95,"forks":96,"last_commit_at":97,"license":98,"difficulty_score":23,"env_os":99,"env_gpu":99,"env_ram":99,"env_deps":100,"category_tags":107,"github_topics":108,"view_count":23,"oss_zip_url":78,"oss_zip_packed_at":78,"status":16,"created_at":121,"updated_at":122,"faqs":123,"releases":159},1334,"guillaumegenthial\u002Ftf_ner","tf_ner","Simple and Efficient Tensorflow implementations of NER models with tf.estimator and tf.data","tf_ner 把“命名实体识别”这件事拆成了几个极简的 TensorFlow 脚本，每个模型只有约 100 行代码，却能跑出论文级的 91+ F1 成绩。它用 tf.estimator 和 tf.data 把训练、评估、预测封装得干净利落，解决了网上常见实现“又旧又乱还跑不通”的痛点。  \n如果你刚入门 NLP、想用最少代码理解 Bi-LSTM+CRF 在 TensorFlow 里的正确姿势，或者你是研究员，需要快速验证新想法而不想被工程细节拖慢，tf_ner 都很合适。只要把文本和标签按 IOBES 格式准备好，脚本会自动帮你生成词典、加载 GloVe，一行命令就能开训。","# Tensorflow - Named Entity Recognition\n\nEach folder contains a __standalone__, __short (~100 lines of Tensorflow)__, `main.py` that implements a neural-network based model for Named Entity Recognition (NER) using [`tf.estimator`](https:\u002F\u002Fwww.tensorflow.org\u002Fguide\u002Fcustom_estimators) and [`tf.data`](https:\u002F\u002Fwww.tensorflow.org\u002Fguide\u002Fdatasets).\n\n![Named Entity Recognition](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fguillaumegenthial_tf_ner_readme_e5c7adf2db43.png)\n\n\nThese implementations are __simple, efficient, and state-of-the-art__, in the sense that they do __as least as well as the results reported in the papers__. The best model achieves in *average* an __f1 score of 91.21__. To my knowledge, *existing implementations available on the web are convoluted, outdated and not always accurate* (including my [previous work](https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Fsequence_tagging)). This repo is an attempt to fix this, in the hope that it will enable people to test and validate new ideas quickly.\n\nThe script [`lstm_crf\u002Fmain.py`](https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_ner\u002Fblob\u002Fmaster\u002Fmodels\u002Flstm_crf\u002Fmain.py) can also be seen as a __simple introduction to Tensorflow high-level APIs [`tf.estimator`](https:\u002F\u002Fwww.tensorflow.org\u002Fguide\u002Fcustom_estimators) and [`tf.data`](https:\u002F\u002Fwww.tensorflow.org\u002Fguide\u002Fdatasets) applied to Natural Language Processing__. [Here is a longer discussion about this implementation along with an introduction to tf.estimator and tf.data](https:\u002F\u002Fguillaumegenthial.github.io\u002Fintroduction-tensorflow-estimator.html)\n\n\n## Install\n\nYou need __python3__ -- If you haven't switched yet, do it.\n\nYou need to install [`tf_metrics` ](https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_metrics) (multi-class precision, recall and f1 metrics for Tensorflow).\n```\npip install git+https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_metrics.git\n```\nOR\n```\ngit clone https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_metrics.git\ncd tf_metrics\npip install .\n```\n\n## Data Format\n\nFollow the [`data\u002Fexample`](https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_ner\u002Ftree\u002Fmaster\u002Fdata\u002Fexample).\n\n1. For `name` in `{train, testa, testb}`, create files `{name}.words.txt` and `{name}.tags.txt` that contain one sentence per line, each\nword \u002F tag separated by space. I recommend using the `IOBES` tagging scheme.\n2. Create files `vocab.words.txt`, `vocab.tags.txt` and `vocab.chars.txt` that contain one token per line.\n3. Create a `glove.npz` file containing one array `embeddings` of shape `(size_vocab_words, 300)` using [GloVe 840B vectors](https:\u002F\u002Fnlp.stanford.edu\u002Fprojects\u002Fglove\u002F) and [`np.savez_compressed`](https:\u002F\u002Fdocs.scipy.org\u002Fdoc\u002Fnumpy-1.13.0\u002Freference\u002Fgenerated\u002Fnumpy.savez_compressed.html).\n\nAn example of scripts to build the `vocab` and the `glove.npz` files from the  `{name}.words.txt` and `{name}.tags.txt` files is provided in [`data\u002Fexample`](https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_ner\u002Ftree\u002Fmaster\u002Fdata\u002Fexample). See\n\n1. [`build_vocab.py`](https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_ner\u002Fblob\u002Fmaster\u002Fdata\u002Fexample\u002Fbuild_vocab.py)\n2. [`build_glove.py`'](https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_ner\u002Fblob\u002Fmaster\u002Fdata\u002Fexample\u002Fbuild_glove.py)\n\n![Data Format](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fguillaumegenthial_tf_ner_readme_8514eba9f5c6.png)\n\nIf you just want to get started, once you have created your `{name}.words.txt` and `{name}.tags.txt` files, simply do\n\n```\ncd data\u002Fexample\nmake download-glove\nmake build\n```\n\n(These commands will build the __example__ dataset)\n\n*Note that the example dataset is here for debugging purposes only and won't be of much use to train an actual model*\n\n## Get Started\n\nOnce you've produced all the required data files, simply pick one of the `main.py` scripts. Then, modify the `DATADIR` variable at the top of `main.py`.\n\nTo train, evaluate and write predictions to file, run\n\n```\ncd models\u002Flstm_crf\npython main.py\n```\n\n(These commands will train a bi-LSTM + CRF on the __example__ dataset if you haven't changed `DATADIR` in the `main.py`.)\n\n__Each model subdirectory contains a breakdown of the instructions__.\n\n## Models\n\nTook inspiration from these papers\n\n- [Bidirectional LSTM-CRF Models for Sequence Tagging](https:\u002F\u002Farxiv.org\u002Fabs\u002F1508.01991) by Huang, Xu and Yu\n- [Neural Architectures for Named Entity Recognition](https:\u002F\u002Farxiv.org\u002Fabs\u002F1603.01360) by Lample et al.\n- [End-to-end Sequence Labeling via Bi-directional LSTM-CNNs-CRF](https:\u002F\u002Farxiv.org\u002Fabs\u002F1603.01354) by Ma et Hovy\n\nYou can also read [this blog post](https:\u002F\u002Fguillaumegenthial.github.io\u002Fsequence-tagging-with-tensorflow.html).\n\nWord-vectors are __not retrained__ to avoid any undesirable shift (explanation in [these CS224N notes](https:\u002F\u002Fgithub.com\u002Fstanfordnlp\u002Fcs224n-winter17-notes\u002Fblob\u002Fmaster\u002Fnotes2.pdf)).\n\nThe models are tested on the [CoNLL2003 shared task](https:\u002F\u002Fwww.clips.uantwerpen.be\u002Fconll2003\u002Fner\u002F).\n\nTraining times are provided for indicative purposes only. Obtained on a 2016 13-inch MBPro 3.3 GHz Intel Core i7.\n\nFor each model, we run 5 experiments\n\n- Train on `train` only\n- __Early stopping__ on `testa`\n- Select best of 5 on the perfomance on `testa` (token-level F1)\n- Report __F1 score mean and standard deviation__ (entity-level F1 from the official `conlleval` script)\n- Select best on `testb` for reference (but shouldn't be used for comparison as this is just overfitting on the final test set)\n\nIn addition, we run 5 other experiments, keeping an __Exponential Moving Average (EMA)__ of the weights (used for evaluation) and report the best F1, mean \u002F std.\n\nAs you can see, there's no clear statistical evidence of which of the 2 character-based models is the best. EMA seems to help most of the time. Also, considering the complexity of the models and the relatively small gap in performance (0.6 F1), using the `lstm_crf` model is probably a safe bet for most of the concrete applications.\n\n---\n\n### `lstm_crf`\n\n__Architecture__\n\n1. [GloVe 840B vectors](https:\u002F\u002Fnlp.stanford.edu\u002Fprojects\u002Fglove\u002F)\n2. Bi-LSTM\n3. CRF\n\n__Related Paper__ [Bidirectional LSTM-CRF Models for Sequence Tagging](https:\u002F\u002Farxiv.org\u002Fabs\u002F1508.01991) by Huang, Xu and Yu\n\n__Training time__ ~ 20 min\n\n|| `train` | `testa` | `testb` | Paper, `testb` |\n|---|:---:|:---:|:---:|:---:|\n|best | 98.45 |93.81 | __90.61__ |  90.10 |\n|best (EMA)| 98.82 | 94.06 | 90.43 | |\n|mean ± std| 98.85 ± 0.22| 93.68 ± 0.12| 90.42 ± 0.10|  |\n|mean ± std (EMA)| 98.71 ± 0.47 | 93.81 ± 0.24 | __90.50__ ± 0.21| |\n|abs. best |   | | 90.61 |  |\n|abs. best (EMA) | |  | 90.75 |  |\n\n\n---\n\n### `chars_lstm_lstm_crf`\n\n__Architecture__\n\n1. [GloVe 840B vectors](https:\u002F\u002Fnlp.stanford.edu\u002Fprojects\u002Fglove\u002F)\n2. Chars embeddings\n3. Chars bi-LSTM\n4. Bi-LSTM\n5. CRF\n\n__Related Paper__ [Neural Architectures for Named Entity Recognition](https:\u002F\u002Farxiv.org\u002Fabs\u002F1603.01360) by Lample et al.\n\n__Training time__ ~ 35 min\n\n|| `train` | `testa` | `testb` | Paper, `testb` |\n|---|:---:|:---:|:---:|:---:|\n|best| 98.81 | 94.36 | 91.02 | 90.94 |\n|best (EMA) |98.73 | 94.50 | __91.14__ | |\n|mean ± std | 98.83 ± 0.27| 94.02 ± 0.26| 91.01 ± 0.16 |  |\n|mean ± std (EMA) | 98.51 ± 0.25| 94.20 ± 0.28| __91.21__ ± 0.05 |  |\n|abs. best |   | |91.22 | |\n|abs. best (EMA) | |   | 91.28 |  |\n\n---\n\n### `chars_conv_lstm_crf`\n\n__Architecture__\n\n1. [GloVe 840B vectors](https:\u002F\u002Fnlp.stanford.edu\u002Fprojects\u002Fglove\u002F)\n2. Chars embeddings\n3. Chars 1d convolution and max-pooling\n4. Bi-LSTM\n5. CRF\n\n__Related Paper__ [End-to-end Sequence Labeling via Bi-directional LSTM-CNNs-CRF](https:\u002F\u002Farxiv.org\u002Fabs\u002F1603.01354) by Ma et Hovy\n\n__Training time__ ~ 35 min\n\n|| `train` | `testa` | `testb` | Paper, `testb` |\n|---|:---:|:---:|:---:|:---:|\n|best| 99.16 | 94.53 | __91.18__ | 91.21 |\n|best (EMA) |99.44 | 94.50 | 91.17 | |\n|mean ± std | 98.86 ± 0.30| 94.10 ± 0.26| __91.20__ ± 0.15 |  |\n|mean ± std (EMA) | 98.67 ± 0.39| 94.29 ± 0.17| 91.13 ± 0.11 |  |\n|abs. best |  | | 91.42 |  |\n|abs. best (EMA) |   | | 91.22 |  |\n\n\n","# Tensorflow - 命名实体识别\n\n每个文件夹都包含一个__独立的__、__简短（约100行Tensorflow代码）__的`main.py`脚本，该脚本使用[`tf.estimator`](https:\u002F\u002Fwww.tensorflow.org\u002Fguide\u002Fcustom_estimators)和[`tf.data`](https:\u002F\u002Fwww.tensorflow.org\u002Fguide\u002Fdatasets)实现了一个基于神经网络的命名实体识别（NER）模型。\n\n![命名实体识别](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fguillaumegenthial_tf_ner_readme_e5c7adf2db43.png)\n\n\n这些实现__简单、高效且处于当前最先进水平__，因为它们的表现__至少与论文中报告的结果相当__。最佳模型的*平均*F1分数达到91.21。据我所知，*目前网络上已有的实现要么过于复杂、要么已经过时，而且并不总是准确的*（包括我的[先前工作](https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Fsequence_tagging)）。本仓库旨在解决这一问题，希望能让人们快速测试和验证新想法。\n\n脚本[`lstm_crf\u002Fmain.py`](https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_ner\u002Fblob\u002Fmaster\u002Fmodels\u002Flstm_crf\u002Fmain.py)也可以被视为一个__关于Tensorflow高级API [`tf.estimator`](https:\u002F\u002Fwww.tensorflow.org\u002Fguide\u002Fcustom_estimators)和[`tf.data`](https:\u002F\u002Fwww.tensorflow.org\u002Fguide\u002Fdatasets)在自然语言处理中的简单入门__。[这里有一篇更详细的讨论，介绍了这个实现以及tf.estimator和tf.data的使用](https:\u002F\u002Fguillaumegenthial.github.io\u002Fintroduction-tensorflow-estimator.html)\n\n\n## 安装\n\n你需要__Python 3__——如果你还没有切换到Python 3，现在就去做吧。\n\n你还需要安装[`tf_metrics`](https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_metrics)（Tensorflow的多分类精确率、召回率和F1指标）。\n```\npip install git+https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_metrics.git\n```\n或者\n```\ngit clone https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_metrics.git\ncd tf_metrics\npip install .\n```\n\n## 数据格式\n\n请遵循[`data\u002Fexample`](https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_ner\u002Ftree\u002Fmaster\u002Fdata\u002Fexample)。\n\n1. 对于`name`在 `{train, testa, testb}`中，创建文件 `{name}.words.txt` 和 `{name}.tags.txt`，每行包含一个句子，每个单词\u002F标签之间用空格分隔。我建议使用`IOBES`标注方案。\n2. 创建文件 `vocab.words.txt`、`vocab.tags.txt` 和 `vocab.chars.txt`，每行包含一个标记。\n3. 创建一个`glove.npz`文件，其中包含一个形状为`(size_vocab_words, 300)`的数组`embeddings`，使用[GloVe 840B向量](https:\u002F\u002Fnlp.stanford.edu\u002Fprojects\u002Fglove\u002F)和[`np.savez_compressed`](https:\u002F\u002Fdocs.scipy.org\u002Fdoc\u002Fnumpy-1.13.0\u002Freference\u002Fgenerated\u002Fnumpy.savez_compressed.html)生成。\n\n从`{name}.words.txt`和`{name}.tags.txt`文件构建`vocab`和`glove.npz`文件的脚本示例已在[`data\u002Fexample`](https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_ner\u002Ftree\u002Fmaster\u002Fdata\u002Fexample)中提供。详见：\n\n1. [`build_vocab.py`](https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_ner\u002Fblob\u002Fmaster\u002Fdata\u002Fexample\u002Fbuild_vocab.py)\n2. [`build_glove.py`](https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_ner\u002Fblob\u002Fmaster\u002Fdata\u002Fexample\u002Fbuild_glove.py)\n\n![数据格式](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fguillaumegenthial_tf_ner_readme_8514eba9f5c6.png)\n\n如果你只是想开始使用，一旦你创建了`{name}.words.txt`和`{name}.tags.txt`文件，只需执行：\n\n```\ncd data\u002Fexample\nmake download-glove\nmake build\n```\n\n（这些命令将构建__示例__数据集）\n\n*请注意，示例数据集仅用于调试目的，对训练实际模型帮助不大*\n\n## 开始使用\n\n一旦你生成了所有所需的数据文件，只需选择其中一个`main.py`脚本。然后，在`main.py`顶部修改`DATADIR`变量。\n\n要训练、评估并将预测结果写入文件，运行：\n\n```\ncd models\u002Flstm_crf\npython main.py\n```\n\n（如果未在`main.py`中更改`DATADIR`，这些命令将在__示例__数据集上训练一个双向LSTM + CRF模型。）\n\n__每个模型子目录都包含了操作说明的详细分解__。\n\n## 模型\n\n灵感来源于以下论文：\n\n- [用于序列标注的双向LSTM-CRF模型](https:\u002F\u002Farxiv.org\u002Fabs\u002F1508.01991) by Huang, Xu and Yu\n- [用于命名实体识别的神经架构](https:\u002F\u002Farxiv.org\u002Fabs\u002F1603.01360) by Lample et al.\n- [通过双向LSTM-CNNs-CRF实现端到端序列标注](https:\u002F\u002Farxiv.org\u002Fabs\u002F1603.01354) by Ma et Hovy\n\n你也可以阅读[这篇博客文章](https:\u002F\u002Fguillaumegenthial.github.io\u002Fsequence-tagging-with-tensorflow.html)。\n\n为了避免任何不希望的偏移（解释见[这些CS224N笔记](https:\u002F\u002Fgithub.com\u002Fstanfordnlp\u002Fcs224n-winter17-notes\u002Fblob\u002Fmaster\u002Fnotes2.pdf)），词向量__不会重新训练__。\n\n这些模型在[CoNLL2003共享任务](https:\u002F\u002Fwww.clips.uantwerpen.be\u002Fconll2003\u002Fner\u002F)上进行了测试。\n\n训练时间仅供参考。是在一台2016年款13英寸MBPro 3.3 GHz Intel Core i7上测得的。\n\n对于每个模型，我们进行5次实验：\n\n- 仅在`train`上训练\n- 在`testa`上进行__早停__\n- 根据`testa`上的表现（token-level F1）选出5次中的最佳\n- 报告__F1分数的均值和标准差__（来自官方`conlleval`脚本的entity-level F1）\n- 在`testb`上选出最佳作为参考（但不应用于比较，因为这只是对最终测试集的过拟合）\n\n此外，我们还进行另外5次实验，保留权重的__指数移动平均（EMA）__（用于评估），并报告最佳F1、均值\u002F标准差。\n\n正如你所见，没有明确的统计证据表明两种基于字符的模型中哪一种更好。EMA似乎在大多数情况下都有帮助。另外，考虑到模型的复杂性和性能差距相对较小（0.6 F1），使用`lstm_crf`模型可能是大多数具体应用的安全选择。\n\n---\n\n### `lstm_crf`\n\n__架构__\n\n1. [GloVe 840B向量](https:\u002F\u002Fnlp.stanford.edu\u002Fprojects\u002Fglove\u002F)\n2. 双向LSTM\n3. CRF\n\n__相关论文__ [用于序列标注的双向LSTM-CRF模型](https:\u002F\u002Farxiv.org\u002Fabs\u002F1508.01991) by Huang, Xu and Yu\n\n__训练时间__ ~ 20分钟\n\n|| `train` | `testa` | `testb` | 论文，`testb` |\n|---|:---:|:---:|:---:|:---:|\n|最佳 | 98.45 |93.81 | __90.61__ |  90.10 |\n|最佳（EMA）| 98.82 | 94.06 | 90.43 | |\n|均值 ± 标准差| 98.85 ± 0.22| 93.68 ± 0.12| 90.42 ± 0.10|  |\n|均值 ± 标准差（EMA）| 98.71 ± 0.47 | 93.81 ± 0.24 | __90.50__ ± 0.21| |\n|绝对最佳 |   | | 90.61 | |\n|绝对最佳（EMA） | |  | 90.75 |  |\n\n\n---\n\n### `chars_lstm_lstm_crf`\n\n__架构__\n\n1. [GloVe 840B向量](https:\u002F\u002Fnlp.stanford.edu\u002Fprojects\u002Fglove\u002F)\n2. 字符嵌入\n3. 字符双向LSTM\n4. 双向LSTM\n5. CRF\n\n__相关论文__ [用于命名实体识别的神经架构](https:\u002F\u002Farxiv.org\u002Fabs\u002F1603.01360) by Lample et al.\n\n__训练时间__ ~ 35分钟\n\n|| `train` | `testa` | `testb` | 论文，`testb` |\n|---|:---:|:---:|:---:|:---:|\n|最佳| 98.81 | 94.36 | 91.02 | 90.94 |\n|最佳（EMA） |98.73 | 94.50 | __91.14__ | |\n|均值 ± 标准差 | 98.83 ± 0.27| 94.02 ± 0.26| 91.01 ± 0.16 |  |\n|均值 ± 标准差（EMA） | 98.51 ± 0.25| 94.20 ± 0.28| __91.21__ ± 0.05 |  |\n|绝对最佳 |   | |91.22 | |\n|绝对最佳（EMA） | |   | 91.28 |  |\n\n\n---\n\n### `chars_conv_lstm_crf`\n\n__架构__\n\n1. [GloVe 840B 向量](https:\u002F\u002Fnlp.stanford.edu\u002Fprojects\u002Fglove\u002F)\n2. 字符嵌入\n3. 字符一维卷积与最大池化\n4. 双向 LSTM\n5. CRF\n\n__相关论文__ [通过双向 LSTM-CNNs-CRF 实现端到端序列标注](https:\u002F\u002Farxiv.org\u002Fabs\u002F1603.01354)，作者为 Ma 和 Hovy\n\n__训练时间__ ~ 35 分钟\n\n|| `train` | `testa` | `testb` | 论文中的 `testb` |\n|---|:---:|:---:|:---:|:---:|\n|最佳| 99.16 | 94.53 | __91.18__ | 91.21 |\n|最佳（EMA）|99.44 | 94.50 | 91.17 | |\n|均值 ± 标准差 | 98.86 ± 0.30| 94.10 ± 0.26| __91.20__ ± 0.15 |  |\n|均值 ± 标准差（EMA）| 98.67 ± 0.39| 94.29 ± 0.17| 91.13 ± 0.11 |  |\n|绝对最佳 |  | | 91.42 |  |\n|绝对最佳（EMA）|   | | 91.22 |  |","# tf_ner 快速上手指南\n\n`tf_ner` 是一个基于 TensorFlow 的命名实体识别（NER）开源工具集。它提供了多个独立、简洁（约 100 行代码）的模型实现，利用 `tf.estimator` 和 `tf.data` 高级 API 构建。该工具包含 Bi-LSTM+CRF 等主流架构，在 CoNLL2003 数据集上平均 F1 分数可达 91.21%，适合快速验证新想法或作为学习 TensorFlow NLP 应用的入门项目。\n\n## 环境准备\n\n- **操作系统**：Linux \u002F macOS \u002F Windows\n- **Python 版本**：必须使用 **Python 3**\n- **核心依赖**：\n  - TensorFlow (支持 `tf.estimator` 和 `tf.data` 的版本)\n  - `tf_metrics` (用于计算多分类 Precision, Recall, F1)\n  - NumPy\n  - GloVe 词向量文件 (840B vectors)\n\n## 安装步骤\n\n### 1. 安装 tf_metrics\n该项目依赖自定义的评估指标库 `tf_metrics`。你可以选择通过 pip 直接安装或源码安装：\n\n```bash\npip install git+https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_metrics.git\n```\n\n或者克隆源码安装：\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_metrics.git\ncd tf_metrics\npip install .\n```\n\n> **提示**：如果下载速度较慢，可尝试配置国内 pip 镜像源（如清华源）：\n> `pip install -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple git+https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_metrics.git`\n\n### 2. 获取项目代码\n克隆 `tf_ner` 仓库到本地：\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_ner.git\ncd tf_ner\n```\n\n### 3. 准备数据\n项目要求特定的数据格式。如果你只想快速测试流程，可以使用内置的示例脚本生成调试数据（注意：示例数据仅用于调试，不适合训练正式模型）。\n\n进入示例数据目录并执行：\n\n```bash\ncd data\u002Fexample\nmake download-glove\nmake build\n```\n\n*上述命令会自动下载 GloVe 向量并构建 `vocab` 及 `glove.npz` 文件。*\n\n若需使用自己的数据集，请参照 `data\u002Fexample` 格式准备以下文件：\n- `{name}.words.txt` 和 `{name}.tags.txt`：每行一个句子，词与标签用空格分隔（推荐 IOBES 标注体系）。\n- `vocab.words.txt`, `vocab.tags.txt`, `vocab.chars.txt`：每行一个 token。\n- `glove.npz`：形状为 `(vocab_size, 300)` 的压缩数组。\n\n## 基本使用\n\n完成数据准备后，选择一个模型目录即可开始训练。以下以经典的 **Bi-LSTM + CRF** 模型为例：\n\n1. 进入模型目录：\n   ```bash\n   cd models\u002Flstm_crf\n   ```\n\n2. （可选）修改 `main.py` 顶部的 `DATADIR` 变量，指向你的实际数据目录。若未修改，默认使用 `data\u002Fexample` 下的示例数据。\n\n3. 运行训练、评估及预测脚本：\n   ```bash\n   python main.py\n   ```\n\n执行后，程序将自动：\n- 加载数据和预训练词向量\n- 训练模型（示例数据约需几分钟，完整数据集约 20-35 分钟）\n- 在验证集上进行早停（Early Stopping）\n- 输出测试结果并保存预测文件\n\n### 其他可用模型\n项目还提供了结合字符级特征的进阶模型，使用方法同上，只需切换目录：\n- `models\u002Fchars_lstm_lstm_crf`：基于字符级 Bi-LSTM 特征\n- `models\u002Fchars_conv_lstm_crf`：基于字符级 CNN 特征\n\n对于大多数实际应用，推荐使用 `lstm_crf` 模型，它在性能和复杂度之间取得了良好的平衡。","某金融科技公司的 NLP 团队正致力于从海量非结构化的信贷审批报告中，自动提取借款人姓名、企业名称及金额等关键实体，以构建自动化风控系统。\n\n### 没有 tf_ner 时\n- **代码冗余且难维护**：团队需从零搭建基于 TensorFlow 的 Bi-LSTM+CRF 模型，数百行底层数据加载与估算器逻辑导致开发周期长达数周。\n- **复现论文效果困难**：网络上现有的开源实现往往架构陈旧或逻辑复杂，难以复现学术论文中报道的 SOTA（最先进）性能指标。\n- **实验迭代缓慢**：由于缺乏模块化设计，每次尝试新的网络结构或超参数调整时，都需要修改大量耦合代码，验证新想法的效率极低。\n- **数据预处理繁琐**：缺少标准化的 `tf.data` 流水线示例，处理自定义的 IOBES 标注格式和 GloVe 词向量映射需要耗费大量精力调试。\n\n### 使用 tf_ner 后\n- **快速落地生产模型**：直接复用 `lstm_crf\u002Fmain.py` 中仅约 100 行的核心代码，利用其内置的 `tf.estimator` 和 `tf.data` 接口，三天内即可完成模型部署。\n- **确保高精度识别**：借助其经过验证的架构，模型在内部测试集上平均 F1 分数迅速达到 91% 以上，表现媲美甚至优于主流论文结果。\n- **敏捷验证创新思路**：清晰的独立脚本结构让算法工程师能专注于业务逻辑，轻松替换组件以测试新策略，大幅缩短研发迭代周期。\n- **标准化数据流程**：遵循项目提供的标准数据格式指南，快速编写脚本将公司内部文档转换为训练所需的 `.words.txt` 和 `.tags.txt`，无缝对接预训练词向量。\n\ntf_ner 通过提供简洁、高效且状态先进的参考实现，将原本复杂的序列标注任务转化为可快速验证的工程实践，显著降低了高性能 NER 模型的落地门槛。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fguillaumegenthial_tf_ner_e5c7adf2.png","guillaumegenthial","Guillaume Genthial","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fguillaumegenthial_40e1db0a.png",null,"Paris","https:\u002F\u002Fguillaumegenthial.github.io","https:\u002F\u002Fgithub.com\u002Fguillaumegenthial",[83,87,91],{"name":84,"color":85,"percentage":86},"Python","#3572A5",87.7,{"name":88,"color":89,"percentage":90},"Perl","#0298c3",12.1,{"name":92,"color":93,"percentage":94},"Makefile","#427819",0.2,927,270,"2026-03-25T04:26:19","Apache-2.0","未说明",{"notes":101,"python":102,"dependencies":103},"需要安装额外的 tf_metrics 库用于多分类评估。数据预处理需要下载 GloVe 840B 词向量并转换为 .npz 格式。README 中提到的训练时间基于 2016 款 MacBook Pro (CPU)，表明该工具可在 CPU 环境下运行，未强制要求 GPU。","3.x",[104,105,106],"tensorflow (使用 tf.estimator 和 tf.data)","tf_metrics","numpy",[51,52,14,13,55,26],[109,110,111,112,113,114,115,116,117,118,119,120],"ner","named-entity-recognition","conll-2003","lstm-crf","state-of-the-art","tensorflow","bi-lstm-crf","exponential-moving-average","glove","character-embeddings","tf-estimator","tf-data","2026-03-27T02:49:30.150509","2026-04-06T08:08:36.403088",[124,129,134,139,144,149,154],{"id":125,"question_zh":126,"answer_zh":127,"source_url":128},6097,"运行时报错 `InvalidArgumentError: labels contains negative values` 怎么办？","该错误通常是因为数据集中缺少 'O'（Other）标签，但代码在填充（padding）不等长样本时使用了 'O' 标签，导致词汇表不匹配。解决方法是：在运行 `build_vocab.py` 脚本生成词汇表后，手动在 `vocab.tags.txt` 文件中新起一行添加大写的 'O' 标签。","https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_ner\u002Fissues\u002F8",{"id":130,"question_zh":131,"answer_zh":132,"source_url":133},6098,"遇到 `AttributeError: module 'tensorflow.contrib.estimator' has no attribute 'stop_if_no_increase_hook'` 错误如何解决？","这是因为 TensorFlow 版本升级导致 API 变更。解决方案是将 TensorFlow 升级到 1.14 或更高版本，并将代码中的 `tf.contrib.estimator.stop_if_no_increase_hook` 替换为 `tf.estimator.experimental.stop_if_no_increase_hook`。","https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_ner\u002Fissues\u002F58",{"id":135,"question_zh":136,"answer_zh":137,"source_url":138},6099,"训练完成后如何保存模型以便下次直接使用而无需重新训练？","模型训练结束后，权重会自动保存在 `results` 目录中。下次运行时，只要实例化相同的 estimator，使用相同的计算图结构并指定相同的 `model_dir`，程序会自动加载已保存的权重。你可以尝试注释掉 `train_and_evaluate` 函数，直接运行 `python main.py` 来验证它是否会重载图形并输出预测结果。","https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_ner\u002Fissues\u002F2",{"id":140,"question_zh":141,"answer_zh":142,"source_url":143},6100,"运行程序时报 `ValueError: max() arg is an empty sequence` 错误是什么原因？","该错误通常是由数据文件中存在空行引起的。请检查你的训练或测试数据文件，删除其中的所有空行即可解决此问题。","https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_ner\u002Fissues\u002F46",{"id":145,"question_zh":146,"answer_zh":147,"source_url":148},6101,"项目是否有可以直接使用的训练数据集推荐？","虽然示例数据仅用于调试，但你可以使用 CONLL2003 等标准数据集。如果需要与本项目代码格式兼容的数据集，可以参考 GitHub 上的 [NER-datasets](https:\u002F\u002Fgithub.com\u002Fdavidsbatista\u002FNER-datasets) 仓库获取相关资源。","https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_ner\u002Fissues\u002F3",{"id":150,"question_zh":151,"answer_zh":152,"source_url":153},6102,"在使用 CRF 解码时，如何获取前 K 个（top-k）最佳候选序列？","当前实现主要关注最优序列。如果需要获取 top-k 最佳候选序列，建议参考 [CRF++](https:\u002F\u002Ftaku910.github.io\u002Fcrfpp\u002F) 工具中提到的 n-best 输出算法，并尝试自行在 TensorFlow 中重新实现该逻辑。","https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_ner\u002Fissues\u002F47",{"id":155,"question_zh":156,"answer_zh":157,"source_url":158},6103,"预测结果中出现了没有对应 'Begin' 标签的 'Inside' 标签（如 I-LOC 前没有 B-LOC），该如何控制这种转移？","这通常是由于数据不足或模型未学习到合法的标签转移规则导致的。可以通过增加训练数据来改善。如果必须严格控制，需要在参数初始化阶段手动设置未知转移的分数（scores），例如通过 `crf_log_likelihood` 的 `transition_params` 参数进行干预，但这需要自定义实现。","https:\u002F\u002Fgithub.com\u002Fguillaumegenthial\u002Ftf_ner\u002Fissues\u002F17",[]]