#seed param

1 messages · Page 1 of 1 (latest)

grand loom
#

how can I use the new seed parameter in the API?

lone jayBOT
#

Hi @grand loom. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

The seed parameter is a new feature in OpenAI's API that allows you to generate consistent outputs across API calls. Here's how you can use it:

  1. Set the seed parameter to any integer of your choice, but use the same value across requests. For example, 12345.

  2. Set all other parameters (prompt, temperature, top_p, etc.) to the same values across requests.

  3. In the response, check the system_fingerprint field. The system fingerprint is an identifier for the current combination of model weights, infrastructure, and other configuration options used by OpenAI servers to generate the completion. It changes whenever you change request parameters, or OpenAI updates numerical configuration of the infrastructure serving our models (which may happen a few times a year).

If the seed, request parameters, and system_fingerprint all match across your requests, then model outputs will mostly be identical. There is a small chance that responses differ even when request parameters and system_fingerprint match, due to the inherent non-determinism of computers.

Here's an example of how to use the seed parameter in Python:

SEED = 123
response = await get_chat_response(
 system_message=system_message, seed=SEED, user_request=user_request
)
previous_response = response
response = await get_chat_response(
 system_message=system_message, seed=SEED, user_request=user_request
)

In this example, get_chat_response is a function that sends a request to the OpenAI API and returns the response. system_message and user_request are the system message and user request for the chat, respectively.

Please note that determinism is not guaranteed, and you should refer to the system_fingerprint response parameter to monitor changes in the backend.