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

TLM constrain_outputs doc #342

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions cleanlab_studio/studio/trustworthy_language_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,11 @@ def prompt(
Args:
prompt (str | Sequence[str]): prompt (or list of multiple prompts) for the language model.
Providing a batch of many prompts here will be faster than calling this method on each prompt separately.
**kwargs: Optional keyword arguments to pass to the underlying TLM object. Currently, only `constrain_outputs` is supported.
`constrain_outputs` is a list of strings or a list of lists of strings.
If a list of strings is provided, each prompt will be constrained to one of the strings in the list.
If a list of lists of strings is provided, each prompt will be constrained to one of the strings in the corresponding list.
If `constrain_outputs` is not provided, the TLM will not constrain the output.
Returns:
TLMResponse | List[TLMResponse]: [TLMResponse](#class-tlmresponse) object containing the response and trustworthiness score.
If multiple prompts were provided in a list, then a list of such objects is returned, one for each prompt.
Expand Down Expand Up @@ -435,6 +440,11 @@ def try_prompt(

Args:
prompt (Sequence[str]): list of multiple prompts for the TLM
**kwargs: Optional keyword arguments to pass to the underlying TLM object. Currently, only `constrain_outputs` is supported.
`constrain_outputs` is a list of strings or a list of lists of strings.
If a list of strings is provided, each prompt will be constrained to one of the strings in the list.
If a list of lists of strings is provided, each prompt will be constrained to one of the strings in the corresponding list.
If `constrain_outputs` is not provided, the TLM will not constrain the output.
Returns:
List[TLMResponse]: list of [TLMResponse](#class-tlmresponse) objects containing the response and trustworthiness score.
The returned list will always have the same length as the input list.
Expand Down Expand Up @@ -472,6 +482,11 @@ async def prompt_async(

Args:
prompt (str | Sequence[str]): prompt (or list of multiple prompts) for the TLM
**kwargs: Optional keyword arguments to pass to the underlying TLM object. Currently, only `constrain_outputs` is supported.
`constrain_outputs` is a list of strings or a list of lists of strings.
If a list of strings is provided, each prompt will be constrained to one of the strings in the list.
If a list of lists of strings is provided, each prompt will be constrained to one of the strings in the corresponding list.
If `constrain_outputs` is not provided, the TLM will not constrain the output.
Returns:
TLMResponse | List[TLMResponse]: [TLMResponse](#class-tlmresponse) object containing the response and trustworthiness score.
If multiple prompts were provided in a list, then a list of such objects is returned, one for each prompt.
Expand Down
Loading