Groundedness Check
Check the groundedness of an assistant's response to a user-provided context.
Large Language Models (LLMs) are capable of generating elaborate, information-rich texts, but they are prone to hallucinations -- they can produce factually incorrect (i.e., ungrounded) responses. A popular approach to overcoming this limitation of LLMs is to provide chunks of text, often called "contexts," which LLMs can use as a point of reference to generate factually correct outputs. This approach is known as Retrieval-Augmented Generation, or RAG.
However, RAG does not always guarantee truthful answers from LLMs. Therefore, an additional step is required to check whether a model-generated output is indeed grounded in a given context. The Groundedness Check API is specifically designed for this purpose: to check the groundedness of an assistant's response to a context provided by a user. Given two messages – a user-provided context and a model response – the API will return whether the response is grounded, not grounded, or if it is unsure about the groundedness of the response to the context.
Available models
Model | Release date | Context Length | Description |
---|---|---|---|
solar-1-mini-groundedness-checkbeta | 2024-05-02 | 32768 | Solar Mini based groundedness check model with a 32k context limit.solar-1-mini-groundedness-check is alias for our latest Solar Mini Groundedness check model. (Currently solar-1-mini-groundedness-check-240502 ) |
Request
POST https://api.upstage.ai/v1/solar/chat/completions
Parameters
The messages
parameter should be a list of message objects containing two elements: 1) a user-provided context and 2) an assistant's response to be checked. Each message object must specify the type of message as either user
(context) or assistant
(response) using the role
attribute, and set the content
attribute with the corresponding text string.
The API response will be a string with a value of either grounded
, notGrounded
, or notSure
. The notSure
response is returned when the groundedness of the assistant's response to the provided context cannot be clearly determined.
Request headers
Authorization string Required |
Request body
messages list Required |
messages[].role string Required |
messages[].content string Required |
model string Required |
temperature float Optional |
Response
Return values
Returns a chat.completion
object.
The chat completion object
id string |
object string |
created integer |
model string |
choices list |
choices[].index integer |
choices[].message object |
choices[].message.role string |
choices[].message.content string |
choices[].logprobs null |
choices[].finish_reason string |
usage object |
usage.completion_tokens integer |
usage.prompt_tokens integer |
usage.total_tokens integer |
system_fingerprint null |
Example
Request
curl --location 'https://api.upstage.ai/v1/solar/chat/completions' \
--header 'Authorization: Bearer UPSTAGE_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "solar-1-mini-groundedness-check",
"messages": [
{
"role": "user",
"content": "Mauna Kea is an inactive volcano on the island of Hawaiʻi. Its peak is 4,207.3 m above sea level, making it the highest point in Hawaii and second-highest peak of an island on Earth."
},
{
"role": "assistant",
"content": "Mauna Kea is 5,207.3 meters tall."
}
],
"temperature": 0.5
}'
Response
Success - HTTP Status 200 OK
{
"id": "c43ecfa6-31a9-4884-a920-a5f44fb727df",
"object": "chat.completion",
"created": 1710338020,
"model": "solar-1-mini-groundedness-check-240502",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "notGrounded"
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 132,
"completion_tokens": 3,
"total_tokens": 135
},
"system_fingerprint": ""
}
Error - HTTP Status : 400 Bad Request (Reason: found more/less than 1 user or assistant message)
{
"error": {
"message": "invalid request: 1 user message expected, found 2",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
Error - HTTP Status : 400 Bad Request (Reason: missing user or assistant message content)
{
"error": {
"message": "invalid request: user message content is required",
"type": "invalid_request_error",
"param": null,
"code": null
}
}