MFTCoder微调codefuse34b模型后,发现模型代码补全这块的回复能力就没了,求解决方案
Closed this issue · 3 comments
yangyubin1 commented
twelveand0 commented
方案1: 用SST格式做推理,即不带<|role_start|>human<|role_end|>和<|role_start|>bot<|role_end|>这些角色标签,例如Prompt设置成下面这样
from typing import List
def separate_paren_groups(paren_string: str) -> List[str]:
""" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
separate those group into separate strings and return the list of those.
Separate groups are balanced (each open brace is properly closed) and not nested within each other
Ignore any spaces in the input string.
>>> separate_paren_groups('( ) (( )) (( )( ))')
['()', '(())', '(()())']
"""
这样可以解决你微调后无法补全的问题,但以这种格式进行部署推理,则无法再支持对话式的问答
方案2: 自己构建一个代码补全数据集,格式示例如下:
Prompt:
<|role_start|>human<|role_end|># language: Python
from typing import List
def separate_paren_groups(paren_string: str) -> List[str]:
""" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
separate those group into separate strings and return the list of those.
Separate groups are balanced (each open brace is properly closed) and not nested within each other
Ignore any spaces in the input string.
>>> separate_paren_groups('( ) (( )) (( )( ))')
['()', '(())', '(()())']
"""
<|role_start|>bot<|role_end|>
Label:
groups = []
current_group = ""
open_parens = 0
for char in paren_string:
if char == "(":
open_parens += 1
elif char == ")":
open_parens -= 1
if open_parens == 0:
groups.append(current_group + char)
current_group = ""
else:
current_group += char
return groups
其他语言类似,其他语言格式可以参考HumanEval-X数据集
将这种方式构建的数据集当成MFTCoder的一个微调任务与其他任务一起微调,这样就可以跟你加训前一样既支持补全也支持问答了
liudonglei commented