Skip to content

Commit 89a96e7

Browse files
author
juanroesel
committed
Updated unit tests with changes to MetricsExporter init
1 parent afd3472 commit 89a96e7

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tests/test_llama.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,18 @@
55
from scipy.special import log_softmax
66

77
import llama_cpp
8+
from llama_cpp.llama_metrics import MetricsExporter
89

910
MODEL = "./vendor/llama.cpp/models/ggml-vocab-llama-spm.gguf"
1011

12+
def set_test_metrics_exporter():
13+
global metrics_exporter
14+
try:
15+
metrics_exporter
16+
except NameError:
17+
metrics_exporter = MetricsExporter()
18+
19+
return metrics_exporter
1120

1221
def test_llama_cpp_tokenization():
1322
llama = llama_cpp.Llama(model_path=MODEL, vocab_only=True, verbose=False)
@@ -156,7 +165,8 @@ def test_llama_patch(mock_llama):
156165
ai_service_completion = "test-label-suggestions"
157166
ai_service_streaming = "test-acceptance-criteria"
158167
llama = llama_cpp.Llama(model_path=MODEL, vocab_only=True, n_ctx=n_ctx)
159-
168+
llama.metrics = set_test_metrics_exporter()
169+
160170
n_vocab = llama_cpp.llama_n_vocab(llama._model.model)
161171
assert n_vocab == 32000
162172

@@ -231,6 +241,7 @@ def test_llama_pickle():
231241

232242
def test_utf8(mock_llama):
233243
llama = llama_cpp.Llama(model_path=MODEL, vocab_only=True, logits_all=True)
244+
llama.metrics = set_test_metrics_exporter()
234245

235246
output_text = "😀"
236247
ai_service = "label-suggestions"

0 commit comments

Comments
 (0)