快速结论:这个报错通常发生在将 Hugging Face 模型转换为 GGUF 格式时,模型的 config.json 中声明的架构(architecture)与实际词表格式不匹配。优先检查模型的真实架构,并在 config.json 中将其修正。
适用环境:Issue 确认的环境为 Windows 系统(路径 C:\Users\ogiev\Desktop\pythonPlayground\llama.cpp),使用 convert_hf_to_gguf.py 脚本(llama.cpp 项目),Python 环境未在 Issue 中明确注明。
最快修复方案:编辑模型的 config.json,将 "architectures": ["BertModel"] 改为 "architectures": ["XLMRobertaModel"],然后重新运行转换命令。
注意事项:该方案来自 Issue 评论中的 workaround,并非官方补丁。修改前请确认模型实际架构确为 XLM-RoBERTa(SentencePiece Unigram 词表),避免对其他模型造成误判。
问题场景
用户使用 convert_hf_to_gguf.py 将 sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 模型转换为 GGUF 格式(指定 --outtype q8_0)时触发此错误。该模型在 Hugging Face 上被标注为 BERT 架构,但实际词表格式并非 BERT 常用的 WordPiece,而是 XLM-RoBERTa 的 SentencePiece Unigram。
报错原文
WARNING:hf-to-gguf:** WARNING: The BPE pre-tokenizer was not recognized!
WARNING:hf-to-gguf:** There are 2 possible reasons for this:
WARNING:hf-to-gguf:** - the model has not been added to convert_hf_to_gguf_update.py yet
WARNING:hf-to-gguf:** - the pre-tokenization config has changed upstream
WARNING:hf-to-gguf:** Check your model files and convert_hf_to_gguf_update.py and update them accordingly.
WARNING:hf-to-gguf:** ref: https://github.com/ggml-org/llama.cpp/pull/6920
...
File "C:\Users\ogiev\Desktop\pythonPlayground\llama.cpp\conversion\base.py", line 1775, in get_vocab_base_pre
raise NotImplementedError("BPE pre-tokenizer was not recognized - update get_vocab_base_pre()")
NotImplementedError: BPE pre-tokenizer was not recognized - update get_vocab_base_pre()
原因分析
可能原因:这不是一个真正的“预分词器未注册”问题,而是模型的 config.json 中 architectures 字段声明不准确所致。该模型的 config.json 声明为 ["BertModel"],导致转换脚本按 BERT 的 WordPiece 词表路径处理;但模型的 tokenizer.json 中 model.type == "Unigram",并包含 sentencepiece.bpe.model 文件,说明它实际是 XLM-RoBERTa(SentencePiece Unigram)架构。由于架构声明与真实词表格式不匹配,转换脚本进入 get_vocab_base_pre() 后无法识别预分词器,最终抛出 NotImplementedError。
环境排查
- 确认目标模型的
tokenizer.json中model.type字段值(应为"Unigram"而非"BPE"或"WordPiece")。 - 检查模型目录中是否包含
sentencepiece.bpe.model文件(存在则强烈提示为 SentencePiece 词表)。 - 确认
config.json的architectures字段是否与实际模型结构一致。 - 确认使用的 llama.cpp 版本是否包含
conversion/base.py与conversion/bert.py模块(较新版本已将转换逻辑拆分到子目录)。
解决步骤
- 进入模型目录(例如
model_hf),打开config.json。 - 将
"architectures": ["BertModel"]修改为"architectures": ["XLMRobertaModel"],保存文件。 - 重新运行转换命令:
python convert_hf_to_gguf.py model_hf --outtype q8_0 --outfile paraphrase-multilingual-MiniLM-L12-v2.Q8_0.gguf。 - 若修改后仍报错,可尝试在模型目录中确认
tokenizer.json的model.type字段,并检查 llama.cpp 是否为最新版本(可优先尝试拉取最新代码)。
验证方法
重新运行转换命令后,观察是否不再出现 “BPE pre-tokenizer was not recognized” 的 NotImplementedError,且转换脚本能正常生成 .gguf 文件。也可在转换完成后,用 llama.cpp 的推理工具加载该 GGUF 文件,确认模型能正常推理。
参考来源
AI 工具推荐
想把多个 AI 模型放在一个入口?
GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。
推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。
这个方案解决了吗?
可以继续搜索完整报错,或查看同一工具的其他排查指南。
![[Question]: How to deal with the situation that the user_id returned in the Conversation table in the database is null?](https://www.chat-gpts.plus/wp-content/uploads/2026/08/7940-bcfd3c79-768x403.jpg)
![[Question]: dependency failed to start: container ragflow-mysql is unhealthy](https://www.chat-gpts.plus/wp-content/uploads/2026/08/7501-3cad0829-768x403.jpg)
