feat: Update vendored llama.cpp to include ModernBERT support

Đang mở
#2,144 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
c, cmake, python
Lĩnh vực
ai-infra-agents, backend

Hướng nghiên cứu

Issue này yêu cầu cập nhật submodule vendored llama.cpp lên một commit sau ngày 22 tháng 12 năm 2025, sau đó cập nhật các binding Python ctypes trong llama_cpp/llama_cpp.py để khớp với C API đã thay đổi (ví dụ: llama_get_kv_self đã bị loại bỏ). Ngoài ra, CMakeLists.txt cũng cần được sửa, đặc biệt là xung quanh LLAVA_BUILD. Hãy bắt đầu bằng cách kiểm tra submodule vendor/llama.cpp hiện tại và mã binding, sau đó kiểm tra các thay đổi trong C API của llama.cpp ở commit mục tiêu. Build với -DLLAVA_BUILD=OFF là một workaround, nhưng các binding phải hoàn toàn tương thích. Công việc được xem là hoàn tất khi thư viện có thể tải các model ModernBERT GGUF mà không có lỗi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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).

Ngôn ngữ chính
Python
Star
10.7k
Fork
1.5k
Merge trung bình
1 giờ 40 phút
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của abetlen/llama-cpp-python

Tất cả issue của abetlen/llama-cpp-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.