metadata
language:
- ko
- en
license: cc-by-nc-sa-4.0
library_name: transformers
Llama-3-KoEn-8B-xtuner-llava-preview π
Llama-3-KoEn-8B-xtuner-llava-preview π is Korean based MutliModal based on Llava architecture, merged with ChatVector methods leveraging 2 models:
Model Details
Model Description
- Developed by: Junbum Lee (Beomi)
- Model type: HuggingFace Llava π
- Language(s) (NLP): Korean, English
- License: cc-by-nc-sa-4.0 under Llama3 License
- Merged from model: beomi/Llama-3-KoEn-8B-preview & xtuner/llava-llama-3-8b-transformers
Direct Use
Two version recommended
v1.
revision='a38aac3'
: Basic ChatVector, with 25B+ trained KoEn ckpt(rev. d4d25a2).v1-1.
revision='0224971'
: Basic ChatVector, with 40B+ trained KoEn ckpt(rev. ad39b32).v2.
revision='4f04d1e'
: Model diff based merging(ref. https://huggingface.co./blog/maywell/llm-feature-transfer), with 25B+ trained KoEn ckpt(rev. d4d25a2).
import requests
from PIL import Image
import torch
from transformers import AutoProcessor, LlavaForConditionalGeneration
model_id = "beomi/Llama-3-KoEn-8B-xtuner-llava-preview"
model = LlavaForConditionalGeneration.from_pretrained(
model_id,
torch_dtype='auto',
device_map='auto',
revision='a38aac3', # 'a38aac3' for basic ChatVector, '4f04d1e' for Model diff based merging(ref. https://huggingface.co./blog/maywell/llm-feature-transfer)
)
processor = AutoProcessor.from_pretrained(model_id)
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained('./llava-llama-3-KoEn-8b-v1_1-transformers')
terminators = [
tokenizer.eos_token_id,
tokenizer.convert_tokens_to_ids("<|eot_id|>")
]
prompt = ("<|start_header_id|>user<|end_header_id|>\n\n<image>\nμ΄ μ΄λ―Έμ§μ λν΄μ μ€λͺ
ν΄μ£ΌμΈμ.<|eot_id|>"
"<|start_header_id|>assistant<|end_header_id|>\n\nμ΄ μ΄λ―Έμ§μλ")
image_file = "https://cdn-uploads.huggingface.co/production/uploads/5e56829137cb5b49818287ea/NWfoArWI4UPAxpEnolkwT.jpeg"
raw_image = Image.open(requests.get(image_file, stream=True).raw)
inputs = processor(prompt, raw_image, return_tensors='pt').to(0, torch.float16)
output = model.generate(**inputs, max_new_tokens=400, do_sample=True, eos_token_id=terminators,)
print(processor.decode(output[0][2:], skip_special_tokens=False))
# --- Example Output [Chat Vector] ---
user<|end_header_id|>
<image>
μ΄ μ΄λ―Έμ§μ λν΄μ μ€λͺ
ν΄μ£ΌμΈμ.<|eot_id|><|start_header_id|>assistant<|end_header_id|>
μ΄ μ΄λ―Έμ§μλ κ³ μμ΄ ν λ§λ¦¬κ° κ°λ¬Ό μλ₯Ό κ±Έμ΄κ°λ λͺ¨μ΅μ΄ 보μ¬μ§λλ€. κ³ μμ΄λ κ°λ¬Όμ μλ¬Όκ²°μ λ―ΈλλΌμ νκ³ κ° κ°λ‘λ₯Ό μ§λλ λ° λ₯μνκ² λ³΄μ
λλ€. κ³ μμ΄μ λ°μ κ°λ¬Όλ‘ μ λ€μ΄κ°, κ·Έκ²μ μ¦κΈ°λ©° κ±Έμ΄κ°λλ€.
λν μ΄ μ΄λ―Έμ§λ μμ± λ
Ήμμ νκ±°λ λ
Ήνλ μλ£λ‘ μ μλμμΌλ©°, μ£Όλ‘ κ³ μμ΄μ λͺ¨μ΅μ κ°νκ² λ³΄μ¬μ€λλ€. μ리 ν¨κ³Όλ μ¬λ¬ κ°μ§λ‘ μΆκ°νμ¬ κ³ μμ΄μ μ€ν 리λ₯Ό λ€μνκ² μ λ¬ν©λλ€. κ°λ¬Όμ μλ¬Όκ²°μ λνλ΄λ©° κ°λ¬Ό μλ₯Ό κ±·λ κ³ μμ΄μ λͺ¨μ΅μ λμ± κ°λ ¬νκ² κ°μ‘°νκΈ° μν΄ μλ¬Όκ²°μ ν΅ν΄ λ λν
μΌν μ₯λ©΄μ 보μ¬μ€λλ€.<|eot_id|>
# --- Example Output [Model diff based merging] ---
user<|end_header_id|>
<image>
μ΄ μ΄λ―Έμ§μ λν΄μ μ€λͺ
ν΄μ£ΌμΈμ.<|eot_id|><|start_header_id|>assistant<|end_header_id|>
μ΄ μ΄λ―Έμ§μλ νκ΅μ΄ μλ§κ³Ό ν¨κ» κ³ μμ΄κ° λ¬Όμ λ°μ λλκ³ κ±·λ λͺ¨μ΅μ΄ λ΄κ²¨ μμ΅λλ€. κ³ μμ΄λ μ€λ₯Έμͺ½ λ°μ λ¬Όμ λ΄κ·Έκ³ κ±·λ μ€μ΄λ©°, νκ΅μ΄ μλ§μ "κ³ μμ΄λ λ¬Όμ μ’μν©λλ€"λΌλ λ¬Έμ₯μ ν¬ν¨νκ³ μμ΅λλ€. μ΄ μλ§μ κ³ μμ΄κ° λ¬Όμ μ’μνλ κ²μ κ°μ‘°νκ³ μμ΅λλ€.<|eot_id|>