-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multiple sampling support through
lf.query
and add `lf.query_and_re…
…duce`. With this CL, `lf.query` now supports issuing parallel queries to multiple LLMs with multiple samples (through accepting list for `lm` and the `num_samples` argument). Additionally, we introduce `lf.query_and_reduce` to perform map-reduce style operation with `lf.query`. The motivation of introducing `lf.query_and_reduce` is to maintain an 1:1 mapping at the interface level, while allowing users to use the `reduce` function to perform regularizations on LLM outputs. `lf.query_and_reduce` is a drop-in replacement for `lf.query` with compatible arguments and default behavior. Example usage: sampling Gpt4 and Gemini2 each with 5 samples and obtain the final output through majority voting. ```python lf.query_and_reduce( 'compute 256 * 345', int, reduce=lambda answers: lf.query('Find majority from {{answers}}', int, lm=lf.llms.Gpt4(), answers=answers), lm=[lf.llms.Gpt4(), lf.llms.Gemini2()], num_samples=5, ... ) ``` PiperOrigin-RevId: 701557382
- Loading branch information
Showing
5 changed files
with
315 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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 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 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.