LogLikelihoodRollingAction
dendron.actions.loglikelihood_rolling_action.LogLikelihoodRollingAction
Bases: ActionNode
An action node that uses a causal language model to calculate the log-likelihood of a given a prompt in the blackboard.
This node is based on the HFLM library, and will download the model that you specify by name. This can take a long time and/or use a lot of storage, depending on the model you name.
There are enough configuration options for this type of node that the options have all been placed in a dataclass config object. See the documentation for that object to learn about the many options available to you.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The given name of this node. |
required |
cfg
|
CausalLMActionConfig
|
The configuration object for this model. |
required |
Source code in src/dendron/actions/loglikelihood_rolling_action.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
set_model(new_model)
I'm not sure what type new_model should be
if it is supposed to be an HFLM model, then we need to adjust this
set_input_processor(f)
Set the input processor to use during tick()
s.
An input processor is applied to the prompt text stored in the
blackboard, and can be used to preprocess the prompt. The
processor function should be a map from str
to str
. During a
tick()
, the output of this function will be what is tokenized
and sent to the model for generation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f
|
Callable
|
The input processor function to use. Should be a callable object that maps (self, Any) to str. |
required |
Source code in src/dendron/actions/loglikelihood_rolling_action.py
set_output_processor(f)
Set the output processor to use during tick()
s.
An output processor is applied to the text generated by the model,
before that text is written to the output slot of the blackboard.
The function should be a map from str
to str
.
A typical example of an output processor would be a function that removes the prompt from the text returned by a model, so that only the newly generated text is written to the blackboard.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f
|
Callable
|
The output processor function. Should be a callable object that maps from (self, str) to Any. |
required |
Source code in src/dendron/actions/loglikelihood_rolling_action.py
tick()
Execute a tick, consisting of the following steps:
- Retrieve a prompt from the node's blackboard, using the input_key.
- Apply the input processor, if one exists.
- Tokenize the prompt text.
- Generate new tokens based on the prompt.
- Decode the model output into a text string.
- Apply the output processor, if one exists,
- Write the result back to the blackboard, using the output_key.
If any of the above fail, the exception text is printed and the node
returns a status of FAILURE
. Otherwise the node returns SUCCESS
. If
you want to use a language model to make decisions, consider looking at
the CompletionConditionNode
.
Source code in src/dendron/actions/loglikelihood_rolling_action.py
set_tree(tree)
Set the behavior tree for this node, which includes setting up the blackboard and registering the model configuration with the tree.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tree
|
BehaviorTree
|
The behavior tree this node belongs to. |
required |