Ollama에 올려 사용해 봤는데.. 대답이 끊기질 안고, 갑자기 영어문장 나옴. Modelfile 추천 해주세요.
Ollama에 올려 사용해 봤는데.. 대답이 끊기질 않고, 어떨 때는 한국어로 대답하다가 갑자기 영어문장 나옵니다.
Modelfile은 Qwen 2.5용으로도 사용해 보고, 가장 간단한 내용으로도 해봤는데.. 여전히 대답이 끊기질 않네요..
Modelfile 추천 부탁드립니다.
제가 사용한 Qwen 2.5용 Modlefile은 아래와 같습니다.
https://qwen.readthedocs.io/en/latest/run_locally/ollama.html#run-ollama-with-your-gguf-files
안녕하세요.
공유해주신 Modelfile로 INTERX/Qwen2.5-GenX-14B 모델에 대해 저희가 Ollama에서 reproduce해봤을 때는 답변이 잘 (끊기게) 나오는데요,
혹시 어떤 질문을 입력했을 때 문제가 발생했는지나, 사용하신 정확한 Modelfile을 공유해주시면 문제 파악에 도움이 될 것 같습니다.
아래와 같이 수행했습니다.
최종 결과물은 Open WebUI에서 확인했구요,
Open WebUI에서 Qwen2.5 모델이 반복 답변 문제가 있다고 해서, repetition penalty 값을 0으로 했는데도 반복 답변 됩니다.
https://www.reddit.com/r/LocalLLaMA/comments/1gpwrq1/how_to_use_qwen25coderinstruct_without/
'너는 어떤 LLM 모델로 만든거야?', '사출 성형이 뭐야?' 라고 물어보면 반복 답변이 나옵니다.
'사출 성형이 뭐야? 반복 답변 하지 말고 간략히 대답해' 라고 물어봐도, 반복.. 너무 길게 답변합니다.
허깅페이스 모델 다운로드
from huggingface_hub import snapshot_download
model_id = "INTERX/Qwen2.5-GenX-14B"
snapshot_download(repo_id=model_id, local_dir="huggingface_llm/inerx", local_dir_use_symlinks=False, revision="main")모델 변환 (to GGUF)
python convert_hf_to_gguf.py
huggingface_llm/interx
--outtype q8_0
--outfile Qwen2.5-GenX-14B_q8.ggufOllama 모델 만들기
ollama create InterX-GenX-14B -f Modelfile
Modelfile
FROM InterX-GenX-14B_q8.gguf
set the temperature to 1 [higher is more creative, lower is more coherent]
PARAMETER temperature 0.7
PARAMETER top_p 0.8
PARAMETER repeat_penalty 1.05
PARAMETER top_k 20
TEMPLATE """{{ if .Messages }}
{{- if or .System .Tools }}<|im_start|>system
{{ .System }}
{{- if .Tools }}
Tools
You are provided with function signatures within XML tags:
{{- range .Tools }}
{"type": "function", "function": {{ .Function }}}{{- end }}
For each function call, return a json object with function name and arguments within XML tags:
{"name": , "arguments": }
{{- end }}<|im_end|>
{{ end }}
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1 -}}
{{- if eq .Role "user" }}<|im_start|>user
{{ .Content }}<|im_end|>
{{ else if eq .Role "assistant" }}<|im_start|>assistant
{{ if .Content }}{{ .Content }}
{{- else if .ToolCalls }}
{{ range .ToolCalls }}{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}
{{ end }}
{{- end }}{{ if not $last }}<|im_end|>
{{ end }}
{{- else if eq .Role "tool" }}<|im_start|>user
{{ .Content }}
<|im_end|>
{{ end }}
{{- if and (ne .Role "assistant") $last }}<|im_start|>assistant
{{ end }}
{{- end }}
{{- else }}
{{- if .System }}<|im_start|>system
{{ .System }}<|im_end|>
{{ end }}{{ if .Prompt }}<|im_start|>user
{{ .Prompt }}<|im_end|>
{{ end }}<|im_start|>assistant
{{ end }}{{ .Response }}{{ if .Response }}<|im_end|>{{ end }}"""
set the system message
SYSTEM """너는 사출 금형 전문가야."""
저희 모델은 아직 GGUF를 지원하지 않고 있습니다만, safetensor를 gguf로 변환하여 사용하시는 과정에서 chat template 쪽에 문제가 생긴 것으로 보입니다.
일단 현재는 safetensor를 사용해주시면 감사드리겠습니다.
https://github.com/ollama/ollama/blob/main/docs/import.md#importing-a-model-from-safetensors-weights
허깅페이스에 올라온 오픈소스는 대부분은 로컬로 받아서 사용하고 싶어 할 겁니다.
로컬에서는 대부분 transform 패키지를 사용하지 않고, 사용하기 쉬운 ollama 를 이용하여 챗봇을 개발할 것 같구요.
Qwen 계열의 모델은 gguf 변환 및 ollama 형식의 모델이 많던데요,
GenX 모델을 오픈소스로 공유해 주신 만큼, 응답 품질에 문제가 없도록 변환된 gguf 형식으로도 지원 / gguf 파일 공유해주시면 좋겠습니다.
저 처럼 직접 gguf로 변환해 사용하면, 귀사의 LLM 성능이 좋지 않다는 오해를 갖게 될 것 같습니다.
소중한 피드백 감사합니다.
Quick Start를 따라 해 보는데요..
generated_ids를 덮어쓰기 하는 부분도 이상하고,
generated_ids = [ 코드에는 사용하지 않는 model_inputs 객체가 있네요..
2번째의 generated_ids = [ 코드 블록은 불필요한거죠?
해당 코드 블록을 주석처리 하고, 수행해 보니.. 반복답변 현상은 안나타납니다.
generated_ids = model.generate(tokenized_chat, max_new_tokens=512)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
해당 코드 블록은 생성된 토큰에서 입력 토큰 부분은 제외하고 출력 토큰만 보여주기 위한 부분입니다. 생략하셔도 무방합니다.
만약 사용을 원하신다면 model_inputs .input_ids
를 tokenized_chat
로 변경하시면 정상 작동합니다. 감사합니다.
정상 작동 확인했습니다. 빠른 답변 감사드립니다.
(gguf 지원도 해주시면 좋겠네요)