textgrad.autograd.string_based_ops#

Classes

StringBasedFunction(fn, function_purpose)

Autograd function for string-based functions.

class textgrad.autograd.string_based_ops.StringBasedFunction(fn, function_purpose)#

Bases: Function

Autograd function for string-based functions.

Parameters:
  • fn (Callable) – The function to execute for the forward pass.

  • function_purpose (str) – The description of the purpose of the function. Analogous to role description for variables.

backward(response, function_purpose, inputs, backward_engine)#
Parameters:
forward(inputs, response_role_description=None)#

The forward mode for string-based functions

Parameters:
  • inputs (Dict[str, Variable]) – The arguments that will be passed to the string based function. The keys are the names of the arguments.

  • response_role_description (str) – The role description of the output variable.

Return type:

Variable