Skip to content

Commit

Permalink
fix bugs (modelscope#1038)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jintao-Huang committed May 31, 2024
1 parent c1f8761 commit df58536
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docs/source/LLM/VLLM推理加速与部署.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
pip install 'ms-swift[llm]' -U

# vllm与cuda版本有对应关系,请按照`https://docs.vllm.ai/en/latest/getting_started/installation.html`选择版本
pip install vllm -U
pip install vllm
pip install openai -U

# 环境对齐 (通常不需要运行. 如果你运行错误, 可以跑下面的代码, 仓库使用最新环境测试)
Expand Down Expand Up @@ -484,7 +484,7 @@ CUDA_VISIBLE_DEVICES=0 swift deploy --ckpt_dir 'xxx/vx-xxx/checkpoint-xxx-merged

客户端示例代码同原始模型.

### 多LoRA部署
## 多LoRA部署

目前pt方式部署模型已经支持`peft>=0.10.0`进行多LoRA部署,具体方法为:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
pip install 'ms-swift[llm]' -U

# vllm version corresponds to cuda version, please select version according to `https://docs.vllm.ai/en/latest/getting_started/installation.html`
pip install vllm -U
pip install vllm
pip install openai -U

# Environment alignment (usually not needed. If you get errors, you can run the code below, the repo uses the latest environment for testing)
Expand Down Expand Up @@ -481,7 +481,7 @@ CUDA_VISIBLE_DEVICES=0 swift deploy --ckpt_dir 'xxx/vx-xxx/checkpoint-xxx-merged
The example code for the client side is the same as the original models.
### Multiple LoRA Deployments
## Multiple LoRA Deployments
The current model deployment method now supports multiple LoRA deployments with `peft>=0.10.0`. The specific steps are:
Expand Down
6 changes: 3 additions & 3 deletions examples/pytorch/llm/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ class CustomDatasetName:
stsb_en = 'stsb-en'


@register_model(CustomModelType.tigerbot_7b, 'TigerResearch/tigerbot-7b-base-v3', LoRATM.llama,
@register_model(CustomModelType.tigerbot_7b, 'TigerResearch/tigerbot-7b-base-v3', LoRATM.llama2,
TemplateType.default_generation)
@register_model(CustomModelType.tigerbot_13b, 'TigerResearch/tigerbot-13b-base-v2', LoRATM.llama,
@register_model(CustomModelType.tigerbot_13b, 'TigerResearch/tigerbot-13b-base-v2', LoRATM.llama2,
TemplateType.default_generation)
@register_model(CustomModelType.tigerbot_13b_chat, 'TigerResearch/tigerbot-13b-chat-v4', LoRATM.llama,
@register_model(CustomModelType.tigerbot_13b_chat, 'TigerResearch/tigerbot-13b-chat-v4', LoRATM.llama2,
CustomTemplateType.tigerbot)
def get_tigerbot_model_tokenizer(model_dir: str,
torch_dtype: Dtype,
Expand Down
2 changes: 1 addition & 1 deletion swift/llm/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def get_available_models():
if _args.lora_request_list is not None:
model_list += [lora_request.lora_name for lora_request in _args.lora_request_list]
data = [
Model(id=model_id, is_chat=not is_generation_template(model_id), owned_by=_args.owned_by)
Model(id=model_id, is_chat=not is_generation_template(_args.template_type), owned_by=_args.owned_by)
for model_id in model_list
]
return ModelList(data=data)
Expand Down
2 changes: 2 additions & 0 deletions swift/llm/utils/argument.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ def handle_compatibility(self: Union['SftArguments', 'InferArguments']) -> None:
_dataset = getattr(self, key)
if isinstance(_dataset, str):
_dataset = [_dataset]
elif _dataset is None:
_dataset = []
if len(_dataset) == 1 and ',' in _dataset[0]:
_dataset = _dataset[0].split(',')
for i, d in enumerate(_dataset):
Expand Down
2 changes: 2 additions & 0 deletions swift/llm/utils/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ class LoRATM(NamedTuple):
'kv_b_proj',
'o_proj',
]
# compat
llama2 = llama


GetModelTokenizerFunction = Callable[..., Tuple[Optional[PreTrainedModel], PreTrainedTokenizerBase]]
Expand Down

0 comments on commit df58536

Please sign in to comment.