[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-Tencent--TurboTransformers":3,"tool-Tencent--TurboTransformers":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":75,"owner_avatar_url":76,"owner_bio":77,"owner_company":78,"owner_location":78,"owner_email":78,"owner_twitter":78,"owner_website":79,"owner_url":80,"languages":81,"stars":106,"forks":107,"last_commit_at":108,"license":109,"difficulty_score":110,"env_os":111,"env_gpu":112,"env_ram":113,"env_deps":114,"category_tags":122,"github_topics":123,"view_count":23,"oss_zip_url":78,"oss_zip_packed_at":78,"status":16,"created_at":136,"updated_at":137,"faqs":138,"releases":169},2784,"Tencent\u002FTurboTransformers","TurboTransformers","a fast and user-friendly runtime for transformer inference (Bert, Albert, GPT2, Decoders, etc) on CPU and GPU.","TurboTransformers 是由微信 AI 开源的一款高性能推理运行时，专为在 CPU 和 GPU 上加速 BERT、ALBERT、GPT-2 等 Transformer 模型而设计。它主要解决了传统推理框架在处理变长输入时效率低下、需要繁琐离线调优以及部署难度大的痛点。通过智能批处理技术，TurboTransformers 能自动最小化不同长度请求间的填充开销，无需预处理即可实时调整批次大小和序列长度，从而显著提升服务吞吐量。\n\n在实际应用中，TurboTransformers 已帮助腾讯内部多个业务场景实现大幅提速，例如将微信问答服务加速 1.88 倍，QQ 推荐系统加速高达 13.6 倍。其独特亮点在于“开箱即用”的易用性：开发者只需在现有的 PyTorch 代码中添加寥寥数行，即可无缝切换至加速模式，同时支持 Python 和 C++ 双接口。无论是致力于算法落地的工程师，还是需要进行大规模模型部署的研究人员，都能利用 TurboTransformers 轻松构建高效的自然语言处理服务，在保持开发灵活性的同时获得极致的推理性能。","## TurboTransformers: a fast and user-friendly runtime for transformer inference on CPU and GPU\n![logo](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FTencent_TurboTransformers_readme_948d3a3479b5.jpeg)\n\n\u003Ccenter>Make transformers serving fast by adding a turbo to your inference engine!\u003C\u002Fcenter>\n\nThe WeChat AI open-sourced TurboTransformers with the following characteristics.\n\n1. Supporting both Transformers Encoder and Decoder.\n3. Supports Variable Length inputs. No time-consuming offline tuning is required. You can change batch size and sequence length at real-time.\n3. Excellent CPU \u002F GPU performance.\n4. Perfect Usibility. TurboTransformers supports python and C++ APIs.\n5. Smart Batching. Minimize zero-padding overhead for a batch of requests of different lengths.\nIt can be used as a plugin for pytorch. Tthe end-to-end acceleration is obtained by adding a few lines of python code.\n\n\nTurboTransformers has been applied to multiple online BERT service scenarios in Tencent.\nFor example, It brings 1.88x acceleration to the WeChat FAQ service, 2.11x acceleration to the public cloud sentiment analysis service, and 13.6x acceleration to the QQ recommendation system.\nMoreover, it has already been applied to build services such as Chitchating, Searching, and Recommendation.\n\nThe following table is a comparison of TurboTransformers and related work.\n\n| Related Works  |  Performance | Need Preprocess  |  Variable Length  | Usage |\n|------------------|---|---|---|---|\n| pytorch JIT (CPU) |  Fast |  Yes  | No  | Hard   |\n| TensorRT (GPU) | Fast | Yes  | No  | Hard  |\n| tf-Faster Transformers (GPU) | Fast  | Yes  | No  | Hard  |\n| ONNX-runtime (CPU\u002FGPU) | Fast\u002FFast | No  | Yes  | Medium  |\n| tensorflow-1.x (CPU\u002FGPU) | Slow\u002FMedium | Yes | No | Easy |\n| pytorch (CPU\u002FGPU) | Medium\u002FMedium | No | Yes | Easy |\n| **turbo-transformers (CPU\u002FGPU)** | **Fastest\u002FFastest** | **No** | **Yes** | **Easy** |\n\n### Supported Models\nWe currently support the following transformer models.\n\n\n* [BERT](https:\u002F\u002Farxiv.org\u002Fabs\u002F1810.04805) [[Python]](.\u002Fexample\u002Fpython\u002Fbert_example.py) [[C++]](.\u002Fexample\u002Fpython\u002Fbert_example.cpp)\n* [ALBERT](https:\u002F\u002Farxiv.org\u002Fabs\u002F1909.11942) [[Python]](.\u002Fexample\u002Fpython\u002Falbert_example.py)\n* [Roberta](https:\u002F\u002Farxiv.org\u002Fabs\u002F1907.11692) [[Python]](.\u002Fexample\u002Fpython\u002Froberta_example.py)\n* [Transformer Decoder](https:\u002F\u002Fgithub.com\u002FOpenNMT\u002FOpenNMT-py\u002Fblob\u002Fmaster\u002Fonmt\u002Fdecoders\u002Ftransformer.py) [[Python]](https:\u002F\u002Fgithub.com\u002FTurboNLP\u002FTranslate-Demo)\n* [GPT2](https:\u002F\u002Fwww.ceid.upatras.gr\u002Fwebpages\u002Ffaculty\u002Fzaro\u002Fteaching\u002Falg-ds\u002FPRESENTATIONS\u002FPAPERS\u002F2019-Radford-et-al_Language-Models-Are-Unsupervised-Multitask-%20Learners.pdf) [[Python]](.\u002Fexample\u002Fpython\u002Fgpt2_example.py)\n\n### Boost BERT Inference in 2 Lines of Python Code\n```python\nimport torch\nimport transformers\nimport turbo_transformers\n\nif __name__ == \"__main__\":\n    turbo_transformers.set_num_threads(4)\n    torch.set_num_threads(4)\n    model_id = \"bert-base-uncased\"\n    model = transformers.BertModel.from_pretrained(model_id)\n    model.eval()\n    cfg = model.config\n\n    input_ids = torch.tensor(\n        ([12166, 10699, 16752, 4454], [5342, 16471, 817, 16022]),\n        dtype=torch.long)\n    position_ids = torch.tensor(([1, 0, 0, 0], [1, 1, 1, 0]), dtype=torch.long)\n    segment_ids = torch.tensor(([1, 1, 1, 0], [1, 0, 0, 0]), dtype=torch.long)\n    torch.set_grad_enabled(False)\n    torch_res = model(\n        input_ids, position_ids=position_ids, token_type_ids=segment_ids\n    )  # sequence_output, pooled_output, (hidden_states), (attentions)\n    torch_seqence_output = torch_res[0][:, 0, :]\n    tt_model = turbo_transformers.BertModel.from_torch(model)\n    res = tt_model(\n        input_ids, position_ids=position_ids,\n        token_type_ids=segment_ids)  # pooled_output, sequence_output\n    tt_seqence_output = res[0]\n```\n\n### Installation\nNote that the building scripts only apply to specific OS and software (Pytorch, OpenNMT, transformers, etc.) versions.\nPlease adjust them according to your needs.\n\n#### CPU\n```\ngit clone https:\u002F\u002Fgithub.com\u002FTencent\u002FTurboTransformers --recursive\n```\n1. build docker images and containers on your machine.\n```\nsh tools\u002Fbuild_docker_cpu.sh\n# optional: If you want to compare the performance of onnxrt-mkldnn during benchmark, you need to set BUILD_TYPE=dev to compile onnxruntime into the docker image, as follows\nenv BUILD_TYPE=dev sh tools\u002Fbuild_docker_cpu.sh\ndocker run -it --rm --name=turbort -v $PWD:\u002Fworkspace your_image_name \u002Fbin\u002Fbash\n```\n\n2. Install turbo in docker\n\nMethod 1: I want to unitest\n```\ncd \u002Fworkspace\nsh tools\u002Fbuild_and_run_unittests.sh $PWD -DWITH_GPU=OFF\n# you can switch between Openblas and MKL by modifying this line in CMakeList.txt\n# set(BLAS_PROVIDER \"mkl\" CACHE STRING \"Set the blas provider library, in [openblas, mkl, blis]\")\n\n```\nMethod 2: I do not want to unitest\n```\ncd \u002Fworkspace\nmkdir -p build && cd build\ncmake .. -DWITH_GPU=OFF\nmake -j 4\npip install `find . -name *whl`\n```\n3. Run benchmark (optional) in docker, compare with pytorch, torch-JIT, onnxruntime\n```\ncd benchmark\nbash run_benchmark.sh\n```\n4. Install conda packages in docker (optional)\n```\nsh tool\u002Fbuild_conda_package.sh\n# The conda package will be in \u002Fworkspace\u002Fdist\u002F*.tar.bz2\n# When using turbo_transformers in other environments outside this container: conda install your_root_path\u002Fdist\u002F*.tar.bz2\n```\n\n*We also prepared a docker image containing CPU version of TurboTransformers, as well as other related works, i.e. onnxrt v1.2.0 and pytorch-jit on dockerhub*\n```\ndocker pull thufeifeibear\u002Fturbo_transformers_cpu:latest\n```\n#### GPU\n```\ngit clone https:\u002F\u002Fgithub.com\u002FTencent\u002FTurboTransformers --recursive\n```\n1. build docker images and containers on your machine.\n```\n# You can modify the environment variables in the script to specify the cuda version and operating system version\nsh tools\u002Fbuild_docker_gpu.sh $PWD\nnvidia-docker run --gpus all --net=host --rm -it -v $PWD:\u002Fworkspace -v \u002Fetc\u002Fpasswd:\u002Fetc\u002Fpasswd --name=your_container_name REPOSITORY:TAG\n# for example: nvidia-docker run --gpus all --net=host --rm -it -v $PWD:\u002Fworkspace -v \u002Fetc\u002Fpasswd:\u002Fetc\u002Fpasswd --name=turbo_gpu_env thufeifeibear:0.1.1-cuda9.0-ubuntu16.04-gpu-dev\n```\n\n2. Install pip package in docker and unitest test\n```\ncd \u002Fworkspace\nsh tools\u002Fbuild_and_run_unittests.sh $PWD -DWITH_GPU=ON\n```\n\n3. Run benchmark (optional) in docker container, compare with pytorch\n```\ncd benchmark\nbash gpu_run_benchmark.sh\n```\nWe also prepared a docker image containing GPU version of TurboTransformers.\n```\ndocker pull thufeifeibear\u002Fturbo_transformers_gpu:latest\n```\n#### Using Tensor Core (FP16)\n[Tensor Core](https:\u002F\u002Fdeveloper.download.nvidia.cn\u002Fvideo\u002Fgputechconf\u002Fgtc\u002F2019\u002Fpresentation\u002Fs9926-tensor-core-performance-the-ultimate-guide.pdf)  can accelerate computing on GPU. It is disabled by default in TurboTransformers. If you want to turn it on, before compiling code, set option WITH_MODULE_BENCHMAKR ON in CMakeLists.txt\n```\noption(WITH_TENSOR_CORE     \"Use Tensor core to accelerate\"     ON)\n```\n### Usage\nTurboTransformers provides C++ \u002F python API interfaces. We hope to do our best to adapt to a variety of online environments to reduce the difficulty of development for users.\n\n\n#### Pretrained Model Loading\nThe first step in using turbo is to load a pre-trained model. We provide a way to load pytorch and tensorflow pre-trained models in [huggingface\u002Ftransformers](https:\u002F\u002Fgithub.com\u002Fhuggingface).\nThe specific conversion method is to use the corresponding script in .\u002Ftools to convert the pre-trained model into an npz format file, and turbo uses the C ++ or python interface to load the npz format model.\nIn particular, we consider that most of the pre-trained models are in PyTorch format and used with python. We provide a shortcut for calling directly in python for the PyTorch saved model.\n\n\u003Cimg width=\"700\" height=\"150\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FTencent_TurboTransformers_readme_716a3e8354f8.jpg\" alt=\"pretrained\">\n\n#### APIs\n###### python APIs\nRefer to examples of supported models in [.\u002Fexample\u002Fpython](.\u002Fexample\u002Fpython \"python\").\n[TurboNLP\u002FTranslate-Demo](https:\u002F\u002Fgithub.com\u002FTurboNLP\u002FTranslate-Demo \"translate\") shows a demo of applying TurboTransformer in Translation Task.\nSince the user of BERT acceleration always requires a customized post-processing process for the task, we provide an example of how to write a sequence classification application.\n###### C++ APIs\nRefer to [.\u002Fexample\u002Fcpp](.\u002Fexample\u002Fcpp \"C ++\") for an example.\nOur example provides the GPU and two CPU multi-thread calling methods. One is to do one BERT inference using multiple threads; the other is to do multiple BERT inference, each of which using one thread.\nUsers can link turbo-transformers to your code through add_subdirectory.\n\n#### Smart Batching (Minimize Zero-Padding Overhead in Batching)\nUsually, feeding a batch of requests of different lengths into a bert model for inference,\nzero-padding is required to make all the requests have the same length.\nFor example, serving requests list of lengths (100, 10, 50), you need a preprocessing stage to pad them as lengths (100, 100, 100).\nIn this way, 90% and 50% of the last two sequence's computation are wasted.\nAs indicated in [Effective Transformer](https:\u002F\u002Fgithub.com\u002Fbytedance\u002Feffective_transformer),\nit is not necessary to pad the input tensors.\nAs an alternative, you just have to pad the batch-gemm operations inside multi-headed attentions,\nwhich accouts to a small propation of the entire BERT computation.\nTherefore most of gemm operations are processed without zero-padding.\nTurbo provides a model as `BertModelSmartBatch` including a smart batching technique.\nThe example is presented in [.\u002Fexample\u002Fpython\u002Fbert_smart_pad.py](.\u002Fexample\u002Fpython\u002Fbert_smart_pad.py \"smart_batching\").\n\n\n## How to contribute new models\n[How to know hotspots of your code?](.\u002Fdocs\u002Fprofiler.md)\n\n[How to add a new layer?](.\u002Fturbo_transformers\u002Flayers\u002FREADME.md)\n\n\n## TODO\nCurrently (June 2020), In the near future, we will add support for low-precision models (CPU int8, GPU FP16).\n**Looking forwards to your contribution!**\n\n## License\nBSD 3-Clause License\n\n## Known Issues\n1. The results of Turbo Transformers may be different from the results of PyTorch after 2 digits behind the decimal point.\nThe diff mainly comes from Bert Output Layer. We use an approximate GELU algorithm, which may be different from PyTorch.\n2. Turbo and PyTorch share the same MKL. MKL of PyTorch 1.5.0 may slow in Turbo. Reasons need to be determined.\nDownload PyTorch version to 1.1.0 will improve Turbo's Performance.\n3. onnxruntime-cpu==1.4.0 and onnxruntime-gpu==1.3.0 can not work simultaneously.\n\n## History\n1. Janurary 2021 v0.6.0, TurboTransformers supports smart batching.\n2. July 2020 v0.4.0, TurboTransformers used onnxruntime as cpu backend, supports GPT2. Anded a Quantized BERT.\n3. July 2020 v0.3.1, TurboTransformers added support for ALbert, Roberta on CPU\u002FGPU.\n4. June 2020 v0.3.0, TurboTransformers added support for Transformer Decoder on CPU\u002FGPU.\n5. June 2020 v0.2.1, TurboTransformers added BLIS as a BLAS provider option. Better performance on AMD CPU.\n6. April 2020 v0.0.1, TurboTransformers released, and achieved state-of-the-art BERT inference speed on CPU\u002FGPU.\n\n## Cite us\nCite this paper, if you use TurboTransformers in your research publication.\n\n```\n@inproceedings{fang2021turbotransformers,\n  title={TurboTransformers: an efficient GPU serving system for transformer models},\n  author={Fang, Jiarui and Yu, Yang and Zhao, Chengduo and Zhou, Jie},\n  booktitle={Proceedings of the 26th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming},\n  pages={389--402},\n  year={2021}\n}\n```\n\nThe artifacts of the paper can be found at branch `ppopp21_artifact_centos`.\n\n## Contact us\nAlthough we recommend you post your problem with github issues, you can also join in our Turbo user group.\n1. Scan this [QR code](.\u002Fimages\u002Fnamecode.pdf \"qrcode\") and add our contactor as your WeChat friend.\n2. QQ Group, Name: TurboTransformers, Number : 1109315167.\n","## TurboTransformers：一款在 CPU 和 GPU 上运行的快速且易用的 Transformer 推理运行时\n![logo](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FTencent_TurboTransformers_readme_948d3a3479b5.jpeg)\n\n\u003Ccenter>为你的推理引擎装上涡轮增压，让 Transformer 服务更加快速！\u003C\u002Fcenter>\n\n微信 AI 开源了 TurboTransformers，它具有以下特点：\n\n1. 同时支持 Transformer 的编码器和解码器。\n3. 支持可变长度输入。无需耗时的离线调优，你可以实时调整批大小和序列长度。\n3. 出色的 CPU\u002FGPU 性能。\n4. 完美的易用性。TurboTransformers 提供 Python 和 C++ API。\n5. 智能批处理。针对不同长度的请求批次，最小化零填充开销。\n它可以作为 PyTorch 的插件使用，只需添加几行 Python 代码即可实现端到端加速。\n\nTurboTransformers 已经应用于腾讯内部多个在线 BERT 服务场景。例如，它使微信 FAQ 服务加速 1.88 倍，公有云情感分析服务加速 2.11 倍，QQ 推荐系统加速 13.6 倍。此外，它还被用于构建聊天、搜索和推荐等服务。\n\n下表是 TurboTransformers 与相关工作的对比：\n\n| 相关工作       | 性能     | 是否需要预处理 | 可变长度 | 使用难度 |\n|------------------|----------|-----------------|----------|----------|\n| pytorch JIT (CPU) | 快      | 是              | 否       | 难       |\n| TensorRT (GPU)   | 快      | 是              | 否       | 难       |\n| tf-Faster Transformers (GPU) | 快  | 是  | 否  | 难  |\n| ONNX-runtime (CPU\u002FGPU) | 快\u002F快 | 否  | 是  | 中等  |\n| tensorflow-1.x (CPU\u002FGPU) | 慢\u002F中等 | 是 | 否 | 易 |\n| pytorch (CPU\u002FGPU) | 中等\u002F中等 | 否 | 是 | 易 |\n| **turbo-transformers (CPU\u002FGPU)** | **最快\u002F最快** | **否** | **是** | **易** |\n\n### 支持的模型\n我们目前支持以下 Transformer 模型。\n\n* [BERT](https:\u002F\u002Farxiv.org\u002Fabs\u002F1810.04805) [[Python]](.\u002Fexample\u002Fpython\u002Fbert_example.py) [[C++]](.\u002Fexample\u002Fpython\u002Fbert_example.cpp)\n* [ALBERT](https:\u002F\u002Farxiv.org\u002Fabs\u002F1909.11942) [[Python]](.\u002Fexample\u002Fpython\u002Falbert_example.py)\n* [Roberta](https:\u002F\u002Farxiv.org\u002Fabs\u002F1907.11692) [[Python]](.\u002Fexample\u002Fpython\u002Froberta_example.py)\n* [Transformer 解码器](https:\u002F\u002Fgithub.com\u002FOpenNMT\u002FOpenNMT-py\u002Fblob\u002Fmaster\u002Fonmt\u002Fdecoders\u002Ftransformer.py) [[Python]](https:\u002F\u002Fgithub.com\u002FTurboNLP\u002FTranslate-Demo)\n* [GPT2](https:\u002F\u002Fwww.ceid.upatras.gr\u002Fwebpages\u002Ffaculty\u002Fzaro\u002Fteaching\u002Falg-ds\u002FPRESENTATIONS\u002FPAPERS\u002F2019-Radford-et-al_Language-Models-Are-Unsupervised-Multitask-%20Learners.pdf) [[Python]](.\u002Fexample\u002Fpython\u002Fgpt2_example.py)\n\n### 用两行 Python 代码加速 BERT 推理\n```python\nimport torch\nimport transformers\nimport turbo_transformers\n\nif __name__ == \"__main__\":\n    turbo_transformers.set_num_threads(4)\n    torch.set_num_threads(4)\n    model_id = \"bert-base-uncased\"\n    model = transformers.BertModel.from_pretrained(model_id)\n    model.eval()\n    cfg = model.config\n\n    input_ids = torch.tensor(\n        ([12166, 10699, 16752, 4454], [5342, 16471, 817, 16022]),\n        dtype=torch.long)\n    position_ids = torch.tensor(([1, 0, 0, 0], [1, 1, 1, 0]), dtype=torch.long)\n    segment_ids = torch.tensor(([1, 1, 1, 0], [1, 0, 0, 0]), dtype=torch.long)\n    torch.set_grad_enabled(False)\n    torch_res = model(\n        input_ids, position_ids=position_ids, token_type_ids=segment_ids\n    )  # sequence_output, pooled_output, (hidden_states), (attentions)\n    torch_seqence_output = torch_res[0][:, 0, :]\n    tt_model = turbo_transformers.BertModel.from_torch(model)\n    res = tt_model(\n        input_ids, position_ids=position_ids,\n        token_type_ids=segment_ids)  # pooled_output, sequence_output\n    tt_seqence_output = res[0]\n```\n\n### 安装\n请注意，构建脚本仅适用于特定的操作系统和软件（PyTorch、OpenNMT、transformers 等）版本。请根据你的需求进行调整。\n\n#### CPU\n```\ngit clone https:\u002F\u002Fgithub.com\u002FTencent\u002FTurboTransformers --recursive\n```\n1. 在你的机器上构建 Docker 镜像和容器。\n```\nsh tools\u002Fbuild_docker_cpu.sh\n# 可选：如果你想在基准测试中比较 onnxrt-mkldnn 的性能，需要将 BUILD_TYPE 设置为 dev，以便将 onnxruntime 编译到 Docker 镜像中，如下所示\nenv BUILD_TYPE=dev sh tools\u002Fbuild_docker_cpu.sh\ndocker run -it --rm --name=turbort -v $PWD:\u002Fworkspace your_image_name \u002Fbin\u002Fbash\n```\n\n2. 在 Docker 中安装 Turbo\n\n方法 1：我想进行单元测试\n```\ncd \u002Fworkspace\nsh tools\u002Fbuild_and_run_unittests.sh $PWD -DWITH_GPU=OFF\n# 你可以通过修改 CMakeList.txt 中的这一行在 Openblas 和 MKL 之间切换\n# set(BLAS_PROVIDER \"mkl\" CACHE STRING \"设置 BLAS 提供库，在 [openblas, mkl, blis] 中选择\")\n```\n\n方法 2：我不想进行单元测试\n```\ncd \u002Fworkspace\nmkdir -p build && cd build\ncmake .. -DWITH_GPU=OFF\nmake -j 4\npip install `find . -name *whl`\n```\n\n3. 在 Docker 中运行基准测试（可选），并与 PyTorch、torch-JIT、onnxruntime 进行比较\n```\ncd benchmark\nbash run_benchmark.sh\n```\n\n4. 在 Docker 中安装 Conda 包（可选）\n```\nsh tool\u002Fbuild_conda_package.sh\n# Conda 包将位于 \u002Fworkspace\u002Fdist\u002F*.tar.bz2\n# 当在该容器之外的其他环境中使用 turbo_transformers 时：conda install your_root_path\u002Fdist\u002F*.tar.bz2\n```\n\n*我们还准备了一个包含 CPU 版 TurboTransformers 以及其他相关工具（如 onnxrt v1.2.0 和 pytorch-jit）的 Docker 镜像，托管在 Docker Hub 上*\n```\ndocker pull thufeifeibear\u002Fturbo_transformers_cpu:latest\n```\n\n#### GPU\n```\ngit clone https:\u002F\u002Fgithub.com\u002FTencent\u002FTurboTransformers --recursive\n```\n1. 在你的机器上构建 Docker 镜像和容器。\n```\n# 你可以修改脚本中的环境变量来指定 CUDA 版本和操作系统版本\nsh tools\u002Fbuild_docker_gpu.sh $PWD\nnvidia-docker run --gpus all --net=host --rm -it -v $PWD:\u002Fworkspace -v \u002Fetc\u002Fpasswd:\u002Fetc\u002Fpasswd --name=your_container_name REPOSITORY:TAG\n# 例如：nvidia-docker run --gpus all --net=host --rm -it -v $PWD:\u002Fworkspace -v \u002Fetc\u002Fpasswd:\u002Fetc\u002Fpasswd --name=turbo_gpu_env thufeifeibear:0.1.1-cuda9.0-ubuntu16.04-gpu-dev\n```\n\n2. 在 Docker 中安装 pip 包并进行单元测试\n```\ncd \u002Fworkspace\nsh tools\u002Fbuild_and_run_unittests.sh $PWD -DWITH_GPU=ON\n```\n\n3. 在 Docker 容器中运行基准测试（可选），并与 PyTorch 进行比较\n```\ncd benchmark\nbash gpu_run_benchmark.sh\n```\n\n我们还准备了一个包含 GPU 版 TurboTransformers 的 Docker 镜像。\n```\ndocker pull thufeifeibear\u002Fturbo_transformers_gpu:latest\n```\n\n#### 使用 Tensor Core（FP16）\n[Tensor Core](https:\u002F\u002Fdeveloper.download.nvidia.cn\u002Fvideo\u002Fgputechconf\u002Fgtc\u002F2019\u002Fpresentation\u002Fs9926-tensor-core-performance-the-ultimate-guide.pdf) 可以加速 GPU 上的计算。默认情况下，TurboTransformers 中它是关闭的。如果你想启用它，在编译代码之前，请在 CMakeLists.txt 中设置选项 WITH_MODULE_BENCHMAKR ON：\n```\noption(WITH_TENSOR_CORE     \"使用 Tensor core 加速\"     ON)\n```\n\n### 使用方法\nTurboTransformers 提供 C++ 和 Python API 接口。我们致力于适应各种线上环境，以降低用户的开发难度。\n\n\n#### 预训练模型加载\n使用 Turbo 的第一步是加载预训练模型。我们提供了加载 [huggingface\u002Ftransformers](https:\u002F\u002Fgithub.com\u002Fhuggingface) 中 PyTorch 和 TensorFlow 预训练模型的方法。具体转换方式是使用 `.\u002Ftools` 目录下的相应脚本将预训练模型转换为 npz 格式文件，然后通过 Turbo 的 C++ 或 Python 接口加载该 npz 文件。特别地，考虑到大多数预训练模型采用 PyTorch 格式并通常与 Python 一起使用，我们还提供了一种直接在 Python 中调用 PyTorch 模型的快捷方式。\n\n\u003Cimg width=\"700\" height=\"150\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FTencent_TurboTransformers_readme_716a3e8354f8.jpg\" alt=\"pretrained\">\n\n#### API 接口\n###### Python API\n请参考 [.\u002Fexample\u002Fpython](.\u002Fexample\u002Fpython \"python\") 中支持模型的示例。\n[TurboNLP\u002FTranslate-Demo](https:\u002F\u002Fgithub.com\u002FTurboNLP\u002FTranslate-Demo \"translate\") 展示了在翻译任务中应用 TurboTransformer 的演示。\n由于 BERT 加速的用户通常需要针对特定任务进行自定义后处理，我们提供了一个编写序列分类应用的示例。\n###### C++ API\n请参阅 [.\u002Fexample\u002Fcpp](.\u002Fexample\u002Fcpp \"C ++\") 中的示例。\n我们的示例提供了 GPU 以及两种 CPU 多线程调用方式：一种是使用多线程执行单次 BERT 推理；另一种则是多个 BERT 推理任务，每个任务由一个线程独立完成。\n用户可以通过 `add_subdirectory` 将 turbo-transformers 链接到自己的代码中。\n\n#### 智能批处理（最小化批处理中的零填充开销）\n通常情况下，当我们将一批长度不同的请求输入到 BERT 模型进行推理时，需要对这些请求进行零填充，以使它们具有相同的长度。例如，如果服务的请求列表长度分别为 (100, 10, 50)，则需要在预处理阶段将其填充为 (100, 100, 100)。这样一来，后两个序列分别有 90% 和 50% 的计算量被浪费掉了。正如 [Effective Transformer](https:\u002F\u002Fgithub.com\u002Fbytedance\u002Feffective_transformer) 所指出的那样，实际上并不需要对输入张量进行零填充。相反，只需对多头注意力机制内部的批量矩阵乘法操作进行填充即可，而这部分填充仅占整个 BERT 计算的一小部分。因此，大部分矩阵乘法运算都可以在不进行零填充的情况下完成。Turbo 提供了一个名为 `BertModelSmartBatch` 的模型，其中包含了智能批处理技术。相关示例可在 [.\u002Fexample\u002Fpython\u002Fbert_smart_pad.py](.\u002Fexample\u002Fpython\u002Fbert_smart_pad.py \"smart_batching\") 中找到。\n\n\n## 如何贡献新模型\n[如何找出代码中的热点？](.\u002Fdocs\u002Fprofiler.md)\n\n[如何添加新层？](.\u002Fturbo_transformers\u002Flayers\u002FREADME.md)\n\n\n## 待办事项\n目前（2020年6月），在不久的将来，我们将增加对低精度模型的支持（CPU int8、GPU FP16）。\n**期待您的贡献！**\n\n## 许可证\nBSD 3-Clause 许可证\n\n## 已知问题\n1. Turbo Transformers 的结果可能与 PyTorch 的结果在小数点后两位之后有所不同。这种差异主要来自 BERT 的输出层。我们使用了一种近似的 GELU 算法，这可能与 PyTorch 的实现有所区别。\n2. Turbo 和 PyTorch 共享同一个 MKL 库。PyTorch 1.5.0 版本的 MKL 可能在 Turbo 中运行较慢，具体原因尚待确认。将 PyTorch 版本降级到 1.1.0 可以提升 Turbo 的性能。\n3. onnxruntime-cpu==1.4.0 和 onnxruntime-gpu==1.3.0 无法同时工作。\n\n## 历史\n1. 2021年1月 v0.6.0，TurboTransformers 支持智能批处理。\n2. 2020年7月 v0.4.0，TurboTransformers 使用 onnxruntime 作为 CPU 后端，支持 GPT2，并新增了量化 BERT。\n3. 2020年7月 v0.3.1，TurboTransformers 在 CPU\u002FGPU 上增加了对 ALbert 和 Roberta 的支持。\n4. 2020年6月 v0.3.0，TurboTransformers 在 CPU\u002FGPU 上增加了对 Transformer 解码器的支持。\n5. 2020年6月 v0.2.1，TurboTransformers 添加了 BLIS 作为 BLAS 提供者选项，在 AMD CPU 上表现更佳。\n6. 2020年4月 v0.0.1，TurboTransformers 正式发布，并实现了 CPU\u002FGPU 上最先进的 BERT 推理速度。\n\n## 引用我们\n如果您在研究论文中使用了 TurboTransformers，请引用以下文献：\n\n```\n@inproceedings{fang2021turbotransformers,\n  title={TurboTransformers: an efficient GPU serving system for transformer models},\n  author={Fang, Jiarui and Yu, Yang and Zhao, Chengduo and Zhou, Jie},\n  booktitle={Proceedings of the 26th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming},\n  pages={389--402},\n  year={2021}\n}\n```\n\n该论文的相关成果可在 `ppopp21_artifact_centos` 分支中找到。\n\n## 联系我们\n虽然我们建议您通过 GitHub Issues 提出问题，但您也可以加入我们的 Turbo 用户群。\n1. 扫描此 [二维码](.\u002Fimages\u002Fnamecode.pdf \"qrcode\")，将我们的联系人添加为您的微信好友。\n2. QQ 群名称：TurboTransformers，群号：1109315167。","# TurboTransformers 快速上手指南\n\nTurboTransformers 是腾讯微信 AI 开源的高性能 Transformer 推理运行时，支持 CPU 和 GPU。它无需耗时的离线调优，支持变长输入和智能批处理（Smart Batching），可显著提升 BERT、GPT2 等模型的推理速度（最高可达 13.6 倍加速），并提供易用的 Python 和 C++ 接口。\n\n## 环境准备\n\n*   **操作系统**: Linux (推荐 Ubuntu 16.04\u002F18.04\u002F20.04)\n*   **编译器**: GCC 5.4+ 或更高版本\n*   **依赖软件**:\n    *   CMake 3.10+\n    *   Python 3.6+\n    *   PyTorch (建议 1.1.0 - 1.7.0，部分版本 MKL 兼容性更佳)\n    *   CUDA & cuDNN (仅 GPU 版本需要，推荐 CUDA 9.0+\u002F10.0+)\n*   **硬件要求**:\n    *   CPU: 支持 AVX2 指令集\n    *   GPU: NVIDIA GPU (支持 Tensor Core 的显卡可获得 FP16 加速)\n\n> **提示**: 为了简化环境配置，官方强烈推荐使用提供的 Docker 镜像进行开发和部署。\n\n## 安装步骤\n\n### 方式一：使用 Docker（推荐）\n\n这是最快捷的方式，已预装所有依赖。\n\n#### 1. CPU 版本\n```bash\n# 拉取镜像\ndocker pull thufeifeibear\u002Fturbo_transformers_cpu:latest\n\n# 运行容器\ndocker run -it --rm --name=turbort -v $PWD:\u002Fworkspace thufeifeibear\u002Fturbo_transformers_cpu:latest \u002Fbin\u002Fbash\n```\n\n#### 2. GPU 版本\n```bash\n# 拉取镜像\ndocker pull thufeifeibear\u002Fturbo_transformers_gpu:latest\n\n# 运行容器 (需确保宿主机安装了 nvidia-docker)\nnvidia-docker run --gpus all --net=host --rm -it -v $PWD:\u002Fworkspace --name=turbo_gpu_env thufeifeibear\u002Fturbo_transformers_gpu:latest \u002Fbin\u002Fbash\n```\n\n### 方式二：源码编译安装\n\n如果你需要在本地环境中直接安装，请按以下步骤操作。\n\n#### 1. 克隆代码\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FTencent\u002FTurboTransformers --recursive\ncd TurboTransformers\n```\n\n#### 2. 编译与安装 (CPU)\n```bash\nmkdir -p build && cd build\ncmake .. -DWITH_GPU=OFF\nmake -j 4\n# 安装生成的 wheel 包\npip install `find . -name *whl`\n```\n\n#### 3. 编译与安装 (GPU)\n```bash\nmkdir -p build && cd build\ncmake .. -DWITH_GPU=ON\nmake -j 4\npip install `find . -name *whl`\n```\n\n> **注意**: 若需启用 GPU Tensor Core (FP16) 加速，请在 cmake 命令中添加 `-DWITH_TENSOR_CORE=ON`。\n\n## 基本使用\n\nTurboTransformers 可以无缝集成到现有的 PyTorch 代码中。只需几行代码即可将 Hugging Face `transformers` 加载的模型转换为高性能推理模型。\n\n以下是一个加速 BERT 推理的最小化示例：\n\n```python\nimport torch\nimport transformers\nimport turbo_transformers\n\nif __name__ == \"__main__\":\n    # 设置线程数以获得最佳性能\n    turbo_transformers.set_num_threads(4)\n    torch.set_num_threads(4)\n    \n    # 1. 加载原生 PyTorch 模型\n    model_id = \"bert-base-uncased\"\n    model = transformers.BertModel.from_pretrained(model_id)\n    model.eval()\n    \n    # 准备输入数据\n    input_ids = torch.tensor(\n        ([12166, 10699, 16752, 4454], [5342, 16471, 817, 16022]),\n        dtype=torch.long)\n    position_ids = torch.tensor(([1, 0, 0, 0], [1, 1, 1, 0]), dtype=torch.long)\n    segment_ids = torch.tensor(([1, 1, 1, 0], [1, 0, 0, 0]), dtype=torch.long)\n    \n    torch.set_grad_enabled(False)\n    \n    # (可选) 原生 PyTorch 推理\n    # torch_res = model(input_ids, position_ids=position_ids, token_type_ids=segment_ids)\n    \n    # 2. 转换为 TurboTransformers 模型 (核心步骤)\n    tt_model = turbo_transformers.BertModel.from_torch(model)\n    \n    # 3. 执行高速推理\n    res = tt_model(\n        input_ids, position_ids=position_ids,\n        token_type_ids=segment_ids)\n    \n    # 获取结果 (pooled_output, sequence_output)\n    tt_seqence_output = res[0]\n    print(\"Inference completed with TurboTransformers.\")\n```\n\n### 进阶特性：智能批处理 (Smart Batching)\n针对不同长度的输入序列，TurboTransformers 提供了 `BertModelSmartBatch` 类，可自动最小化零填充（Zero-Padding）带来的计算浪费，进一步提升吞吐量。具体用法可参考官方示例 `.\u002Fexample\u002Fpython\u002Fbert_smart_pad.py`。","某大型电商平台的智能客服团队正在部署基于 BERT 模型的实时意图识别系统，以应对大促期间每秒数千次的用户咨询请求。\n\n### 没有 TurboTransformers 时\n- **响应延迟高**：面对变长输入的句子，传统 PyTorch 推理需强制填充至最大长度，导致大量无效计算，平均响应时间超过 80ms，难以满足实时交互需求。\n- **资源浪费严重**：为维持并发量不得不堆砌 GPU 实例，但受限于固定 Batch Size 和序列长度，硬件利用率长期低于 40%，成本居高不下。\n- **运维调优复杂**：每次调整业务流量或模型参数，都需要耗时的离线编译与预处理（如 TensorRT 引擎重构建），无法动态适应突发流量。\n- **开发集成困难**：现有加速方案往往需要重写大量 C++ 代码或修改模型结构，算法工程师难以快速将实验模型转化为线上服务。\n\n### 使用 TurboTransformers 后\n- **推理速度倍增**：利用智能批处理（Smart Batching）技术自动消除零填充开销，支持动态变长输入，使核心接口响应时间降至 40ms 以内，吞吐量提升 2.1 倍。\n- **弹性伸缩自如**：无需离线调优即可在运行时实时调整 Batch Size 和序列长度，完美适配早晚高峰的流量波动，同等算力下支撑的并发请求数翻倍。\n- **极简接入流程**：仅需在原有 PyTorch 代码中增加两行调用指令，即可无缝切换至 TurboTransformers 后端，算法团队半天内完成全量模型上线。\n- **软硬性能兼优**：同时在 CPU 和 GPU 环境下获得极致加速效果，不仅降低了云端 GPU 依赖，还让边缘侧 CPU 部署成为高性能备选方案。\n\nTurboTransformers 通过“零改造、动态变长、极致加速”的特性，将原本沉重的 Transformer 推理任务变成了轻量高效的实时服务，显著降低了运营成本并提升了用户体验。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FTencent_TurboTransformers_948d3a34.jpg","Tencent","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FTencent_f7e55588.png","",null,"https:\u002F\u002Fopensource.tencent.com","https:\u002F\u002Fgithub.com\u002FTencent",[82,86,90,94,98,102],{"name":83,"color":84,"percentage":85},"C++","#f34b7d",45.5,{"name":87,"color":88,"percentage":89},"Python","#3572A5",43.9,{"name":91,"color":92,"percentage":93},"Cuda","#3A4E3A",5.7,{"name":95,"color":96,"percentage":97},"CMake","#DA3434",3.1,{"name":99,"color":100,"percentage":101},"Shell","#89e051",1.6,{"name":103,"color":104,"percentage":105},"C","#555555",0.1,1545,207,"2026-04-02T08:40:05","NOASSERTION",4,"Linux","GPU 版本可选，需 NVIDIA GPU 支持 CUDA（脚本示例提及 CUDA 9.0），支持开启 Tensor Core (FP16) 加速","未说明",{"notes":115,"python":116,"dependencies":117},"官方构建脚本主要针对 Linux 环境（提供 Docker 镜像构建脚本）；CPU 后端支持 OpenBLAS、MKL 和 BLIS；已知问题：PyTorch 1.5.0 的 MKL 可能导致性能下降，建议降级至 1.1.0；结果可能与 PyTorch 有微小精度差异（源于近似 GELU 算法）；支持智能批处理（Smart Batching）以减少零填充开销。","未说明 (需配合 PyTorch 使用)",[118,95,119,120,121],"PyTorch (推荐 1.1.0 以获得最佳性能，已知 1.5.0 MKL 存在性能问题)","BLAS 库 (OpenBLAS, MKL, 或 BLIS)","transformers (HuggingFace)","ONNX Runtime (可选，作为 CPU 后端)",[26,13,14],[124,125,126,127,128,129,130,131,132,133,134,135],"nlp","transformer","bert","decoder","gpu","machine-translation","inference","huggingface-transformers","pytorch","albert","roberta","gpt2","2026-03-27T02:49:30.150509","2026-04-06T08:09:06.472332",[139,144,149,154,159,164],{"id":140,"question_zh":141,"answer_zh":142,"source_url":143},12867,"为什么使用 TurboTransformers 优化后的模型输出结果相同，不随输入变化？","这通常是因为模型权重未正确初始化导致的。请检查启动时的警告信息，如果看到类似 'Some weights are not initialized correctly' 的提示（例如 cls.predictions.bias 等权重），说明模型加载存在问题。虽然随机权重理论上应产生不同输出，但错误的初始化可能导致计算图固定。建议检查代码中从 PyTorch 模型转换到 TurboTransformers 模型的步骤，确保权重正确复制，并确认环境配置无误。","https:\u002F\u002Fgithub.com\u002FTencent\u002FTurboTransformers\u002Fissues\u002F256",{"id":145,"question_zh":146,"answer_zh":147,"source_url":148},12868,"为什么在 CPU 上运行 TurboTransformers 比原始 PyTorch 模型还要慢？","这通常是由于 Docker 镜像中内置的 MKL (Math Kernel Library) 版本在某些 CPU 上性能不佳造成的。解决方案是拉取维护者最新更新的 Docker 镜像，其中重新安装了 MKL：\n`docker pull thufeifeibear\u002Fturbo_transformers_cpu:latest`\n此外，可以通过设置环境变量 `MKL_VERBOSE=1` 来观察 PyTorch 和 Turbo 之间 MKL 例程的时间差异，以进一步诊断是否由特定 MKL 版本或环境变量配置不当引起。","https:\u002F\u002Fgithub.com\u002FTencent\u002FTurboTransformers\u002Fissues\u002F127",{"id":150,"question_zh":151,"answer_zh":152,"source_url":153},12869,"项目支持长序列模型（如 BigBird）吗？","目前该项目尚未支持长序列模型所需的稀疏注意力机制（sparse attention kernels）。如果您尝试运行此类模型（如 BigBird），可能会遇到编译错误或运行时不支持的情况。维护者指出，这类模型需要特定的算子支持，而当前版本暂未实现。","https:\u002F\u002Fgithub.com\u002FTencent\u002FTurboTransformers\u002Fissues\u002F231",{"id":155,"question_zh":156,"answer_zh":157,"source_url":158},12870,"如何在内存中加载 Albert 模型进行推理？","Albert 模型的支持已在 `develop` 分支中提供。您可以从内存中的 PyTorch 格式模型加载 Albert，但目前尚不支持直接从磁盘加载预训练模型或 npz 文件。具体的加载和使用方法可以参考项目中的测试文件：`turbo_transformers\u002Fpython\u002Ftests\u002Falbert_model_test.py`。","https:\u002F\u002Fgithub.com\u002FTencent\u002FTurboTransformers\u002Fissues\u002F110",{"id":160,"question_zh":161,"answer_zh":162,"source_url":163},12871,"遇到 'data type mismatch' (数据类型不匹配) 的 RuntimeError 该如何调试？","当遇到张量数据类型不匹配的错误（例如 `enforce errordetails::IsDataType\u003CT>(t.dtype)`）时，可以通过提高日志详细级别来获取更具体的错误堆栈和上下文信息。请在代码初始化阶段添加以下命令：\n`turbo_transformers.set_stderr_verbose_level(3)`\n这将输出详细的调试信息，帮助定位具体是哪个算子或张量导致了类型冲突。","https:\u002F\u002Fgithub.com\u002FTencent\u002FTurboTransformers\u002Fissues\u002F112",{"id":165,"question_zh":166,"answer_zh":167,"source_url":168},12872,"为什么 embedding_lookup 算子在 GPU 上的速度比 TensorFlow 慢？","如果在调整 batch_size、vocab_size 和 seq_len 后速度仍然不如 TensorFlow，可能是因为 TurboTransformers 中该算子的实现尚未达到最优，或者缺少针对特定硬件的深度优化。维护者表示项目欢迎社区贡献算子库（例如当时 conv1d 算子尚未实现），如果遇到性能瓶颈，可以考虑参与贡献或联系维护者探讨具体的优化策略。","https:\u002F\u002Fgithub.com\u002FTencent\u002FTurboTransformers\u002Fissues\u002F114",[170,175,180,185,190,195,200],{"id":171,"version":172,"summary_zh":173,"released_at":174},71528,"v0.5.1","阿尔伯特模型使用模型感知分配器。","2020-11-25T09:46:57",{"id":176,"version":177,"summary_zh":178,"released_at":179},71529,"v0.5.0","为Bert模型添加模型感知分配器。","2020-11-19T12:18:06",{"id":181,"version":182,"summary_zh":183,"released_at":184},71530,"v0.4.2","使用 ONNX Runtime 添加量化后的 BERT。","2020-08-19T09:12:33",{"id":186,"version":187,"summary_zh":188,"released_at":189},71531,"v0.4.1","使用 onnxruntime-cpu 作为 CPU 后端，与我们自研的实现并行运行。","2020-08-12T02:23:59",{"id":191,"version":192,"summary_zh":193,"released_at":194},71532,"v0.3.0","支持 OpenNMT-py 中使用的 Transformer 解码器。  \n新的 GPU 内存分配器。  \n兼容 PyTorch 1.5.0 版本。","2020-06-30T04:09:13",{"id":196,"version":197,"summary_zh":198,"released_at":199},71533,"0.2.1","将 blis 添加到 BLAS 选项中。","2020-06-11T03:58:30",{"id":201,"version":202,"summary_zh":203,"released_at":204},71534,"v0.0.1","CPU和GPU上的Bert加速。","2020-04-25T14:34:24"]