Explorar el Código

clip: (minicpmv) fix resampler kq_scale (#17516)

* debug:"solve minicpmv precision problem"

* “debug minicpmv”

* Apply suggestion from @ngxson

---------

Co-authored-by: Xuan-Son Nguyen <thichthat@gmail.com>
Han Qingzhe hace 1 mes
padre
commit
1d594c295c
Se han modificado 1 ficheros con 2 adiciones y 1 borrados
  1. 2 1
      tools/mtmd/clip.cpp

+ 2 - 1
tools/mtmd/clip.cpp

@@ -1175,10 +1175,11 @@ struct clip_graph {
             cb(K, "resampler_K", -1);
             cb(K, "resampler_K", -1);
             cb(V, "resampler_V", -1);
             cb(V, "resampler_V", -1);
 
 
+            float resampler_kq_scale = 1.0f/ sqrtf(float(d_head));
             embeddings = build_attn(
             embeddings = build_attn(
                 model.mm_model_attn_o_w,
                 model.mm_model_attn_o_w,
                 model.mm_model_attn_o_b,
                 model.mm_model_attn_o_b,
-                Q, K, V, nullptr, kq_scale, -1);
+                Q, K, V, nullptr, resampler_kq_scale, -1);
             cb(embeddings, "resampler_attn_out", -1);
             cb(embeddings, "resampler_attn_out", -1);
         }
         }
         // layernorm
         // layernorm