Skip to content

Conversation

@Libres-coder
Copy link

Summary:
This PR introduces automatic language detection for user input, enabling DeepSeek-VL2 to dynamically adjust its response language (e.g., Chinese or English) based on the detected input language. This resolves the issue where the model would sometimes unexpectedly switch to English during Chinese conversations.

Key Changes:

  • web_demo.py:
    • Added langdetect import.
    • Implemented automatic language detection in predict function.
    • Configured generate_prompt_with_history to set a system message based on the detected language.
  • deepseek_vl2/serve/inference.py:
    • Modified convert_conversation_to_prompts to include the system message in the conversation payload passed to the model.
  • requirements.txt:
    • Added langdetect as a dependency.

Problem Solved:
Previously, the model could inconsistently switch its response language, even when the user maintained a single language (e.g., Chinese). This change ensures the model receives a clear language instruction via a system message, leading to stable and contextually appropriate language responses.

Verification Steps:

  1. Ensure all dependencies are installed: pip install -r requirements.txt
  2. Run the web demo: python web_demo.py --model_name DeepSeek-VL2-tiny
  3. In the Gradio interface, try inputs in both Chinese and English and observe the model's response language.
    • Example Chinese input: "你好,请介绍一下你自己" (Expected: Chinese response)
    • Example English input: "Hello, please introduce yourself" (Expected: English response)
    • Example mixed input: "请问你有什么好的idea吗" (Expected: Chinese response based on primary language)

@Libres-coder
Copy link
Author

ptal,thx @gnobitab @StevenLiuWen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant