Update README.md
Browse files
README.md
CHANGED
@@ -15,7 +15,7 @@ base_model: meta-llama/Llama-2-7b-hf
|
|
15 |
|
16 |
This instruction model was built via parameter-efficient QLoRA finetuning of [Llama-2-7b](https://huggingface.co/meta-llama/Llama-2-7b-hf) on the first 5k rows of [ehartford/dolphin](https://huggingface.co/datasets/ehartford/dolphin) and the first 5k rows of [garage-bAInd/Open-Platypus](https://huggingface.co/datasets/garage-bAInd/Open-Platypus). Finetuning was executed on 1x A100 (40 GB SXM) for roughly xx hours on the [Lambda Labs](https://cloud.lambdalabs.com/instances) platform.
|
17 |
|
18 |
-
|
19 |
|
20 |
| Metric | Value |
|
21 |
|-----------------------|-------|
|
@@ -27,7 +27,7 @@ This instruction model was built via parameter-efficient QLoRA finetuning of [Ll
|
|
27 |
|
28 |
We use state-of-the-art [Language Model Evaluation Harness](https://github.com/EleutherAI/lm-evaluation-harness) to run the benchmark tests above, using the same version as Hugging Face's [Open LLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard).
|
29 |
|
30 |
-
|
31 |
|
32 |
* Model license: coming
|
33 |
* Basic usage: coming
|
@@ -51,9 +51,76 @@ While great efforts have been taken to clean the pretraining data, it is possibl
|
|
51 |
|
52 |
## How to use
|
53 |
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
-
|
57 |
|
58 |
coming
|
59 |
|
@@ -85,6 +152,6 @@ The following `bitsandbytes` quantization config was used during training:
|
|
85 |
- bnb_4bit_use_double_quant: False
|
86 |
- bnb_4bit_compute_dtype: bfloat16
|
87 |
|
88 |
-
|
89 |
|
90 |
- PEFT 0.6.0.dev0
|
|
|
15 |
|
16 |
This instruction model was built via parameter-efficient QLoRA finetuning of [Llama-2-7b](https://huggingface.co/meta-llama/Llama-2-7b-hf) on the first 5k rows of [ehartford/dolphin](https://huggingface.co/datasets/ehartford/dolphin) and the first 5k rows of [garage-bAInd/Open-Platypus](https://huggingface.co/datasets/garage-bAInd/Open-Platypus). Finetuning was executed on 1x A100 (40 GB SXM) for roughly xx hours on the [Lambda Labs](https://cloud.lambdalabs.com/instances) platform.
|
17 |
|
18 |
+
## Benchmark metrics
|
19 |
|
20 |
| Metric | Value |
|
21 |
|-----------------------|-------|
|
|
|
27 |
|
28 |
We use state-of-the-art [Language Model Evaluation Harness](https://github.com/EleutherAI/lm-evaluation-harness) to run the benchmark tests above, using the same version as Hugging Face's [Open LLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard).
|
29 |
|
30 |
+
## Helpful links
|
31 |
|
32 |
* Model license: coming
|
33 |
* Basic usage: coming
|
|
|
51 |
|
52 |
## How to use
|
53 |
|
54 |
+
* [notebook](assets/basic_inference_llama_2_dolphin.ipynb)
|
55 |
+
|
56 |
+
```python
|
57 |
+
!pip install -q -U huggingface_hub peft transformers torch accelerate
|
58 |
+
```
|
59 |
+
|
60 |
+
```python
|
61 |
+
from huggingface_hub import notebook_login
|
62 |
+
import torch
|
63 |
+
from peft import PeftModel, PeftConfig
|
64 |
+
from transformers import (
|
65 |
+
AutoModelForCausalLM,
|
66 |
+
AutoTokenizer,
|
67 |
+
BitsAndBytesConfig,
|
68 |
+
pipeline,
|
69 |
+
)
|
70 |
+
|
71 |
+
notebook_login()
|
72 |
+
```
|
73 |
+
|
74 |
+
```python
|
75 |
+
peft_model_id = "dfurman/llama-2-7b-instruct-peft"
|
76 |
+
config = PeftConfig.from_pretrained(peft_model_id)
|
77 |
+
|
78 |
+
bnb_config = BitsAndBytesConfig(
|
79 |
+
load_in_4bit=True,
|
80 |
+
bnb_4bit_quant_type="nf4",
|
81 |
+
bnb_4bit_compute_dtype=torch.bfloat16,
|
82 |
+
)
|
83 |
+
|
84 |
+
model = AutoModelForCausalLM.from_pretrained(
|
85 |
+
config.base_model_name_or_path,
|
86 |
+
quantization_config=bnb_config,
|
87 |
+
use_auth_token=True,
|
88 |
+
device_map="auto",
|
89 |
+
)
|
90 |
+
|
91 |
+
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path, use_fast=True)
|
92 |
+
tokenizer.pad_token = tokenizer.eos_token
|
93 |
+
|
94 |
+
model = PeftModel.from_pretrained(model, peft_model_id)
|
95 |
+
|
96 |
+
format_template = "You are a helpful assistant. {query}\n"
|
97 |
+
```
|
98 |
+
|
99 |
+
```python
|
100 |
+
# First, format the prompt
|
101 |
+
query = "Tell me a recipe for vegan banana bread."
|
102 |
+
prompt = format_template.format(query=query)
|
103 |
+
|
104 |
+
# Inference can be done using model.generate
|
105 |
+
print("\n\n*** Generate:")
|
106 |
+
|
107 |
+
input_ids = tokenizer(prompt, return_tensors="pt").input_ids.cuda()
|
108 |
+
with torch.autocast("cuda", dtype=torch.bfloat16):
|
109 |
+
output = model.generate(
|
110 |
+
input_ids=input_ids,
|
111 |
+
max_new_tokens=512,
|
112 |
+
do_sample=True,
|
113 |
+
temperature=0.7,
|
114 |
+
return_dict_in_generate=True,
|
115 |
+
eos_token_id=tokenizer.eos_token_id,
|
116 |
+
pad_token_id=tokenizer.pad_token_id,
|
117 |
+
repetition_penalty=1.2,
|
118 |
+
)
|
119 |
+
|
120 |
+
print(tokenizer.decode(output["sequences"][0], skip_special_tokens=True))
|
121 |
+
```
|
122 |
|
123 |
+
## Runtime tests
|
124 |
|
125 |
coming
|
126 |
|
|
|
152 |
- bnb_4bit_use_double_quant: False
|
153 |
- bnb_4bit_compute_dtype: bfloat16
|
154 |
|
155 |
+
## Framework versions
|
156 |
|
157 |
- PEFT 0.6.0.dev0
|