prompt 문의

#6
by HugJihun - opened

안녕하세요!
Bllossom/llama-3.2-Korean-Bllossom-AICA-5B 사용해서 local ai 개발중인데
prompt 적용은 어떻게 하는지 알 수 있을까요?
chat_template.json 에서 system 부분을 수정해도 수정한 내용대로 model 이 적용이 안 됩니다,,
chat_template.json 에서 prompt 조정하는게 맞을까요?

Bllossom org

MllamaProcessor는 image가 들어갈 경우 시스템 메시지가 출력하지 않도록 구성되어 있습니다.
image를 사용하지 않고 text만 사용할경우 chat_template.json 에서 system 부분을 수정하면 정상적으로 작동하시는 걸 볼 수 있습니다.

답변 감사합니다! image 사용하지 않고 text만 사용하니 chat_template.json 에서 system 부분 적용이 됩니다! 감사합니다.
prompt 를 꼭 chat_template.json 에서 사용을 해야 되는건가요? 내부소스에 prompt를 만들어서 적용을 할 순 없을까요?

Bllossom org

chat_template.json을 직접 수정하지 않고 아래의 코드와 같이 코드상에서 프로세서를 불러온 뒤 chat_template을 지정해서 사용하실수 있습니다

processor = MllamaProcessor.from_pretrained('Bllossom/llama-3.2-Korean-Bllossom-AICA-5B')
my_template="""
{%- for message in messages %}
  {%- if message['role'] == 'user' %}
    {{ bos_token + '[USER] ' + message['content'].strip() + ' [/USER]' }}
  {%- elif message['role'] == 'assistant' %}
    {{ '[ASST] ' + message['content'] + ' [/ASST]' + eos_token }}
  {%- endif %}
{%- endfor %}"""
processor.chat_template = my_template

jinja2 template에 대한 간단한 예제들은 아래의 링크에서 확인하시길바랍니다!
https://huggingface.co/docs/transformers/main/en/chat_templating

항상 친절하고 자세한 답변 감사합니다!
혹시 이전 대화 내용을 저장하는 것에 대하여 조언을 얻을 수 있을까요?
이전 대화 내용을 DB에 저장하고 대화 내용을 통째로 받아서 사용해봤는데, 대화 내용이 커질수록 토큰값 문제인건지 답변이 제대로 안 나오더라고요,,
대화 내용을 어떻게 저장하고 사용하는지 궁금합니다!

Your need to confirm your account before you can post a new comment.

Sign up or log in to comment