Feat: deepseek-ocr logits processor (#12415)
Co-authored-by: xinyuant <xinyuant@usc.edu>
This commit is contained in:
@@ -15,6 +15,10 @@ from sglang.srt.multimodal.customized_mm_processor_utils import (
|
||||
register_customized_processor,
|
||||
)
|
||||
|
||||
from sglang.srt.sampling.custom_logit_processor import (
|
||||
DeepseekOCRNoRepeatNGramLogitProcessor,
|
||||
)
|
||||
|
||||
BASE_SIZE = 1024
|
||||
IMAGE_SIZE = 640
|
||||
CROP_MODE = True
|
||||
@@ -26,6 +30,24 @@ PRINT_NUM_VIS_TOKENS = False
|
||||
SKIP_REPEAT = True
|
||||
MODEL_PATH = "deepseek-ai/DeepSeek-OCR" # change to your model path
|
||||
|
||||
NGRAM_NO_REPEAT_SIZE = 30
|
||||
NGRAM_NO_REPEAT_WINDOW = 90
|
||||
# Whitelist `<td>` and `</td>` token ids to allow table structures.
|
||||
NGRAM_NO_REPEAT_WHITELIST = (128821, 128822)
|
||||
|
||||
DEFAULT_CUSTOM_LOGIT_PROCESSOR = DeepseekOCRNoRepeatNGramLogitProcessor.to_str()
|
||||
|
||||
|
||||
def get_default_ngram_custom_params() -> Dict[str, Any]:
|
||||
"""Return default custom params for the DeepSeek-OCR n-gram no repeat processor."""
|
||||
|
||||
return {
|
||||
"ngram_size": NGRAM_NO_REPEAT_SIZE,
|
||||
"window_size": NGRAM_NO_REPEAT_WINDOW,
|
||||
"whitelist_token_ids": list(NGRAM_NO_REPEAT_WHITELIST),
|
||||
}
|
||||
|
||||
|
||||
PROMPT = "<image>\n<|grounding|>Convert the document to markdown."
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user