Skip to content

Openai api completion params [seed, temperature, max_tokens, system_fingerprint] #1016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 7, 2024

Conversation

vmpuri
Copy link
Contributor

@vmpuri vmpuri commented Aug 6, 2024

Implement [seed, temperature, max_tokens, system_fingerprint(partial)]
Improve determinism of generated responses.

  • seed: simply set torch.manual_seed() each time the seed is provided
  • max_tokens: default to 16 as per API spec.
  • temperature: default to 1.0 as per API spec.
  • system_fingerprint: for now, the backend and torch.dtype of the model weights. In the future, we should add model version information to this.

Testing: With the same seeds, the generated response is the same.

Screen.Recording.2024-08-07.at.11.40.10.AM.mov

Tested with the following cURL:

curl http://127.0.0.1:5000/v1/chat \
  -H "Content-Type: application/json" \
  -d '{
    "model": "stories15M",
    "stream": "true",
    "max_tokens": "123",
    "temperature": "0.2",
    "seed": "813",
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "Story about a dog."
      }
    ]
  }'

Copy link

pytorch-bot bot commented Aug 6, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/torchchat/1016

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit e08f809 with merge base 67f678b (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 6, 2024
@vmpuri vmpuri force-pushed the openai_api_completion_params branch from 129829a to 46b49e8 Compare August 6, 2024 22:51
@vmpuri vmpuri changed the base branch from main to openai_api_version_route August 6, 2024 22:51
Copy link
Contributor

@byjlw byjlw left a comment

Choose a reason for hiding this comment

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

several mostly nits other than that looks good

@vmpuri vmpuri force-pushed the openai_api_completion_params branch from 46b49e8 to 770218c Compare August 7, 2024 18:32
@vmpuri vmpuri marked this pull request as ready for review August 7, 2024 18:33
@vmpuri vmpuri force-pushed the openai_api_completion_params branch 2 times, most recently from dc56a48 to 7d5a3b1 Compare August 7, 2024 18:36
@vmpuri vmpuri force-pushed the openai_api_completion_params branch from 7d5a3b1 to e08f809 Compare August 7, 2024 18:43
@vmpuri vmpuri merged commit 3d702af into openai_api_version_route Aug 7, 2024
51 checks passed
byjlw pushed a commit that referenced this pull request Aug 14, 2024
* Add OPENAI_API_VERSION constant to routes

* Add seed, temperature, max_tokens  and system_fingerprint paramters to request/response (#1016)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants