From 0ba52f218c16b7ddfe5b55b9ff179bf07afcf825 Mon Sep 17 00:00:00 2001 From: Jay Zhang Date: Wed, 18 Dec 2024 13:06:18 -0800 Subject: [PATCH] TLM constrain_outputs doc --- .../studio/trustworthy_language_model.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cleanlab_studio/studio/trustworthy_language_model.py b/cleanlab_studio/studio/trustworthy_language_model.py index 82f9464d..e331b755 100644 --- a/cleanlab_studio/studio/trustworthy_language_model.py +++ b/cleanlab_studio/studio/trustworthy_language_model.py @@ -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. @@ -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. @@ -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.