Skip to content

Commit b0f0ecc

Browse files
tempstudioqwaqrm
andauthored
model : support output bias for qwen2 (#14711)
Co-authored-by: qwaqrm <qwaqrm@126.com>
1 parent 225e7a1 commit b0f0ecc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/llama-model.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2692,6 +2692,7 @@ bool llama_model::load_tensors(llama_model_loader & ml) {
26922692
// output
26932693
output_norm = create_tensor(tn(LLM_TENSOR_OUTPUT_NORM, "weight"), {n_embd}, 0);
26942694
output = create_tensor(tn(LLM_TENSOR_OUTPUT, "weight"), {n_embd, n_vocab}, TENSOR_NOT_REQUIRED);
2695+
output_b = create_tensor(tn(LLM_TENSOR_OUTPUT, "bias"), {n_vocab}, TENSOR_NOT_REQUIRED);
26952696
// if output is NULL, init from the input tok embed
26962697
if (output == NULL) {
26972698
output = create_tensor(tn(LLM_TENSOR_TOKEN_EMBD, "weight"), {n_embd, n_vocab}, TENSOR_DUPLICATED);
@@ -7765,6 +7766,10 @@ struct llm_build_qwen2 : public llm_graph_context {
77657766
// lm_head
77667767
cur = build_lora_mm(model.output, cur);
77677768

7769+
if (model.output_b != nullptr) {
7770+
cur = ggml_add(ctx0, cur, model.output_b);
7771+
}
7772+
77687773
cb(cur, "result_output", -1);
77697774
res->t_logits = cur;
77707775

0 commit comments

Comments
 (0)