Views
No views yet

peft adapters, transformers, and bitsandbytes. Training relied on a method called "Low Rank Adapters" (LoRA), specifically the QLoRA variant. The run took approximately 6.25 hours and was executed on a workstation with a single A100-SXM NVIDIA GPU with 37 GB of available memory. See attached Colab Notebook for the code and hyperparams used to train the model.<human>: [Instruction]
<bot>:"""<human>: My name is Daniel. Write a short email to my closest friends inviting them to come to my home on Friday for a dinner party, I will make the food but tell them to BYOB.
<bot>:"""Dear friends,
I am so excited to host a dinner party at my home this Friday! I will be making a delicious meal, but I would love for you to bring your favorite bottle of wine to share with everyone.
Please let me know if you can make it and if you have any dietary restrictions I should be aware of. I look forward to seeing you soon!
Best,
Daniel<human>: Create a list of things to do in San Francisco.
<bot>:Here are some things to do in San Francisco:
1. Visit the Golden Gate Bridge
2. Explore the city's many museums and art galleries
3. Take a walk along the Embarcadero waterfront
4. Enjoy the views from the top of Coit Tower
5. Shop at Union Square and the Ferry Building
6. Eat at one of the city's many restaurants and cafes
7. Attend a sporting event at AT&T Park
8. Visit the Castro District and the Mission District
9. Take a day trip to Napa Valley or Muir Woods National Monument
10. Explore the city's many parks and gardens1# Install packages
2!pip install -q -U bitsandbytes loralib einops
3!pip install -q -U git+https://github.com/huggingface/transformers.git
4!pip install -q -U git+https://github.com/huggingface/peft.git
5!pip install -q -U git+https://github.com/huggingface/accelerate.git1import torch
2from peft import PeftModel, PeftConfig
3from transformers import AutoModelForCausalLM, AutoTokenizer
4
5# load the model
6peft_model_id = "dfurman/Falcon-7B-Chat-v0.1"
7config = PeftConfig.from_pretrained(peft_model_id)
8
9model = AutoModelForCausalLM.from_pretrained(
10 config.base_model_name_or_path,
11 return_dict=True,
12 device_map={"":0},
13 trust_remote_code=True,
14 load_in_8bit=True,
15)
16
17tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
18tokenizer.pad_token = tokenizer.eos_token
19
20model = PeftModel.from_pretrained(model, peft_model_id)1prompt = """<human>: My name is Daniel. Write a short email to my closest friends inviting them to come to my home on Friday for a dinner party, I will make the food but tell them to BYOB.
2<bot>:"""
3
4batch = tokenizer(
5 prompt,
6 padding=True,
7 truncation=True,
8 return_tensors='pt'
9)
10batch = batch.to('cuda:0')
11
12with torch.cuda.amp.autocast():
13 output_tokens = model.generate(
14 inputs=batch.input_ids,
15 max_new_tokens=200,
16 do_sample=False,
17 use_cache=True,
18 temperature=1.0,
19 top_k=50,
20 top_p=1.0,
21 num_return_sequences=1,
22 pad_token_id=tokenizer.eos_token_id,
23 eos_token_id=tokenizer.eos_token_id,
24 bos_token_id=tokenizer.eos_token_id,
25 )
26
27generated_text = tokenizer.decode(output_tokens[0], skip_special_tokens=True)
28# Inspect message response in the outputs
29print(generated_text.split("<human>: ")[1].split("<bot>: ")[-1])torch: 2.0.1+cu118transformers: 4.30.0.dev0peft: 0.4.0.dev0accelerate: 0.19.0bitsandbytes: 0.39.0einops: 0.6.1