max token arttılırdı
#38
by ismailhakki37 - opened
350 unmodified lines3513523533543553563573583593603613 unmodified lines3653663673683693703713723733741 unmodified line3763773783793803813823835 unmodified lines3893903913923933943953963973985 unmodified lines4044054064074084094101 unmodified line412413414415416417418419104 unmodified lines52452552651252752852953073 unmodified lines604605606607608609610611612613614615616617618619350 unmodified lines try: if hasattr(our_chatbot, 'conv_mode') and our_chatbot.conv_mode and LLAVA_AVAILABLE: our_chatbot.conversation = conv_templates[our_chatbot.conv_mode].copy() print(f"[DEBUG] Reset conversation using conv_mode: {our_chatbot.conv_mode}") else: # Use default conversation template our_chatbot.conversation = our_chatbot.conversation.__class__() print(f"[DEBUG] Reset conversation using default template") except Exception as e: print(f"[DEBUG] Failed to reset conversation: {e}") # Continue with existing conversation3 unmodified lines our_chatbot.conversation.append_message(our_chatbot.conversation.roles[1], None) prompt = our_chatbot.conversation.get_prompt() print(f"[DEBUG] Conversation template: {type(our_chatbot.conversation).__name__}") print(f"[DEBUG] Conversation roles: {our_chatbot.conversation.roles if hasattr(our_chatbot.conversation, 'roles') else 'No roles'}") print(f"[DEBUG] Final prompt length: {len(prompt)} characters") # Tokenize input input_ids = tokenizer_image_token( prompt, our_chatbot.tokenizer, IMAGE_TOKEN_INDEX, return_tensors="pt"1 unmodified line # No stopping criteria - let model generate freely up to max_new_tokens print(f"[DEBUG] No stopping criteria - free generation up to {max_output_tokens} tokens") print(f"[DEBUG] Input prompt length: {len(prompt)} characters") print(f"[DEBUG] Input tokens: {input_ids.shape[1]} tokens") stopping_criteria = None # Set seed for deterministic generation5 unmodified lines # Generate response using deterministic greedy decoding # This eliminates randomness and ensures consistent responses print(f"[DEBUG] About to generate with max_new_tokens: {max_output_tokens}") print(f"[DEBUG] Model device: {our_chatbot.model.device}") print(f"[DEBUG] Image tensor device: {image_tensor.device}") with torch.no_grad(): outputs = our_chatbot.model.generate( inputs=input_ids,5 unmodified lines 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 early_stopping=False, # Ensure no early stopping ) # Decode response1 unmodified line print(f"[DEBUG] Outputs shape: {outputs.shape if hasattr(outputs, 'shape') else 'No shape attr'}") print(f"[DEBUG] Outputs length: {len(outputs) if hasattr(outputs, '__len__') else 'No length'}") print(f"[DEBUG] Input IDs shape: {input_ids.shape}") print(f"[DEBUG] Generated tokens: {outputs.shape[1] - input_ids.shape[1] if hasattr(outputs, 'shape') else 'Unknown'}") print(f"[DEBUG] Expected max tokens: {max_output_tokens}") if len(outputs) == 0: return {"error": "Model generated empty output"}104 unmodified lines self.model_base = None self.num_gpus = 1 self.conv_mode = None self.max_new_tokens = 1024 self.max_new_tokens = 4096 self.num_frames = 16 self.load_8bit = False self.load_4bit = False73 unmodified lines repetition_penalty = float(payload.get("repetition_penalty", 1.0)) conv_mode_override = payload.get("conv_mode", None) # Debug: Log all generation parameters print(f"[DEBUG] Generation parameters:") print(f"[DEBUG] max_output_tokens: {max_output_tokens}") print(f"[DEBUG] repetition_penalty: {repetition_penalty}") print(f"[DEBUG] Original payload max_output_tokens: {payload.get('max_output_tokens')}") print(f"[DEBUG] Original payload max_new_tokens: {payload.get('max_new_tokens')}") print(f"[DEBUG] Original payload max_tokens: {payload.get('max_tokens')}") print(f"[DEBUG] Full payload keys: {list(payload.keys())}") print(f"[DEBUG] Payload values: {dict(payload)}") if not message_text or not message_text.strip(): return {"error": "Missing prompt text. Use 'message', 'query', 'prompt', or 'istem' key"} handler.py+26-1