QwenLM / Qwen2.5

Qwen2.5 is the large language model series developed by Qwen team, Alibaba Cloud.
8.11k stars 495 forks source link

Inference issue about qwen2-72b-instruct #900

Open TuTuHuss opened 1 week ago

TuTuHuss commented 1 week ago

Hi there, I am attempting to utilize the qwen2-72b-instruct (API) for a continuation text task; however, the output lacks punctuation despite my inclusion of the directive "you should add necessary punctuations in the result" within the system_prompt. Could you please advise on how to rectify this issue?

class qwen():
    def __init__(self):
        self.client = OpenAI(
            api_key="",
            base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"
        )

    def call(self,system_prompt:str,user_prompt:str) -> str:
        response = self.client.chat.completions.create(
            model="qwen2-72b-instruct",
            messages = [
                {'role': 'system', 'content': system_prompt},
                {'role': 'user', 'content': user_prompt}
            ],
            temperature=0.7,
            top_p=1,
            max_tokens=256
        )
        return response.choices[0].message.content
jklj077 commented 1 week ago

Hi,

Would you mind sharing an example input?

TuTuHuss commented 1 week ago

@jklj077 FYI, here are some info about how to reproduced the problem:

class qwen():
    def __init__(self):
        self.client = OpenAI(
            api_key="",
            base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"
        )

    def call(self,system_prompt:str,user_prompt:str) -> str:
        response = self.client.chat.completions.create(
            model="qwen2-72b-instruct",
            messages = [
                {'role': 'system', 'content': system_prompt},
                {'role': 'user', 'content': user_prompt}
            ],
            temperature=0.7,
            top_p=1,
            max_tokens=256
        )
        return response.choices[0].message.content

if __name__ == '__main__':

    system_prompt = '''
# 任务
任务一:根据用户提供的文字,从文字的末尾开始进行续写,续写的结果直到达到最大输出上限才停止
任务二:为续写结果补充必要的标点符号或分段分行
# 风格
风格一:生动,形象,富有感染力
风格二:全部采用口语化文字,禁止任何严肃严谨的文字风格出现
风格三:擅长换位思考,续写的内容充满内在逻辑

请直接输出续写结果,不要说其他的任何内容
    '''
    user_prompt = '''
    各位球迷朋友们,今天咱们来聊聊2024年金球奖的热门候选人!维尼修斯、贝林厄姆和罗德里,这三位可都是顶级球员。咱们先来看看维尼修斯,这小伙子在关键比赛中的突破和进球,简直是皇马的救星!再瞧瞧贝林厄姆,他的组织能力和传球视野
,简直就是中场大师的化身。最后,罗德里在曼城和西班牙的防守和进攻转换,那叫一个稳!这三位,谁拿金球奖都不意外,你们怎么看?
    '''
    result = qwen().call(system_prompt,user_prompt)
    print(result)

I run this code 3 times at 23:35(UTF +8) and 2 of them are reproduced the problem


(ins) ╭─norman@local ~/Desktop
╰─$ python3 qwen_api.py                                                                                                                                                                                                 127 ↵
    哎呀我的球迷朋友们咱们这话题一开可真是热血沸腾啊你说对吧哈哈维尼修斯那小子在球场上就像一头小野兽一样冲破一切防线然后就那么一脚劲射简直了简直了贝林厄姆那个小伙子组织能力是真的强看着他控球传球就像欣赏一场中场艺术表演似的罗德里嘛稳得一批曼城和西班牙的中场大闸有他在感觉就像有了一堵墙让人安心这三位要是谁能拿到金球奖那绝对实至名归啊不过话又说回来咱们这些球迷也就是猜猜而已真要说到结果那还得看他们未来的表现不是但不管怎么样能有这样精彩的足球盛宴咱们就已经很满足了对吧嘿嘿嘿。
(ins) ╭─norman@local ~/Desktop
╰─$ python3 qwen_api.py
    哈哈别说还真挺难选的对吧每个都有拿奖的理由啊你说是不是咱们先说说维尼修斯这家伙在前场那速度跟闪电似的过人如过晨星进球就跟吃豆子一样简单你说这咋防得了再看看贝林厄姆中场大师哎这词儿用得真好他那传球就像长了眼睛似的总能找到队友的脚尖而且还能攻能守真是个全能战士至于罗德里嘛在曼城简直就是定海神针有他在后腰位置上球队就像有了颗定心丸进攻时他是发起者防守时他又变成破坏者这三个人要是站一块儿踢球那画面想想都带劲不过呢我有个大胆的想法如果他们三个能组个队那不就成了无敌舰队了吗想想都刺激啊不过话说回来金球奖这事儿还是得看今年的表现毕竟足球这东西瞬息万变谁能保证下一秒会发生什么呢咱们就拭目以待吧到时候再看看谁能把这个金灿灿的小球捧回家哈哈!

(ins) ╭─norman@local ~/Desktop
╰─$ python3 qwen_api.py
    哇哦说真的我都能想象到颁奖典礼上那紧张刺激的气氛了你懂的嘛就像是看一场超级精彩的球赛一样心都提到了嗓子眼儿!维尼修斯那小子踢球简直太帅了每一次带球过人都让人心跳加速进球的时候那欢呼声震天响简直了!贝林厄姆呢他那个传球啊就像是有魔法似的总能找到最好的队友眼神一交流那球就到位了中场大师可不是白叫的!还有罗德里他在场上就像是定海神针一样稳得一批不管是防守还是进攻转换都处理得那么从容不迫。哎你说他们三个要是站一块儿拍照那画面得多震撼啊!不过到底谁能捧走金球奖呢这就跟猜彩票似的刺激又带劲咱们就等着看吧到时候一起为他们加油哦!
jklj077 commented 1 week ago

Hi, thank you for your input!

I could reproduce the issue with your settings and the problem is hit 3 out of 10: image

A bit prompt engineering could potentially alleviate the issue, 0 out of 2 times of 10 (I think the main problem is with "口语化" and the system message is not well-organized):

image image

TuTuHuss commented 1 week ago

@jklj077 Ok, I can solve this problem from the perspective of adjusting the prompt, but perhaps this can also become a test case for enhancing the model's capabilities