[Model] Initialize support for InternVL2 series models (#6514)
Co-authored-by: Roger Wang <ywang@roblox.com>
This commit is contained in:
@@ -106,6 +106,20 @@ def run_minicpmv(question):
|
||||
return llm, prompt
|
||||
|
||||
|
||||
# InternVL
|
||||
def run_internvl(question):
|
||||
# Generally, InternVL can use chatml template for conversation
|
||||
TEMPLATE = "<|im_start|>User\n{prompt}<|im_end|>\n<|im_start|>Assistant\n"
|
||||
prompt = f"<image>\n{question}\n"
|
||||
prompt = TEMPLATE.format(prompt=prompt)
|
||||
llm = LLM(
|
||||
model="OpenGVLab/InternVL2-4B",
|
||||
trust_remote_code=True,
|
||||
max_num_seqs=5,
|
||||
)
|
||||
return llm, prompt
|
||||
|
||||
|
||||
# BLIP-2
|
||||
def run_blip2(question):
|
||||
|
||||
@@ -125,6 +139,7 @@ model_example_map = {
|
||||
"chameleon": run_chameleon,
|
||||
"minicpmv": run_minicpmv,
|
||||
"blip-2": run_blip2,
|
||||
"internvl_chat": run_internvl,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ chat_completion_from_url = client.chat.completions.create(
|
||||
],
|
||||
}],
|
||||
model=model,
|
||||
max_tokens=64,
|
||||
)
|
||||
|
||||
result = chat_completion_from_url.choices[0].message.content
|
||||
@@ -78,6 +79,7 @@ chat_completion_from_base64 = client.chat.completions.create(
|
||||
],
|
||||
}],
|
||||
model=model,
|
||||
max_tokens=64,
|
||||
)
|
||||
|
||||
result = chat_completion_from_base64.choices[0].message.content
|
||||
|
||||
Reference in New Issue
Block a user