Mới trong llama.cpp- Quản lý Mô hình
Hướng dẫn này giới thiệu các cải tiến mới nhất trong llama.cpp liên quan đến quản lý mô hình.
- 4 min read
Mới trong llama.cpp: Quản lý Model
Được đăng bởi: Xuan-Son Nguyen & Victor Mustar (từ ggml.ai) Ngày đăng: 11 tháng 12 năm 2025
https://huggingface.co/blog/ggml-org/model-management-in-llamacpp
Khởi động nhanh
Khởi động máy chủ ở chế độ router bằng cách không chỉ định model:
bash llama-server
Lệnh này sẽ tự động phát hiện các model từ bộ nhớ cache của llama.cpp (LLAMA_CACHE hoặc ~/.cache/llama.cpp). Nếu bạn đã tải model trước đó qua llama-server -hf user/model, chúng sẽ có sẵn ngay lập tức.
Bạn cũng có thể trỏ đến một thư mục cục bộ chứa các tệp GGUF:
bash llama-server –models-dir ./my-models
Tính năng
- Tự động phát hiện: Quét bộ nhớ cache của llama.cpp (mặc định) hoặc một thư mục –models-dir tùy chỉnh để tìm các tệp GGUF.
- Tải theo yêu cầu: Các model sẽ tự động tải khi được yêu cầu lần đầu tiên.
- Loại bỏ theo LRU (Least Recently Used): Khi đạt đến giới hạn –models-max (mặc định: 4), model ít được sử dụng nhất sẽ bị dỡ bỏ.
- Định tuyến yêu cầu: Trường
modeltrong yêu cầu của bạn sẽ xác định model nào xử lý yêu cầu đó.
Ví dụ
Trò chuyện với một model cụ thể
bash
curl http://localhost:8080/v1/chat/completions
-H “Content-Type: application/json”
-d ‘{
“model”: “ggml-org/gemma-3-4b-it-GGUF:Q4_K_M”,
“messages”: [{“role”: “user”, “content”: “Hello!”}]
}’
Lần yêu cầu đầu tiên, máy chủ sẽ tự động tải model vào bộ nhớ (thời gian tải phụ thuộc vào kích thước model). Các yêu cầu tiếp theo tới cùng model sẽ ngay lập tức vì nó đã được tải.
Liệt kê các model khả dụng
bash curl http://localhost:8080/models
Trả về tất cả các model đã được phát hiện cùng với trạng thái của chúng (loaded, loading, hoặc unloaded).
Tải model thủ công
bash
curl -X POST http://localhost:8080/models/load
-H “Content-Type: application/json”
-d ‘{“model”: “my-model.gguf”}’
Gỡ bỏ model để giải phóng VRAM
bash
curl -X POST http://localhost:8080/models/unload
-H “Content-Type: application/json”
-d ‘{“model”: “my-model.gguf”}’
Các tùy chọn chính
| Cờ | Mô tả |
|---|---|
--models-dir PATH |
Thư mục chứa các tệp GGUF của bạn |
--models-max N |
Số lượng model tối đa được tải đồng thời (mặc định: 4) |
--no-models-autoload |
Tắt tự động tải; yêu cầu gọi /models/load rõ ràng |
Tất cả các phiên bản model sẽ kế thừa cài đặt từ router:
bash llama-server –models-dir ./models -c 8192 -ngl 99
Tất cả các model được tải sẽ sử dụng ngữ cảnh 8192 và tải toàn bộ GPU. Bạn cũng có thể định cấu hình cài đặt cho từng model bằng cách sử dụng presets:
bash llama-server –models-preset config.ini
ini [my-model] model = /path/to/model.gguf ctx-size = 65536 temp = 0.7
Cũng có sẵn trong Web UI
Giao diện web tích hợp sẵn cũng hỗ trợ chuyển đổi model. Chỉ cần chọn một model từ menu thả xuống và nó sẽ tự động tải.
Tham gia thảo luận
Chúng tôi hy vọng tính năng này sẽ giúp bạn dễ dàng hơn trong việc thử nghiệm các phiên bản model khác nhau, triển khai đa người dùng hoặc đơn giản là chuyển đổi model trong quá trình phát triển mà không cần khởi động lại máy chủ.
Có câu hỏi hoặc phản hồi? Hãy để lại bình luận bên dưới hoặc mở một issue trên GitHub.
Thảo luận
Bukit: Mmproj support?
sbeltz: Supported via presets.ini, where you can specify the mmproj (and other long and short arguments) per model.
grailfinder: https://github.com/ggml-org/llama.cpp/tree/master/tools/server#using-multiple-models
models_directory │ │ # single file ├─ llama-3.2-1b-Q4_K_M.gguf ├─ Qwen3-8B-Q4_K_M.gguf │ │ # multimodal ├─ gemma-3-4b-it-Q8_0 │ ├─ gemma-3-4b-it-Q8_0.gguf │ └─ mmproj-F16.gguf # file name must start with “mmproj”
ngxson: mmproj is also automatically selected for cached models, downloaded via the
-hf user/modeloption
sbeltz: Awesome new feature! Can model selection be done on something other than requested model name? Like maybe specify the ranking in presets.ini, and then the highest ranked model that can satisfy the request will be the default. So maybe one model is best for short context, another (or the same with other settings) for when the context gets too long, and another when image input is required.
xbruce22: This is good addition, Thank you.
etemiz: what is the best way to get and the tokens in between? openAI library is removing them.. i want to run llama-server in console and talk to it using a python library that does not remove the thinking tokens.
i checked the llama-cpp-python but it does not have that.
razvanab: Now I can use llama.cpp all the time. A big thank you to the devs.
sbeltz: Is there currently a way to have a “default” model if the request doesn’t specify? Could be the currently loaded model or a specific model. (Just noticed one of my apps broke because it’s used to llama-server not requiring a model name.)
+57 replies
Link bài viết gốc
- Tags:
- Ai
- 11 December 2025
- Huggingface.co