-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af444c9
commit 390b6c4
Showing
5 changed files
with
24 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from torch import nn | ||
|
||
|
||
class LLMUtils: | ||
@staticmethod | ||
def get_max_length(model: nn.Module) -> int: | ||
for length_setting in ["n_positions", "max_position_embeddings", "seq_length"]: | ||
max_length = getattr(model.config, length_setting, None) | ||
if max_length: | ||
print(f"Found max length: {max_length}") | ||
break | ||
if not max_length: | ||
max_length = 1024 | ||
print(f"Using default max length: {max_length}") | ||
return max_length | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters