inference 시 tool calling format 관련 문의
#8
by
HyezNee
- opened
안녕하세요.
당사에서 개발해주신 모델 잘 쓰고 있습니다.
다름이 아니라 HyperCLOVA X SEED 14B Think 모델을 이용하여 tool calling을 할 때, 모델 소개 페이지에 나와 있는 포맷을 지키지 않을 때가 많아 이 부분에 대해 문의 드리고자 글을 올리게 되었습니다.
huggingface에 나와 있는 모델의 tool calling 형식은 아래와 같습니다.
{following the previous context}
Let's check the weather using the get_weather tool.<|im_end|>
<|im_start|>assistant -> tool/function_call
{"name": "get_weather","input": {"location":"Seoul"}}<|im_end|><|stop|>
그러나 적지 않은 응답에서 아래와 같이 잘못된 형식으로 함수를 호출하였습니다.
(BFCL과 FunctionChat-Bench를 사용하여 모델의 tool calling 능력을 평가했을 때 얻은 응답입니다.)
-> tool/informWeather\n{\"location\": \"노원구\"}
-> tool/informWeather\n{\"name\": \"informWeather\", \"arguments\": {\"location\": \"부산\"}}
이렇게 호출을 할 경우 hcx parser로도 파싱이 되지 않아 오답 처리가 되는데요. 시스템 프롬프트를 바꿔보아도 결과가 달라지지 않아 문의 드립니다.
혹시 함수의 function calling format을 강제할 수 있는 다른 방법이 있을까요?
참고가 될까 싶어 제가 사용한 인퍼런스 코드 snippet도 첨부합니다.
감사합니다.
---인퍼런스 코드 snippet----
- vLLM 실행 부분
cmd = [
"vllm", "serve",
self.model_path,
"--host", self.host,
"--port", str(self.port),
"--dtype", "bfloat16",
"--gpu-memory-utilization", "0.90",
"--trust-remote-code",
"--reasoning-parser", "hcx",
"--enable-auto-tool-choice",
"--tool-call-parser", "hcx",
]
self.proc = subprocess.Popen(
cmd,
stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
start_new_session=True
)
- OpenAI compatible API로 single inference하는 부분
response = self.openai_chat_completion(
model=self.model_path,
temperature=api_request['temperature'],
messages=api_request['messages'],
tools=api_request['tools'],
tool_choice="auto",
max_completion_tokens=self.max_tokens,
stop=["<|im_end|><|endofturn|>", "<|im_end|><|stop|>"],
extra_body={
"skip_special_tokens": False,
}
)