[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-bilibili--Index-1.9B":3,"tool-bilibili--Index-1.9B":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 真正成长为懂上",148568,2,"2026-04-09T23:34:24",[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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108111,"2026-04-08T11:23:26",[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":66,"readme_en":67,"readme_zh":68,"quickstart_zh":69,"use_case_zh":70,"hero_image_url":71,"owner_login":72,"owner_name":72,"owner_avatar_url":73,"owner_bio":74,"owner_company":75,"owner_location":75,"owner_email":75,"owner_twitter":75,"owner_website":76,"owner_url":77,"languages":78,"stars":87,"forks":88,"last_commit_at":89,"license":90,"difficulty_score":32,"env_os":91,"env_gpu":92,"env_ram":93,"env_deps":94,"category_tags":104,"github_topics":105,"view_count":32,"oss_zip_url":75,"oss_zip_packed_at":75,"status":17,"created_at":108,"updated_at":109,"faqs":110,"releases":141},6173,"bilibili\u002FIndex-1.9B","Index-1.9B","A lightweight multilingual LLM","Index-1.9B 是一款轻量级的多语言大语言模型，专为在有限算力下实现高效智能交互而设计。它基于 2.8 万亿词料（以中英文为主）预训练而成，参数量仅为 19 亿，却能在多项基准测试中媲美甚至超越同量级乃至更大规模的模型，有效解决了小型模型往往能力不足、难以兼顾多语言与长文本处理的痛点。\n\n该系列包含多个版本以满足不同需求：基础版适合二次开发；对话版（Chat）因融入了丰富的互联网社区语料，拥有更生动有趣的聊天能力及出色的东亚语言翻译水平；角色版（Character）支持少样本角色扮演定制；最新推出的 32K 版本更是突破了小模型的上下文限制，能一次性阅读超过 3.5 万字的文章。\n\nIndex-1.9B 非常适合开发者集成到移动端或边缘设备应用中，也利于研究人员探索小模型的高效训练策略，同时普通用户也可通过在线演示体验流畅的多语言对话与角色扮演乐趣。其独特亮点在于极致的“小而美”：不仅支持 32K 超长上下文，还适配了 llamacpp 和 Ollama 等本地部署框架，让高性能 AI 触手可及。","\u003Cdiv align=\"center\">\n\u003Ch1>\n  Index-1.9B\n\u003C\u002Fh1>\n\u003C\u002Fdiv>\n\u003Cp align=\"center\">\n  \u003Ca href=\".\u002FREADME_zh.md\" target=\"_blank\">切换到中文\u003C\u002Fa> |\n  Online:\n  \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FIndexTeam\u002FIndex-1.9B\" target=\"_blank\">Chat\u003C\u002Fa> and\n  \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FIndexTeam\u002FIndex-1.9B-Character\" target=\"_blank\">Role-playing\u003C\u002Fa> |\n  QQ: \u003Ca href=\"media\u002Fgroup_qrcode.jpg\" target=\"_blank\">QQ Group\u003C\u002Fa> \n\u003C\u002Fp>\n\n### Recent Updates  :star2:\n1. Open-source 32K long-context model Index-1.9B-32K. Details: 📖 [Index-1.9B-32K_Long_Context_Technical_Report.md](https:\u002F\u002Fgithub.com\u002Fbilibili\u002FIndex-1.9B\u002Fblob\u002Fmain\u002FIndex-1.9B-32K_Long_Context_Technical_Report.md)\n2. Adapted to llamacpp and Ollama, see [Index-1.9B-Chat-GGUF](https:\u002F\u002Fhuggingface.co\u002FIndexTeam\u002FIndex-1.9B-Chat-GGUF)\n3. Open source Checkpoint before Decay available for research, see [Index-1.9B-Constant-LR](https:\u002F\u002Fhuggingface.co\u002FIndexTeam\u002FIndex-1.9B-Constant-LR)\n\n## Model Introduction\n\nThe Index-1.9B series is a lightweight version of the Index series models, including the following models:\n- Index-1.9B base: Base model with 1.9 billion non-embedding parameters, pre-trained on 2.8T mainly Chinese and English corpus, leading in multiple evaluation benchmarks compared to models of the same level.\n- Index-1.9B pure: Control version of the base model with the same parameters and training strategy, but strictly filtered out all instruction-related data from the corpus to verify the impact of instructions on benchmarks.\n- Index-1.9B chat: A dialogue model aligned with SFT and DPO based on the index-1.9B base. We found that due to the introduction of a lot of internet community corpus in our pre-training, the model has significantly more interesting chat capabilities and strong multilingual (especially East Asian languages) translation abilities compared to models of the same level.\n- Index-1.9B character: Introduces RAG on top of SFT and DPO to achieve \u003Cb>fewshots role-playing\u003C\u002Fb> customization.\n- Index-1.9B-32K: Index-1.9B-32K is a language model with only 1.9B parameters, but it supports a 32K context length (meaning this extremely, extremely small model can read documents of over 35,000 words in one go).\n\n## Evaluation Results\n\n|Model|Average score|Average English score|MMLU|CEVAL|CMMLU|HellaSwag|Arc-C|Arc-E|\n|----|----|----|----|----|----|----|----|----|\n|Google Gemma 2B|41.58|46.77|41.81|31.36|31.02|66.82|36.39|42.07|\n|Phi-2 (2.7B)|58.89|**72.54**|57.61|31.12|32.05|70.94|74.51|87.1|\n|Qwen1.5-1.8B|58.96|59.28|47.05|59.48|57.12|58.33|56.82|74.93|\n|Qwen2-1.5B(report)|**65.17**|62.52 |56.5|70.6|70.3|66.6|43.9|83.09|\n|MiniCPM-2.4B-SFT|62.53|68.75|53.8|49.19|50.97|67.29|69.44|84.48|\n|**Index-1.9B-Pure**|50.61 |52.99 |46.24|46.53|45.19|62.63|41.97|61.1|\n|**Index-1.9B**|**64.92** |**69.93**|52.53|57.01|52.79|80.69|65.15|81.35|\n|Llama2-7B|50.79|60.31|44.32|32.42|31.11|76|46.3|74.6|\n|Mistral-7B (report) |\u002F|**69.23**|60.1|\u002F|\u002F|81.3|55.5|80|\n|Baichuan2-7B|54.53|53.51|54.64|56.19|56.95|25.04|57.25|77.12|\n|Llama2-13B|57.51|66.61|55.78|39.93|38.7|76.22|58.88|75.56|\n|Baichuan2-13B|68.90|71.69|59.63|59.21|61.27|72.61|70.04|84.48|\n|MPT-30B (report)|\u002F|63.48|46.9|\u002F|\u002F|79.9|50.6|76.5|\n|Falcon-40B (report)|\u002F|68.18|55.4|\u002F|\u002F|83.6|54.5|79.2|\n\nEvaluation code is based on [OpenCompass](https:\u002F\u002Fgithub.com\u002Fopen-compass\u002Fopencompass) with compatibility modifications. See the [evaluate](.\u002Fevaluate\u002F) folder for details.\n\n## Model Download\n\n| HuggingFace   | ModelScope  |\n|:-------:|:-------:|\n| 🤗 [Index-1.9B-Chat](https:\u002F\u002Fhuggingface.co\u002FIndexTeam\u002FIndex-1.9B-Chat) |[Index-1.9B-Chat](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FIndexTeam\u002FIndex-1.9B-Chat) |\n| 🤗 [Index-1.9B-Character](https:\u002F\u002Fhuggingface.co\u002FIndexTeam\u002FIndex-1.9B-Character) (Role-playing)| [Index-1.9B-Character](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FIndexTeam\u002FIndex-1.9B-Character) (Role-playing)|\n| 🤗 [Index-1.9B-Base](https:\u002F\u002Fhuggingface.co\u002FIndexTeam\u002FIndex-1.9B) | [Index-1.9B-Base](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FIndexTeam\u002FIndex-1.9B) |\n| 🤗 [Index-1.9B-Base-Pure](https:\u002F\u002Fhuggingface.co\u002FIndexTeam\u002FIndex-1.9B-Pure) |  [Index-1.9B-Base-Pure](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FIndexTeam\u002FIndex-1.9B-Pure) \n| 🤗 [Index-1.9B-32K](https:\u002F\u002Fhuggingface.co\u002FIndexTeam\u002FIndex-1.9B-32K) (32K Long Context)|  [Index-1.9B-32K](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FIndexTeam\u002FIndex-1.9B-32K) (32K Long Context)\n\n## Usage Instructions\n-  **Note: `Index-1.9B-32K` can only be launched using this tool: `demo\u002Fcli_long_text_demo.py`!!!**\n### Environment Setup\n\n1. Download this repository:\n\n```shell\ngit clone https:\u002F\u002Fgithub.com\u002Fbilibili\u002FIndex-1.9B\ncd Index-1.9B\n```\n\n2. Install dependencies using pip:\n\n```shell\npip install -r requirements.txt\n```\n### Loading with Transformers\n\nYou can load the Index-1.9B-Chat model for dialogue using the following code:\n\n```python\nimport argparse\nfrom transformers import AutoTokenizer, pipeline\n\n# Attention! The directory must not contain \".\" and can be replaced with \"_\".\nparser = argparse.ArgumentParser()\nparser.add_argument('--model_path', default=\".\u002FIndexTeam\u002FIndex-1.9B-Chat\u002F\", type=str, help=\"\")\nparser.add_argument('--device', default=\"cpu\", type=str, help=\"\") # also could be \"cuda\" or \"mps\" for Apple silicon\nargs = parser.parse_args()\n\ntokenizer = AutoTokenizer.from_pretrained(args.model_path, trust_remote_code=True)\ngenerator = pipeline(\"text-generation\",\n                    model=args.model_path,\n                    tokenizer=tokenizer, trust_remote_code=True, \n                    device=args.device)\n\n\nsystem_message = \"你是由哔哩哔哩自主研发的大语言模型，名为“Index”。你能够根据用户传入的信息，帮助用户完成指定的任务，并生成恰当的、符合要求的回复。\"\nquery = \"续写 天不生我金坷垃\"\nmodel_input = []\nmodel_input.append({\"role\": \"system\", \"content\": system_message})\nmodel_input.append({\"role\": \"user\", \"content\": query})\n\nmodel_output = generator(model_input, max_new_tokens=300, top_k=5, top_p=0.8, temperature=0.3, repetition_penalty=1.1, do_sample=True)\n\nprint('User:', query)\nprint('Model:', model_output)\n```\n\n### Web Demo\n\nDepends on Gradio, install with:\n```shell\npip install gradio==4.29.0\n```\nStart a web server with the following code. After entering the access address in the browser, you can use the Index-1.9B-Chat model for dialogue:\n```shell\npython demo\u002Fweb_demo.py --port='port' --model_path='\u002Fpath\u002Fto\u002Fmodel\u002F'\n```\n\n\n### Terminal Demo\n **Note: `Index-1.9B-32K` can only be launched using this tool: `demo\u002Fcli_long_text_demo.py`!!!**\n\nStart a terminal demo with the following code to use the Index-1.9B-Chat model for dialogue:\n```shell\npython demo\u002Fcli_demo.py  --model_path='\u002Fpath\u002Fto\u002Fmodel\u002F'\n```\n\n### Openai Api Demo\n\nDepends on Flask, install with:\n```shell\npip install flask==2.2.5\n```\nStart a Flask API with the following code:\n```shell\npython demo\u002Fopenai_demo.py --model_path='\u002Fpath\u002Fto\u002Fmodel\u002F'\n```\nYou can conduct dialogues via command line:\n```shell\ncurl http:\u002F\u002F127.0.0.1:8010\u002Fv1\u002Fchat\u002Fcompletions \\\n    -H \"Content-Type: application\u002Fjson\" \\\n    -d '{\n    \"messages\": [\n    {\"role\": \"system\", \"content\": \"你是由哔哩哔哩自主研发的大语言模型，名为“Index”。你能够根据用户传入的信息，帮助用户完成指定的任务，并生成恰当的、符合要求的回复。\"},\n    {\"role\": \"user\", \"content\": \"花儿为什么这么红？\"}\n    ]\n    }'\n```\n\n# Index-1.9B-32K Long Context Model Introduction\n## Model Overview\nIndex-1.9B-32K is a language model with only 1.9 billion parameters, yet it supports a context length of 32K (meaning this extremely small model can read documents of over 35,000 words in one go). The model has undergone Continue Pre-Training and Supervised Fine-Tuning (SFT) specifically for texts longer than 32K tokens, based on carefully curated long-text training data and self-built long-text instruction sets. The model is now open-source on both Hugging Face and ModelScope.\n\nDespite its small size (about 2% of models like GPT-4), Index-1.9B-32K demonstrates excellent long-text processing capabilities. \nAs shown in the figure below, our 1.9B-sized model's score even surpasses that of the 7B-sized model. Below is a comparison with models like GPT-4 and Qwen2:\n\n\u003Cp align=\"center\"> \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbilibili_Index-1.9B_readme_b208a664ad04.png\" alt=\"\" width=\"800\"> \n\u003C\u002Fp> \u003Cp align=\"center\">\u003Cstrong>Comparison of Index-1.9B-32K with GPT-4, Qwen2, and other models in Long Context capability\u003C\u002Fstrong>\n\u003C\u002Fp>\n\nIn a 32K-length needle-in-a-haystack test, Index-1.9B-32K achieved excellent results, as shown in the figure below. The only exception was a small yellow spot (91.08 points) in the region of (32K length, 10% depth), with all other areas performing excellently in mostly green zones.\n\u003Cp align=\"center\">\n    \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbilibili_Index-1.9B_readme_d3d333dcc112.png\" alt=\"\" width=\"900\">\n\u003C\u002Fp>\n\u003Cp align=\"center\">\u003Cstrong>NeedleBench Evaluation\u003C\u002Fstrong>\u003C\u002Fp>\n\n## Index-1.9B-32K Model Download, Usage, and Technical Report:\nFor details on downloading, usage, and the technical report for Index-1.9B-32K, see:\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fbilibili\u002FIndex-1.9B\u002Fblob\u002Fmain\u002FIndex-1.9B-32K_Long_Context_Technical_Report.md\" style=\"color: blue;\">\n    📖 \u003Cstrong>Index-1.9B-32K Long Context Technical Report\u003C\u002Fstrong>\n\u003C\u002Fa>\n\n---\n---\n# Details and Disclaimer for the Index Series Models\n## Index-1.9B-Chat Output Examples\n\n- Below are some examples using `web_demo.py` to get Index-1.9B-Chat outputs.\n    ![gradio demo](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbilibili_Index-1.9B_readme_951e7c44b687.png)\n    ![gradio demo](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbilibili_Index-1.9B_readme_8a67ee61378b.png)\n- Change the `System Message` to role-play a stereotype of bilibili user!\n    ![gradio demo](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbilibili_Index-1.9B_readme_a07b568636bc.png)\n- Translate Chinese to Japanese\n    ![gradio demo](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbilibili_Index-1.9B_readme_71d511fe9e81.png)\n- Translate Japanese to Chinese \n    ![gradio demo](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbilibili_Index-1.9B_readme_b3496d2b0f90.png)\n\n## Role Playing\nWe have simultaneously open-sourced the role-playing model and the accompanying framework.\n![gradio demo](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbilibili_Index-1.9B_readme_491dca126717.png)\n\n* We currently have the character `三三` built-in.\n* If you need to create your own character, please prepare a dialogue corpus similar to [roleplay\u002Fcharacter\u002F三三.csv](roleplay\u002Fcharacter\u002F三三.csv) (note that the file name should match the name of the character you want to create) and a corresponding character description. Click `生成角色` to create it successfully.\n* If the corresponding character has already been created, please directly enter the character you want to converse with in the `Role name` field, input your `query`, and click `submit` to start the conversation.\n\nFor detailed usage, please refer to the [roleplay](.\u002Froleplay) folder.\n\n## Long Text Translation and Summary（Index-1.9B-32K）\n- Run the interactive tool for long text: **demo\u002Fcli_long_text_demo.py**\n- The model will, by default, read this file: data\u002Fuser_long_text.txt and summarize the text in Chinese.\n- You can open a new window and modify the file content in real-time, and the model will read the updated file and summarize it.\n\n```shell\ncd demo\u002F\nCUDA_VISIBLE_DEVICES=0 python cli_long_text_demo.py --model_path '\u002Fpath\u002Fto\u002Fmodel\u002F' --input_file_path data\u002Fuser_long_text.txt\n```\n- Run & Interaction Example (Translation and summarization of the Bilibili financial report released on 2024.8.22 in English --- [Original English report here](https:\u002F\u002Fgithub.com\u002Fbilibili\u002FIndex-1.9B\u002Ftree\u002Fmain\u002Fdemo\u002Fdata\u002Fuser_long_text.txt))：\n\n\u003Cp align=\"center\">\n    \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbilibili_Index-1.9B_readme_c92c8448b2cf.png\" alt=\"\" width=\"1000\">\n\u003C\u002Fp>\n\u003Cp align=\"center\">\u003Cstrong>Translation and Summary (Bilibili financial report released on 2024.8.22)\u003C\u002Fstrong>\u003C\u002Fp>\n\n\n## Quantization\n\nDepends on bitsandbytes, installation command:\n```shell\npip install bitsandbytes==0.43.0\n```\nYou can use the following script to perform int4 quantization, which has less performance loss and further saves video memory usage.\n```python\nimport torch\nimport argparse\nfrom transformers import (\n    AutoModelForCausalLM,\n    AutoTokenizer,\n    TextIteratorStreamer,\n    GenerationConfig,\n    BitsAndBytesConfig\n)\n\nparser = argparse.ArgumentParser()\nparser.add_argument('--model_path', default=\"\", type=str, help=\"\")\nparser.add_argument('--save_model_path', default=\"\", type=str, help=\"\")\nargs = parser.parse_args()\n\ntokenizer = AutoTokenizer.from_pretrained(args.model_path, trust_remote_code=True)\nquantization_config = BitsAndBytesConfig(\n    load_in_4bit=True,\n    bnb_4bit_compute_dtype=torch.float16,\n    bnb_4bit_use_double_quant=True,\n    bnb_4bit_quant_type=\"nf4\",\n    llm_int8_threshold=6.0,\n    llm_int8_has_fp16_weight=False,\n)\nmodel = AutoModelForCausalLM.from_pretrained(args.model_path, \n                                             device_map=\"auto\",\n                                             torch_dtype=torch.float16,\n                                             quantization_config=quantization_config,\n                                             trust_remote_code=True)\nmodel.save_pretrained(args.save_model_path)\ntokenizer.save_pretrained(args.save_model_path)\n```\n\n### Fine-tuning\n\nFollow the steps in the [fine-tuning tutorial](https:\u002F\u002Fgithub.com\u002Fbilibili\u002FIndex-1.9B\u002Fblob\u002Fmain\u002Ffinetune\u002FREADME.md)  to quickly fine-tune the Index-1.9B-Chat model. Give it a try and customize your exclusive Index model!\n\n## Limitations and Disclaimer\n\nIndex-1.9B may generate inaccurate, biased, or otherwise objectionable content in certain situations. The model cannot understand, express personal opinions, or make value judgments. Its outputs do not represent the views and positions of the model developers. Therefore, please use the generated content with caution. Users should independently evaluate and verify the content generated by the model and should not disseminate harmful content. Developers should conduct safety tests and fine-tuning according to specific applications before deploying any related applications.\n\nWe strongly advise against using these models to create or disseminate harmful information or engage in activities that may harm public, national, or social security or violate regulations. Do not use the models for internet services without proper safety review and filing. We have made every effort to ensure the compliance of the training data, but due to the complexity of the model and data, unforeseen issues may still exist. We will not be held responsible for any problems arising from the use of these models, whether related to data security, public opinion risks, or any risks and issues caused by misunderstanding, misuse, dissemination, or non-compliant use of the model.\n\n## Model Open Source License\n\nUsing the source code from this repository requires compliance with the [Apache-2.0](LICENSE). The use of the Index-1.9B model weights requires compliance with the [INDEX_MODEL_LICENSE](INDEX_MODEL_LICENSE).\n\nThe Index-1.9B model weights are **fully open** for academic research and support **free commercial use**.\n\n## Citation\nIf you think our work is helpful to you, please feel free to cite it!\n\n```\n@article{Index,\n  title={Index1.9B Technical Report},\n  year={2024}\n}\n```\n## Extended Works\nlibllm: https:\u002F\u002Fgithub.com\u002Fling0322\u002Flibllm\u002Fblob\u002Fmain\u002Fexamples\u002Fpython\u002Frun_bilibili_index.py\n\nchatllm.cpp：https:\u002F\u002Fgithub.com\u002Ffoldl\u002Fchatllm.cpp\u002Fblob\u002Fmaster\u002Fdocs\u002Frag.md#role-play-with-rag\n\nollama：https:\u002F\u002Follama.com\u002Fmilkey\u002Fbilibili-index\n\nself llm: https:\u002F\u002Fgithub.com\u002Fdatawhalechina\u002Fself-llm\u002Fblob\u002Fmaster\u002Fbilibili_Index-1.9B\u002F04-Index-1.9B-Chat%20Lora%20微调.md\n","\u003Cdiv align=\"center\">\n\u003Ch1>\n  Index-1.9B\n\u003C\u002Fh1>\n\u003C\u002Fdiv>\n\u003Cp align=\"center\">\n  \u003Ca href=\".\u002FREADME_zh.md\" target=\"_blank\">切换到中文\u003C\u002Fa> |\n  Online:\n  \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FIndexTeam\u002FIndex-1.9B\" target=\"_blank\">Chat\u003C\u002Fa> and\n  \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FIndexTeam\u002FIndex-1.9B-Character\" target=\"_blank\">Role-playing\u003C\u002Fa> |\n  QQ: \u003Ca href=\"media\u002Fgroup_qrcode.jpg\" target=\"_blank\">QQ Group\u003C\u002Fa> \n\u003C\u002Fp>\n\n### 最新更新 :star2:\n1. 开源32K长上下文模型Index-1.9B-32K。详情：📖 [Index-1.9B-32K_Long_Context_Technical_Report.md](https:\u002F\u002Fgithub.com\u002Fbilibili\u002FIndex-1.9B\u002Fblob\u002Fmain\u002FIndex-1.9B-32K_Long_Context_Technical_Report.md)\n2. 适配llamacpp和Ollama，详见[Index-1.9B-Chat-GGUF](https:\u002F\u002Fhuggingface.co\u002FIndexTeam\u002FIndex-1.9B-Chat-GGUF)\n3. 开放衰减前的检查点供研究使用，详见[Index-1.9B-Constant-LR](https:\u002F\u002Fhuggingface.co\u002FIndexTeam\u002FIndex-1.9B-Constant-LR)\n\n## 模型介绍\n\nIndex-1.9B系列是Index系列模型的轻量级版本，包含以下模型：\n- Index-1.9B base：基础模型，拥有19亿非嵌入参数，在主要由中文和英文组成的2.8T语料上预训练而成，在多个评测基准上表现优于同级别模型。\n- Index-1.9B pure：与基础模型参数和训练策略相同，但严格过滤掉了所有指令相关数据的对照版本，用于验证指令对基准测试的影响。\n- Index-1.9B chat：基于Index-1.9B base，通过SFT和DPO对齐得到的对话模型。我们发现，由于在预训练中引入了大量互联网社区语料，该模型相比同级别模型具有更有趣的聊天能力以及强大的多语言（尤其是东亚语言）翻译能力。\n- Index-1.9B character：在SFT和DPO的基础上引入RAG，实现\u003Cb>少样本角色扮演\u003C\u002Fb>定制。\n- Index-1.9B-32K：Index-1.9B-32K是一款仅有19亿参数的语言模型，却支持32K的上下文长度（这意味着这个极其、极其小型的模型可以一次性读取超过35,000字的文档）。\n\n## 评估结果\n\n|模型|平均分|英语平均分|MMLU|CEVAL|CMMLU|HellaSwag|Arc-C|Arc-E|\n|----|----|----|----|----|----|----|----|----|\n|Google Gemma 2B|41.58|46.77|41.81|31.36|31.02|66.82|36.39|42.07|\n|Phi-2 (2.7B)|58.89|**72.54**|57.61|31.12|32.05|70.94|74.51|87.1|\n|Qwen1.5-1.8B|58.96|59.28|47.05|59.48|57.12|58.33|56.82|74.93|\n|Qwen2-1.5B(报告)|**65.17**|62.52 |56.5|70.6|70.3|66.6|43.9|83.09|\n|MiniCPM-2.4B-SFT|62.53|68.75|53.8|49.19|50.97|67.29|69.44|84.48|\n|**Index-1.9B-Pure**|50.61 |52.99 |46.24|46.53|45.19|62.63|41.97|61.1|\n|**Index-1.9B**|**64.92** |**69.93**|52.53|57.01|52.79|80.69|65.15|81.35|\n|Llama2-7B|50.79|60.31|44.32|32.42|31.11|76|46.3|74.6|\n|Mistral-7B(报告) |\u002F|**69.23**|60.1|\u002F|\u002F|81.3|55.5|80|\n|Baichuan2-7B|54.53|53.51|54.64|56.19|56.95|25.04|57.25|77.12|\n|Llama2-13B|57.51|66.61|55.78|39.93|38.7|76.22|58.88|75.56|\n|Baichuan2-13B|68.90|71.69|59.63|59.21|61.27|72.61|70.04|84.48|\n|MPT-30B(报告)|\u002F|63.48|46.9|\u002F|\u002F|79.9|50.6|76.5|\n|Falcon-40B(报告)|\u002F|68.18|55.4|\u002F|\u002F|83.6|54.5|79.2|\n\n评估代码基于[OpenCompass](https:\u002F\u002Fgithub.com\u002Fopen-compass\u002Fopencompass)，并进行了兼容性修改。详细信息请参阅[evaluate](.\u002Fevaluate\u002F)文件夹。\n\n## 模型下载\n\n| HuggingFace   | ModelScope  |\n|:-------:|:-------:|\n| 🤗 [Index-1.9B-Chat](https:\u002F\u002Fhuggingface.co\u002FIndexTeam\u002FIndex-1.9B-Chat) |[Index-1.9B-Chat](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FIndexTeam\u002FIndex-1.9B-Chat) |\n| 🤗 [Index-1.9B-Character](https:\u002F\u002Fhuggingface.co\u002FIndexTeam\u002FIndex-1.9B-Character) (角色扮演)| [Index-1.9B-Character](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FIndexTeam\u002FIndex-1.9B-Character) (角色扮演)|\n| 🤗 [Index-1.9B-Base](https:\u002F\u002Fhuggingface.co\u002FIndexTeam\u002FIndex-1.9B) | [Index-1.9B-Base](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FIndexTeam\u002FIndex-1.9B) |\n| 🤗 [Index-1.9B-Base-Pure](https:\u002F\u002Fhuggingface.co\u002FIndexTeam\u002FIndex-1.9B-Pure) |  [Index-1.9B-Base-Pure](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FIndexTeam\u002FIndex-1.9B-Pure) \n| 🤗 [Index-1.9B-32K](https:\u002F\u002Fhuggingface.co\u002FIndexTeam\u002FIndex-1.9B-32K) (32K长上下文)|  [Index-1.9B-32K](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FIndexTeam\u002FIndex-1.9B-32K) (32K长上下文)\n\n## 使用说明\n-  **注意：`Index-1.9B-32K`只能使用此工具启动：`demo\u002Fcli_long_text_demo.py`!!!**\n### 环境搭建\n\n1. 克隆本仓库：\n\n```shell\ngit clone https:\u002F\u002Fgithub.com\u002Fbilibili\u002FIndex-1.9B\ncd Index-1.9B\n```\n\n2. 使用pip安装依赖：\n\n```shell\npip install -r requirements.txt\n```\n### 使用Transformers加载\n\n您可以通过以下代码加载Index-1.9B-Chat模型进行对话：\n\n```python\nimport argparse\nfrom transformers import AutoTokenizer, pipeline\n\n# 注意！目录名不能包含“.”，可替换为“_”。\nparser = argparse.ArgumentParser()\nparser.add_argument('--model_path', default=\".\u002FIndexTeam\u002FIndex-1.9B-Chat\u002F\", type=str, help=\"\")\nparser.add_argument('--device', default=\"cpu\", type=str, help=\"\") # 也可以是“cuda”或“mps”（适用于Apple芯片）\nargs = parser.parse_args()\n\ntokenizer = AutoTokenizer.from_pretrained(args.model_path, trust_remote_code=True)\ngenerator = pipeline(\"text-generation\",\n                    model=args.model_path,\n                    tokenizer=tokenizer, trust_remote_code=True, \n                    device=args.device)\n\n\nsystem_message = \"你是由哔哩哔哩自主研发的大语言模型，名为“Index”。你能够根据用户传入的信息，帮助用户完成指定的任务，并生成恰当的、符合要求的回复。\"\nquery = \"续写 天不生我金坷垃\"\nmodel_input = []\nmodel_input.append({\"role\": \"system\", \"content\": system_message})\nmodel_input.append({\"role\": \"user\", \"content\": query})\n\nmodel_output = generator(model_input, max_new_tokens=300, top_k=5, top_p=0.8, temperature=0.3, repetition_penalty=1.1, do_sample=True)\n\nprint('User:', query)\nprint('Model:', model_output)\n```\n\n### Web演示\n\n依赖Gradio，安装命令如下：\n\n```shell\npip install gradio==4.29.0\n```\n\n使用以下代码启动Web服务器。在浏览器中输入访问地址后，即可使用Index-1.9B-Chat模型进行对话：\n\n```shell\npython demo\u002Fweb_demo.py --port='端口' --model_path='\u002F模型路径\u002F'\n```\n\n\n### 终端演示\n **注意：`Index-1.9B-32K`只能使用此工具启动：`demo\u002Fcli_long_text_demo.py`!!!**\n\n使用以下代码启动终端演示，以使用Index-1.9B-Chat模型进行对话：\n\n```shell\npython demo\u002Fcli_demo.py  --model_path='\u002F模型路径\u002F'\n```\n\n### OpenAI API 示例\n\n依赖 Flask，安装命令如下：\n```shell\npip install flask==2.2.5\n```\n使用以下代码启动一个 Flask API：\n```shell\npython demo\u002Fopenai_demo.py --model_path='\u002Fpath\u002Fto\u002Fmodel\u002F'\n```\n你可以通过命令行进行对话：\n```shell\ncurl http:\u002F\u002F127.0.0.1:8010\u002Fv1\u002Fchat\u002Fcompletions \\\n    -H \"Content-Type: application\u002Fjson\" \\\n    -d '{\n    \"messages\": [\n    {\"role\": \"system\", \"content\": \"你是由哔哩哔哩自主研发的大语言模型，名为“Index”。你能够根据用户传入的信息，帮助用户完成指定的任务，并生成恰当的、符合要求的回复。\"},\n    {\"role\": \"user\", \"content\": \"花儿为什么这么红？\"}\n    ]\n    }'\n```\n\n# Index-1.9B-32K 长上下文模型介绍\n## 模型概述\nIndex-1.9B-32K 是一款仅有 19 亿参数的语言模型，却支持 32K 的上下文长度（这意味着这个极小的模型可以一次性读取超过 3.5 万字的文档）。该模型基于精心筛选的长文本训练数据和自建的长文本指令集，针对超过 32K 个 token 的文本进行了持续预训练和监督微调（SFT）。目前，该模型已在 Hugging Face 和 ModelScope 上开源。\n\n尽管规模较小（约为 GPT-4 等模型的 2%），Index-1.9B-32K 却展现出卓越的长文本处理能力。\n如图所示，我们的 19 亿参数模型得分甚至超过了 70 亿参数的模型。以下是与 GPT-4、Qwen2 等模型的对比：\n\n\u003Cp align=\"center\"> \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbilibili_Index-1.9B_readme_b208a664ad04.png\" alt=\"\" width=\"800\"> \n\u003C\u002Fp> \u003Cp align=\"center\">\u003Cstrong>Index-1.9B-32K 与 GPT-4、Qwen2 等模型在长上下文能力上的对比\u003C\u002Fstrong>\n\u003C\u002Fp>\n\n在 32K 长度的“大海捞针”测试中，Index-1.9B-32K 取得了优异的成绩，如下图所示。唯一的例外是在 (32K 长度, 10% 深度) 区域出现了一个小小的黄色区域（91.08 分），其他大部分区域都表现良好，呈现绿色。\n\u003Cp align=\"center\">\n    \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbilibili_Index-1.9B_readme_d3d333dcc112.png\" alt=\"\" width=\"900\">\n\u003C\u002Fp>\n\u003Cp align=\"center\">\u003Cstrong>NeedleBench 评估\u003C\u002Fstrong>\u003C\u002Fp>\n\n## Index-1.9B-32K 模型下载、使用及技术报告：\n有关 Index-1.9B-32K 的下载、使用方法和技术报告的详细信息，请参阅：\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fbilibili\u002FIndex-1.9B\u002Fblob\u002Fmain\u002FIndex-1.9B-32K_Long_Context_Technical_Report.md\" style=\"color: blue;\">\n    📖 \u003Cstrong>Index-1.9B-32K 长上下文技术报告\u003C\u002Fstrong>\n\u003C\u002Fa>\n\n---\n---\n# Index 系列模型的详细信息及免责声明\n## Index-1.9B-Chat 输出示例\n\n- 下面是一些使用 `web_demo.py` 获取 Index-1.9B-Chat 输出的示例。\n    ![gradio 演示](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbilibili_Index-1.9B_readme_951e7c44b687.png)\n    ![gradio 演示](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbilibili_Index-1.9B_readme_8a67ee61378b.png)\n- 将 `System Message` 改为扮演哔哩哔哩用户的刻板印象！\n    ![gradio 演示](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbilibili_Index-1.9B_readme_a07b568636bc.png)\n- 中文翻译成日语\n    ![gradio 演示](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbilibili_Index-1.9B_readme_71d511fe9e81.png)\n- 日语翻译成中文\n    ![gradio 演示](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbilibili_Index-1.9B_readme_b3496d2b0f90.png)\n\n## 角色扮演\n我们同时开源了角色扮演模型及其配套框架。\n![gradio 演示](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbilibili_Index-1.9B_readme_491dca126717.png)\n\n* 目前内置了角色 `三三`。\n* 如果你需要创建自己的角色，请准备一份类似于 [roleplay\u002Fcharacter\u002F三三.csv](roleplay\u002Fcharacter\u002F三三.csv) 的对话语料库（注意文件名应与你要创建的角色名称一致）以及相应的角色描述。点击 `生成角色` 即可成功创建。\n* 如果对应的角色已经创建完毕，请直接在 `Role name` 栏中输入你想对话的角色，输入你的 `query`，然后点击 `submit` 开始对话。\n\n详细使用方法请参考 [roleplay](.\u002Froleplay) 文件夹。\n\n## 长文本翻译与摘要（Index-1.9B-32K）\n- 运行长文本交互工具：**demo\u002Fcli_long_text_demo.py**\n- 模型默认会读取此文件：data\u002Fuser_long_text.txt，并用中文对文本进行摘要。\n- 你可以打开一个新的窗口实时修改文件内容，模型会读取更新后的文件并重新摘要。\n\n```shell\ncd demo\u002F\nCUDA_VISIBLE_DEVICES=0 python cli_long_text_demo.py --model_path '\u002Fpath\u002Fto\u002Fmodel\u002F' --input_file_path data\u002Fuser_long_text.txt\n```\n- 运行与互动示例（将 2024 年 8 月 22 日发布的哔哩哔哩财报翻译成英文并摘要 --- [原始英文报告在此](https:\u002F\u002Fgithub.com\u002Fbilibili\u002FIndex-1.9B\u002Ftree\u002Fmain\u002Fdemo\u002Fdata\u002Fuser_long_text.txt))：\n\n\u003Cp align=\"center\">\n    \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbilibili_Index-1.9B_readme_c92c8448b2cf.png\" alt=\"\" width=\"1000\">\n\u003C\u002Fp>\n\u003Cp align=\"center\">\u003Cstrong>翻译与摘要（2024 年 8 月 22 日发布的哔哩哔哩财报）\u003C\u002Fstrong>\u003C\u002Fp>\n\n\n## 量化\n\n依赖 bitsandbytes，安装命令如下：\n```shell\npip install bitsandbytes==0.43.0\n```\n你可以使用以下脚本进行 int4 量化，这样性能损失更小，同时还能进一步节省显存。\n```python\nimport torch\nimport argparse\nfrom transformers import (\n    AutoModelForCausalLM,\n    AutoTokenizer,\n    TextIteratorStreamer,\n    GenerationConfig,\n    BitsAndBytesConfig\n)\n\nparser = argparse.ArgumentParser()\nparser.add_argument('--model_path', default=\"\", type=str, help=\"\")\nparser.add_argument('--save_model_path', default=\"\", type=str, help=\"\")\nargs = parser.parse_args()\n\ntokenizer = AutoTokenizer.from_pretrained(args.model_path, trust_remote_code=True)\nquantization_config = BitsAndBytesConfig(\n    load_in_4bit=True,\n    bnb_4bit_compute_dtype=torch.float16,\n    bnb_4bit_use_double_quant=True,\n    bnb_4bit_quant_type=\"nf4\",\n    llm_int8_threshold=6.0,\n    llm_int8_has_fp16_weight=False,\n)\nmodel = AutoModelForCausalLM.from_pretrained(args.model_path, \n                                             device_map=\"auto\",\n                                             torch_dtype=torch.float16,\n                                             quantization_config=quantization_config,\n                                             trust_remote_code=True)\nmodel.save_pretrained(args.save_model_path)\ntokenizer.save_pretrained(args.save_model_path)\n```\n\n### 微调\n\n按照 [微调教程](https:\u002F\u002Fgithub.com\u002Fbilibili\u002FIndex-1.9B\u002Fblob\u002Fmain\u002Ffinetune\u002FREADME.md) 中的步骤，快速微调 Index-1.9B-Chat 模型。快来试试吧，定制属于你的专属 Index 模型！\n\n## 限制与免责声明\n\nIndex-1.9B 在某些情况下可能会生成不准确、有偏见或令人反感的内容。该模型无法理解语境、表达个人观点或做出价值判断。其输出并不代表模型开发者的观点和立场。因此，请谨慎使用生成的内容。用户应自行评估和验证模型生成的内容，并避免传播有害信息。开发者在部署任何相关应用之前，应根据具体应用场景进行安全测试和微调。\n\n我们强烈建议不要使用这些模型来创建或传播有害信息，或从事可能危害公共、国家和社会安全、违反法律法规的活动。未经适当的安全审查和备案，不得将这些模型用于互联网服务。尽管我们已尽最大努力确保训练数据的合规性，但由于模型和数据本身的复杂性，仍可能存在未预见的问题。对于因使用这些模型而产生的任何问题，无论是数据安全、舆论风险，还是因误解、误用、传播或不合规使用所引发的风险和问题，我们概不承担任何责任。\n\n## 模型开源许可\n\n使用本仓库中的源代码需遵守 [Apache-2.0](LICENSE) 许可协议。使用 Index-1.9B 模型权重则需遵守 [INDEX_MODEL_LICENSE](INDEX_MODEL_LICENSE) 许可协议。\n\nIndex-1.9B 模型权重对学术研究 **完全开放**，并支持 **免费商业使用**。\n\n## 引用\n如果您认为我们的工作对您有所帮助，请随时引用！\n\n```\n@article{Index,\n  title={Index1.9B 技术报告},\n  year={2024}\n}\n```\n\n## 扩展工作\nlibllm：https:\u002F\u002Fgithub.com\u002Fling0322\u002Flibllm\u002Fblob\u002Fmain\u002Fexamples\u002Fpython\u002Frun_bilibili_index.py\n\nchatllm.cpp：https:\u002F\u002Fgithub.com\u002Ffoldl\u002Fchatllm.cpp\u002Fblob\u002Fmaster\u002Fdocs\u002Frag.md#role-play-with-rag\n\nollama：https:\u002F\u002Follama.com\u002Fmilkey\u002Fbilibili-index\n\nself llm：https:\u002F\u002Fgithub.com\u002Fdatawhalechina\u002Fself-llm\u002Fblob\u002Fmaster\u002Fbilibili_Index-1.9B\u002F04-Index-1.9B-Chat%20Lora%20微调.md","# Index-1.9B 快速上手指南\n\nIndex-1.9B 是由哔哩哔哩开源的轻量级大语言模型系列，包含基座、对话、角色扮演及支持 32K 长上下文的版本。该模型在同等参数量下表现优异，尤其在中文语境、多语言翻译及长文本处理方面具有显著优势。\n\n## 环境准备\n\n*   **系统要求**：Linux \u002F macOS \u002F Windows (推荐 Linux)\n*   **Python 版本**：建议 Python 3.8+\n*   **硬件要求**：\n    *   常规推理：支持 CPU 或 NVIDIA GPU (CUDA)。Apple Silicon 可使用 MPS 加速。\n    *   长文本模型 (32K)：建议使用显存较大的 GPU 以获得更佳体验。\n*   **前置依赖**：Git, pip\n\n## 安装步骤\n\n1.  **克隆项目仓库**\n    ```shell\n    git clone https:\u002F\u002Fgithub.com\u002Fbilibili\u002FIndex-1.9B\n    cd Index-1.9B\n    ```\n\n2.  **安装 Python 依赖**\n    ```shell\n    pip install -r requirements.txt\n    ```\n\n3.  **可选：安装 Web 演示依赖 (Gradio)**\n    如需使用网页版交互界面：\n    ```shell\n    pip install gradio==4.29.0\n    ```\n\n4.  **可选：安装 API 服务依赖 (Flask)**\n    如需部署 OpenAI 兼容接口：\n    ```shell\n    pip install flask==2.2.5\n    ```\n\n> **提示**：国内用户若下载模型权重较慢，推荐使用 **ModelScope (魔搭)** 镜像源。\n> *   HuggingFace 地址：`IndexTeam\u002FIndex-1.9B-Chat`\n> *   ModelScope 地址：`IndexTeam\u002FIndex-1.9B-Chat` (可在代码中将路径替换为本地 ModelScope 缓存路径)\n\n## 基本使用\n\n### 1. Python 代码调用 (Transformers)\n\n以下示例展示如何加载 `Index-1.9B-Chat` 模型进行对话。请确保已下载模型权重至本地目录。\n\n```python\nimport argparse\nfrom transformers import AutoTokenizer, pipeline\n\n# 注意：模型目录名称中不要包含\".\"，如有需要可用\"_\"替换\nparser = argparse.ArgumentParser()\nparser.add_argument('--model_path', default=\".\u002FIndexTeam\u002FIndex-1.9B-Chat\u002F\", type=str, help=\"\")\nparser.add_argument('--device', default=\"cpu\", type=str, help=\"\") # 也可设置为 \"cuda\" 或 \"mps\" (Apple Silicon)\nargs = parser.parse_args()\n\ntokenizer = AutoTokenizer.from_pretrained(args.model_path, trust_remote_code=True)\ngenerator = pipeline(\"text-generation\",\n                    model=args.model_path,\n                    tokenizer=tokenizer, trust_remote_code=True, \n                    device=args.device)\n\n\nsystem_message = \"你是由哔哩哔哩自主研发的大语言模型，名为\"Index\"。你能够根据用户传入的信息，帮助用户完成指定的任务，并生成恰当的、符合要求的回复。\"\nquery = \"续写 天不生我金坷垃\"\nmodel_input = []\nmodel_input.append({\"role\": \"system\", \"content\": system_message})\nmodel_input.append({\"role\": \"user\", \"content\": query})\n\nmodel_output = generator(model_input, max_new_tokens=300, top_k=5, top_p=0.8, temperature=0.3, repetition_penalty=1.1, do_sample=True)\n\nprint('User:', query)\nprint('Model:', model_output)\n```\n\n### 2. 命令行终端对话 (CLI Demo)\n\n运行以下命令启动终端交互式对话：\n\n```shell\npython demo\u002Fcli_demo.py --model_path='\u002Fpath\u002Fto\u002Fmodel\u002F'\n```\n\n> **特别注意**：如果您使用的是 **Index-1.9B-32K** (长上下文版本)，**必须**使用专用脚本启动：\n> ```shell\n> python demo\u002Fcli_long_text_demo.py --model_path='\u002Fpath\u002Fto\u002Fmodel\u002F' --input_file_path data\u002Fuser_long_text.txt\n> ```\n\n### 3. Web 网页演示\n\n启动本地 Web 服务器，通过浏览器访问进行对话：\n\n```shell\npython demo\u002Fweb_demo.py --port='8080' --model_path='\u002Fpath\u002Fto\u002Fmodel\u002F'\n```\n启动后在浏览器输入 `http:\u002F\u002F127.0.0.1:8080` 即可使用。\n\n### 4. OpenAI 兼容 API\n\n启动 Flask 服务以提供兼容 OpenAI 格式的 API：\n\n```shell\npython demo\u002Fopenai_demo.py --model_path='\u002Fpath\u002Fto\u002Fmodel\u002F'\n```\n\n调用示例 (curl)：\n```shell\ncurl http:\u002F\u002F127.0.0.1:8010\u002Fv1\u002Fchat\u002Fcompletions \\\n    -H \"Content-Type: application\u002Fjson\" \\\n    -d '{\n    \"messages\": [\n    {\"role\": \"system\", \"content\": \"你是由哔哩哔哩自主研发的大语言模型，名为\"Index\"。\"},\n    {\"role\": \"user\", \"content\": \"花儿为什么这么红？\"}\n    ]\n    }'\n```","一位独立开发者正在为一款面向东亚市场的移动端应用构建本地化智能客服，需要在有限的设备资源下实现多语言交互和长文档理解。\n\n### 没有 Index-1.9B 时\n- **部署门槛高**：主流大模型参数量过大，无法在低成本服务器或边缘设备上流畅运行，导致推理延迟高、成本昂贵。\n- **多语言支持弱**：同量级的轻量模型（如部分 2B 以下模型）对中文及日韩等东亚语言的理解能力不足，常出现翻译生硬或语境误解。\n- **长文本处理难**：传统小模型上下文窗口通常仅限 2K-4K，无法一次性读取超过万字的用户手册或政策文档，需复杂的切片处理且易丢失关键信息。\n- **角色定制复杂**：若要实现个性化的客服人设，往往需要额外的微调训练或外挂复杂的检索系统，开发周期长。\n\n### 使用 Index-1.9B 后\n- **极致轻量化部署**：凭借仅 1.9B 的参数量，Index-1.9B 可轻松通过 Ollama 或 llamacpp 部署在消费级显卡甚至端侧设备上，推理速度显著提升。\n- **原生多语言优势**：得益于预训练中包含的大量互联网社区语料，Index-1.9B 在中英及东亚语言的对话与翻译上表现自然，准确捕捉文化语境。\n- **32K 长上下文突破**：利用 Index-1.9B-32K 版本，模型能一次性“读完”整本数十页的产品说明书，直接基于全文回答细节问题，无需繁琐的分段逻辑。\n- **开箱即用的角色扮演**：Index-1.9B-Character 版本内置 RAG 机制，仅需少量示例即可快速定制出语气亲切、知识准确的专属客服形象。\n\nIndex-1.9B 以极小的算力代价，打破了轻量模型在多语言能力与长文本理解上的性能瓶颈，让资源受限场景下的智能化应用成为可能。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fbilibili_Index-1.9B_951e7c44.png","bilibili","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fbilibili_296f3217.png","bilibili Open Source Task Force",null,"http:\u002F\u002Fwww.bilibili.com","https:\u002F\u002Fgithub.com\u002Fbilibili",[79,83],{"name":80,"color":81,"percentage":82},"Python","#3572A5",99.9,{"name":84,"color":85,"percentage":86},"Shell","#89e051",0.1,1017,49,"2026-04-09T09:54:28","Apache-2.0","Linux, macOS, Windows","非必需（支持 CPU、CUDA GPU 及 Apple Silicon MPS）。若使用 NVIDIA GPU，需安装 bitsandbytes 进行量化；示例命令中包含 'CUDA_VISIBLE_DEVICES=0'，暗示推荐至少单卡环境以运行长文本或量化模型。","未说明（取决于是否量化及上下文长度，32K 长文本模型对内存要求较高）",{"notes":95,"python":96,"dependencies":97},"1. Index-1.9B-32K 长文本模型必须使用专用脚本 'demo\u002Fcli_long_text_demo.py' 启动，不可使用普通对话脚本。\n2. 模型路径目录名称中不能包含点号（.），如有需替换为下划线（_）。\n3. 支持通过 bitsandbytes 进行 int4 量化以减少显存占用。\n4. 在 Apple Silicon 设备上可将 device 参数设置为 'mps'。\n5. 角色扮演的自定义角色文件命名需与角色名一致。","未说明（需兼容 requirements.txt 中的依赖库）",[98,99,100,101,102,103],"transformers","gradio==4.29.0","flask==2.2.5","bitsandbytes==0.43.0","torch","accelerate",[35,14],[106,107],"llm","nlp","2026-03-27T02:49:30.150509","2026-04-10T19:13:49.924469",[111,116,121,126,131,136],{"id":112,"question_zh":113,"answer_zh":114,"source_url":115},27955,"Index-1.9B 模型是否真正应用了 RAG（检索增强生成）技术？","是的，该模型应用了 RAG 技术。RAG 的核心是从外部数据检索相关信息并注入 prompt 以增强用户输入。在角色扮演场景中，代码会在用户每次输入时，从语料库中检索相关的历史对话并拼接到 prompt 中。代码中的 `self.generate_with_question` 和 `self.create_datasets` 两行正是用于将检索生成的 prompt 结果写入文件。如果注释掉这两行代码，程序虽然能运行，但每次的输入内容将不会更新，导致无法实现动态检索增强。","https:\u002F\u002Fgithub.com\u002Fbilibili\u002FIndex-1.9B\u002Fissues\u002F19",{"id":117,"question_zh":118,"answer_zh":119,"source_url":120},27956,"Index-1.9B 模型能否在安卓手机等移动端设备上运行？","可以。该模型已验证可在 Android 系统上运行，支持的 CPU 包括骁龙 888、骁龙 888+ 和骁龙 8 Gen1。推荐的推理框架为 llama.cpp 或 Ollama。用户需参考相应框架的文档自行进行部署和实操。此外，也有用户反馈可以使用 ChatterUI 等 App 来运行此类小模型。","https:\u002F\u002Fgithub.com\u002Fbilibili\u002FIndex-1.9B\u002Fissues\u002F34",{"id":122,"question_zh":123,"answer_zh":124,"source_url":125},27957,"使用 llama.cpp 加载模型时提示不支持自定义 chat_template 或输出格式异常怎么办？","原生的 llama.cpp 目前不支持自定义 chat_template。建议尝试使用 `llama-cpp-python` 包，它支持自定义模板（例如：`[\u003Cunk>]sytem_message[reserved_0]user_message[reserved_1]response` 格式）。如果前端不是基于 Python 开发导致无法使用该包，或者仍然遇到字符间有空格等格式问题，官方建议直接使用 Ollama 框架进行部署，或者等待官方后续提供的测试用 prompt 格式。","https:\u002F\u002Fgithub.com\u002Fbilibili\u002FIndex-1.9B\u002Fissues\u002F28",{"id":127,"question_zh":128,"answer_zh":129,"source_url":130},27958,"导入模型时报错 `ImportError: cannot import name 'IndexForCausalLM' from 'transformers'` 如何解决？","`IndexForCausalLM` 类尚未直接加入 transformers 库中。正确的调用方法是使用 `AutoModelForCausalLM` 进行加载：\n```python\nfrom transformers import AutoTokenizer, AutoModelForCausalLM\n```\n`AutoModelForCausalLM` 会自动解析模型配置文件（config.json）中的 `auto_map` 字段，将其映射到项目本地的 `modeling_index.py` 文件中的 `IndexForCausalLM` 类。请确保已更新 Hugging Face 上的 config.json 文件。","https:\u002F\u002Fgithub.com\u002Fbilibili\u002FIndex-1.9B\u002Fissues\u002F24",{"id":132,"question_zh":133,"answer_zh":134,"source_url":135},27959,"使用代码下载模型权重时出现 401 Repository Not Found 错误怎么办？","这通常是因为模型仓库名称中包含点号（`.`），在某些环境下会被误识别为模块分隔符。解决方法是将仓库名称中的点号替换为下划线。例如，将 `IndexTeam\u002FIndex-1.9B-Chat` 修改为 `IndexTeam\u002FIndex-1_9B-Chat`。请在代码的 `model_path` 参数或命令行参数中进行此替换后再尝试下载。","https:\u002F\u002Fgithub.com\u002Fbilibili\u002FIndex-1.9B\u002Fissues\u002F11",{"id":137,"question_zh":138,"answer_zh":139,"source_url":140},27960,"在多 GPU 环境下运行演示脚本时出现 `Expected all tensors to be on the same device` 错误如何处理？","该错误表明张量分布在了不同的 GPU 设备上（如 cuda:0 和 cuda:1）。可以通过设置环境变量来限制程序可见的 GPU 设备，从而强制所有张量位于同一设备上。在运行程序前，设置 `os.environ['CUDA_VISIBLE_DEVICES'] = '0'`（或指定其他单个显卡编号），确保程序只使用指定的单张显卡进行推理。","https:\u002F\u002Fgithub.com\u002Fbilibili\u002FIndex-1.9B\u002Fissues\u002F3",[]]