Code Monkey home page Code Monkey logo

Comments (7)

ArtificialZeng avatar ArtificialZeng commented on May 13, 2024

首先感谢开源 Qwen-7B 模型,我基于该模型实现了 QLoRA 多轮对话微调,项目地址:https://github.com/hiyouga/LLaMA-Efficient-Tuning

QLoRA 指令微调:

CUDA_VISIBLE_DEVICES=0 python src/train_bash.py \
    --stage sft \
    --model_name_or_path Qwen/Qwen-7B-Chat \
    --do_train \
    --dataset sharegpt_zh \
    --template chatml \
    --finetuning_type lora \
    --lora_target c_attn \
    --output_dir qwen_lora \
    --per_device_train_batch_size 4 \
    --gradient_accumulation_steps 4 \
    --lr_scheduler_type cosine \
    --logging_steps 10 \
    --save_steps 100 \
    --learning_rate 3e-5 \
    --num_train_epochs 1.0 \
    --quantization_bit 4 \
    --fp16

Web Demo:

python src/web_demo.py \
    --model_name_or_path Qwen/Qwen-7B-Chat \
    --template chatml

API 部署(基于 OpenAI 格式):

python src/api_demo.py \
    --model_name_or_path Qwen/Qwen-7B-Chat \
    --template chatml

另外,希望开发者可以修复一下 tokenizer 的 decode 方法,使其支持 skip_special_tokens 参数,便于后续开发,目前该参数没有实际生效。 (最新版已修复)

源码对应位置:huggingface.co/Qwen/Qwen-7B-Chat/blob/5e7f6a3f41724e7cb8ea3e3be7a1faf2bd5d6a38/tokenization_qwen.py#L228

def _decode(
    self,
    token_ids: Union[int, List[int]],
    skip_special_tokens: bool = False,
    clean_up_tokenization_spaces: bool = None,
    **kwargs,
) -> str:
    if isinstance(token_ids, int):
        token_ids = [token_ids]
    return self.tokenizer.decode(token_ids)

ValueError: Encountered text corresponding to disallowed special token '<|im_start|>'.
If you want this text to be encoded as a special token, pass it to allowed_special, e.g. allowed_special={'<|im_start|>', ...}.
If you want this text to be encoded as normal text, disable the check for this token by passing disallowed_special=(enc.special_tokens_set - {'<|im_start|>'}).
To disable this check for all special tokens, pass disallowed_special=().

from qwen.

stuarthe avatar stuarthe commented on May 13, 2024

首先感谢开源 Qwen-7B 模型,我基于该模型实现了 QLoRA 多轮对话微调,项目地址:https://github.com/hiyouga/LLaMA-Efficient-Tuning
QLoRA 指令微调:

CUDA_VISIBLE_DEVICES=0 python src/train_bash.py \
    --stage sft \
    --model_name_or_path Qwen/Qwen-7B-Chat \
    --do_train \
    --dataset sharegpt_zh \
    --template chatml \
    --finetuning_type lora \
    --lora_target c_attn \
    --output_dir qwen_lora \
    --per_device_train_batch_size 4 \
    --gradient_accumulation_steps 4 \
    --lr_scheduler_type cosine \
    --logging_steps 10 \
    --save_steps 100 \
    --learning_rate 3e-5 \
    --num_train_epochs 1.0 \
    --quantization_bit 4 \
    --fp16

Web Demo:

python src/web_demo.py \
    --model_name_or_path Qwen/Qwen-7B-Chat \
    --template chatml

API 部署(基于 OpenAI 格式):

python src/api_demo.py \
    --model_name_or_path Qwen/Qwen-7B-Chat \
    --template chatml

另外,希望开发者可以修复一下 tokenizer 的 decode 方法,使其支持 skip_special_tokens 参数,便于后续开发,目前该参数没有实际生效。 (最新版已修复)
源码对应位置:huggingface.co/Qwen/Qwen-7B-Chat/blob/5e7f6a3f41724e7cb8ea3e3be7a1faf2bd5d6a38/tokenization_qwen.py#L228

def _decode(
    self,
    token_ids: Union[int, List[int]],
    skip_special_tokens: bool = False,
    clean_up_tokenization_spaces: bool = None,
    **kwargs,
) -> str:
    if isinstance(token_ids, int):
        token_ids = [token_ids]
    return self.tokenizer.decode(token_ids)

ValueError: Encountered text corresponding to disallowed special token '<|im_start|>'. If you want this text to be encoded as a special token, pass it to allowed_special, e.g. allowed_special={'<|im_start|>', ...}. If you want this text to be encoded as normal text, disable the check for this token by passing disallowed_special=(enc.special_tokens_set - {'<|im_start|>'}). To disable this check for all special tokens, pass disallowed_special=().

我能成功运行,加载了Qwen7B .但是如果是openAI格式的API, 客户端的api key填什么呢?

from qwen.

hiyouga avatar hiyouga commented on May 13, 2024

@stuarthe 留空

from qwen.

stuarthe avatar stuarthe commented on May 13, 2024

@stuarthe 留空

嗯,已成功连接。谢谢!

from qwen.

ArtificialZeng avatar ArtificialZeng commented on May 13, 2024

@stuarthe 留空

求通过 llama efficient tuning 的PR, 解决了 bos token的问题

from qwen.

yechong316 avatar yechong316 commented on May 13, 2024

mark

from qwen.

sunzhaowei avatar sunzhaowei commented on May 13, 2024

Lora微调后的Qwen模型根本不能直接调用chat接口!报错 generation_config缺少chat_ml字段

from qwen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.