Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 63d65ac

Browse filesBrowse files
committed
feat: Update llama.cpp
1 parent fc19cc7 commit 63d65ac
Copy full SHA for 63d65ac

File tree

Expand file treeCollapse file tree

4 files changed

+19
-21
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+19
-21
lines changed

‎llama_cpp/_internals.py

Copy file name to clipboardExpand all lines: llama_cpp/_internals.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,11 @@ def token_eot(self) -> int:
179179
assert self.model is not None
180180
return llama_cpp.llama_token_eot(self.model)
181181

182-
def add_bos_token(self) -> int:
182+
def add_bos_token(self) -> bool:
183183
assert self.model is not None
184184
return llama_cpp.llama_add_bos_token(self.model)
185185

186-
def add_eos_token(self) -> int:
186+
def add_eos_token(self) -> bool:
187187
assert self.model is not None
188188
return llama_cpp.llama_add_eos_token(self.model)
189189

@@ -691,8 +691,8 @@ def _detokenize_bpe(model: _LlamaModel, tokens: List[int]) -> str:
691691
def _should_add_bos(model: _LlamaModel) -> bool:
692692
assert model.model is not None
693693
add_bos = llama_cpp.llama_add_bos_token(model.model)
694-
if add_bos != -1:
695-
return add_bos != 0
694+
if add_bos:
695+
return add_bos
696696
else:
697697
return llama_cpp.llama_vocab_type(model.model) == llama_cpp.LLAMA_VOCAB_TYPE_SPM
698698

‎llama_cpp/llama.py

Copy file name to clipboardExpand all lines: llama_cpp/llama.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,13 +1058,13 @@ def _create_completion(
10581058

10591059
if (
10601060
(isinstance(prompt, list) and suffix is None)
1061-
or self._model.add_bos_token() == 0
1061+
or not self._model.add_bos_token()
10621062
or bos_tokens[:1] == [-1]
10631063
):
10641064
bos_tokens = []
10651065

10661066
if (isinstance(prompt, list) and suffix is None) or (
1067-
self._model.add_eos_token() != 1 and sep_token_id == -1
1067+
not self._model.add_eos_token() and sep_token_id == -1
10681068
):
10691069
eos_tokens = []
10701070

‎llama_cpp/llama_cpp.py

Copy file name to clipboardExpand all lines: llama_cpp/llama_cpp.py
+12-14Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ def byref(obj: CtypesCData, offset: Optional[int] = None) -> CtypesRef[CtypesCDa
314314
# LLAMA_VOCAB_PRE_TYPE_TEKKEN = 20,
315315
# LLAMA_VOCAB_PRE_TYPE_SMOLLM = 21,
316316
# LLAMA_VOCAB_PRE_TYPE_CODESHELL = 22,
317+
# LLAMA_VOCAB_PRE_TYPE_BLOOM = 23,
318+
# LLAMA_VOCAB_PRE_TYPE_GPT3_FINNISH = 24,
317319
# };
318320
LLAMA_VOCAB_PRE_TYPE_DEFAULT = 0
319321
LLAMA_VOCAB_PRE_TYPE_LLAMA3 = 1
@@ -338,20 +340,20 @@ def byref(obj: CtypesCData, offset: Optional[int] = None) -> CtypesRef[CtypesCDa
338340
LLAMA_VOCAB_PRE_TYPE_TEKKEN = 20
339341
LLAMA_VOCAB_PRE_TYPE_SMOLLM = 21
340342
LLAMA_VOCAB_PRE_TYPE_CODESHELL = 22
343+
LLAMA_VOCAB_PRE_TYPE_BLOOM = 23
344+
LLAMA_VOCAB_PRE_TYPE_GPT3_FINNISH = 24
341345

342346

343347
# // note: these values should be synchronized with ggml_rope
344348
# // TODO: maybe move this enum to ggml.h (ggml_rope_type)
345349
# enum llama_rope_type {
346350
# LLAMA_ROPE_TYPE_NONE = -1,
347351
# LLAMA_ROPE_TYPE_NORM = 0,
348-
# LLAMA_ROPE_TYPE_NEOX = 2,
349-
# LLAMA_ROPE_TYPE_GLM = 4,
352+
# LLAMA_ROPE_TYPE_NEOX = GGML_ROPE_TYPE_NEOX,
350353
# };
351354
LLAMA_ROPE_TYPE_NONE = -1
352355
LLAMA_ROPE_TYPE_NORM = 0
353-
LLAMA_ROPE_TYPE_NEOX = 2
354-
LLAMA_ROPE_TYPE_GLM = 4
356+
LLAMA_ROPE_TYPE_NEOX = GGML_ROPE_TYPE_NEOX = 2
355357

356358

357359
# enum llama_token_type { //TODO: remove, required until per token attributes are available from GGUF file
@@ -2741,19 +2743,15 @@ def llama_token_nl(model: llama_model_p, /) -> int:
27412743
...
27422744

27432745

2744-
# // Returns -1 if unknown, 1 for true or 0 for false.
2745-
# LLAMA_API int32_t llama_add_bos_token(const struct llama_model * model);
2746-
@ctypes_function("llama_add_bos_token", [llama_model_p_ctypes], ctypes.c_int32)
2747-
def llama_add_bos_token(model: llama_model_p, /) -> int:
2748-
"""Returns -1 if unknown, 1 for true or 0 for false."""
2746+
# LLAMA_API bool llama_add_bos_token(const struct llama_model * model);
2747+
@ctypes_function("llama_add_bos_token", [llama_model_p_ctypes], ctypes.c_bool)
2748+
def llama_add_bos_token(model: llama_model_p, /) -> bool:
27492749
...
27502750

27512751

2752-
# // Returns -1 if unknown, 1 for true or 0 for false.
2753-
# LLAMA_API int32_t llama_add_eos_token(const struct llama_model * model);
2754-
@ctypes_function("llama_add_eos_token", [llama_model_p_ctypes], ctypes.c_int32)
2755-
def llama_add_eos_token(model: llama_model_p, /) -> int:
2756-
"""Returns -1 if unknown, 1 for true or 0 for false."""
2752+
# LLAMA_API bool llama_add_eos_token(const struct llama_model * model);
2753+
@ctypes_function("llama_add_eos_token", [llama_model_p_ctypes], ctypes.c_bool)
2754+
def llama_add_eos_token(model: llama_model_p, /) -> bool:
27572755
...
27582756

27592757

‎vendor/llama.cpp

Copy file name to clipboard

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.