Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<think>标签训练后,模型预测结果无<think>标签 #7119

Open
1 task done
qubingxin opened this issue Feb 28, 2025 · 2 comments
Open
1 task done

<think>标签训练后,模型预测结果无<think>标签 #7119

qubingxin opened this issue Feb 28, 2025 · 2 comments
Labels
bug Something isn't working pending This problem is yet to be addressed

Comments

@qubingxin
Copy link

Reminder

  • I have read the above rules and searched the existing issues.

System Info

  • llamafactory version: 0.9.2.dev0
  • Platform: Linux-5.4.241-1-tlinux4-0017.7-x86_64-with-glibc2.35
  • Python version: 3.10.14
  • PyTorch version: 2.4.0+cu124 (GPU)
  • Transformers version: 4.45.2
  • Datasets version: 3.1.0
  • Accelerate version: 1.2.0
  • PEFT version: 0.12.0
  • TRL version: 0.9.6
  • GPU type: NVIDIA H20
  • GPU number: 8
  • GPU memory: 95.00GB
  • DeepSpeed version: 0.15.4
  • vLLM version: dev

训练数据如alpaca格式,在output中的思维过程前后增加和, 无system prompt

训练过程中loss正常,但用vllm部署服务后,用openai接口请求输出结果没有和,这里很奇怪为什么和不遵循?

在源码中看到这里对和</think>进行了特殊处理,请问是这个原因吗?把前后这2个标签丢掉了?
@DataClass
class FunctionFormatter(StringFormatter):
def post_init(self):
super().post_init()
self.tool_utils = get_tool_utils(self.tool_format)

@override
def apply(self, **kwargs) -> SLOTS:
    content: str = kwargs.pop("content")
    regex = re.compile(r"<think>(.*)</think>", re.DOTALL)
    thought = re.search(regex, content)
    if thought:
        content = content.replace(thought.group(0), "")

    functions: List["FunctionCall"] = []
    try:
        tool_calls = json.loads(content)
        if not isinstance(tool_calls, list):  # parallel function call
            tool_calls = [tool_calls]

        for tool_call in tool_calls:
            functions.append(
                FunctionCall(tool_call["name"], json.dumps(tool_call["arguments"], ensure_ascii=False))
            )

    except json.JSONDecodeError:
        raise RuntimeError(f"Invalid JSON format in function message: {str([content])}.")  # flat string

    function_str = self.tool_utils.function_formatter(functions)
    if thought:
        function_str = thought.group(1) + function_str

    return super().apply(content=function_str)

Reproduction

Put your message here.

Others

No response

@qubingxin qubingxin added bug Something isn't working pending This problem is yet to be addressed labels Feb 28, 2025
@qubingxin
Copy link
Author

追加,提问内容的“"和“”内容不见了

@qubingxin
Copy link
Author

think标签不输出了,带尖括号

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending This problem is yet to be addressed
Projects
None yet
Development

No branches or pull requests

1 participant