gradient¶
GradientContext and Gradient
Classes
|
It will handle gradients and feedbacks. |
|
GradientContext is used to describe the component's function and trace its input and output. |
- class GradientContext(variable_desc: str, input_output: str, response_desc: str)[source]¶
Bases:
DataClass
GradientContext is used to describe the component’s function and trace its input and output.
To get the component’s function desc, use GradientContext.to_yaml_signature() To get the data: use instance.to_yaml()
- variable_desc: str¶
- input_output: str¶
- response_desc: str¶
- class Gradient(*, from_response: Parameter, to_pred: Parameter, id: str | None = None, score: float | None = None, data_id: str | None = None, data: Any = None)[source]¶
Bases:
DataClass
It will handle gradients and feedbacks.
It tracks the d_from_response_id / d_to_pred_id and the score of the whole response.
if two gradients have the same data_id, different from_response_id, and same from_response_component_id, this is a cycle component structure.
- context: GradientContext = None¶
- prompt: str | None = None¶
- is_default_copy: bool = False¶
- from_response_component_id: str = None¶
- from_response_id: str = None¶
- to_pred_id: str = None¶
- score: float | None = None¶
- data_id: str | None = None¶
- data: Any = None¶
- order: int | None = None¶
- add_context(context: GradientContext)[source]¶