huggingface
SGHFLM
¶
Bases: HFLM
Eval harness model class for evaluating Stained Glass Transforms.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
str
|
The path to the Stained Glass Transform. |
required |
|
bool
|
Whether to apply the Stained Glass Transform. |
required |
|
bool
|
Pass clean embeddings to the model, only for debugging purposes. |
False
|
|
int | None
|
The seed to use for the Stained Glass Transform. |
1234
|
|
Any
|
Additional arguments to pass to the parent class. |
()
|
|
Any
|
Additional keyword arguments to pass to the parent class. |
{}
|
apply_chat_template
¶
apply_chat_template(
chat_history: list[dict[str, str]],
add_generation_prompt: bool = True,
) -> str
Return the json string of the chat history which will be processed by _apply_noise_tokenizer_mapper
method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
list[dict[str, str]]
|
The chat history. |
required |
|
bool
|
If this is set, a prompt with the token(s) that indicate the start of an assistant message will be appended to the formatted output. |
True
|
Raises:
Type | Description |
---|---|
ValueError
|
If |
Returns:
Type | Description |
---|---|
str
|
The json string of the chat history. |
tok_batch_encode
¶
tok_batch_encode(
strings: list[str],
padding_side: str = "left",
left_truncate_len: int | None = None,
truncation: bool = False,
) -> tuple[torch.Tensor, torch.Tensor]
Encode a batch of strings into input ids and attention masks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
list[str]
|
The list of strings to encode. |
required |
|
str
|
The side to pad the sequences. |
'left'
|
|
int | None
|
The length to truncate the left side of the sequences. |
None
|
|
bool
|
Whether to truncate the sequences. |
False
|
Returns:
Type | Description |
---|---|
tuple[torch.Tensor, torch.Tensor]
|
A tuple of input embeddings and attention masks if |