feat: add automatic language detection for responses#144
Open
Libres-coder wants to merge 2 commits intodeepseek-ai:mainfrom
Open
feat: add automatic language detection for responses#144Libres-coder wants to merge 2 commits intodeepseek-ai:mainfrom
Libres-coder wants to merge 2 commits intodeepseek-ai:mainfrom
Conversation
Author
|
ptal,thx @gnobitab @StevenLiuWen |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:langdetectimport.predictfunction.generate_prompt_with_historyto set a system message based on the detected language.deepseek_vl2/serve/inference.py:convert_conversation_to_promptsto include the system message in the conversation payload passed to the model.requirements.txt:langdetectas 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:
pip install -r requirements.txtpython web_demo.py --model_name DeepSeek-VL2-tiny