stop criteria removed (#33)
Browse files- stop criteria removed (bd60586a6b6289b6cf23424e030a3107e5ae0143)
Co-authored-by: ismail hakkı özçelik <ismailhakki37@users.noreply.huggingface.co>
346 unmodified lines3473483493503513523533543553563573583593603613623633643653663673683693703713726 unmodified lines379380381382383384385346 unmodified linesprompt, our_chatbot.tokenizer, IMAGE_TOKEN_INDEX, return_tensors="pt").unsqueeze(0).to(our_chatbot.model.device)# Set up stopping criteria - more flexible to allow longer responsesstop_str = (our_chatbot.conversation.sepif our_chatbot.conversation.sep_style != SeparatorStyle.TWOelse our_chatbot.conversation.sep2)# Use minimal stopping criteria to allow longer responseskeywords = []if stop_str and stop_str.strip():keywords.append(stop_str)# Only add very basic stopping criteria to prevent infinite generationif not keywords:keywords = ["</s>", "<s>"]print(f"[DEBUG] Using stopping criteria: {keywords}")stopping_criteria = KeywordsStoppingCriteria(keywords, our_chatbot.tokenizer, input_ids)# Generate responsewith torch.no_grad():6 unmodified linesmax_new_tokens=max_output_tokens,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 sequences346 unmodified lines3473483493503513523533543556 unmodified lines362363364365366367346 unmodified linesprompt, our_chatbot.tokenizer, IMAGE_TOKEN_INDEX, return_tensors="pt").unsqueeze(0).to(our_chatbot.model.device)# No stopping criteria - let model generate freely up to max_new_tokensprint(f"[DEBUG] No stopping criteria - free generation up to {max_output_tokens} tokens")stopping_criteria = None# Generate responsewith torch.no_grad():6 unmodified linesmax_new_tokens=max_output_tokens,repetition_penalty=repetition_penalty,use_cache=False,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
handler.py+3-21