Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions fastchat/model/model_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,6 @@ def get_generate_stream_function(model: torch.nn.Module, model_path: str):

model_type = str(type(model)).lower()
is_peft = "peft" in model_type
if is_peft:
model.set_adapter(model_path)
model_type = str(type(model.base_model.model))

is_chatglm = "chatglm" in model_type
is_falcon = "rwforcausallm" in model_type
is_codet5p = "codet5p" in model_type
Expand Down Expand Up @@ -407,7 +403,24 @@ def generate_stream_peft(
judge_sent_end: bool = False,
):
model.set_adapter(model_path)
for x in generate_stream(
base_model_type = str(type(model.base_model.model))
is_chatglm = "chatglm" in base_model_type
is_falcon = "rwforcausallm" in base_model_type
is_codet5p = "codet5p" in base_model_type
is_exllama = "exllama" in base_model_type
is_xft = "xft" in base_model_type
generate_stream_function = generate_stream
if is_chatglm:
generate_stream_function = generate_stream_chatglm
elif is_falcon:
generate_stream_function = generate_stream_falcon
elif is_codet5p:
generate_stream_function = generate_stream_codet5p
elif is_exllama:
generate_stream_function = generate_stream_exllama
elif is_xft:
generate_stream_function = generate_stream_xft
for x in generate_stream_function(
model,
tokenizer,
params,
Expand Down