Skip to content

Commit c73eb68

Browse files
committed
added cls token per previous modern bert attempt, still working on checking out the rest
1 parent 2a1c750 commit c73eb68

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

gguf-py/gguf/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,8 @@ class MODEL_TENSOR(IntEnum):
11851185
MODEL_TENSOR.FFN_UP,
11861186
MODEL_TENSOR.FFN_DOWN,
11871187
MODEL_TENSOR.FFN_NORM,
1188+
MODEL_TENSOR.CLS,
1189+
MODEL_TENSOR.CLS_OUT,
11881190
],
11891191
MODEL_ARCH.NOMIC_BERT: [
11901192
MODEL_TENSOR.TOKEN_EMBD,

src/llama-arch.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,8 @@ static const std::map<llm_arch, std::map<llm_tensor, const char *>> LLM_TENSOR_N
519519
{ LLM_TENSOR_FFN_DOWN, "blk.%d.ffn_down" },
520520
{ LLM_TENSOR_FFN_UP, "blk.%d.ffn_up" },
521521
{ LLM_TENSOR_FFN_NORM, "blk.%d.ffn_norm" },
522+
{ LLM_TENSOR_CLS, "cls" },
523+
{ LLM_TENSOR_CLS_OUT, "cls.output" },
522524
},
523525
},
524526
{

src/llama-model.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2710,6 +2710,11 @@ bool llama_model::load_tensors(llama_model_loader & ml) {
27102710
layer.ffn_down = create_tensor(tn(LLM_TENSOR_FFN_DOWN, "weight", i), {n_ff, n_embd}, 0);
27112711
layer.ffn_norm = create_tensor(tn(LLM_TENSOR_FFN_NORM, "weight", i), {n_embd}, 0);
27122712
}
2713+
2714+
cls = create_tensor(tn(LLM_TENSOR_CLS, "weight"), {n_embd, n_embd}, TENSOR_NOT_REQUIRED);
2715+
cls_out = create_tensor(tn(LLM_TENSOR_CLS_OUT, "weight"), {n_embd, hparams.n_cls_out}, TENSOR_NOT_REQUIRED);
2716+
cls_out_b = create_tensor(tn(LLM_TENSOR_CLS_OUT, "bias"), {hparams.n_cls_out}, TENSOR_NOT_REQUIRED);
2717+
27132718
} break;
27142719
case LLM_ARCH_NEO_BERT:
27152720
{

0 commit comments

Comments
 (0)