small fixes
This commit is contained in:
parent
49dce94885
commit
a8a9f19689
1 changed files with 5 additions and 8 deletions
|
@ -137,8 +137,6 @@ struct llama_server_context
|
||||||
void beginCompletion()
|
void beginCompletion()
|
||||||
{
|
{
|
||||||
// number of tokens to keep when resetting context
|
// number of tokens to keep when resetting context
|
||||||
|
|
||||||
|
|
||||||
n_remain = params.n_predict;
|
n_remain = params.n_predict;
|
||||||
llama_set_rng_seed(ctx, params.seed);
|
llama_set_rng_seed(ctx, params.seed);
|
||||||
}
|
}
|
||||||
|
@ -192,9 +190,8 @@ struct llama_server_context
|
||||||
auto n_vocab = llama_n_vocab(ctx);
|
auto n_vocab = llama_n_vocab(ctx);
|
||||||
|
|
||||||
// Apply params.logit_bias map
|
// Apply params.logit_bias map
|
||||||
for (auto it = params.logit_bias.begin(); it != params.logit_bias.end(); it++)
|
for (const auto &it : params.logit_bias) {
|
||||||
{
|
logits[it.first] += it.second;
|
||||||
logits[it->first] += it->second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<llama_token_data> candidates;
|
std::vector<llama_token_data> candidates;
|
||||||
|
@ -271,7 +268,7 @@ struct llama_server_context
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
has_next_token = params.n_predict == -1 ? true : n_remain != 0;
|
has_next_token = params.n_predict == -1 || n_remain != 0;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,7 +327,7 @@ struct llama_server_context
|
||||||
std::vector<float> embedding(std::string content, int threads) {
|
std::vector<float> embedding(std::string content, int threads) {
|
||||||
content.insert(0, 1, ' ');
|
content.insert(0, 1, ' ');
|
||||||
std::vector<llama_token> tokens = ::llama_tokenize(ctx, content, true);
|
std::vector<llama_token> tokens = ::llama_tokenize(ctx, content, true);
|
||||||
if (tokens.size() > 0)
|
if (!tokens.empty())
|
||||||
{
|
{
|
||||||
if (llama_eval(ctx, tokens.data(), tokens.size(), 0, threads))
|
if (llama_eval(ctx, tokens.data(), tokens.size(), 0, threads))
|
||||||
{
|
{
|
||||||
|
@ -340,7 +337,7 @@ struct llama_server_context
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const int n_embd = llama_n_embd(ctx);
|
const int n_embd = llama_n_embd(ctx);
|
||||||
const auto embeddings = llama_get_embeddings(ctx);
|
auto *const embeddings = llama_get_embeddings(ctx);
|
||||||
std::vector<float> embeddings_(embeddings, embeddings + n_embd);
|
std::vector<float> embeddings_(embeddings, embeddings + n_embd);
|
||||||
return embeddings_;
|
return embeddings_;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue