Skip to content
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

feat: reduce document selection overhead #3464

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

jonathan-rohde
Copy link
Contributor

@jonathan-rohde jonathan-rohde commented Jun 27, 2024

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

  • Each document that is part of the chat is stored within the chat data and is part of each chat completion request
  • With this change this overhead is reduced
  • For queries with all documents, the collection names are extracted in the backend
  • For queries with tags, the collection names are extracted in the backend
  • No change for single file selection
  • Benefit: Much faster request/response handling. Please see the screenshots of before and after.

Changed

  • Reduce the request size and chat history storage size by removing the file checksums from the request

Additional Information

  • Example with 10,000 documents
  • Browser used: Google Chrome
  • Environment: Localhost on MacOS
  • Headers before the change. Request size is 88785. Also the UI was a bit lagging around with computing the payload
    headers-before

  • Headers after the change. Request size is just 237. UI is very usable
    headers-after

  • Payload before the change. Quite a long list of checksum in payload
    payload-before

  • Payload after the change. Just the collection type is required
    payload-after

  • Timing before the change. Processing the request took 35s
    timing-before

  • Timing after the change. Processing the request took 8s. Side note: I did also a prove of concept by using just one single collection in ChromaDB and got the request down to under a second (after filling some caches, which is not possible storing it in different collections)
    timing-after

Script used to create the files

for i in {1..100000}
do
echo "Test file $i" > files/"test-$i.txt"
done

@jannikstdl
Copy link
Contributor

Yes very nice! We hat the same issue when using a large collection, it throwed an error in the UI:
image

And the Logs:
image

* no change for document selection
* only send the tag name or the type all_documents to backend
* fetch collection names in backend instead
@jonathan-rohde jonathan-rohde force-pushed the feat/reduce-document-selection-overhead branch from 03613a9 to 4d681ec Compare July 8, 2024 06:05
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.

None yet

2 participants