Instructions to use Bllossom/llama-3.2-Korean-Bllossom-AICA-5B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Bllossom/llama-3.2-Korean-Bllossom-AICA-5B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Bllossom/llama-3.2-Korean-Bllossom-AICA-5B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("Bllossom/llama-3.2-Korean-Bllossom-AICA-5B") model = AutoModelForMultimodalLM.from_pretrained("Bllossom/llama-3.2-Korean-Bllossom-AICA-5B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Bllossom/llama-3.2-Korean-Bllossom-AICA-5B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Bllossom/llama-3.2-Korean-Bllossom-AICA-5B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Bllossom/llama-3.2-Korean-Bllossom-AICA-5B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/Bllossom/llama-3.2-Korean-Bllossom-AICA-5B
- SGLang
How to use Bllossom/llama-3.2-Korean-Bllossom-AICA-5B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Bllossom/llama-3.2-Korean-Bllossom-AICA-5B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Bllossom/llama-3.2-Korean-Bllossom-AICA-5B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Bllossom/llama-3.2-Korean-Bllossom-AICA-5B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Bllossom/llama-3.2-Korean-Bllossom-AICA-5B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use Bllossom/llama-3.2-Korean-Bllossom-AICA-5B with Docker Model Runner:
docker model run hf.co/Bllossom/llama-3.2-Korean-Bllossom-AICA-5B
prompt 문의
안녕하세요!
Bllossom/llama-3.2-Korean-Bllossom-AICA-5B 사용해서 local ai 개발중인데
prompt 적용은 어떻게 하는지 알 수 있을까요?
chat_template.json 에서 system 부분을 수정해도 수정한 내용대로 model 이 적용이 안 됩니다,,
chat_template.json 에서 prompt 조정하는게 맞을까요?
MllamaProcessor는 image가 들어갈 경우 시스템 메시지가 출력하지 않도록 구성되어 있습니다.
image를 사용하지 않고 text만 사용할경우 chat_template.json 에서 system 부분을 수정하면 정상적으로 작동하시는 걸 볼 수 있습니다.
답변 감사합니다! image 사용하지 않고 text만 사용하니 chat_template.json 에서 system 부분 적용이 됩니다! 감사합니다.
prompt 를 꼭 chat_template.json 에서 사용을 해야 되는건가요? 내부소스에 prompt를 만들어서 적용을 할 순 없을까요?
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에 저장하고 대화 내용을 통째로 받아서 사용해봤는데, 대화 내용이 커질수록 토큰값 문제인건지 답변이 제대로 안 나오더라고요,,
대화 내용을 어떻게 저장하고 사용하는지 궁금합니다!