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 20c965a

Browse filesBrowse files
authored
Merge branch 'abetlen:main' into main
2 parents c9ec9c8 + fc19cc7 commit 20c965a
Copy full SHA for 20c965a

File tree

Expand file treeCollapse file tree

6 files changed

+41
-4
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+41
-4
lines changed

‎CHANGELOG.md

Copy file name to clipboardExpand all lines: CHANGELOG.md
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.2.88]
11+
12+
- feat: Update llama.cpp to ggerganov/llama.cpp@fc4ca27b25464a11b3b86c9dbb5b6ed6065965c2
13+
- fix: only print 'cache saved' in verbose mode by @lsorber in #1668
14+
- fix: Added back from_file method to LlamaGrammar by @ExtReMLapin in #1673
15+
- fix: grammar prints on each call by @abetlen in 0998ea0deea076a547d54bd598d6b413b588ee2b
16+
- feat: Enable recursive search of HFFS.ls when using from_pretrained by @benHeidabetlen in #1656
17+
- feat: Add more detailed log for prefix-match by @xu-song in #1659
18+
1019
## [0.2.87]
1120

1221
- feat: Update llama.cpp to ggerganov/llama.cpp@be55695eff44784a141a863f273661a6bce63dfc

‎llama_cpp/__init__.py

Copy file name to clipboard
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from .llama_cpp import *
22
from .llama import *
33

4-
__version__ = "0.2.87"
4+
__version__ = "0.2.88"

‎llama_cpp/llama.py

Copy file name to clipboardExpand all lines: llama_cpp/llama.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,8 @@ def logit_bias_processor(
15281528
if self.verbose:
15291529
print("Llama._create_completion: cache save", file=sys.stderr)
15301530
self.cache[prompt_tokens + completion_tokens] = self.save_state()
1531-
print("Llama._create_completion: cache saved", file=sys.stderr)
1531+
if self.verbose:
1532+
print("Llama._create_completion: cache saved", file=sys.stderr)
15321533
return
15331534

15341535
if self.cache:

‎llama_cpp/llama_cpp.py

Copy file name to clipboardExpand all lines: llama_cpp/llama_cpp.py
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,14 @@ def llama_model_has_encoder(model: llama_model_p, /) -> bool:
15051505
...
15061506

15071507

1508+
# // Returns true if the model contains a decoder that requires llama_decode() call
1509+
# LLAMA_API bool llama_model_has_decoder(const struct llama_model * model);
1510+
@ctypes_function("llama_model_has_decoder", [llama_model_p_ctypes], ctypes.c_bool)
1511+
def llama_model_has_decoder(model: llama_model_p, /) -> bool:
1512+
"""Returns true if the model contains a decoder that requires llama_decode() call"""
1513+
...
1514+
1515+
15081516
# // For encoder-decoder models, this function returns id of the token that must be provided
15091517
# // to the decoder to start generating output sequence. For other models, it returns -1.
15101518
# LLAMA_API llama_token llama_model_decoder_start_token(const struct llama_model * model);

‎llama_cpp/llama_grammar.py

Copy file name to clipboardExpand all lines: llama_cpp/llama_grammar.py
+20-1Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Python implementation of llama grammar parser directly translated from C++ source file in vendor/llama.cpp/common/grammar-parser.cpp."""
22

33
# flake8: noqa
4+
from pathlib import Path
45
import sys
56
import ctypes
67
import enum
@@ -890,8 +891,26 @@ def reset(self):
890891
@classmethod
891892
def from_string(cls, grammar: str, verbose: bool = True) -> "LlamaGrammar":
892893
parsed_grammar = parse(grammar)
893-
print_grammar(file=sys.stdout, state=parsed_grammar)
894+
if verbose:
895+
print_grammar(file=sys.stdout, state=parsed_grammar)
894896
return cls(parsed_grammar)
897+
898+
@classmethod
899+
def from_file(cls, file: Union[str, Path], verbose: bool = True) -> "LlamaGrammar":
900+
try:
901+
with open(file) as f:
902+
grammar = f.read()
903+
except Exception as err:
904+
raise Exception(
905+
f"{cls.from_file.__name__}: error reading grammar file: {err}"
906+
)
907+
908+
if grammar:
909+
return cls.from_string(grammar, verbose=verbose)
910+
911+
raise ValueError(
912+
f"{cls.from_file.__name__}: error parsing grammar file: params_grammer is empty"
913+
)
895914

896915
@classmethod
897916
def from_json_schema(cls, json_schema: str, verbose: bool = True) -> "LlamaGrammar":

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