mirror of
https://github.com/huggingface/text-generation-inference.git
synced 2025-09-11 04:14:52 +00:00
feat: add integration tests and snapshots for phi
This commit is contained in:
parent
18f13a1b5f
commit
c7ad2b61a1
@ -0,0 +1,84 @@
|
|||||||
|
{
|
||||||
|
"details": {
|
||||||
|
"best_of_sequences": null,
|
||||||
|
"finish_reason": "length",
|
||||||
|
"generated_tokens": 10,
|
||||||
|
"prefill": [
|
||||||
|
{
|
||||||
|
"id": 14402,
|
||||||
|
"logprob": null,
|
||||||
|
"text": "Test"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2581,
|
||||||
|
"logprob": -11.6171875,
|
||||||
|
"text": " request"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"seed": null,
|
||||||
|
"tokens": [
|
||||||
|
{
|
||||||
|
"id": 25,
|
||||||
|
"logprob": -2.3203125,
|
||||||
|
"special": false,
|
||||||
|
"text": ":"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1391,
|
||||||
|
"logprob": -0.98779297,
|
||||||
|
"special": false,
|
||||||
|
"text": " {"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 25927,
|
||||||
|
"logprob": -0.76660156,
|
||||||
|
"special": false,
|
||||||
|
"text": "request"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 92,
|
||||||
|
"logprob": -0.7246094,
|
||||||
|
"special": false,
|
||||||
|
"text": "}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4943,
|
||||||
|
"logprob": -0.41333008,
|
||||||
|
"special": false,
|
||||||
|
"text": "\")"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 198,
|
||||||
|
"logprob": -0.11785889,
|
||||||
|
"special": false,
|
||||||
|
"text": "\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 50280,
|
||||||
|
"logprob": -0.97265625,
|
||||||
|
"special": false,
|
||||||
|
"text": " "
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 26209,
|
||||||
|
"logprob": -1.4414062,
|
||||||
|
"special": false,
|
||||||
|
"text": "response"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 796,
|
||||||
|
"logprob": -0.0569458,
|
||||||
|
"special": false,
|
||||||
|
"text": " ="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2116,
|
||||||
|
"logprob": -1.1533203,
|
||||||
|
"special": false,
|
||||||
|
"text": " self"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"top_tokens": null
|
||||||
|
},
|
||||||
|
"generated_text": ": {request}\")\n response = self"
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
{
|
||||||
|
"details": {
|
||||||
|
"best_of_sequences": null,
|
||||||
|
"finish_reason": "stop_sequence",
|
||||||
|
"generated_tokens": 6,
|
||||||
|
"prefill": [
|
||||||
|
{
|
||||||
|
"id": 14402,
|
||||||
|
"logprob": null,
|
||||||
|
"text": "Test"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2581,
|
||||||
|
"logprob": -11.6171875,
|
||||||
|
"text": " request"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"seed": 0,
|
||||||
|
"tokens": [
|
||||||
|
{
|
||||||
|
"id": 284,
|
||||||
|
"logprob": -0.19421387,
|
||||||
|
"special": false,
|
||||||
|
"text": " to"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3758,
|
||||||
|
"logprob": -0.62597656,
|
||||||
|
"special": false,
|
||||||
|
"text": " send"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1366,
|
||||||
|
"logprob": -0.87060547,
|
||||||
|
"special": false,
|
||||||
|
"text": " data"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 625,
|
||||||
|
"logprob": -0.88427734,
|
||||||
|
"special": false,
|
||||||
|
"text": " over"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 257,
|
||||||
|
"logprob": -1.0830078,
|
||||||
|
"special": false,
|
||||||
|
"text": " a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3127,
|
||||||
|
"logprob": -1.9462891,
|
||||||
|
"special": false,
|
||||||
|
"text": " network"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"top_tokens": null
|
||||||
|
},
|
||||||
|
"generated_text": "Test request to send data over a network"
|
||||||
|
}
|
@ -0,0 +1,338 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"details": {
|
||||||
|
"best_of_sequences": null,
|
||||||
|
"finish_reason": "length",
|
||||||
|
"generated_tokens": 10,
|
||||||
|
"prefill": [
|
||||||
|
{
|
||||||
|
"id": 14402,
|
||||||
|
"logprob": null,
|
||||||
|
"text": "Test"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2581,
|
||||||
|
"logprob": -11.6171875,
|
||||||
|
"text": " request"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"seed": null,
|
||||||
|
"tokens": [
|
||||||
|
{
|
||||||
|
"id": 25,
|
||||||
|
"logprob": -2.3203125,
|
||||||
|
"special": false,
|
||||||
|
"text": ":"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1391,
|
||||||
|
"logprob": -0.98779297,
|
||||||
|
"special": false,
|
||||||
|
"text": " {"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 25927,
|
||||||
|
"logprob": -0.7729492,
|
||||||
|
"special": false,
|
||||||
|
"text": "request"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 92,
|
||||||
|
"logprob": -0.7241211,
|
||||||
|
"special": false,
|
||||||
|
"text": "}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4943,
|
||||||
|
"logprob": -0.4091797,
|
||||||
|
"special": false,
|
||||||
|
"text": "\")"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 198,
|
||||||
|
"logprob": -0.119018555,
|
||||||
|
"special": false,
|
||||||
|
"text": "\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 50280,
|
||||||
|
"logprob": -0.9707031,
|
||||||
|
"special": false,
|
||||||
|
"text": " "
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 26209,
|
||||||
|
"logprob": -1.4414062,
|
||||||
|
"special": false,
|
||||||
|
"text": "response"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 796,
|
||||||
|
"logprob": -0.056854248,
|
||||||
|
"special": false,
|
||||||
|
"text": " ="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2116,
|
||||||
|
"logprob": -1.1533203,
|
||||||
|
"special": false,
|
||||||
|
"text": " self"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"top_tokens": null
|
||||||
|
},
|
||||||
|
"generated_text": ": {request}\")\n response = self"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"details": {
|
||||||
|
"best_of_sequences": null,
|
||||||
|
"finish_reason": "length",
|
||||||
|
"generated_tokens": 10,
|
||||||
|
"prefill": [
|
||||||
|
{
|
||||||
|
"id": 14402,
|
||||||
|
"logprob": null,
|
||||||
|
"text": "Test"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2581,
|
||||||
|
"logprob": -11.6171875,
|
||||||
|
"text": " request"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"seed": null,
|
||||||
|
"tokens": [
|
||||||
|
{
|
||||||
|
"id": 25,
|
||||||
|
"logprob": -2.3203125,
|
||||||
|
"special": false,
|
||||||
|
"text": ":"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1391,
|
||||||
|
"logprob": -0.98779297,
|
||||||
|
"special": false,
|
||||||
|
"text": " {"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 25927,
|
||||||
|
"logprob": -0.7729492,
|
||||||
|
"special": false,
|
||||||
|
"text": "request"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 92,
|
||||||
|
"logprob": -0.7241211,
|
||||||
|
"special": false,
|
||||||
|
"text": "}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4943,
|
||||||
|
"logprob": -0.4091797,
|
||||||
|
"special": false,
|
||||||
|
"text": "\")"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 198,
|
||||||
|
"logprob": -0.119018555,
|
||||||
|
"special": false,
|
||||||
|
"text": "\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 50280,
|
||||||
|
"logprob": -0.9707031,
|
||||||
|
"special": false,
|
||||||
|
"text": " "
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 26209,
|
||||||
|
"logprob": -1.4414062,
|
||||||
|
"special": false,
|
||||||
|
"text": "response"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 796,
|
||||||
|
"logprob": -0.056854248,
|
||||||
|
"special": false,
|
||||||
|
"text": " ="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2116,
|
||||||
|
"logprob": -1.1533203,
|
||||||
|
"special": false,
|
||||||
|
"text": " self"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"top_tokens": null
|
||||||
|
},
|
||||||
|
"generated_text": ": {request}\")\n response = self"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"details": {
|
||||||
|
"best_of_sequences": null,
|
||||||
|
"finish_reason": "length",
|
||||||
|
"generated_tokens": 10,
|
||||||
|
"prefill": [
|
||||||
|
{
|
||||||
|
"id": 14402,
|
||||||
|
"logprob": null,
|
||||||
|
"text": "Test"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2581,
|
||||||
|
"logprob": -11.6171875,
|
||||||
|
"text": " request"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"seed": null,
|
||||||
|
"tokens": [
|
||||||
|
{
|
||||||
|
"id": 25,
|
||||||
|
"logprob": -2.3203125,
|
||||||
|
"special": false,
|
||||||
|
"text": ":"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1391,
|
||||||
|
"logprob": -0.98779297,
|
||||||
|
"special": false,
|
||||||
|
"text": " {"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 25927,
|
||||||
|
"logprob": -0.7729492,
|
||||||
|
"special": false,
|
||||||
|
"text": "request"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 92,
|
||||||
|
"logprob": -0.7241211,
|
||||||
|
"special": false,
|
||||||
|
"text": "}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4943,
|
||||||
|
"logprob": -0.4091797,
|
||||||
|
"special": false,
|
||||||
|
"text": "\")"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 198,
|
||||||
|
"logprob": -0.119018555,
|
||||||
|
"special": false,
|
||||||
|
"text": "\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 50280,
|
||||||
|
"logprob": -0.9707031,
|
||||||
|
"special": false,
|
||||||
|
"text": " "
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 26209,
|
||||||
|
"logprob": -1.4414062,
|
||||||
|
"special": false,
|
||||||
|
"text": "response"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 796,
|
||||||
|
"logprob": -0.056854248,
|
||||||
|
"special": false,
|
||||||
|
"text": " ="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2116,
|
||||||
|
"logprob": -1.1533203,
|
||||||
|
"special": false,
|
||||||
|
"text": " self"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"top_tokens": null
|
||||||
|
},
|
||||||
|
"generated_text": ": {request}\")\n response = self"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"details": {
|
||||||
|
"best_of_sequences": null,
|
||||||
|
"finish_reason": "length",
|
||||||
|
"generated_tokens": 10,
|
||||||
|
"prefill": [
|
||||||
|
{
|
||||||
|
"id": 14402,
|
||||||
|
"logprob": null,
|
||||||
|
"text": "Test"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2581,
|
||||||
|
"logprob": -11.6171875,
|
||||||
|
"text": " request"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"seed": null,
|
||||||
|
"tokens": [
|
||||||
|
{
|
||||||
|
"id": 25,
|
||||||
|
"logprob": -2.3203125,
|
||||||
|
"special": false,
|
||||||
|
"text": ":"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1391,
|
||||||
|
"logprob": -0.98779297,
|
||||||
|
"special": false,
|
||||||
|
"text": " {"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 25927,
|
||||||
|
"logprob": -0.7729492,
|
||||||
|
"special": false,
|
||||||
|
"text": "request"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 92,
|
||||||
|
"logprob": -0.7241211,
|
||||||
|
"special": false,
|
||||||
|
"text": "}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4943,
|
||||||
|
"logprob": -0.4091797,
|
||||||
|
"special": false,
|
||||||
|
"text": "\")"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 198,
|
||||||
|
"logprob": -0.119018555,
|
||||||
|
"special": false,
|
||||||
|
"text": "\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 50280,
|
||||||
|
"logprob": -0.9707031,
|
||||||
|
"special": false,
|
||||||
|
"text": " "
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 26209,
|
||||||
|
"logprob": -1.4414062,
|
||||||
|
"special": false,
|
||||||
|
"text": "response"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 796,
|
||||||
|
"logprob": -0.056854248,
|
||||||
|
"special": false,
|
||||||
|
"text": " ="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2116,
|
||||||
|
"logprob": -1.1533203,
|
||||||
|
"special": false,
|
||||||
|
"text": " self"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"top_tokens": null
|
||||||
|
},
|
||||||
|
"generated_text": ": {request}\")\n response = self"
|
||||||
|
}
|
||||||
|
]
|
65
integration-tests/models/test_flash_phi.py
Normal file
65
integration-tests/models/test_flash_phi.py
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="module")
|
||||||
|
def flash_phi_handle(launcher):
|
||||||
|
with launcher("microsoft/phi-2", num_shard=1) as handle:
|
||||||
|
yield handle
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="module")
|
||||||
|
async def flash_phi(flash_phi_handle):
|
||||||
|
await flash_phi_handle.health(300)
|
||||||
|
return flash_phi_handle.client
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
@pytest.mark.private
|
||||||
|
async def test_flash_phi(flash_phi, response_snapshot):
|
||||||
|
response = await flash_phi.generate(
|
||||||
|
"Test request", max_new_tokens=10, decoder_input_details=True
|
||||||
|
)
|
||||||
|
|
||||||
|
assert response.details.generated_tokens == 10
|
||||||
|
assert response.generated_text == ": {request}\")\n response = self"
|
||||||
|
assert response == response_snapshot
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
@pytest.mark.private
|
||||||
|
async def test_flash_phi_all_params(flash_phi, response_snapshot):
|
||||||
|
response = await flash_phi.generate(
|
||||||
|
"Test request",
|
||||||
|
max_new_tokens=10,
|
||||||
|
repetition_penalty=1.2,
|
||||||
|
return_full_text=True,
|
||||||
|
stop_sequences=["network"],
|
||||||
|
temperature=0.5,
|
||||||
|
top_p=0.9,
|
||||||
|
top_k=10,
|
||||||
|
truncate=5,
|
||||||
|
typical_p=0.9,
|
||||||
|
watermark=True,
|
||||||
|
decoder_input_details=True,
|
||||||
|
seed=0,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert response.details.generated_tokens == 6
|
||||||
|
assert response.generated_text == "Test request to send data over a network"
|
||||||
|
assert response == response_snapshot
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
@pytest.mark.private
|
||||||
|
async def test_flash_phi_load(flash_phi, generate_load, response_snapshot):
|
||||||
|
responses = await generate_load(
|
||||||
|
flash_phi, "Test request", max_new_tokens=10, n=4
|
||||||
|
)
|
||||||
|
|
||||||
|
assert len(responses) == 4
|
||||||
|
assert all(
|
||||||
|
[r.generated_text == responses[0].generated_text for r in responses]
|
||||||
|
), f"{[r.generated_text for r in responses]}"
|
||||||
|
assert responses[0].generated_text == ": {request}\")\n response = self"
|
||||||
|
|
||||||
|
assert responses == response_snapshot
|
Loading…
Reference in New Issue
Block a user