Skip to content

Can only get a limited number of logprobs from completions? #38

Closed

Description

@yangkevin2

Hi,

I am specifying that I want the logprobs of the top 100 tokens but the API seems to give me at most 5:

(Pdb) response = openai.Completion.create(engine='ada', prompt='test', max_tokens=1, logprobs=100)
(Pdb) response
<OpenAIObject text_completion id=cmpl-3qtEQ4P8iNmTHqV8Eh4Wq59vzqnbm at 0x7fcf271ebb30> JSON: {
  "choices": [
    {
      "finish_reason": "length",
      "index": 0,
      "logprobs": {
        "text_offset": [
          4
        ],
        "token_logprobs": [
          -10.029023
        ],
        "tokens": [
          " goal"
        ],
        "top_logprobs": [
          {
            ",": -3.721809,
            "-": -2.6293674,
            ".": -2.6775126,
            "/": -2.527664,
            "_": -2.10408
          }
        ]
      },
      "text": " goal"
    }
  ],
  "created": 1633734378,
  "id": "cmpl-3qtEQ4P8iNmTHqV8Eh4Wq59vzqnbm",
  "model": "ada:2020-05-03",
  "object": "text_completion"
}

Is there any way I can get around this?

Activity

  1. added a commit that references this issue on Oct 10, 2021
  2. BigSalmon2 commented on Oct 12, 2021

    @BigSalmon2
    openai.api_key = "[X]"
    response = openai.Completion.create(engine="davinci-codex",
                                        prompt="Hello",
                                        logprobs=100,
                                        max_tokens=1)
    print(response['choices'][0]['logprobs']['top_logprobs'][0])```
    
  3. yangkevin2 commented on Oct 14, 2021

    @yangkevin2
    Author

    Er, was this supposed to be a fix? The response still only has 5 logprobs when I run that command.

  4. kimyoonduk commented on Oct 29, 2021

    @kimyoonduk

    Having the same issue with logprobs being hardcoded to 5, even as I send POST requests to the API endpoint via curl.
    Perhaps this is a serverside problem? Definitely would like to hear updates on this!

  5. hallacy commented on Dec 23, 2021

    @hallacy
    Contributor

    I'm a bit late here. There default was recently changed to 5 as mentioned here: https://beta.openai.com/docs/api-reference/completions/create#completions/create-logprobs. If you'd like more, please reach out to support@openai.com

  6. added a commit that references this issue on Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions