Skip to content

Commit ce3dd8b

Browse files
committed
Update llama.cpp to use instruct mode
1 parent 5b9577f commit ce3dd8b

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

llama.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,18 @@ void llama_update_input(llama_context& ctx, const std::string& text)
11761176
state.embd_inp.insert(state.embd_inp.end(), line_inp.begin(), line_inp.end());
11771177
state.remaining_tokens -= line_inp.size();
11781178
}
1179+
/// @brief Updates the context and appends new input tokens (overloaded version)
1180+
/// @param ctx
1181+
/// @param tokens
1182+
void llama_update_input(llama_context& ctx, const std::vector<gpt_vocab::id>& tokens)
1183+
{
1184+
llama_state& state = *ctx.state;
1185+
llama_model& model = ctx.model;
1186+
const gpt_params& params = ctx.params;
1187+
1188+
state.embd_inp.insert(state.embd_inp.end(), tokens.begin(), tokens.end());
1189+
state.remaining_tokens -= tokens.size();
1190+
}
11791191

11801192
/// @brief Ingests a batch of input tokens into the context
11811193
/// @param ctx

llama.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ const std::vector<gpt_vocab::id> llama_tokenize_text(const llama_context& ctx, c
5050
void llama_add_bos(llama_context& ctx);
5151
// Queues up input text to the model input
5252
void llama_update_input(llama_context& ctx, const std::string& text);
53+
// Queues up input tokens to the model input
54+
void llama_update_input(llama_context& ctx, const std::vector<gpt_vocab::id>& tokens);
5355
// Ingests input previously added using llama_update_input()
5456
void llama_ingest_input_batch(llama_context& ctx);
5557
// Ingests all input previously added using llama_update_input() in multiple batches

0 commit comments

Comments
 (0)