Repository navigation
Add LLMRecommender for LLM-based experimental design #855
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
Open
tobiasploetz
wants to merge
89
commits into
main
Choose a base branch
from
feature/llm-recommender
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+8,053
−2,182
Open
Changes from all commits
Commits
Show all changes
89 commits
Select commit
Hold shift + click to select a range
d742e15
Add LLM optional dependency infrastructure
tobiasploetz e6d36c6
Add LLMResponseError exception
tobiasploetz feb82b2
Add LLMRecommender for LLM-based experimental design
tobiasploetz 8d2bb13
Add tests for LLMRecommender
tobiasploetz d443bbb
Update CHANGELOG
tobiasploetz b7f01d6
Update LLMRecommender model version to gpt-5.4 in tests
tobiasploetz 831d0a5
Address PR review findings for LLMRecommender
tobiasploetz 8418b20
Address review findings for LLMRecommender
tobiasploetz ca1d3ff
fix mypy error and exclude problematic litellm versions
tobiasploetz 6ef7974
Derive LLMRecommender from PureRecommender
AVHopp 7019b3e
Remove concept of feasibility check from `LLMRecommender`
AVHopp de839ed
Remove overflow_experiments from LLMRecommender
AVHopp 4ddef5f
Feed objective into LLMRecommender prompt
AVHopp 6275385
Exclude LLMRecommender from recommender auto-enumeration in tests
AVHopp e861583
Add parse-error test cases
AVHopp 4b934c1
Add helper for extracting JSON from response
AVHopp c146340
Remove related_data field
AVHopp 43cb52c
Add serialization test for LLMRecommender
AVHopp f2fd5be
Remove test for related data
AVHopp e91b16c
Reorganize subpackage
AVHopp 04fd78a
Bump version of litellm
AVHopp ef83fa1
Add example
AVHopp f58d911
Update user guide
AVHopp 5456c64
Add test for JSON parsing
AVHopp 69ea49b
Update CHANGELOG
AVHopp 0ffb204
Reduce number of warmstart experiments
AVHopp 461c3ae
Reduce number of MC iterations to 1
AVHopp ca0312d
Deactivate parallel simulation for LLMRecommender example
AVHopp 2f435a2
Fix broken link in example
AVHopp 6d43304
Replace frozenset by set
AVHopp 4398ace
Rename helper for autotestable recommenders
AVHopp 1045760
Use `is not None` instead of `or` for checking recovery_litellm_args
AVHopp c516809
Remove option to provide format constructions
AVHopp 67b7fda
Prevent the usage of preserved key in construction
AVHopp 134e655
Add missing validation
AVHopp f17c84f
Unify tests for handling protected keys
AVHopp 8120b0a
Add `litellm` to list for `replace-imports-with-any`
AVHopp 6021e35
Raise instead of warn if too few recommendations are returned
AVHopp ae91603
Add hypothesis strategies and tests for `LLMRecommender`
AVHopp dc58144
Fix test about raising errors
AVHopp 01030eb
Improve metadata usage in `LLMRecommender`
AVHopp 2624c5b
Pass full dict of metadata to the prompt
AVHopp ca350ec
Handle constraints for LLM responses
AVHopp e9adf55
Align index of returned recommendations with search space
AVHopp 81fe399
Re-use existing validation mechanisms for LLM response
AVHopp eb3f9dc
Match against actual candidates, not the full space
AVHopp 7a729a8
Add `SerialMixin` to `LLMRecommender`
AVHopp 7d5bc9b
Simplify methods for parsing responses and building prompts
AVHopp c6b5f88
Rename `build_*`-named functions to `make_*`-named functions
AVHopp ef3cf8a
Replace hardcoded names
AVHopp af7f06e
Simplify comments and docstring
AVHopp 06a0dfa
Remove unnecessary check
AVHopp 469a3d2
Generalize type
AVHopp 394b02b
Introduce more fine-grained LLM error handling
AVHopp f142246
Remove user-configurable recovery functionality
AVHopp 8aa9c6b
Use recovery instructions from errors
AVHopp dfe3b53
Rework LLM recovery into a single error-specific retry
AVHopp f1d8cb0
Improve type safety of LLM prompt construction and parsing
AVHopp 8d15f8e
Add convenience functions for LLM recommender
AVHopp 4cb94f6
Fix JSON extraction for multi-block LLM responses
AVHopp 031f307
Add type guard
AVHopp 2c27aa6
Add typed converter
AVHopp 578afa4
Fix typing
AVHopp 0a66350
Use DiscreteSelectionConstraint instead of deprecated DiscreteExclude…
AVHopp 39f7ced
Add forbidden configurations into prompt
AVHopp 9d9adcf
Align `make_prompt` signature with the canonical recommender argument…
AVHopp b1647ca
Validate type of `litellm_args` keys
AVHopp 7b254f2
Enable handling of batch sizes >1
AVHopp ab29162
Move CHANGELOG entry to Unreleased section
AVHopp 3b35a86
Improve wording and handling of forbidden configurations
AVHopp 41c7145
Improve docstrings
AVHopp 4a455d9
Change type of `recommenders` to `tuple` in `SequentialMetaRecommender`
AVHopp 6af4ea0
Improve and fix parameter representation in prompts
AVHopp 089c36b
Delete `LLMRecommender` tests
AVHopp bf3f3b8
Bump `litellm` version to 1.97.0
AVHopp 77b4b2e
Rework and improve LLM-related exceptions and error handling
AVHopp 1a3ec1a
Implement `_recommend_hybrid` instead of overriding `recommend`
AVHopp 81484b2
Remove examples and docs on LLMs
AVHopp eb4768a
Create convenience LLM-based meta recommenders
AVHopp 60afb19
Provide full context in recovery prompt
AVHopp 0d90d46
Improve handling of targets and objectives in prompt
AVHopp 233f862
Simplify the JSON array extraction
AVHopp a0e0ece
Remove dead checks
AVHopp a2b78e6
Move model query inside of `try` block
AVHopp 88eaf2d
Improve handling of point matching
AVHopp 75ca275
Force mode to be cyclic in LLMAlternatingRecommender
AVHopp 762fd06
Improve spacing in prompt
AVHopp a3980df
Add tests for LLM-related code parts
AVHopp c60cbb8
Fix typing issues in `get_`- and `find-subclass` methods
AVHopp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Scienfitz marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
AVHopp marked this conversation as resolved.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: Figure out which of the general LLM utilities (e.g. retry) could be extracted (i.e. should not be part of the recommender sub-package), so everything that takes the LLM output and creates a JSON or any other reasonable format. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| """Optional LLM imports.""" | ||
|
|
||
| from baybe.exceptions import OptionalImportError | ||
|
|
||
| try: | ||
| from jinja2 import StrictUndefined, Template | ||
| except ModuleNotFoundError as ex: | ||
| raise OptionalImportError(name="jinja2", group="llm") from ex | ||
|
|
||
| try: | ||
| from litellm import AuthenticationError, completion | ||
| except ModuleNotFoundError as ex: | ||
| raise OptionalImportError(name="litellm", group="llm") from ex | ||
|
|
||
| __all__ = [ | ||
| "AuthenticationError", | ||
| "StrictUndefined", | ||
| "Template", | ||
| "completion", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.