Tiny apply gsm8k mixin to ngram test (#15606)

This commit is contained in:
Liangsheng Yin
2025-12-24 01:30:26 +08:00
committed by GitHub
parent 5f3a47d8a7
commit bd572360f3
6 changed files with 31 additions and 46 deletions

View File

@@ -1,13 +1,18 @@
from types import SimpleNamespace
from typing import Optional
import requests
from sglang.test.few_shot_gsm8k import run_eval as run_eval_gsm8k
from sglang.test.test_utils import CustomTestCase
class GSM8KMixin:
accuracy: float
gsm8k_accuracy_thres: float
gsm8k_accept_length_thres: Optional[float] = None
def test_gsm8k(self):
requests.get(self.base_url + "/flush_cache")
def test_gsm8k(self: CustomTestCase):
args = SimpleNamespace(
num_shots=5,
data_path=None,
@@ -19,4 +24,12 @@ class GSM8KMixin:
)
metrics = run_eval_gsm8k(args)
print(f"{metrics=}")
self.assertGreaterEqual(metrics["accuracy"], self.accuracy)
self.assertGreaterEqual(metrics["accuracy"], self.gsm8k_accuracy_thres)
if self.gsm8k_accept_length_thres is not None:
server_info = requests.get(self.base_url + "/server_info")
avg_spec_accept_length = server_info.json()["internal_states"][0][
"avg_spec_accept_length"
]
print(f"{avg_spec_accept_length=}")
self.assertGreater(avg_spec_accept_length, self.gsm8k_accept_length_thres)