philschmid HF staff commited on
Commit
d5b4525
1 Parent(s): ce0b084

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +106 -0
README.md ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: openrail
3
+ language:
4
+ - en
5
+ tags:
6
+ - llama-2
7
+ ---
8
+
9
+ # **Llama 2 7B Instruction Generator**
10
+
11
+ Llama 2 is a collection of pretrained and fine-tuned generative text models ranging in scale from 7 billion to 70 billion parameters. This is the repository for the 7B pretrained model, converted for the Hugging Face Transformers format. Links to other models can be found in the index at the bottom.
12
+
13
+ `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.
14
+
15
+
16
+ ```bash
17
+ ### Instruction:
18
+ Use the Input below to create an instruction, which could have been used to generate the input using an LLM.
19
+
20
+ ### Input:
21
+ Dear [boss name],
22
+
23
+ I'm writing to request next week, August 1st through August 4th,
24
+ off as paid time off.
25
+
26
+ I have some personal matters to attend to that week that require
27
+ me to be out of the office. I wanted to give you as much advance
28
+ notice as possible so you can plan accordingly while I am away.
29
+
30
+ Please let me know if you need any additional information from me
31
+ or have any concerns with me taking next week off. I appreciate you
32
+ considering this request.
33
+
34
+ Thank you, [Your name]
35
+
36
+ ### Response:
37
+ Write an email to my boss that I need next week 08/01 - 08/04 off.
38
+ ```
39
+
40
+ _Everything after `### Response` will be generated by the model._
41
+
42
+ The idea of the model was to be able to synthetically generate instruction data from unsupervised data, like emails to personalize LLMs.
43
+
44
+ ## Model Date
45
+
46
+ July 25, 2023
47
+
48
+ ## How to use the model
49
+
50
+ ```python
51
+ import torch
52
+ from transformers import AutoTokenizer, AutoModelModelForCausalLM
53
+
54
+ # load base LLM model and tokenizer
55
+ model = AutoModelModelForCausalLM.from_pretrained(
56
+ "philschmid/llama-7b-instruction-generator",
57
+ low_cpu_mem_usage=True,
58
+ torch_dtype=torch.float16,
59
+ load_in_4bit=True,
60
+ )
61
+ tokenizer = AutoTokenizer.from_pretrained("philschmid/llama-7b-instruction-generator")
62
+
63
+ prompt = f"""### Instruction:
64
+ Use the Input below to create an instruction, which could have been used to generate the input using an LLM.
65
+
66
+ ### Input:
67
+ Dear [boss name],
68
+
69
+ I'm writing to request next week, August 1st through August 4th,
70
+ off as paid time off.
71
+
72
+ I have some personal matters to attend to that week that require
73
+ me to be out of the office. I wanted to give you as much advance
74
+ notice as possible so you can plan accordingly while I am away.
75
+
76
+ Please let me know if you need any additional information from me
77
+ or have any concerns with me taking next week off. I appreciate you
78
+ considering this request.
79
+
80
+ Thank you, [Your name]
81
+
82
+ ### Response:
83
+ """
84
+
85
+ input_ids = tokenizer(prompt, return_tensors="pt", truncation=True).input_ids.cuda()
86
+ outputs = model.generate(input_ids=input_ids, max_new_tokens=100, do_sample=True, top_p=0.9,temperature=0.9)
87
+
88
+ print(f"Generated instruction:\n{tokenizer.batch_decode(outputs.detach().cpu().numpy(), skip_special_tokens=True)[0][len(prompt):]}")
89
+ ```
90
+
91
+ ## Evaluated example
92
+
93
+ ```bash
94
+ Prompt:
95
+ Plastic 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.
96
+
97
+ Generated instruction:
98
+ Given this paragraph, where does plastic come from?
99
+
100
+ Ground truth:
101
+ How is plastic made?
102
+ ```
103
+
104
+
105
+
106
+ Planning to experiment with bigger sizes and starting from the chat models.