From: tempstudio Date: Wed, 16 Jul 2025 15:02:06 +0000 (-0500) Subject: model : support output bias for qwen2 (#14711) X-Git-Tag: upstream/0.0.6073~159 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=b0f0ecc3dce806c68609d375a2b3edc430d8db18;p=pkg%2Fggml%2Fsources%2Fllama.cpp model : support output bias for qwen2 (#14711) Co-authored-by: qwaqrm --- diff --git a/src/llama-model.cpp b/src/llama-model.cpp index 67cae695..9d8a686e 100644 --- a/src/llama-model.cpp +++ b/src/llama-model.cpp @@ -2692,6 +2692,7 @@ bool llama_model::load_tensors(llama_model_loader & ml) { // output output_norm = create_tensor(tn(LLM_TENSOR_OUTPUT_NORM, "weight"), {n_embd}, 0); output = create_tensor(tn(LLM_TENSOR_OUTPUT, "weight"), {n_embd, n_vocab}, TENSOR_NOT_REQUIRED); + output_b = create_tensor(tn(LLM_TENSOR_OUTPUT, "bias"), {n_vocab}, TENSOR_NOT_REQUIRED); // if output is NULL, init from the input tok embed if (output == NULL) { 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 { // lm_head cur = build_lora_mm(model.output, cur); + if (model.output_b != nullptr) { + cur = ggml_add(ctx0, cur, model.output_b); + } + cb(cur, "result_output", -1); res->t_logits = cur;