Llama() silently accepts and discards `embedding` kwarg; .embed() then raises confusingly
I maintainer di solito rispondono entro 1 giorno
@Anai-Guo ci sta già lavorando.
Dal 5/9/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 65/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- backend-api-design
Direzione di ricerca
Il problema si trova nel metodo Llama.init in llama_cpp/llama.py, che attualmente ignora silenziosamente il kwarg 'embedding'. Cerca la gestione di **kwargs e l’assegnazione di context_params.embeddings. La correzione consiste nel sollevare un TypeError per i kwargs sconosciuti oppure nel mappare 'embedding' a 'embeddings' con un avviso di deprecazione. Esegui lo script di riproduzione per confermare l’errore, quindi, dopo la modifica, assicurati che .embed() funzioni quando viene passato 'embedding=True'.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Prerequisites
- I am running the latest code. Development is very rapid so there are no tagged versions as of now.
- I carefully followed the README.md.
- I searched using keywords relevant to my issue to make sure that I am creating a new issue that is not already open (or closed).
- I reviewed the Discussions, and have a new bug or useful enhancement to share.
Expected Behavior
When constructing Llama with the older spelling embedding=True (singular — the parameter name in 0.2.x), one of two things should happen:
- The kwarg is accepted as a deprecated alias of
embeddingsand aDeprecationWarningis emitted, OR - A
TypeErroris raised at construction time, surfacing the issue at the call site rather than swallowing it silently.
Current Behavior
Neither happens. embedding=True is silently swallowed via **kwargs, context_params.embeddings stays at its default False, and the failure surfaces much later — deep inside .embed() — with a misleading error message that suggests the user didn't pass the flag, when in fact they did (just under the historical name).
RuntimeError: Llama model must be created with embeddings=True to call this method
This is especially painful for users integrating older libraries that haven't migrated to the new spelling yet — the error points at the wrong thing.
Environment and Context
- Hardware: x86_64, NVIDIA GeForce RTX 4090
- OS: Windows 10 22H2
- Python 3.12.9
- llama-cpp-python 0.3.36 (CUDA 12.8 prebuilt wheel)
$ python --version
Python 3.12.9
$ pip show llama-cpp-python | findstr Version
Version: 0.3.36
Failure Information (for bugs)
The constructor's **kwargs swallows unknown keyword arguments with no warning, so a typo or stale parameter name produces a delayed, confusing failure rather than an immediate error.
Steps to Reproduce
from llama_cpp import Llama
# Pass the older `embedding` (singular) instead of `embeddings` (plural).
m = Llama(model_path="path/to/model.gguf", embedding=True)
m.embed("hello")
Result:
RuntimeError: Llama model must be created with embeddings=True to call this method
Even though embedding=True was passed at construction. The fix is to either accept embedding as a deprecated alias or to validate kwargs strictly.
Failure Logs
Traceback (most recent call last):
File "...\Lib\site-packages\llama_cpp\llama.py", line 1602, in embed
raise RuntimeError(
RuntimeError: Llama model must be created with embeddings=True to call this method
Hit while integrating Tencent's HY-Motion text-to-motion model — the hymotion package's text encoder still uses the older embedding= spelling, so anyone running it against llama-cpp-python 0.3.x sees this confusing failure at first inference instead of at construction. Workaround in our case is a runtime monkey-patch that translates embedding → embeddings in Llama.__init__, but that doesn't help anyone else.
- Lingua principale
- Python
- Stelle
- 10.7k
- Fork
- 1.5k
- Merge medio
- 1h 40m
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di abetlen/llama-cpp-python
-
Windows: every failed `import llama_cpp` prepends to PATH and adds DLL directories againForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
abetlen/llama-cpp-python#2424 ·
I maintainer di solito rispondono entro 1 giorno
-
Seven llama_sampler_init_* bindings admit keyword arguments that the ctypes function object silently dropsForse già presa @Belal0066 l’ha presa 59 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
abetlen/llama-cpp-python#2371 ·
I maintainer di solito rispondono entro 1 giorno
-
uv add llama-cpp-python wheels fails for versions above 0.3.30Forse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
abetlen/llama-cpp-python#2352 · 1 commento · 3 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
abetlen/llama-cpp-python#2314 ·
I maintainer di solito rispondono entro 1 giorno
-
Llama.embed() calls LlamaBatch.add_sequence with old 3-arg signature; missing logits_arrayForse di nuovo libera @lxcxjxhx l’ha presa 136 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
abetlen/llama-cpp-python#2211 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di abetlen/llama-cpp-python
Issue simili
-
LLMContextNode tool builders fail on nested params like `params:retrieval.max_matches`Forse già presa @Shizoqua l’ha presa oggi. ApertaCommunity
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 2 giorni
-
security
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
btclib-org/portanode#985 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: maps skill OSRM foot/cycling returns car times (router.project-osrm.org ignores profile)Apertacomp/tools P2 tool/skills type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NousResearch/hermes-agent#158494 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
needs-format
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Niko1221/Strata#6475 · 1 commento ·
I maintainer di solito rispondono entro 6 giorni