Team Ai
Modelpublic

Felipe97/llama-cpp-compiled

sourceHugging Faceupdated 21d agoView on Hugging Face
0likes1.2kdownloads
test_ignore_eos.py44 linesDownload Raw Back to unit
1import pytest2from utils import *3 4server = ServerPreset.tinyllama2()5 6 7@pytest.fixture(autouse=True)8def create_server():9    global server10    server = ServerPreset.tinyllama2()11 12 13def test_ignore_eos_populates_logit_bias():14    """ignore_eos=true must add EOG logit biases to generation_settings."""15    global server16    server.start()17    res = server.make_request("POST", "/completion", data={18        "n_predict": 8,19        "prompt": "Once upon a time",20        "ignore_eos": True,21        "temperature": 0.0,22    })23    assert res.status_code == 20024    # EOG token biases must be present with -inf bias25    logit_bias = res.body["generation_settings"]["logit_bias"]26    assert len(logit_bias) > 027    for entry in logit_bias:28        assert entry["bias"] is None  # null in JSON represents -inf29 30 31def test_ignore_eos_false_no_logit_bias():32    """ignore_eos=false (default) must NOT add EOG logit biases."""33    global server34    server.start()35    res = server.make_request("POST", "/completion", data={36        "n_predict": 8,37        "prompt": "Once upon a time",38        "ignore_eos": False,39        "temperature": 0.0,40    })41    assert res.status_code == 20042    logit_bias = res.body["generation_settings"]["logit_bias"]43    assert len(logit_bias) == 044