language:
- en
- ko
license: apache-2.0
library_name: peft
tags:
- facebook
- meta
- pytorch
- llama
- llama-2
- llama-2-chat
pipeline_tag: text-generation
inference: false
base_model: davidkim205/komt-Llama-2-7b-chat-hf
komt-llama-2-7b-lora
This model fine-tuned the aaa model using PEFT-LoRA.
The "komt-llama-2-7b" model was developed using a multi-task instruction technique aimed at enhancing Korean language performance. For more details, please refer to the GitHub Repository. Please refer below for more detailed information.
For more detailed information, please refer to the https://huggingface.co/davidkim205/komt-Llama-2-7b-chat-hf.
Model Details
- Model Developers : davidkim(changyeon kim)
- Repository : https://github.com/davidkim205/komt
- Lora target modules : q_proj, o_proj, v_proj, gate_proj, down_proj, k_proj, up_proj
- Model Size : 80MB
- Model Architecture : komt-llama-2-7b is an auto-regressive language model that uses an optimized transformer architecture. The tuned versions use supervised fine-tuning by multi-task instruction
Dataset
korean multi-task instruction dataset
Prompt Template
### instruction: {prompt}
### Response:
Examples:
### instruction: ์๋์ฐจ ์ข
ํฉ(์ ๊ธฐ)๊ฒ์ฌ ์๋ฌด๊ธฐ๊ฐ์ ์ผ๋ง์ธ๊ฐ์?
### Response:
response:
### instruction: ์๋์ฐจ ์ข
ํฉ(์ ๊ธฐ)๊ฒ์ฌ ์๋ฌด๊ธฐ๊ฐ์ ์ผ๋ง์ธ๊ฐ์?
### Response: ์๋์ฐจ ์ข
ํฉ(์ ๊ธฐ)๊ฒ์ฌ ์๋ฌด๊ธฐ๊ฐ์ 2๋
์
๋๋ค. ์ด ๊ธฐ๊ฐ ๋์ ๊ฒ์ฌ๋ฅผ ๋ฐ์ง ์์ผ๋ฉด ๊ณผํ๋ฃ๊ฐ ๋ถ๊ณผ๋ฉ๋๋ค. ์๋์ฐจ ์ข
ํฉ(์ ๊ธฐ)๊ฒ์ฌ ์๋ฌด๊ธฐ๊ฐ์ 2013๋
12์ 31์ผ๋ถํฐ ์ํ๋์์ต๋๋ค
Usage
After downloading from GitHub, please install as follows:
git clone https://github.com/davidkim205/komt
cd komt
pip install -r lora/requirements_lora.txt
- Requirements Python >=3.8. Linux distribution (Ubuntu, MacOS, etc.) + CUDA > 10.0. Refer https://github.com/TimDettmers/bitsandbytes#tldr
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
from transformers import StoppingCriteria, StoppingCriteriaList
from transformers import TextStreamer, GenerationConfig
from peft import PeftModel, PeftConfig
class LocalStoppingCriteria(StoppingCriteria):
def __init__(self, tokenizer, stop_words = []):
super().__init__()
stops = [tokenizer(stop_word, return_tensors='pt', add_special_tokens = False)['input_ids'].squeeze() for stop_word in stop_words]
print('stop_words', stop_words)
print('stop_words_ids', stops)
self.stop_words = stop_words
self.stops = [stop.cuda() for stop in stops]
self.tokenizer = tokenizer
def _compare_token(self, input_ids):
for stop in self.stops:
if len(stop.size()) != 1:
continue
stop_len = len(stop)
if torch.all((stop == input_ids[0][-stop_len:])).item():
return True
return False
def _compare_decode(self, input_ids):
input_str = self.tokenizer.decode(input_ids[0])
for stop_word in self.stop_words:
if input_str.endswith(stop_word):
return True
return False
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor):
input_str = self.tokenizer.decode(input_ids[0])
for stop_word in self.stop_words:
if input_str.endswith(stop_word):
return True
return False
#
# config
peft_model_name = 'davidkim205/komt-Llama-2-7b-chat-hf-lora'
model_name = 'davidkim205/komt-Llama-2-7b-chat-hf'
instruction_prefix = "### instruction: "
input_prefix = "### input: "
answer_prefix = "### Response: "
endoftext = "<|end|>"
stop_words = [endoftext, '<s>', '###']
generation_config = GenerationConfig(
temperature=0.9,
top_p=0.7,
top_k=100,
max_new_tokens=2048,
early_stopping=True,
do_sample=True,
)
#
# create model
config = PeftConfig.from_pretrained(peft_model_name)
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_use_double_quant=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16
)
model = AutoModelForCausalLM.from_pretrained(model_name, quantization_config=bnb_config,
device_map="auto")
model = PeftModel.from_pretrained(model, peft_model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
stopping_criteria = StoppingCriteriaList([LocalStoppingCriteria(tokenizer=tokenizer, stop_words=stop_words)])
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
model.eval()
#
# generate
prompt = f"### instruction: ์๋์ฐจ ์ข
ํฉ(์ ๊ธฐ)๊ฒ์ฌ ์๋ฌด๊ธฐ๊ฐ์ ์ผ๋ง์ธ๊ฐ์?.\n\n### Response:"
gened = model.generate(
**tokenizer(
prompt,
return_tensors='pt',
return_token_type_ids=False
).to('cuda'),
generation_config=generation_config,
eos_token_id=model.config.eos_token_id,
stopping_criteria=stopping_criteria,
streamer=streamer
)
output_text = tokenizer.decode(gened[0], skip_special_tokens=True)
print('--------------------')
print(output_text)
response:
nlp๋ ์์ฐ์ด ์ฒ๋ฆฌ์ ์ฝ์๋ก, ์์ฐ์ด๋ฅผ ์ฌ์ฉํ์ฌ ์ธ๊ฐ๊ณผ ์ปดํจํฐ ๊ฐ์ ์ํธ ์์ฉ์ ๋ค๋ฃจ๋ ๋ถ์ผ์
๋๋ค. ์ปดํจํฐ์ ์ธ๊ฐ์ด ์๋ก ์ํธ ์์ฉํ๋ ๋ฐ ์ฌ์ฉ๋๋ ์ธ์ด์ ๊ธฐ์ ์ ํฌํจํ๋ฉฐ, ์ปดํจํฐ๋ ์ธ๊ฐ์ ์ธ์ด๋ฅผ ์ฒ๋ฆฌํ๊ณ ๋ถ์ํ์ฌ ์ธ๊ฐ์ ์์
์ ๋๊ฑฐ๋ ์์
์ ์๋ํํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. ๋ฐ๋ผ์ ์ปดํจํฐ๊ฐ ์ปดํจํฐ์์ ์์
ํ๋ ๋ฐ ์ฌ์ฉ๋๋ ์ปดํจํฐ ํ๋ก๊ทธ๋จ์ด๋ ํ๋ก๊ทธ๋จ๊ณผ ๋น์ทํ๊ฒ ์ธ๊ฐ๋ ์์ ์ ์์
์ ์ฌ์ฉ๋๋ ์ปดํจํฐ ํ๋ก๊ทธ๋จ๊ณผ ๋น์ทํ ๋ฐฉ์์ผ๋ก ์์
ํ ์ ์์ต๋๋ค.
Hardware and Software
- nvidia driver : 535.54.03
- CUDA Version: 12.2
Framework versions
- PEFT 0.4.0
Training
Refer github
Model Benchmark
- Used EleutherAI's lm-evaluation-harness https://github.com/EleutherAI/lm-evaluation-harness/tree/polyglot
Korean Semantic Textual Similarity
model name | Version | Metric | Value | Stderr | |
---|---|---|---|---|---|
meta-llama/Llama-2-7b-chat-hf | 0 | acc | 0.4817 | ยฑ | 0.0220 |
beomi/llama-2-ko-7b | 0 | acc | 0.5029 | ยฑ | 0.0220 |
kfkas/Llama-2-ko-7b-Chat | 0 | acc | 0.5318 | ยฑ | 0.0219 |
komt-llama-2-7b (ours) | 0 | acc | 0.5530 | ยฑ | 0.0218 |
Example Output
Please refer to the GitHub link below for performance results of each model. https://github.com/davidkim205/komt/tree/main/eval_results
์ง๋ฌธ/๋ต๋ณ |
---|
๋์ ์ฐจ๋จ๊ธฐ๊ฐ ๋ด๋ ค๊ฐ๋ ์ด์ ๋ ๋ฌด์์ ๋๊น? |
๋์ ์ฐจ๋จ๊ธฐ๋ ๋์ ์ ์ ๊ธฐ๋ฅผ ์ฐจ๋จํ์ฌ ํ์ฌ ์ํ์ ์ค์ด๊ธฐ ์ํด ์ค์น๋ฉ๋๋ค. ํ์ง๋ง ๋์ ์ฐจ๋จ๊ธฐ๋ ์๊ฐ์ด ์ง๋๋ฉด์ ์ค์น๋ ์ฅ์์์ ๋ฉ์ด์ง๊ฒ ๋๋ฉฐ, ์ด๋ก ์ธํด ์ค์น๋ ์ฅ์์์ ๋์ ์ฐจ๋จ๊ธฐ๊ฐ ๋จ์ด์ง๋ฉด ์์๋ ์ ์์ต๋๋ค. ๋ฐ๋ผ์ ๋์ ์ฐจ๋จ๊ธฐ๊ฐ ๋ด๋ ค๊ฐ๋ ๊ฒ์ ์ด๋ฌํ ์ด์ ๋๋ฌธ์ ๋๋ค. ๋์ ์ฐจ๋จ๊ธฐ๋ ๋์ ์ ์ ๊ธฐ๋ฅผ ์ฐจ๋จํ๊ธฐ ์ํด ์ค์น๋๋ ์ฅ์น์ด๋ฏ๋ก, ์ค์น๋ ์ฅ์์์ ๋์ ์ฐจ๋จ๊ธฐ๊ฐ ๋จ์ด์ง๋ฉด ์์๋ ์ ์์ผ๋ฏ๋ก ๋์ ์ฐจ๋จ๊ธฐ๊ฐ ๋ด๋ ค๊ฐ๋ ๊ฒ์ ์ ์ ํ ๊ด๋ฆฌ๊ฐ ํ์ํฉ๋๋ค. |
ํ๋ ฅ๊ณต์ธ์ค๊ฐ์ฌ๋ ๋ฌด์์ธ๊ฐ์? |
ํ๋ ฅ๊ณต์ธ์ค๊ฐ์ฌ๋ ๊ฑด์ถ, ๋ฌผ๋ฅ, ํ ๋ชฉ, ๊ฑด์ค ๋ฑ ๋ค์ํ ์ฐ์ ๋ถ์ผ์์ ๊ณต์ธ์ค๊ฐ์ฌ์ ํ๋ ฅํ์ฌ ๊ฑด์ถ์ ์, ์์ ์ ๋ฐ ํ ์ง์ฃผ๋ฅผ ๋์ ํ์ฌ ๊ฑด์ถ ํ๋ก์ ํธ๋ฅผ ์คํํ๋ ์ ๋ฌธ๊ฐ์ ๋๋ค. ์ด๋ค์ ๊ณต์ธ์ค๊ฐ์ฌ์ ํ๋ ฅํ์ฌ ๊ณต์ฌ ๊ณ์ฝ, ๋ฒ๋ฅ ์๋ฌธ, ๊ฑด์ถ ํ๊ฐ ๋ฐ ๊ฑด์ถ ๊ท์ ์ค์์ ๊ฐ์ ํ๋ก์ ํธ ์ ๋ฌด๋ฅผ ์ฒ๋ฆฌํฉ๋๋ค. ํ๋ ฅ๊ณต์ธ์ค๊ฐ์ฌ๋ ๊ณต์ธ์ค๊ฐ์ฌ๊ฐ ๊ฑด์ถ ํ๋ก์ ํธ๋ฅผ ๊ด๋ฆฌํ๊ณ ๊ฑด์ถ์ ์, ์์ ์ฃผ ๋ฐ ํ ์ง์ฃผ์ ๊ด๋ จ๋ ๋ค๋ฅธ ๋น์ฌ์๋ฅผ ๋์ ํ์ฌ ํ๋ ฅํ ์ ์๋๋ก ์ง์ํฉ๋๋ค. ํ๋ ฅ๊ณต์ธ์ค๊ฐ์ฌ๋ ๊ณต์ธ์ค๊ฐ์ฌ์ ํ๋ ฅํ์ฌ ํ๋ก์ ํธ๊ฐ ์ํํ๊ฒ ์งํ๋๊ณ ๊ถ๊ทน์ ์ผ๋ก ์์ ์๊ฐ ์ํ๋ ๊ฒฐ๊ณผ๋ฅผ ์ป์ ์ ์๋๋ก ์ง์ํฉ๋๋ค. |
์์ถ๋ฌผํ์๋ ์์ฐ์งํ์๋ฅผ ํ์ฌ์ผ ํ๋์? |
์ผ๋ฐ์ ์ผ๋ก ์์ถ๋ฌผํ์ ์์ฐ์งํ์๋ฅผ ํ์ง ์๋ ๊ฒ์ด ์ผ๋ฐ์ ์ ๋๋ค. ๊ทธ๋ฌ๋ ์์ฐ์งํ์๋ ์์ฐ์ง๊ฐ ์๋ ์ ํ์ ์์ถํ ๊ฒฝ์ฐ์๋ ํ์์ ๋๋ค. ์์ฐ์งํ์ ์ ๋๋ ์ ํ์ ์์ฐ์ง๋ฅผ ํ์ํ์ฌ ์์ ์ ํ์ ์์ฐ์ง ๊ฑฐ์งํ์๋ฅผ ๋ฐฉ์งํ๊ณ ๊ตญ๋ด ์๋น์์๊ฒ ์ ํ์ ์์ฐ์ง๋ฅผ ์ ๋ขฐํ ์ ์๋๋ก ํ๊ธฐ ์ํด ์ํ๋๋ ์ ๋์ ๋๋ค. ์์ฐ์งํ์๋ ํ์์๋ฌด๋์์๊ฐ ์์ฐ์งํ์ ์๋ฌด๋์์์ ๋ํ ํ์์๋ฌด๋ฅผ ์ดํํ์ง ์์ ๊ฒฝ์ฐ ์ต๋ 100๋ง์ ์ดํ์ ๊ณผํ๋ฃ๊ฐ ๋ถ๊ณผ๋ฉ๋๋ค. ํ์ง๋ง ์์ถ๋ฌผํ์๋ ์์ฐ์งํ์๋ฅผ ํ์ง ์๋ ๊ฒ์ด ์ผ๋ฐ์ ์ด๋ฉฐ, ์์ ๋ฌผํ์๋ ์์ฐ์งํ์๊ฐ ์๋ฌด์ ์ ๋๋ค. ๋ฐ๋ผ์ ์์ถ๋ฌผํ์ ์์ฐ์งํ์๋ฅผ ํ์ง ์๋ ๊ฒ์ ์ผ๋ฐ์ ์ด๋ฉฐ, ์์ฐ์งํ์ ์ ๋๋ ์์ ๋ฌผํ์๋ง ์ ์ฉ๋ฉ๋๋ค. |
์๋์ฐจ ๊ณต๊ธฐ์ ๊ด๋ฆฌ๊ฐ ์ ์ค์ํ๋์? |
์๋์ฐจ ๊ณต๊ธฐ์ ๊ด๋ฆฌ๋ ์ฌ๋ฌ ๊ฐ์ง ์ด์ ๋ก ์ค์ํฉ๋๋ค. ์ฒซ์งธ, ์๋์ฐจ ๊ณต๊ธฐ์์ ๋ ธ๋ฉด ๋ง์ฐฐ๋ ฅ์ ๋์ฌ์ฃผ๋ ์ญํ ์ ํ๋ฉฐ, ๋ ธ๋ฉด ๋ง์ฐฐ ๊ฐ์๋ก ์ฐ๋น๋ฅผ ํฅ์์ํค๋ ํจ๊ณผ๊ฐ ์์ต๋๋ค. ๋์งธ, ๊ณต๊ธฐ์์ด ๋ฎ์ผ๋ฉด ๋ ธ๋ฉด ๋ง์ฐฐ๋ ฅ์ด ๋ฎ์์ง๋ฉฐ, ๊ฒฐ๊ตญ ์ฐจ๋ ์ ๋๋ ฅ์ด ๋จ์ด์ง๋๋ค. ๋ฐ๋ผ์ ๊ณต๊ธฐ์์ด ๋ฎ์ ๋๋ ๋ ธ๋ฉด ๋ง์ฐฐ๋ ฅ์ ๋์ฌ์ฃผ๋ ํจ๊ณผ๊ฐ ์์ผ๋ฉฐ, ๋ฐ๋๋ก ๊ณต๊ธฐ์์ด ๋์ ๋๋ ๋ ธ๋ฉด ๋ง์ฐฐ๋ ฅ์ด ๋์์ ธ ์ฐ๋น๊ฐ ์ ํ๋๊ธฐ๋ ํฉ๋๋ค. |
์ฃผ์ฐจ์๋ฐ์ผ๋ก ๊ณผํ๋ฃ๊ฐ ๋์๋๋ฐ ํ์ ์ฌํ์ ์ฒญ๊ตฌํ ์ ์๋์? |
ํ์ ์ฌํ์ ์ฒญ๊ตฌํ ์ ์์ต๋๋ค. ํ์ง๋ง ํ์ ์ฌํ์ ์ฒญ๊ตฌํ๊ธฐ ์ ์ ๋ฒ์ ํ๊ฒฐ์ ํ์ธํด๋ณด๋ ๊ฒ์ด ์ข์ต๋๋ค. ํ์ ์ฌํ ์ฒญ๊ตฌ ํ ๋ฒ์ ํ๊ฒฐ์ ๋ฐ๋ผ ํ์ ์ฌํ์ ์ฒญ๊ตฌํ ์ ์์ต๋๋ค. ํ์ง๋ง ๋ฒ์ ํ๊ฒฐ์ ๋ฐ๋ผ ํ์ ์ฌํ์ ์ฒญ๊ตฌํ ์ ์์ ์๋ ์์ต๋๋ค. ํ์ ์ฌํ ์ฒญ๊ตฌ ํ ํ๊ฒฐ์ ๋ฐ๋ผ ์ฒญ๊ตฌ๋ ์ฌ์์ ๋ณ๊ฒฝํ ์ ์๋ ๊ถ๋ฆฌ๋ ์์ต๋๋ค. |
ํ๋ฆฌ๋ ์ด๋ ๋๋ผ์ ์ ๋๋ฉ์ด์ ์ด์ผ |
์ผ๋ณธ\nใํ๋ฆฌใ(ใใชใผ ํธ๋ฆฌ์ด)๋ ์ผ๋ณธ์ ์ ๋๋ฉ์ด์ ์ํ์ด๋ค. 2003๋ 4์ 10์ผ๋ถํฐ 2004๋ 3์ 31์ผ๊น์ง ํ์ง TV์์ ๋ฐฉ์๋์์ผ๋ฉฐ, ๋ฐฉ์์๊ฐ์ ์ด 108ํ์ด๋ค. ๋จํ๋ณธ์ ๋ชจ๋ 6๊ถ์ด๋ฉฐ, ์ 3๊ถ ๋ณธํธ, ์ 3๊ถ ์ธ์ , ์ 1๊ถ ์์ ํ์ด ์๋ค. ใํ๋ฆฌใ๋ ์ด์ฌ ์์ ์ ๊ฟ์ ์์ด๋ฒ๋ฆฐ 20๋ ์ด๋ฐ์ ์ฒญ๋ ์ด ์์ ์ ์ํ์ ๋ํ ์์ ๊ฐ์ ๊ฐ๊ณ ์๊ฐ๊ฐ ๋๊ธฐ ์ํด ๋ ธ๋ ฅํ๋ ์ด์ผ๊ธฐ๋ฅผ ๊ทธ๋ฆฐ ์ํ์ด๋ค. ๋ํ ๊ฟ์ ํฅํ ์ฒญ๋ ์ ์ด์ ๊ณผ ๋ ธ๋ ฅ์ด ์ฑ๊ณต์ผ๋ก ์ด์ด์ง๋ ๊ณผ์ ์ ๊ทธ๋ฆฌ๊ณ ์๋ค. ์ํ ๋ด์์ ์๊ฐ์ ๋ชจ์ต์ด ์์ ๊ณผ ๋ฎ์๋ค๋ ์ ์์ ๋ง์ ํ์ ๊ฐ ๋์๋ค. ์ 24ํ ์ผ๊ฐ์ฟ ์นธ ๋งํ์์ ์์ํ๋ค. |
์ํ ํด๋ฆฌํฌํฐ ์๋ฆฌ์ฆ ๋ฐฐ๊ธ์ฌ๊ฐ ์ด๋์ผ |
์๋ ๋ธ๋ผ๋์ค\n๋ฐ์ด๋น๋ ์๊ธ๋ฆฌ์๋ 1990๋ ๋ ์ด ์๋ฆฌ์ฆ๋ฅผ ์์ํ๋ค. ์ด ์ํ๋ค์ ์ด 8๋ถ์์ผ๋ก ๋ง๋ค์ด์ก์ผ๋ฉฐ, ์ฒซ ๋ฒ์งธ ์ํ์ ใํด๋ฆฌ ํฌํฐ์ ๋ง๋ฒ์ฌ์ ๋ใ์ด๋ค. ์๊ฐ๋ J. K. ๋กค๋ง์ด๋ฉฐ, ์ํ ์๋ฆฌ์ฆ๋ ๋ฐฐ๊ธ์ฌ์ธ ์๋ ๋ธ๋ผ๋์ค๊ฐ ๋ง๋ค์๋ค. ์ดฌ์์ 1997๋ 7์ 11์ผ๋ถํฐ 12์ 22์ผ๊น์ง ๋ฐ๋์์ ์ด๋ฃจ์ด์ก๋ค. ์ดฌ์ ์ฅ์๋ก๋ ๋ฐ๋ ํฌ๋ฆญ์ค ์คํ๋์ค์ ๋ฐ๋ ์ํฐ ์คํผ์ค๊ฐ ์ฌ์ฉ๋์๋ค. ๋ฐ์ด๋น๋ ์๊ธ๋ฆฌ์๋ ํด๋ฆฌ ํฌํฐ ์ญํ ์ ๋งก์๋ค. |
์ ์ธ๊ณ์๊ฐ์ ๊ธฐ์ค์ด ์๊ตญ์ GMT์ธ๊ฐ์? ๊ทธ ์ด์ ๋ ๋ฌด์์ผ๊น์? |
์๊ตญ์ GMT๋ ์ธ๊ณ์๊ฐ์ ๊ธฐ์ค์ด ๋๋ ์๊ฐ๋์ ๋๋ค. ๊ทธ๋ฌ๋ ์ด ์๊ฐ๋๋ ํ์คํ๋์ง ์์์ผ๋ฉฐ, ๋ฐ๋ผ์ ๋ค๋ฅธ ๋๋ผ์ ์๊ฐ๋์ ์ฐจ์ด๊ฐ ์์ ์ ์์ต๋๋ค. ๋ฐ๋ผ์ ์ด ์๊ฐ๋๋ฅผ ์ธ๊ณ์๊ฐ์ผ๋ก ์ฐฉ๊ฐํ๋ ์ฌ๋๋ค์ด ์์ ์ ์์ต๋๋ค. ๋ฐ๋ผ์, ์ธ๊ณ์๊ฐ์ ๊ธฐ์ค์ ํ์คํ๋ ์๊ฐ๋๋ฅผ ๋ฐ๋ฅด๋๋ก ํ๋ ๊ฒ์ด ์ค์ํฉ๋๋ค. |
Original model card: Meta's Llama 2 13B-chat
Meta developed and released the Llama 2 family of large language models (LLMs), a collection of pretrained and fine-tuned generative text models ranging in scale from 7 billion to 70 billion parameters. Our fine-tuned LLMs, called Llama-2-Chat, are optimized for dialogue use cases. Llama-2-Chat models outperform open-source chat models on most benchmarks we tested, and in our human evaluations for helpfulness and safety, are on par with some popular closed-source models like ChatGPT and PaLM.
Model Developers Meta
Variations Llama 2 comes in a range of parameter sizes โ 7B, 13B, and 70B โ as well as pretrained and fine-tuned variations.
Input Models input text only.
Output Models generate text only.
Model Architecture Llama 2 is an auto-regressive language model that uses an optimized transformer architecture. The tuned versions use supervised fine-tuning (SFT) and reinforcement learning with human feedback (RLHF) to align to human preferences for helpfulness and safety.
Training Data | Params | Content Length | GQA | Tokens | LR | |
---|---|---|---|---|---|---|
Llama 2 | A new mix of publicly available online data | 7B | 4k | โ | 2.0T | 3.0 x 10-4 |
Llama 2 | A new mix of publicly available online data | 13B | 4k | โ | 2.0T | 3.0 x 10-4 |
Llama 2 | A new mix of publicly available online data | 70B | 4k | โ | 2.0T | 1.5 x 10-4 |
Llama 2 family of models. Token counts refer to pretraining data only. All models are trained with a global batch-size of 4M tokens. The 70B version uses Grouped-Query Attention (GQA) for improved inference scalability.
Model Dates Llama 2 was trained between January 2023 and July 2023.
Status This is a static model trained on an offline dataset. Future versions of the tuned models will be released as we improve model safety with community feedback.
License A custom commercial license is available at: https://ai.meta.com/resources/models-and-libraries/llama-downloads/
Research Paper More information can be found in the paper "Llama-2: Open Foundation and Fine-tuned Chat Models", available at https://ai.meta.com/research/publications/llama-2-open-foundation-and-fine-tuned-chat-models/.
Where to send questions or comments about the model Instructions on how to provide feedback or comments on the model can be found in the model README.
Intended Use
Intended Use Cases Llama 2 is intended for commercial and research use in English. Tuned models are intended for assistant-like chat, whereas pretrained models can be adapted for a variety of natural language generation tasks.
Out-of-scope Uses Use in any manner that violates applicable laws or regulations (including trade compliance laws). Use in languages other than English. Use in any other way that is prohibited by the Acceptable Use Policy and Licensing Agreement for Llama 2.
Hardware and Software
Training Factors We used custom training libraries, Meta's Research Super Cluster, and production clusters for pretraining. Fine-tuning, annotation, and evaluation were also performed on third-party cloud compute.
Carbon Footprint Pretraining utilized a cumulative 3.3M GPU hours of computation on hardware of type A100-80GB (TDP of 350-400W). Estimated total emissions were 539 tCO2eq, 100% of which were offset by Metaโs sustainability program.
Time (GPU hours) | Power Consumption (W) | Carbon Emitted(tCO2eq) | |
---|---|---|---|
Llama 2 7B | 184320 | 400 | 31.22 |
Llama 2 13B | 368640 | 400 | 62.44 |
Llama 2 70B | 1720320 | 400 | 291.42 |
Total | 3311616 | 539.00 |
CO2 emissions during pretraining. Time: total GPU time required for training each model. Power Consumption: peak power capacity per GPU device for the GPUs used adjusted for power usage efficiency. 100% of the emissions are directly offset by Meta's sustainability program, and because we are openly releasing these models, the pretraining costs do not need to be incurred by others.
Training Data
Overview Llama 2 was pretrained on 2 trillion tokens of data from publicly available sources. The fine-tuning data includes publicly available instruction datasets, as well as over one million new human-annotated examples. Neither the pretraining nor the fine-tuning datasets include Meta user data.
Data Freshness The pretraining data has a cutoff of September 2022, but some tuning data is more recent, up to July 2023.
Evaluation Results
In this section, we report the results for the Llama 1 and Llama 2 models on standard academic benchmarks. For all the evaluations, we use our internal evaluations library.
Model | Size | Code | Commonsense Reasoning | World Knowledge | Reading Comprehension | Math | MMLU | BBH | AGI Eval |
---|---|---|---|---|---|---|---|---|---|
Llama 1 | 7B | 14.1 | 60.8 | 46.2 | 58.5 | 6.95 | 35.1 | 30.3 | 23.9 |
Llama 1 | 13B | 18.9 | 66.1 | 52.6 | 62.3 | 10.9 | 46.9 | 37.0 | 33.9 |
Llama 1 | 33B | 26.0 | 70.0 | 58.4 | 67.6 | 21.4 | 57.8 | 39.8 | 41.7 |
Llama 1 | 65B | 30.7 | 70.7 | 60.5 | 68.6 | 30.8 | 63.4 | 43.5 | 47.6 |
Llama 2 | 7B | 16.8 | 63.9 | 48.9 | 61.3 | 14.6 | 45.3 | 32.6 | 29.3 |
Llama 2 | 13B | 24.5 | 66.9 | 55.4 | 65.8 | 28.7 | 54.8 | 39.4 | 39.1 |
Llama 2 | 70B | 37.5 | 71.9 | 63.6 | 69.4 | 35.2 | 68.9 | 51.2 | 54.2 |
Overall performance on grouped academic benchmarks. Code: We report the average pass@1 scores of our models on HumanEval and MBPP. Commonsense Reasoning: We report the average of PIQA, SIQA, HellaSwag, WinoGrande, ARC easy and challenge, OpenBookQA, and CommonsenseQA. We report 7-shot results for CommonSenseQA and 0-shot results for all other benchmarks. World Knowledge: We evaluate the 5-shot performance on NaturalQuestions and TriviaQA and report the average. Reading Comprehension: For reading comprehension, we report the 0-shot average on SQuAD, QuAC, and BoolQ. MATH: We report the average of the GSM8K (8 shot) and MATH (4 shot) benchmarks at top 1.
TruthfulQA | Toxigen | ||
---|---|---|---|
Llama 1 | 7B | 27.42 | 23.00 |
Llama 1 | 13B | 41.74 | 23.08 |
Llama 1 | 33B | 44.19 | 22.57 |
Llama 1 | 65B | 48.71 | 21.77 |
Llama 2 | 7B | 33.29 | 21.25 |
Llama 2 | 13B | 41.86 | 26.10 |
Llama 2 | 70B | 50.18 | 24.60 |
Evaluation of pretrained LLMs on automatic safety benchmarks. For TruthfulQA, we present the percentage of generations that are both truthful and informative (the higher the better). For ToxiGen, we present the percentage of toxic generations (the smaller the better).
TruthfulQA | Toxigen | ||
---|---|---|---|
Llama-2-Chat | 7B | 57.04 | 0.00 |
Llama-2-Chat | 13B | 62.18 | 0.00 |
Llama-2-Chat | 70B | 64.14 | 0.01 |
Evaluation of fine-tuned LLMs on different safety datasets. Same metric definitions as above.
Ethical Considerations and Limitations
Llama 2 is a new technology that carries risks with use. Testing conducted to date has been in English, and has not covered, nor could it cover all scenarios. For these reasons, as with all LLMs, Llama 2โs potential outputs cannot be predicted in advance, and the model may in some instances produce inaccurate, biased or other objectionable responses to user prompts. Therefore, before deploying any applications of Llama 2, developers should perform safety testing and tuning tailored to their specific applications of the model.
Please see the Responsible Use Guide available at https://ai.meta.com/llama/responsible-use-guide/