Преглед изворни кода

[Bugfix] Ensure penalty sampler to be the first one in mixed samplers

[Bugfix] Ensure penalty sampler to be the first one in mixed samplers
huangzhengxiang пре 3 недеља
родитељ
комит
92f8897e95
1 измењених фајлова са 11 додато и 0 уклоњено
  1. 11 0
      transformers/llm/engine/src/sampler.cpp

+ 11 - 0
transformers/llm/engine/src/sampler.cpp

@@ -235,6 +235,17 @@ void Sampler::SamplerConfig::configMixed(std::shared_ptr<LlmConfig> llmConfig) {
         this->configSampler(samplerName, llmConfig);
         // std::cout << samplerName << " " << std::flush;
     }
+    for (int i=1; i<mixedSamplers.size(); ++i) {
+        // "penalty" can only locate at the first position
+        if (mixedSamplers[i]=="penalty") {
+            mixedSamplers.erase(mixedSamplers.begin()+i); 
+            i--;
+            if (mixedSamplers[0]!="penalty") {
+                mixedSamplers.insert(mixedSamplers.begin(), "penalty");
+                i++;
+            }
+        }
+    }
     // std::cout << std::endl;
     // set select type
     // the final sampler select the token