feat: Update vendored llama.cpp to include ModernBERT support

未关闭
#2,144 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
停滞
技术栈
c, cmake, python

调研方向

该 issue 要求将 vendored llama.cpp 子模块更新到 2025 年 12 月 22 日之后的某个 commit,然后更新 llama_cpp/llama_cpp.py 中的 Python ctypes 绑定,使其匹配变更后的 C API(例如,llama_get_kv_self 已不存在)。此外,还需要修复 CMakeLists.txt,尤其是 LLAVA_BUILD 相关的部分。首先检查当前的 vendor/llama.cpp 子模块和绑定代码,然后检查目标 commit 中 llama.cpp C API 的变更。使用 -DLLAVA_BUILD=OFF 进行构建是一种 workaround,但绑定必须完全兼容。当库能够无错误地加载 ModernBERT GGUF 模型时,即可视为完成。

由索引模型根据 Issue 内容生成。

描述

Context

The current release (v0.3.16, Aug 15 2025) vendors llama.cpp at commit 4227c9b (Aug 14, 2025). ModernBERT architecture support was added to llama.cpp on Dec 22, 2025 in PR ggml-org/llama.cpp#15641 (src/models/modern-bert.cpp). The vendor submodule hasn't been updated in ~7 months.

Problem

Loading a ModernBERT GGUF model fails with:

llama_model_load: error loading model: error loading model architecture: unknown model architecture: 'modernbert'

The binary only knows: bert, falcon, gemma, gpt2, llama, mamba, qwen, rwkv, stablelm — no modernbert.

Attempted fix

We tried updating the vendor submodule to llama.cpp b8373 (Mar 16, 2026) and building from source. Results:

  1. CMake fails with LLAVA_BUILD=ON (default) — vendor/llama.cpp/tools/mtmd/CMakeLists.txt:37 has a set_target_properties error incompatible with the binding's CMakeLists.txt
  2. CMake succeeds with -DLLAVA_BUILD=OFF — builds and installs fine
  3. Runtime ABI mismatch — the Python bindings call llama_get_kv_self which no longer exists in b8373 (symbol not found). The C API has diverged significantly in 7 months.

So it's not just a submodule bump — the Python ctypes bindings need updates to match the current llama.cpp C API.

Why it matters

Several recent high-quality embedding models use ModernBERT architecture:

  • granite-embedding-small-english-r2 (IBM, 47M params, 384d, BEIR NDCG@10 50.9, Apache 2.0)
  • modernbert-embed-base (Nomic, 149M params, Apache 2.0)
  • gte-modernbert-base (Alibaba, 149M params)

These models can't be used with llama-cpp-python until the binding is updated.

Request

Update the Python ctypes bindings and CMakeLists.txt to be compatible with a recent llama.cpp build that includes ModernBERT support (post Dec 22, 2025).

主要语言
Python
星标
10.7k
派生
1.5k
平均合并
1 小时 40 分钟
30 天内合并 PR
5

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

abetlen/llama-cpp-python 的其他 Issue

查看 abetlen/llama-cpp-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。