Skip to content

Conversation

@sasha0552
Copy link
Contributor

@sasha0552 sasha0552 commented May 1, 2024

AFAIK, OpenAI allows you to specify -1 to use random seed.

I haven't tested this because I don't have access to their API, but:

  1. The application I am using uses -1 as a random seed and does not allow you to exclude the seed field.
  2. The OpenAI-compatible server implementation I know of (llama.cpp) allows -1 to be used as a random seed.

Copy link
Collaborator

@simon-mo simon-mo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confirming this behavior with openai

(base) ➜  ~ curl https://api.openai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "gpt-4-turbo", "seed": 1,
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "Generate a number!"
      }
    ]
  }'
{
  "id": "chatcmpl-9K8DYBaq9ywPOwl6ys5O7xLbA9tWg",
  "object": "chat.completion",
  "created": 1714585176,
  "model": "gpt-4-turbo-2024-04-09",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Sure! Here is a random number: 453"
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 21,
    "completion_tokens": 10,
    "total_tokens": 31
  },
  "system_fingerprint": "fp_ea6eb70039"
}
(base) ➜  ~ curl https://api.openai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "gpt-4-turbo", "seed": 1,
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "Generate a number!"
      }
    ]
  }'
{
  "id": "chatcmpl-9K8Dap5ALdZPUpmeF4MdbWUkoz4L0",
  "object": "chat.completion",
  "created": 1714585178,
  "model": "gpt-4-turbo-2024-04-09",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Sure! Here is a random number: 453"
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 21,
    "completion_tokens": 10,
    "total_tokens": 31
  },
  "system_fingerprint": "fp_46a93fa712"
}
(base) ➜  ~ curl https://api.openai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "gpt-4-turbo", "seed": -1,
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "Generate a number!"
      }
    ]
  }'
{
  "id": "chatcmpl-9K8DgE5KkC27o9wEiU9eKfXqSVHLj",
  "object": "chat.completion",
  "created": 1714585184,
  "model": "gpt-4-turbo-2024-04-09",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Sure! Here's a random number: 52"
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 21,
    "completion_tokens": 10,
    "total_tokens": 31
  },
  "system_fingerprint": "fp_ea6eb70039"
}
(base) ➜  ~ curl https://api.openai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "gpt-4-turbo", "seed": -1,
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "Generate a number!"
      }
    ]
  }'
{
  "id": "chatcmpl-9K8DnmTTigpuaXjByPNIkb6Eci0in",
  "object": "chat.completion",
  "created": 1714585191,
  "model": "gpt-4-turbo-2024-04-09",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Sure! Here's a random number: **37**."
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 21,
    "completion_tokens": 12,
    "total_tokens": 33
  },
  "system_fingerprint": "fp_3450ce39d5"
}

@simon-mo simon-mo merged commit 6990912 into vllm-project:main May 1, 2024
@sasha0552 sasha0552 deleted the seed-random branch May 2, 2024 02:13
robertgshaw2-redhat pushed a commit to neuralmagic/nm-vllm that referenced this pull request May 6, 2024
z103cb pushed a commit to z103cb/opendatahub_vllm that referenced this pull request May 7, 2024
dtrifiro pushed a commit to opendatahub-io/vllm that referenced this pull request May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants