[PR #10373] [MERGED] feat: logit bias #61369

Closed
opened 2026-05-06 04:50:55 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/10373
Author: @dannyl1u
Created: 2/19/2025
Status: Merged
Merged: 3/1/2025
Merged by: @tjbck

Base: devHead: logit_bias


📝 Commits (8)

  • 4a2a12f feat: scaffolding for logit_bias
  • 8aa6415 include logit_bias in form_data
  • 046f1fb Merge pull request #10927 from open-webui/dev
  • 95cadac Merge pull request #10933 from open-webui/dev
  • 34e3cb6 logit bias: update tooltip message
  • 90aa295 logit_bias: handle comma seperated values
  • f4bd094 Merge remote-tracking branch 'origin' into logit_bias
  • f9292ab Merge branch 'dev' into logit_bias

📊 Changes

5 files changed (+66 additions, -0 deletions)

View changed files

📝 backend/open_webui/utils/middleware.py (+6 -0)
📝 backend/open_webui/utils/misc.py (+12 -0)
📝 backend/open_webui/utils/payload.py (+1 -0)
📝 src/lib/components/chat/Settings/Advanced/AdvancedParams.svelte (+44 -0)
📝 src/lib/components/chat/Settings/General.svelte (+3 -0)

📄 Description

Pull Request Checklist

Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.

Before submitting, make sure you've checked the following:

  • Target branch: Please verify that the pull request targets the dev branch.
  • Description: Provide a concise description of the changes made in this pull request.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Have you written and run sufficient tests for validating the changes?
  • Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
  • Prefix: To cleary categorize this pull request, prefix the pull request title, using one of the following:
    • BREAKING CHANGE: Significant changes that may affect compatibility
    • build: Changes that affect the build system or external dependencies
    • ci: Changes to our continuous integration processes or workflows
    • chore: Refactor, cleanup, or other non-functional code changes
    • docs: Documentation update or addition
    • feat: Introduces a new feature or enhancement to the codebase
    • fix: Bug fix or error correction
    • i18n: Internationalization or localization changes
    • perf: Performance improvement
    • refactor: Code restructuring for better maintainability, readability, or scalability
    • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)
    • test: Adding missing tests or correcting existing tests
    • WIP: Work in progress, a temporary label for incomplete or ongoing work

Changelog Entry

Description

  • adds logit bias parameter for token-level generation bias (closes #9280)

Added

  • Introduced a logit bias parameter which users can utilize to apply biases to specific tokens during text generation through comma separated token:bias pairs in Advanced Parameters

Changed

  • n/a

Deprecated

  • n/a

Removed

  • n/a

Fixed

  • n/a

Security

  • n/a

Breaking Changes

  • n/a

Additional Information

I implemented this by accepting comma separated token:bias pairs as suggested in #9280 . This approach allows for easy copy-pasting and doesn't take up too much vertical space.

I also considered the following implementations:

  1. separating token and bias into separate input boxes side by side, each pair on a new row
  • visually appealing, user friendly
  • supporting copy-paste would require further development efforts
  • takes up more vertical space, would need to scroll longer to find other settings in Advanced Parameters
  1. accepting raw JSON
  • easy to implement
  • less user friendly

Tested with OpenAI APIs.

Screenshots or Videos

Demo video (apologies for not using OLED dark theme (the best))

https://github.com/user-attachments/assets/c6876936-cf15-4112-addc-fdeeb82e41f3


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/10373 **Author:** [@dannyl1u](https://github.com/dannyl1u) **Created:** 2/19/2025 **Status:** ✅ Merged **Merged:** 3/1/2025 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `logit_bias` --- ### 📝 Commits (8) - [`4a2a12f`](https://github.com/open-webui/open-webui/commit/4a2a12fd21c15f1671f82315b7897a0f9af4f6f3) feat: scaffolding for logit_bias - [`8aa6415`](https://github.com/open-webui/open-webui/commit/8aa6415500bd2b7213aa1b655cbe386fb5457810) include logit_bias in form_data - [`046f1fb`](https://github.com/open-webui/open-webui/commit/046f1fb30ace13b81dea846629841c86fa97aa46) Merge pull request #10927 from open-webui/dev - [`95cadac`](https://github.com/open-webui/open-webui/commit/95cadaca72e676199caf894f40cc132d7c8416df) Merge pull request #10933 from open-webui/dev - [`34e3cb6`](https://github.com/open-webui/open-webui/commit/34e3cb688147a1143963a120017d6e98292ce121) logit bias: update tooltip message - [`90aa295`](https://github.com/open-webui/open-webui/commit/90aa29528c0360dc0a93a4c9c6ccc64d5d1b3102) logit_bias: handle comma seperated values - [`f4bd094`](https://github.com/open-webui/open-webui/commit/f4bd09412887a99d5c3fd25fddfb4918aa82a1a9) Merge remote-tracking branch 'origin' into logit_bias - [`f9292ab`](https://github.com/open-webui/open-webui/commit/f9292ab4d2f72c7b87517fdf78fee5595f0f919d) Merge branch 'dev' into logit_bias ### 📊 Changes **5 files changed** (+66 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/middleware.py` (+6 -0) 📝 `backend/open_webui/utils/misc.py` (+12 -0) 📝 `backend/open_webui/utils/payload.py` (+1 -0) 📝 `src/lib/components/chat/Settings/Advanced/AdvancedParams.svelte` (+44 -0) 📝 `src/lib/components/chat/Settings/General.svelte` (+3 -0) </details> ### 📄 Description # Pull Request Checklist ### Note to first-time contributors: Please open a discussion post in [Discussions](https://github.com/open-webui/open-webui/discussions) and describe your changes before submitting a pull request. **Before submitting, make sure you've checked the following:** - [x] **Target branch:** Please verify that the pull request targets the `dev` branch. - [x] **Description:** Provide a concise description of the changes made in this pull request. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [x] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources? - [x] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [x] **Testing:** Have you written and run sufficient tests for validating the changes? - [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards? - [x] **Prefix:** To cleary categorize this pull request, prefix the pull request title, using one of the following: - **BREAKING CHANGE**: Significant changes that may affect compatibility - **build**: Changes that affect the build system or external dependencies - **ci**: Changes to our continuous integration processes or workflows - **chore**: Refactor, cleanup, or other non-functional code changes - **docs**: Documentation update or addition - **feat**: Introduces a new feature or enhancement to the codebase - **fix**: Bug fix or error correction - **i18n**: Internationalization or localization changes - **perf**: Performance improvement - **refactor**: Code restructuring for better maintainability, readability, or scalability - **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.) - **test**: Adding missing tests or correcting existing tests - **WIP**: Work in progress, a temporary label for incomplete or ongoing work # Changelog Entry ### Description - adds logit bias parameter for token-level generation bias (closes #9280) ### Added - Introduced a logit bias parameter which users can utilize to apply biases to specific tokens during text generation through comma separated token:bias pairs in Advanced Parameters ### Changed - n/a ### Deprecated - n/a ### Removed - n/a ### Fixed - n/a ### Security - n/a ### Breaking Changes - n/a --- ### Additional Information I implemented this by accepting comma separated token:bias pairs as suggested in #9280 . This approach allows for easy copy-pasting and doesn't take up too much vertical space. I also considered the following implementations: 1. separating token and bias into separate input boxes side by side, each pair on a new row - visually appealing, user friendly - supporting copy-paste would require further development efforts - takes up more vertical space, would need to scroll longer to find other settings in Advanced Parameters 2. accepting raw JSON - easy to implement - less user friendly Tested with OpenAI APIs. ### Screenshots or Videos Demo video (apologies for not using OLED dark theme (the best)) https://github.com/user-attachments/assets/c6876936-cf15-4112-addc-fdeeb82e41f3 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-06 04:50:55 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#61369