Skip to content
Merged
Show file tree
Hide file tree
Changes from 33 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Additionally, we are expanding capabilities for other modalities. Currently, we
SWIFT has rich documentations for users, please check [here](https://github.com/modelscope/swift/tree/main/docs/source_en/LLM).

## 🎉 News
- 2024.05.20: Supports TeleChat-12B-v2 model, model_type are `telechat-12b-v2`
- 🔥2024.05.20: Support for inferencing and fine-tuning cogvlm2-llama3-chinese-chat-19B, cogvlm2-llama3-chat-19B. you can refer to [cogvlm2 Best Practices](docs/source_en/Multi-Modal/cogvlm2-best-practice.md).
- 🔥2024.05.17: Support peft=0.11.0. Meanwhile support 3 new tuners: `BOFT`, `Vera` and `Pissa`. use `--sft_type boft/vera` to use BOFT or Vera, use `--init_lora_weights pissa` with `--sft_type lora` to use Pissa.
- 2024.05.16: Supports Llava-Next (Stronger) series models. For best practice, you can refer to [here](https://github.com/modelscope/swift/tree/main/docs/source_en/Multi-Modal/llava-best-practice.md).
Expand Down
1 change: 1 addition & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ SWIFT支持近**200种LLM和MLLM**(多模态大模型)的训练、推理、
SWIFT具有丰富的文档体系,如有使用问题请请查看[这里](https://github.com/modelscope/swift/tree/main/docs/source/LLM).

## 🎉 新闻
- 2024.05.21: 支持TeleChat-12b-v2模型, model_type为 `telechat-12b-v2`
- 🔥2024.05.20: 支持 cogvlm2-llama3-chinese-chat-19B, cogvlm2-llama3-chat-19B 的推理与微调, 可以查看[cogvlm2最佳实践](docs/source/Multi-Modal/cogvlm2最佳实践.md).
- 🔥2024.05.17: 支持peft=0.11.0. 同时支持了三个新的tuner方法: `BOFT`, `Vera` 和 `Pissa`. 使用 `--sft_type boft/vera` 开启BOFT或者Vera, 使用 `--init_lora_weights pissa` 以及 `--sft_type lora` 来使用 Pissa.
- 2024.05.16: 支持Llava-Next (Stronger)系列模型,最佳实践可以查看[这里](https://github.com/modelscope/swift/tree/main/docs/source/Multi-Modal/llava最佳实践.md).
Expand Down
47 changes: 45 additions & 2 deletions swift/llm/utils/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ class ModelType:
deepseek_vl_7b_chat = 'deepseek-vl-7b-chat'
# deepseek-v2
deepseek_v2_chat = 'deepseek-v2-chat'
deepseek_v2_lite = 'deepseek-v2-lite'
deepseek_v2_lite_chat = 'deepseek-v2-lite-chat'
# gemma
gemma_2b = 'gemma-2b'
gemma_7b = 'gemma-7b'
Expand Down Expand Up @@ -357,6 +359,8 @@ class ModelType:
# teleAI
telechat_7b = 'telechat-7b'
telechat_12b = 'telechat-12b'
telechat_12b_v2 = 'telechat-12b-v2'
telechat_12b_v2_gptq_int4 = 'telechat-12b-v2-gptq-int4'
# grok-1
grok_1 = 'grok-1'
# dbrx
Expand Down Expand Up @@ -2580,7 +2584,26 @@ def get_model_tokenizer_internlm2(model_dir: str,

return model, tokenizer


@register_model(
ModelType.deepseek_v2_lite,
'deepseek-ai/DeepSeek-V2-Lite',
LoRATM.deepseek2,
TemplateType.default_generation,
support_gradient_checkpointing=False,
support_flash_attn=True,
support_vllm=True,
requires=['transformers>=4.39.3'],
hf_model_id='deepseek-ai/DeepSeek-V2-Lite')
@register_model(
ModelType.deepseek_v2_lite_chat,
'deepseek-ai/DeepSeek-V2-Lite-Chat',
LoRATM.deepseek2,
TemplateType.deepseek2,
support_gradient_checkpointing=False,
support_flash_attn=True,
support_vllm=True,
requires=['transformers>=4.39.3'],
hf_model_id='deepseek-ai/DeepSeek-V2-Lite-Chat')
@register_model(
ModelType.deepseek_v2_chat,
'deepseek-ai/DeepSeek-V2-Chat',
Expand Down Expand Up @@ -3643,6 +3666,24 @@ def get_model_tokenizer_codellama(model_dir: str,
TemplateType.telechat,
support_flash_attn=True,
hf_model_id='Tele-AI/TeleChat-12B')
@register_model(
ModelType.telechat_12b_v2,
'TeleAI/TeleChat-12B-v2',
LoRATM.telechat,
TemplateType.telechat_v2,
eos_token=2,
support_flash_attn=True,
hf_model_id='Tele-AI/TeleChat-12B-v2')
@register_model(
ModelType.telechat_12b_v2_gptq_int4,
'swift/TeleChat-12B-V2-GPTQ-Int4',
LoRATM.telechat,
TemplateType.telechat_v2,
eos_token=2,
requires=['auto_gptq>=0.5'],
support_flash_attn=True,
function_kwargs={'gptq_bits': 4},
hf_model_id='Tele-AI/TeleChat-12B-v2')
def get_model_tokenizer_phi(model_dir: str,
torch_dtype: Dtype,
model_kwargs: Dict[str, Any],
Expand All @@ -3651,9 +3692,11 @@ def get_model_tokenizer_phi(model_dir: str,
model_config = AutoConfig.from_pretrained(model_dir, trust_remote_code=True)
use_flash_attn = kwargs.pop('use_flash_attn', False)
model_config.flash_attn = use_flash_attn
return get_model_tokenizer_from_repo(
model, tokenizer = get_model_tokenizer_from_repo(
model_dir, torch_dtype, model_kwargs, load_model, model_config=model_config, **kwargs)

return model, tokenizer


@register_model(
ModelType.telechat_7b,
Expand Down
3 changes: 3 additions & 0 deletions swift/llm/utils/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class TemplateType:
atom = 'atom'
phi3 = 'phi3'
telechat = 'telechat'
telechat_v2 = 'telechat-v2'
dbrx = 'dbrx'
mengzi = 'mengzi'
c4ai = 'c4ai'
Expand Down Expand Up @@ -1374,6 +1375,8 @@ def get_generate_ids(generate_ids: Tensor, input_token_len: int) -> List[int]:

register_template(TemplateType.telechat, Template([], ['<_user>{{QUERY}}<_bot>'], ['<_end>'], ['<_end>']))

register_template(TemplateType.telechat_v2, Template([], ['<_user> {{QUERY}}<_bot>'], [], ['<_end>']))

DBRX_SYSTEM = (
'You are DBRX, created by Databricks. You were last updated in December 2023. '
'You answer questions based on information available up to that point.\n'
Expand Down