Skip to content

Commit

Permalink
revert to origina llama_sample_token_mirostat
Browse files Browse the repository at this point in the history
  • Loading branch information
guinmoon committed Nov 30, 2023
1 parent 01de340 commit b937dfd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Sources/llmfarm_core/LLMBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public class LLMBase {
if class_name != "llmfarm_core.LLaMa"{
res_token = llama_dadbed9_sample_token_mirostat(ctx, &candidates_p, mirostat_tau, mirostat_eta, Int32(mirostat_m), &mirostat_mu, vocabSize);
}else{
res_token = llama_sample_token_mirostat_for_dadbed9(ctx, &candidates_p, mirostat_tau, mirostat_eta, Int32(mirostat_m), &mirostat_mu, vocabSize);
res_token = llama_sample_token_mirostat_for_dadbed9(ctx, &candidates_p, mirostat_tau, mirostat_eta, Int32(mirostat_m), &mirostat_mu);
}
} else if(mirostat == 2) {
var mirostat_mu: Float = 2.0 * mirostat_tau
Expand Down
4 changes: 2 additions & 2 deletions Sources/llmfarm_core_cpp/gpt_spm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ llama_token llama_sample_token_for_dadbed9(struct llama_context * ctx, llama_dad
}


llama_token llama_sample_token_mirostat_for_dadbed9(struct llama_context * ctx, llama_dadbed9_token_data_array * candidates,float tau,float eta,int m,float * mu,int vocabSize ) {
return llama_sample_token_mirostat(ctx, (llama_token_data_array *)candidates,tau,eta,m,mu,vocabSize );
llama_token llama_sample_token_mirostat_for_dadbed9(struct llama_context * ctx, llama_dadbed9_token_data_array * candidates,float tau,float eta,int m,float * mu) {
return llama_sample_token_mirostat(ctx, (llama_token_data_array *)candidates,tau,eta,m,mu );
}

llama_token llama_sample_token_mirostat_v2_for_dadbed9(struct llama_context * ctx, llama_dadbed9_token_data_array * candidates,float tau,float eta, float * mu ) {
Expand Down
6 changes: 3 additions & 3 deletions Sources/llmfarm_core_cpp/llama/llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7552,11 +7552,11 @@ void llama_sample_classifier_free_guidance(
}
}

llama_token llama_sample_token_mirostat(struct llama_context * ctx, llama_token_data_array * candidates, float tau, float eta, int m, float * mu, int vocabSize) {
llama_token llama_sample_token_mirostat(struct llama_context * ctx, llama_token_data_array * candidates, float tau, float eta, int m, float * mu) {
GGML_ASSERT(ctx);

// auto N = float(llama_n_vocab(llama_get_model(ctx)));
auto N = float(vocabSize);
auto N = float(llama_n_vocab(llama_get_model(ctx)));
// auto N = float(vocabSize);
int64_t t_start_sample_us;
t_start_sample_us = ggml_time_us();

Expand Down
2 changes: 1 addition & 1 deletion Sources/llmfarm_core_cpp/spm-headers/gpt_spm.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ struct llama_grammar* llama_load_grammar(const char* grammar_path);

void llama_sample_grammar_for_dadbed9(struct llama_context * ctx, llama_dadbed9_token_data_array * candidates, const struct llama_grammar * grammar );
llama_token llama_sample_token_for_dadbed9(struct llama_context * ctx, llama_dadbed9_token_data_array * candidates );
llama_token llama_sample_token_mirostat_for_dadbed9(struct llama_context * ctx, llama_dadbed9_token_data_array * candidates,float tau,float eta,int m,float * mu,int vocabSize );
llama_token llama_sample_token_mirostat_for_dadbed9(struct llama_context * ctx, llama_dadbed9_token_data_array * candidates,float tau,float eta,int m,float * mu );
llama_token llama_sample_token_mirostat_v2_for_dadbed9(struct llama_context * ctx, llama_dadbed9_token_data_array * candidates,float tau,float eta, float * mu ) ;

#ifdef __cplusplus
Expand Down
3 changes: 1 addition & 2 deletions Sources/llmfarm_core_cpp/spm-headers/llama.h
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,7 @@ extern "C" {
float tau,
float eta,
int m,
float * mu,
int vocabSize);
float * mu);

/// @details Mirostat 2.0 algorithm described in the paper https://arxiv.org/abs/2007.14966. Uses tokens instead of words.
/// @param candidates A vector of `llama_token_data` containing the candidate tokens, their probabilities (p), and log-odds (logit) for the current position in the generated text.
Expand Down

0 comments on commit b937dfd

Please sign in to comment.