[LLaMA] Bugfix in LLaMA application
authorEunju Yang <ej.yang@samsung.com>
Tue, 23 Apr 2024 04:23:19 +0000 (13:23 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Tue, 30 Apr 2024 04:44:38 +0000 (13:44 +0900)
- This commit fixes a bug in `applyTKP` function.
- It seems applying Top-K and Top-P to logits didn't work as intended

Signed-off-by: Eunju Yang <ej.yang@samsung.com>
Applications/LLaMA/jni/main.cpp

index c4c9d9a4aa43afd8e8e0889686aaccad8b0704db..e394ef395ba85716eaed3557eb21575c96d9ccc1 100644 (file)
@@ -127,8 +127,7 @@ float applyTKP(float *logits, int len, float temperature, unsigned int top_k,
   // Apply Top-K and Top-P
   std::fill_n(logits, sizeof(len), -INFINITY);
   for (unsigned int i = 0; i < top_index; ++i) {
-    logits[top_indices_and_logits[top_index].first] =
-      top_indices_and_logits[top_index].second;
+    logits[top_indices_and_logits[i].first] = top_indices_and_logits[i].second;
   }
 
   return top_indices_and_logits[0].second;