Add vLLM patched image for K100: fix extra_special_tokens list->dict

This commit is contained in:
common-user
2026-04-22 16:39:25 +08:00
commit f27dde3b30
2 changed files with 23 additions and 0 deletions

4
Dockerfile Normal file
View File

@@ -0,0 +1,4 @@
FROM git.modelhub.org.cn:9443/enginex-hygon/vllm:0.9.2
COPY patch.py /tmp/patch.py
RUN python3 /tmp/patch.py

19
patch.py Normal file
View File

@@ -0,0 +1,19 @@
path = '/usr/local/lib/python3.10/dist-packages/transformers/tokenization_utils_base.py'
with open(path, 'r') as f:
content = f.read()
old = (' self.SPECIAL_TOKENS_ATTRIBUTES = self.SPECIAL_TOKENS_ATTRIBUTES'
' + list(special_tokens.keys())')
new = (' # PATCH: some models have extra_special_tokens as list instead of dict\n'
' if isinstance(special_tokens, list):\n'
' special_tokens = {t: t for t in special_tokens}\n'
' self.SPECIAL_TOKENS_ATTRIBUTES = self.SPECIAL_TOKENS_ATTRIBUTES'
' + list(special_tokens.keys())')
if old in content:
content = content.replace(old, new)
with open(path, 'w') as f:
f.write(content)
print('Patch 1 applied successfully')
else:
print('WARNING: Patch 1 pattern not found')