added mechanics for a full clear if fast forward is not used, this should help recover from bad states

This commit is contained in:
Concedo 2025-12-05 16:43:37 +08:00
parent 3550265249
commit b867b67e7e
3 changed files with 19 additions and 5 deletions

View file

@ -513,7 +513,7 @@ std::string gguf_get_model_arch(const std::string & gguf_filename)
void ContextFastForward(std::vector<int> &current_context_tokens, std::vector<int> &embd_inp,
int &n_past, std::vector<int> &last_n_tokens, const int nctx, std::vector<int> &smartcontext,
bool useSmartContext, const bool requireFullSubset)
bool useSmartContext, const bool requireFullSubset, const int minimum_to_proceed)
{
const int SCCtxLenThreshold = nctx * 0.8; //how much context length must be reach to trigger smartcontext
const int SCInpLenThreshold = nctx * 0.6; //how big must the input array be to trigger smartcontext
@ -568,6 +568,13 @@ std::string gguf_get_model_arch(const std::string & gguf_filename)
}
}
if(n_past < minimum_to_proceed) //too few tokens to fast forward, so lets start fresh
{
last_n_tokens.erase(last_n_tokens.end() - n_past, last_n_tokens.end());
n_past = 0;
fastforwardok = false;
}
if(fastforwardok)
{
last_n_tokens.erase(last_n_tokens.begin(), last_n_tokens.begin() + n_past);