Chat Vector: A Simple Approach to Equip LLMs With New Language Chat Capabilities
Paper • 2310.04799 • Published
How to use aeolian83/Llama-3-8B-Instruct-cp-transfer_0.7 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="aeolian83/Llama-3-8B-Instruct-cp-transfer_0.7")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("aeolian83/Llama-3-8B-Instruct-cp-transfer_0.7")
model = AutoModelForCausalLM.from_pretrained("aeolian83/Llama-3-8B-Instruct-cp-transfer_0.7")
messages = [
{"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.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(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use aeolian83/Llama-3-8B-Instruct-cp-transfer_0.7 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "aeolian83/Llama-3-8B-Instruct-cp-transfer_0.7"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "aeolian83/Llama-3-8B-Instruct-cp-transfer_0.7",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/aeolian83/Llama-3-8B-Instruct-cp-transfer_0.7
How to use aeolian83/Llama-3-8B-Instruct-cp-transfer_0.7 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "aeolian83/Llama-3-8B-Instruct-cp-transfer_0.7" \
--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": "aeolian83/Llama-3-8B-Instruct-cp-transfer_0.7",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "aeolian83/Llama-3-8B-Instruct-cp-transfer_0.7" \
--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": "aeolian83/Llama-3-8B-Instruct-cp-transfer_0.7",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use aeolian83/Llama-3-8B-Instruct-cp-transfer_0.7 with Docker Model Runner:
docker model run hf.co/aeolian83/Llama-3-8B-Instruct-cp-transfer_0.7
aeolian83/Llama-3-Open-Ko-8B-aeolian83-chatvec 모델은
chat-vector 논문( https://arxiv.org/abs/2310.04799v2 )에 근거하여,
llama3의 pre-trained 모델의 parameter와 instruction 모델의 매개변수의 차이를
beomi님의 Llama-3-Open-Ko-8B에 적용한 모델
이 방법이 가능하다면 llama3의 instruction 모델에
llama3의 pre-trained 모델과 한국어 CP모델인 Llama-3-Open-Ko-8B 모델의 매개변수 차이를
instruction 모델에 넣었을 때 어떻게 되는지 확인하는 모델
매개변수에 가중치를 0.7 줌
results/all/aeolian83/Llama-3-8B-Instruct-cp-transfer_0.7
| 0 | 5 | |
|---|---|---|
| kobest_boolq (macro_f1) | 0.786414 | 0.775213 |
| kobest_copa (macro_f1) | 0.67162 | 0.719676 |
| kobest_hellaswag (macro_f1) | 0.436275 | 0.423664 |
| kobest_sentineg (macro_f1) | 0.503784 | 0.901741 |
| kohatespeech (macro_f1) | 0.260168 | 0.339337 |
| kohatespeech_apeach (macro_f1) | 0.337667 | 0.611894 |
| kohatespeech_gen_bias (macro_f1) | 0.124535 | 0.505005 |
| korunsmile (f1) | 0.410636 | 0.323403 |
| nsmc (acc) | 0.53778 | 0.81346 |
| pawsx_ko (acc) | 0.5485 | 0.486 |