LlamaTestGenerationTaskPool¶
The LlamaTestGenerationTaskPool
class is used to evaluate a language model on a set of prompts. It can also be used in an interactive mode for debugging purposes.
References¶
test_generation
¶
LlamaTestGenerationTaskPool
¶
Bases: BaseTaskPool
This task pool is used to evaluate a language model on a set of prompts. For the purpose of debugging, it can also be used in an interactive mode.
Source code in fusion_bench/taskpool/llama/test_generation.py
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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
|
__init__(test_prompts, max_length=1024, temperature=0.01, top_p=0.9, iterative_mode=False, **kwargs)
¶
Parameters:
-
test_prompts
(List[str]
) βA list of prompts to be used for testing the model.
-
max_length
(int
, default:1024
) βThe maximum length of the generated text. Defaults to 1024.
-
temperature
(float
, default:0.01
) βThe sampling temperature for text generation. Defaults to 0.01.
-
top_p
(float
, default:0.9
) βThe cumulative probability for nucleus sampling. Defaults to 0.9.
-
iterative_mode
(bool
, default:False
) βIf True, enables interactive mode for debugging. Defaults to False.
Source code in fusion_bench/taskpool/llama/test_generation.py
generate_text(model, tokenizer, prompt, max_length=1024, temperature=0.01, top_p=0.9, device=None)
¶
Generate text using the loaded model.
Parameters:
-
model
(LlamaForCausalLM
) βThe loaded language model
-
tokenizer
(PreTrainedTokenizer
) βThe loaded tokenizer
-
prompt
(str
) βInput prompt text
-
max_length
(int
, default:1024
) βMaximum length of generated sequence
-
temperature
(float
, default:0.01
) βControls randomness (higher = more random)
-
top_p
(float
, default:0.9
) βNucleus sampling parameter
Returns:
-
str
βGenerated text