langchain_experimental.rl_chain.base.RLChain¶
class langchain_experimental.rl_chain.base.RLChain[source]¶
Bases: Chain, Generic[TEvent]
The RLChain class leverages the Vowpal Wabbit (VW) model as a learned policy for reinforcement learning.
- llm_chain
Represents the underlying Language Model chain.
Type
Chain
- prompt
The template for the base prompt.
Type
BasePromptTemplate
- selection_scorer
Scorer for the selection. Can be set to None.
Type
Union[SelectionScorer, None]
- policy
The policy used by the chain to learn to populate a dynamic prompt.
Type
Optional[Policy]
- auto_embed
Determines if embedding should be automatic. Default is False.
Type
bool
- metrics
Tracker for metrics, can be set to None.
Type
Optional[Union[MetricsTrackerRollingWindow, MetricsTrackerAverage]]
Initialization Attributes:
feature_embedder (Embedder): Embedder used for the BasedOn and ToSelectFrom inputs.
model_save_dir (str, optional): Directory for saving the VW model. Default is the current directory.
reset_model (bool): If set to True, the model starts training from scratch. Default is False.
vw_cmd (List[str], optional): Command line arguments for the VW model.
policy (Type[VwPolicy]): Policy used by the chain.
vw_logs (Optional[Union[str, os.PathLike]]): Path for the VW logs.
metrics_step (int): Step for the metrics tracker. Default is -1. If set without metrics_window_size, average metrics will be tracked, otherwise rolling window metrics will be tracked.
metrics_window_size (int): Window size for the metrics tracker. Default is -1. If set, rolling window metrics will be tracked.
Notes