[Model] Initialize support for InternVL2 series models (#6514)

Co-authored-by: Roger Wang <ywang@roblox.com>
This commit is contained in:
Isotr0py
2024-07-29 18:16:30 +08:00
committed by GitHub
parent 3eeb148f46
commit 7cbd9ec7a9
14 changed files with 1042 additions and 6 deletions

View File

@ -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,
}