From 472e117f2105fea14b84777d64035b0d2d971dd8 Mon Sep 17 00:00:00 2001 From: Xin Yang <105740670+xyang16@users.noreply.github.com> Date: Tue, 16 Apr 2024 14:36:47 -0700 Subject: [PATCH] [doc] Fix chat completions input output schema doc (#1778) --- .../user_guides/chat_input_output_schema.md | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/serving/docs/lmi/user_guides/chat_input_output_schema.md b/serving/docs/lmi/user_guides/chat_input_output_schema.md index 3f15f47c6..5beabb875 100644 --- a/serving/docs/lmi/user_guides/chat_input_output_schema.md +++ b/serving/docs/lmi/user_guides/chat_input_output_schema.md @@ -96,7 +96,7 @@ Example response: Chat Completions API supports streaming, and the response format for streaming differs from the response format for non-streaming. -To use streaming, set `"stream": true`, or `option.output_formatter=jsonlines`). +To use streaming, set `"stream": true`, or `option.output_formatter=jsonlines`. The response is returned token by token as application/jsonlines content-type: @@ -110,7 +110,7 @@ The response is returned token by token as application/jsonlines content-type: Example response: ``` -{"id": "chatcmpl-0", "object": "chat.completion.chunk", "created": 1712792433, "choices": [{"index": 0, "delta": {"content": " Oh"}, "logprobs": [{"content": [{"token": " Oh", "logprob": -4.499478340148926, "bytes": [32, 79, 104], "top_logprobs": [{"token": -4.499478340148926, "logprob": -4.499478340148926, "bytes": [32, 79, 104]}]}]}], "finish_reason": null}]} +{"id": "chatcmpl-0", "object": "chat.completion.chunk", "created": 1712792433, "choices": [{"index": 0, "delta": {"content": " Oh", "role": "assistant"}, "logprobs": [{"content": [{"token": " Oh", "logprob": -4.499478340148926, "bytes": [32, 79, 104], "top_logprobs": [{"token": -4.499478340148926, "logprob": -4.499478340148926, "bytes": [32, 79, 104]}]}]}], "finish_reason": null}]} ... {"id": "chatcmpl-0", "object": "chat.completion.chunk", "created": 1712792436, "choices": [{"index": 0, "delta": {"content": " assist"}, "logprobs": [{"content": [{"token": " assist", "logprob": -1.019672155380249, "bytes": [32, 97, 115, 115, 105, 115, 116], "top_logprobs": [{"token": -1.019672155380249, "logprob": -1.019672155380249, "bytes": [32, 97, 115, 115, 105, 115, 116]}]}]}], "finish_reason": "length"}]} ``` @@ -143,12 +143,12 @@ Example: The choice object represents a chat completion choice. It contains the following fields: -| Field Name | Type | Description | Example | -|-----------------|----------------------|---------------------------------------------------|-------------------------------------------| -| `index` | int | The index of the choice | 0 | -| `message` | [Message](#message) | A chat completion message generated by the model. | See the [Message](#message) documentation | -| `logprobs` | [Logprobs](#logprob) | The log probability of the token | See the [Logprobs](#logprob) documentation | -| `finish_reason` | string enum | The reason the model stopped generating tokens | "length", "eos_token", "stop_sequence" | +| Field Name | Type | Description | Example | +|-----------------|-----------------------|---------------------------------------------------|-------------------------------------------| +| `index` | int | The index of the choice | 0 | +| `message` | [Message](#message) | A chat completion message generated by the model. | See the [Message](#message) documentation | +| `logprobs` | [Logprobs](#logprobs) | The log probability of the token | See the [Logprobs](#logprob) documentation | +| `finish_reason` | string enum | The reason the model stopped generating tokens | "length", "eos_token", "stop_sequence" | Example: @@ -169,17 +169,17 @@ Example: The choice object represents a chat completion choice. It contains the following fields: -| Field Name | Type | Description | Example | -|-----------------|----------------------|----------------------------------------------------------------|--------------------------------------------| -| `index` | int | The index of the choice | 0 | -| `delta` | [Message](#message) | A chat completion delta generated by streamed model responses. | See the [Message](#message) documentation | -| `logprobs` | [Logprobs](#logprob) | The log probability of the token | See the [Logprobs](#logprob) documentation | -| `finish_reason` | string enum | The reason the model stopped generating tokens | "length", "eos_token", "stop_sequence" | +| Field Name | Type | Description | Example | +|-----------------|-----------------------|----------------------------------------------------------------|---------------------------------------------| +| `index` | int | The index of the choice | 0 | +| `delta` | [Message](#message) | A chat completion delta generated by streamed model responses. | See the [Message](#message) documentation | +| `logprobs` | [Logprobs](#logprobs) | The log probability of the token | See the [Logprobs](#logprobs) documentation | +| `finish_reason` | string enum | The reason the model stopped generating tokens | "length", "eos_token", "stop_sequence" | Example: ``` -{"index": 0, "delta": {"content": " Oh"}, "logprobs": [{"content": [{"token": " Oh", "logprob": -4.499478340148926, "bytes": [32, 79, 104], "top_logprobs": [{"token": -4.499478340148926, "logprob": -4.499478340148926, "bytes": [32, 79, 104]}]}]} +{"index": 0, "delta": {"content": " Oh", "role": "assistant"}, "logprobs": [{"content": [{"token": " Oh", "logprob": -4.499478340148926, "bytes": [32, 79, 104], "top_logprobs": [{"token": -4.499478340148926, "logprob": -4.499478340148926, "bytes": [32, 79, 104]}]}]} ``` ### Logprobs @@ -232,6 +232,7 @@ Example: ### TopLogprob Top log probability information for the choice. +It contains the following fields: | Field Name | Type | Description | Example | |----------------|------------------------------------|------------------------------------------------------------|-------------------------------------------------|