File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 15
15
MODEL = "./vendor/llama.cpp/models/ggml-vocab-llama-spm.gguf"
16
16
17
17
18
+ def test_llama_cpp_version ():
19
+ assert llama_cpp .__version__
20
+
21
+
18
22
def test_llama_cpp_tokenization ():
19
23
llama = llama_cpp .Llama (model_path = MODEL , vocab_only = True , verbose = False )
20
24
@@ -52,10 +56,6 @@ def test_llama_cpp_tokenization():
52
56
assert text == llama .detokenize (tokens )
53
57
54
58
55
- def test_llama_cpp_version ():
56
- assert llama_cpp .__version__
57
-
58
-
59
59
@pytest .fixture
60
60
def llama_cpp_model_path ():
61
61
repo_id = "Qwen/Qwen2-0.5B-Instruct-GGUF"
@@ -150,8 +150,12 @@ def test_real_llama(llama_cpp_model_path):
150
150
)
151
151
assert output ["choices" ][0 ]["text" ] == "true"
152
152
153
+ suffix = b"rot"
154
+ tokens = model .tokenize (suffix , add_bos = True , special = True )
153
155
def logit_processor_func (input_ids , logits ):
154
- return logits * 1
156
+ for token in tokens :
157
+ logits [token ] *= 1000
158
+ return logits
155
159
156
160
logit_processors = llama_cpp .LogitsProcessorList (
157
161
[logit_processor_func ]
@@ -166,4 +170,4 @@ def logit_processor_func(input_ids, logits):
166
170
seed = 1337 ,
167
171
logits_processor = logit_processors
168
172
)
169
- assert output ["choices" ][0 ]["text" ].lower ().startswith ("is " )
173
+ assert output ["choices" ][0 ]["text" ].lower ().startswith ("rot " )
You can’t perform that action at this time.
0 commit comments