Upload ConlluTokenClassificationPipeline
Browse files- config.json +2 -2
- configuration.py +2 -0
- encoder.py +8 -1
- model.safetensors +1 -1
- modeling_parser.py +6 -1
config.json
CHANGED
|
@@ -27,8 +27,8 @@
|
|
| 27 |
"lora_dropout": 0.05,
|
| 28 |
"lora_r": 8,
|
| 29 |
"lora_target_modules": [
|
| 30 |
-
"
|
| 31 |
-
"
|
| 32 |
],
|
| 33 |
"misc_classifier_hidden_size": 512,
|
| 34 |
"model_type": "cobald_parser",
|
|
|
|
| 27 |
"lora_dropout": 0.05,
|
| 28 |
"lora_r": 8,
|
| 29 |
"lora_target_modules": [
|
| 30 |
+
"query",
|
| 31 |
+
"value"
|
| 32 |
],
|
| 33 |
"misc_classifier_hidden_size": 512,
|
| 34 |
"model_type": "cobald_parser",
|
configuration.py
CHANGED
|
@@ -26,6 +26,8 @@ class CobaldParserConfig(PretrainedConfig):
|
|
| 26 |
lora_target_modules: list = None,
|
| 27 |
**kwargs
|
| 28 |
):
|
|
|
|
|
|
|
| 29 |
self.encoder_model_name = encoder_model_name
|
| 30 |
self.null_classifier_hidden_size = null_classifier_hidden_size
|
| 31 |
self.consecutive_null_limit = consecutive_null_limit
|
|
|
|
| 26 |
lora_target_modules: list = None,
|
| 27 |
**kwargs
|
| 28 |
):
|
| 29 |
+
print("DEBUG (encoder): use_lora:", use_lora)
|
| 30 |
+
print("DEBUG (encoder): lora_target_modules:", lora_target_modules)
|
| 31 |
self.encoder_model_name = encoder_model_name
|
| 32 |
self.null_classifier_hidden_size = null_classifier_hidden_size
|
| 33 |
self.consecutive_null_limit = consecutive_null_limit
|
encoder.py
CHANGED
|
@@ -47,8 +47,15 @@ class WordTransformerEncoder(nn.Module):
|
|
| 47 |
bias="none",
|
| 48 |
task_type="SEQ_CLS"
|
| 49 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
self.model = get_peft_model(self.model, lora_config)
|
| 51 |
-
print(
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
def forward(self, words: list[list[str]]) -> Tensor:
|
| 54 |
"""
|
|
|
|
| 47 |
bias="none",
|
| 48 |
task_type="SEQ_CLS"
|
| 49 |
)
|
| 50 |
+
print("DEBUG: model class =", type(self.model))
|
| 51 |
+
for name, module in self.model.named_modules():
|
| 52 |
+
if "proj" in name:
|
| 53 |
+
print("DEBUG: found module", name, "->", module)
|
| 54 |
self.model = get_peft_model(self.model, lora_config)
|
| 55 |
+
print("LoRA enabled! Model type:", type(self.model))
|
| 56 |
+
for name, param in self.model.named_parameters():
|
| 57 |
+
if "lora" in name:
|
| 58 |
+
print("LoRA param:", name, param.shape)
|
| 59 |
|
| 60 |
def forward(self, words: list[list[str]]) -> Tensor:
|
| 61 |
"""
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 1134190536
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:37137a12604aa1ee98f7cc4627a3ed76c63cdb9eb9d2fd02c4a73aaf17325dae
|
| 3 |
size 1134190536
|
modeling_parser.py
CHANGED
|
@@ -24,7 +24,12 @@ class CobaldParser(PreTrainedModel):
|
|
| 24 |
super().__init__(config)
|
| 25 |
|
| 26 |
self.encoder = WordTransformerEncoder(
|
| 27 |
-
model_name=config.encoder_model_name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
)
|
| 29 |
embedding_size = self.encoder.get_embedding_size()
|
| 30 |
|
|
|
|
| 24 |
super().__init__(config)
|
| 25 |
|
| 26 |
self.encoder = WordTransformerEncoder(
|
| 27 |
+
model_name=config.encoder_model_name,
|
| 28 |
+
use_lora=getattr(config, "use_lora", False),
|
| 29 |
+
lora_r=getattr(config, "lora_r", 8),
|
| 30 |
+
lora_alpha=getattr(config, "lora_alpha", 16),
|
| 31 |
+
lora_dropout=getattr(config, "lora_dropout", 0.05),
|
| 32 |
+
lora_target_modules=getattr(config, "lora_target_modules", None),
|
| 33 |
)
|
| 34 |
embedding_size = self.encoder.get_embedding_size()
|
| 35 |
|