stop criteria esnetildi
#32
by ismailhakki37 - opened
346 unmodified lines34734834935035035135235335435535635735635835936036136236336436536636736836910 unmodified lines380381382383384385386387388177 unmodified lines566567568556569570571572346 unmodified lines prompt, our_chatbot.tokenizer, IMAGE_TOKEN_INDEX, return_tensors="pt" ).unsqueeze(0).to(our_chatbot.model.device) # Set up stopping criteria # Set up stopping criteria - more flexible to allow longer responses stop_str = ( our_chatbot.conversation.sep if our_chatbot.conversation.sep_style != SeparatorStyle.TWO else our_chatbot.conversation.sep2 ) # Use minimal stopping criteria to allow longer responses keywords = [stop_str] keywords = [] if stop_str and stop_str.strip(): keywords.append(stop_str) # Only add very basic stopping criteria to prevent infinite generation if not keywords: keywords = ["</s>", "<s>"] print(f"[DEBUG] Using stopping criteria: {keywords}") stopping_criteria = KeywordsStoppingCriteria( keywords, our_chatbot.tokenizer, input_ids )10 unmodified lines repetition_penalty=repetition_penalty, use_cache=False, stopping_criteria=[stopping_criteria], pad_token_id=our_chatbot.tokenizer.eos_token_id, eos_token_id=our_chatbot.tokenizer.eos_token_id, length_penalty=1.0, # Don't penalize longer sequences ) # Decode response177 unmodified lines top_p = float(payload.get("top_p", 1.0)) max_output_tokens = int(payload.get("max_output_tokens", payload.get("max_new_tokens", payload.get("max_tokens", 4096)))) payload.get("max_tokens", 8192)))) repetition_penalty = float(payload.get("repetition_penalty", 1.0)) conv_mode_override = payload.get("conv_mode", None) handler.py+16-3