Views
No views yet
philschmid/llama-7b-instruction-generator is an fine-tuned version of llama 2 7B to generate instruction on a given input. The model was fined tuned using the Aplaca format and a modified version of dolly. Below you can find an example.1### Instruction:
2Use the Input below to create an instruction, which could have been used to generate the input using an LLM.
3
4### Input:
5Dear [boss name],
6
7I'm writing to request next week, August 1st through August 4th,
8off as paid time off.
9
10I have some personal matters to attend to that week that require
11me to be out of the office. I wanted to give you as much advance
12notice as possible so you can plan accordingly while I am away.
13
14Please let me know if you need any additional information from me
15or have any concerns with me taking next week off. I appreciate you
16considering this request.
17
18Thank you, [Your name]
19
20### Response:
21Write an email to my boss that I need next week 08/01 - 08/04 off.### Response will be generated by the model.1import torch
2from transformers import AutoTokenizer, AutoModelModelForCausalLM
3
4# load base LLM model and tokenizer
5model = AutoModelModelForCausalLM.from_pretrained(
6 "philschmid/llama-2-7b-instruction-generator",
7 low_cpu_mem_usage=True,
8 torch_dtype=torch.float16,
9 load_in_4bit=True,
10)
11tokenizer = AutoTokenizer.from_pretrained("philschmid/llama-2-7b-instruction-generator")
12
13prompt = f"""### Instruction:
14Use the Input below to create an instruction, which could have been used to generate the input using an LLM.
15
16### Input:
17Dear [boss name],
18
19I'm writing to request next week, August 1st through August 4th,
20off as paid time off.
21
22I have some personal matters to attend to that week that require
23me to be out of the office. I wanted to give you as much advance
24notice as possible so you can plan accordingly while I am away.
25
26Please let me know if you need any additional information from me
27or have any concerns with me taking next week off. I appreciate you
28considering this request.
29
30Thank you, [Your name]
31
32### Response:
33"""
34
35input_ids = tokenizer(prompt, return_tensors="pt", truncation=True).input_ids.cuda()
36outputs = model.generate(input_ids=input_ids, max_new_tokens=100, do_sample=True, top_p=0.9,temperature=0.9)
37
38print(f"Generated instruction:\n{tokenizer.batch_decode(outputs.detach().cpu().numpy(), skip_special_tokens=True)[0][len(prompt):]}")1Prompt:
2Plastic is made from oil, natural gas and even plant oils during refining of these oils into other products like gasoline. Ethane and propane are created when treated with heat during a refinery process called cracking. This turns the Ethane and propane into ethylene and propylene which are used with other chemical ingredients to create polymers that are the base of what plastic is made out of.
3
4Generated instruction:
5Given this paragraph, where does plastic come from?
6
7Ground truth:
8How is plastic made?