Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/peft/tuners/alora/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

import warnings
from dataclasses import dataclass, field
from typing import Literal, Optional, Union, List

from torch import nn
from peft.utils import PeftType
from peft.tuners.lora import LoraConfig
from peft.utils import PeftType


@dataclass
Expand All @@ -19,19 +17,27 @@ class aLoraConfig(LoraConfig):
invocation_string (str): String intended to activate the aLoRA. The aLoRA adapted weights will activate
1 token after the first token in this string. This string must be present in all input data.
"""
r: int = field(default=32, metadata={"help": "aLora attention dimension. Typically needs to be higher than used for standard Lora. Default=32."})

r: int = field(
default=32,
metadata={
"help": "aLora attention dimension. Typically needs to be higher than used for standard Lora. Default=32."
},
)
invocation_string: str = field(
default=None,
metadata={
"help": (
"aLoRA invocation string. The aLoRA adapted weights will activate 1 token after the first token in "
"this string. This string must be present in all input data."
)
}
},
)
invocation_tokens: List[int] = field(
invocation_tokens: list[int] = field(
default=None,
metadata={"help": "Tokenized version of `invocation_string` (as a list of token IDs). Use the model's default tokenizer. E.g. invocation_tokens = tokenizer.encode(invocation_string, add_special_tokens=False)"}
metadata={
"help": "Tokenized version of `invocation_string` (as a list of token IDs). Use the model's default tokenizer. E.g. invocation_tokens = tokenizer.encode(invocation_string, add_special_tokens=False)"
},
)

def __post_init__(self):
Expand All @@ -41,5 +47,3 @@ def __post_init__(self):
warnings.warn("invocation_string cannot be None for aLoRA.", UserWarning)
if self.invocation_tokens is None:
warnings.warn("invocation_tokens cannot be None for aLoRA.", UserWarning)


Loading