-
Notifications
You must be signed in to change notification settings - Fork 894
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate out a new CNNConfig object instead of a SimpleNamespace, the…
…n make the load & save code convert all its pieces to types that work with weights_only=True. Will allow the CNNClassifier objects used for sentiment to function with weights_only=True. Also convert the constituency classifier to use torch.load(weights_only=True), although there are no distributed constituency classifiers yet
- Loading branch information
1 parent
f22be05
commit 67871f4
Showing
6 changed files
with
174 additions
and
78 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from dataclasses import dataclass | ||
from typing import List | ||
|
||
# TODO: perhaps put the enums in this file | ||
from stanza.models.classifiers.utils import WVType, ExtraVectors, ModelType | ||
|
||
@dataclass | ||
class CNNConfig: # pylint: disable=too-many-instance-attributes, too-few-public-methods | ||
filter_channels: int | tuple | ||
filter_sizes: tuple | ||
fc_shapes: tuple | ||
dropout: float | ||
num_classes: int | ||
wordvec_type: WVType | ||
extra_wordvec_method: ExtraVectors | ||
extra_wordvec_dim: int | ||
extra_wordvec_max_norm: float | ||
char_lowercase: bool | ||
charlm_projection: int | ||
has_charlm_forward: bool | ||
has_charlm_backward: bool | ||
|
||
use_elmo: bool | ||
elmo_projection: int | ||
|
||
bert_model: str | ||
bert_finetune: bool | ||
bert_hidden_layers: int | ||
force_bert_saved: bool | ||
|
||
use_peft: bool | ||
lora_rank: int | ||
lora_alpha: float | ||
lora_dropout: float | ||
lora_modules_to_save: List | ||
lora_target_modules: List | ||
|
||
bilstm: bool | ||
bilstm_hidden_dim: int | ||
maxpool_width: int | ||
model_type: ModelType | ||
|
||
@dataclass | ||
class ConstituencyConfig: # pylint: disable=too-many-instance-attributes, too-few-public-methods | ||
fc_shapes: tuple | ||
dropout: float | ||
num_classes: int | ||
|
||
constituency_backprop: bool | ||
constituency_batch_norm: bool | ||
constituency_node_attn: bool | ||
constituency_top_layer: bool | ||
constituency_all_words: bool | ||
|
||
model_type: ModelType |
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
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
Oops, something went wrong.