chuanli-lambda commited on
Commit
fe890f8
1 Parent(s): 65b7612

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +95 -8
README.md CHANGED
@@ -1,21 +1,108 @@
1
  ---
2
  language:
3
- - en
4
  tags:
5
- - pytorch
6
- - causal-lm
7
- - pythia
8
  license: apache-2.0
9
  datasets:
10
- - Dahoas/synthetic-instruct-gptj-pairwise
11
  ---
12
 
13
- This model is created by finetuning `EleutherAI/pythia-1.4b-deduped` on the `Dahoas/synthetic-instruct-gptj-pairwise` for 4 epochs.
14
 
15
  You can try a [demo](https://cloud.lambdalabs.com/demos/ml/qa-14b-2000) of the model hosted on [Lambda Cloud](https://lambdalabs.com/service/gpu-cloud).
16
 
17
- It took 8xA100 80GB 2 hours to train the model. We set `batch_size_per_gpu` to `8` (so global batch size is 64), and learning rate to `0.00002` (with linear decay to zero at the last trainig step).
18
 
19
- The Weights and Biases record of the training can be found [here](https://wandb.ai/chuanli11/ft-synthetic-instruct-gptj-pairwise-pythia1.4b?workspace=user-chuanli11).
 
 
 
 
 
 
20
 
 
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  language:
3
+ - en
4
  tags:
5
+ - pytorch
6
+ - causal-lm
7
+ - pythia
8
  license: apache-2.0
9
  datasets:
10
+ - Dahoas/synthetic-instruct-gptj-pairwise
11
  ---
12
 
13
+ This model is created by finetuning [`EleutherAI/pythia-1.4b-deduped`](https://huggingface.co/EleutherAI/pythia-1.4b-deduped) on the [`Dahoas/synthetic-instruct-gptj-pairwise`](https://huggingface.co/datasets/Dahoas/synthetic-instruct-gptj-pairwise).
14
 
15
  You can try a [demo](https://cloud.lambdalabs.com/demos/ml/qa-14b-2000) of the model hosted on [Lambda Cloud](https://lambdalabs.com/service/gpu-cloud).
16
 
17
+ ### Model Details
18
 
19
+ - Developed by: [Lambda](https://lambdalabs.com/)
20
+ - Model type: Transformer-based Language Model
21
+ - Language: English
22
+ - Pre-trained model: [EleutherAI/pythia-1.4b-deduped](https://huggingface.co/EleutherAI/pythia-1.4b-deduped)
23
+ - Dataset: [Dahoas/synthetic-instruct-gptj-pairwise](https://huggingface.co/datasets/Dahoas/synthetic-instruct-gptj-pairwise)
24
+ - Library: [transformers](https://huggingface.co/docs/transformers/index)
25
+ - License: Apache 2.0
26
 
27
+ ### Prerequisites
28
 
29
+ Running inference with the model takes ~4GB of GPU memory.
30
+
31
+ ### Quick Start
32
+
33
+ ```
34
+ import torch
35
+
36
+ from transformers import AutoTokenizer, pipeline, StoppingCriteria, StoppingCriteriaList
37
+
38
+ device = torch.device("cuda:0") if torch.cuda.is_available() else torch.device("cpu")
39
+
40
+ model_name = "lambdalabs/pythia-1.4b-deduped-synthetic-instruct"
41
+ max_new_tokens = 2048
42
+ stop_token = "<|stop|>"
43
+
44
+
45
+ class KeywordsStoppingCriteria(StoppingCriteria):
46
+ def __init__(self, keywords_ids: list):
47
+ self.keywords = keywords_ids
48
+
49
+ def __call__(
50
+ self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs
51
+ ) -> bool:
52
+ if input_ids[0][-1] in self.keywords:
53
+ return True
54
+ return False
55
+
56
+
57
+ tokenizer = AutoTokenizer.from_pretrained(
58
+ model_name,
59
+ )
60
+ tokenizer.pad_token = tokenizer.eos_token
61
+ tokenizer.add_tokens([stop_token])
62
+
63
+ stop_ids = [tokenizer.encode(w)[0] for w in [stop_token]]
64
+ stop_criteria = KeywordsStoppingCriteria(stop_ids)
65
+
66
+ generator = pipeline(
67
+ "text-generation",
68
+ model=model_name,
69
+ device=device,
70
+ max_new_tokens=max_new_tokens,
71
+ torch_dtype=torch.float16,
72
+ stopping_criteria=StoppingCriteriaList([stop_criteria]),
73
+ )
74
+
75
+ example = "Can you give me some tips on how to save money every month."
76
+ text = "Question: {}\nAnswer:".format(example)
77
+
78
+ result = generator(
79
+ text,
80
+ num_return_sequences=1,
81
+ )
82
+
83
+ output = result[0]["generated_text"]
84
+
85
+ print(output)
86
+ ```
87
+
88
+ Output:
89
+
90
+ ```
91
+ Question: Can you give me some tips on how to save money every month.
92
+ Answer:Create a budget and track your spending.
93
+ 2. Cut down on unnecessary expenses, such as eating out, shopping, and entertainment.
94
+ 3. Make a list of your monthly expenses and stick to it.
95
+ 4. Take advantage of discounts and coupons when shopping.
96
+ 5. Make sure to pay your bills on time to avoid late fees.
97
+ 6. Save a portion of your income each month by investing it in a high-yield savings account.
98
+ 7. Consider automating your savings by setting up a recurring transfer from your checking to a savings account.
99
+ 8. Take advantage of free entertainment opportunities, such as going to the park or museum.
100
+ 9. Look for ways to save on utilities, such as installing energy-efficient appliances.
101
+ 10. Research and use public transportation to save on gas.<|stop|>
102
+ ```
103
+
104
+ ### Training
105
+
106
+ The model was trained on the [`Dahoas/synthetic-instruct-gptj-pairwise`](https://huggingface.co/datasets/Dahoas/synthetic-instruct-gptj-pairwise). We split the original dataset into the train (first 32000 examples) and validation (the remaining 1144 examples) subsets.
107
+
108
+ We finetune the model for 4 epoches. This took 8xA100 80GB 2 hours, where we set `batch_size_per_gpu` to `8` (so global batch size is 64), and learning rate to `0.00002` (with linear decay to zero at the last trainig step). You can find a Weights and Biases record [here](https://wandb.ai/chuanli11/ft-synthetic-instruct-gptj-pairwise-pythia1.4b?workspace=user-chuanli11).