import mlx.core as mx
from mlx_vlm import load, generate
model_path = "mlx-community/deepseek-vl-7b-chat-4bit"
model, processor = load(model_path)
prompt = processor.tokenizer.apply_chat_template(
[{"role": "user", "content": f"<image>\nWhat are these?"}],
tokenize=False,
add_generation_prompt=True,
)
output = generate(model, processor, "http://images.cocodataset.org/val2017/000000039769.jpg", prompt, verbose=False)
print(output)
>>> processor
LlamaTokenizerFast(name_or_path='/Users/wayne/.cache/huggingface/hub/models--mlx-community--deepseek-vl-7b-chat-4bit/snapshots/79feff56645faf5f145c834118ca3d43c8c55984', vocab_size=100000, model_max_length=16384, is_fast=True, padding_side='left', truncation_side='right', special_tokens={'bos_token': '<|begin▁of▁sentence|>', 'eos_token': '<|end▁of▁sentence|>', 'additional_special_tokens': ['<image>']}, clean_up_tokenization_spaces=False), added_tokens_decoder={
100000: AddedToken("<|begin▁of▁sentence|>", rstrip=False, lstrip=False, single_word=False, normalized=True, special=True),
100001: AddedToken("<|end▁of▁sentence|>", rstrip=False, lstrip=False, single_word=False, normalized=True, special=True),
100002: AddedToken("ø", rstrip=False, lstrip=False, single_word=False, normalized=True, special=False),
100003: AddedToken("ö", rstrip=False, lstrip=False, single_word=False, normalized=True, special=False),
100004: AddedToken("ú", rstrip=False, lstrip=False, single_word=False, normalized=True, special=False),
100005: AddedToken("ÿ", rstrip=False, lstrip=False, single_word=False, normalized=True, special=False),
100006: AddedToken("õ", rstrip=False, lstrip=False, single_word=False, normalized=True, special=False),
100007: AddedToken("÷", rstrip=False, lstrip=False, single_word=False, normalized=True, special=False),
100008: AddedToken("û", rstrip=False, lstrip=False, single_word=False, normalized=True, special=False),
100009: AddedToken("ý", rstrip=False, lstrip=False, single_word=False, normalized=True, special=False),
100010: AddedToken("À", rstrip=False, lstrip=False, single_word=False, normalized=True, special=False),
100011: AddedToken("ù", rstrip=False, lstrip=False, single_word=False, normalized=True, special=False),
100012: AddedToken("Á", rstrip=False, lstrip=False, single_word=False, normalized=True, special=False),
100013: AddedToken("þ", rstrip=False, lstrip=False, single_word=False, normalized=True, special=False),
100014: AddedToken("ü", rstrip=False, lstrip=False, single_word=False, normalized=True, special=False),
100015: AddedToken("<image_placeholder>", rstrip=False, lstrip=False, single_word=False, normalized=False, special=True),
100016: AddedToken("<image>", rstrip=False, lstrip=False, single_word=False, normalized=False, special=True),
}