ModelLaboratory#

class langchain.model_laboratory.ModelLaboratory(chains: Sequence[Chain], names: List[str] | None = None)[source]#

Experiment with different models.

Initialize with chains to experiment with.

Parameters:
  • chains (Sequence[Chain]) โ€“ list of chains to experiment with.

  • names (Optional[List[str]])

Methods

__init__(chains[,ย names])

Initialize with chains to experiment with.

compare(text)

Compare model outputs on an input text.

from_llms(llms[,ย prompt])

Initialize with LLMs to experiment with and optional prompt.

__init__(chains: Sequence[Chain], names: List[str] | None = None)[source]#

Initialize with chains to experiment with.

Parameters:
  • chains (Sequence[Chain]) โ€“ list of chains to experiment with.

  • names (List[str] | None)

compare(text: str) None[source]#

Compare model outputs on an input text.

If a prompt was provided with starting the laboratory, then this text will be fed into the prompt. If no prompt was provided, then the input text is the entire prompt.

Parameters:

text (str) โ€“ input text to run all models on.

Return type:

None

classmethod from_llms(llms: List[BaseLLM], prompt: PromptTemplate | None = None) ModelLaboratory[source]#

Initialize with LLMs to experiment with and optional prompt.

Parameters:
  • llms (List[BaseLLM]) โ€“ list of LLMs to experiment with

  • prompt (PromptTemplate | None) โ€“ Optional prompt to use to prompt the LLMs. Defaults to None. If a prompt was provided, it should only have one input variable.

Return type:

ModelLaboratory

Examples using ModelLaboratory#