llm.LoRARegressor
llm.LoRARegressor(
model=T5CHEM,
num_outputs=1,
*,
pooling=None,
prompt=None,
rank=4,
alpha=16,
target_modules=None,
hidden=100,
max_length=None,
)A pretrained language model with LoRA adapters and an MLP head, on texts.
A TextEncoder turns each text into one vector and the head maps it to the outcomes.
To change how the vector is made, for a model this class does not handle, subclass it and override features.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| model | str | A Hugging Face model name or path. | T5CHEM |
| num_outputs | int | The number of outcomes. | 1 |
| pooling | Pooling | None | As in TextEncoder. |
None |
| prompt | str | Callable[[str], str] | None | As in TextEncoder. |
None |
| rank | int | The LoRA rank. | 4 |
| alpha | int | The LoRA scale. | 16 |
| target_modules | tuple[str, …] | None | The layers that get adapters. None takes the attention’s query and value layers: those peft knows for the architecture, or else the layers named query and value, q and v, or q_proj and v_proj. |
None |
| hidden | int | Units in each of the head’s two hidden layers. | 100 |
| max_length | int | None | As in TextEncoder. |
None |
Methods
| Name | Description |
|---|---|
| features | The vector of each tokenized text, [N, d], that the head takes. |
| forward | The outcomes [N, m] of the tokenized texts. |
| prepare | Tokenize the texts, as TextEncoder.prepare does. |
features
llm.LoRARegressor.features(input_ids, attention_mask)The vector of each tokenized text, [N, d], that the head takes.
forward
llm.LoRARegressor.forward(input_ids, attention_mask)The outcomes [N, m] of the tokenized texts.
prepare
llm.LoRARegressor.prepare(texts)Tokenize the texts, as TextEncoder.prepare does.