blair-johnson commited on
Commit
ac39175
1 Parent(s): 4a9afd8

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +164 -0
README.md ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: bigcode-openrail-m
3
+ datasets:
4
+ - bigcode/the-stack-dedup
5
+ - teknium1/GPTeacher-codegen
6
+ library_name: transformers
7
+ pipeline_tag: text-generation
8
+ tags:
9
+ - GPT-4 Instruct
10
+ - Code-Gen
11
+ ---
12
+ # StarCoder GPTeacher-Codegen Fine-Tuned
13
+
14
+ <!-- Provide a quick summary of what the model is/does. -->
15
+
16
+ This model is [`bigcode/starcoder`](https://huggingface.co/bigcode/starcoder) fine-tuned on the [`teknium1/GPTeacher`](https://github.com/teknium1/GPTeacher) codegen dataset (GPT-4 code instruction fine-tuning).
17
+
18
+ ## Model Details
19
+
20
+ The base StarCoder models are 15.5B parameter models trained on 80+ programming languages from [The Stack (v1.2)](https://huggingface.co/datasets/bigcode/the-stack), with opt-out requests excluded. The model uses [Multi Query Attention](https://arxiv.org/abs/1911.02150), [a context window of 8192 tokens](https://arxiv.org/abs/2205.14135), and was trained using the [Fill-in-the-Middle objective](https://arxiv.org/abs/2207.14255) on 1 trillion tokens.
21
+
22
+ - **Repository:** [bigcode/Megatron-LM](https://github.com/bigcode-project/Megatron-LM)
23
+ - **Project Website:** [bigcode-project.org](https://www.bigcode-project.org)
24
+ - **Paper:** [💫StarCoder: May the source be with you!](https://drive.google.com/file/d/1cN-b9GnWtHzQRoE7M7gAEyivY0kl4BYs/view)
25
+ - **Point of Contact:** [contact@bigcode-project.org](mailto:contact@bigcode-project.org)
26
+ - **Languages:** 80+ Programming languages
27
+
28
+ ## Uses
29
+
30
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
31
+ ### Intended use
32
+
33
+ The base model was trained on GitHub code and then fine-tuned to follow instructions. Prompts such as "Write a function that computes the square root." should work reasonably well. The original repo recommeds using the [Tech Assistant prompt](https://huggingface.co/datasets/bigcode/ta-prompt) to few-shot prompt it into behaving as a technical assistant. This fine-tuned model uses the [Alpaca prompts](https://github.com/tatsu-lab/stanford_alpaca/blob/main/train.py).
34
+
35
+ ### Generation
36
+ ```python
37
+ import torch
38
+ from transformers import AutoModelForCausalLM, AutoTokenizer
39
+
40
+ checkpoint = "bigcode/starcoder"
41
+ device = "cuda"
42
+
43
+ input_prompt = ("Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n"
44
+ "### Instruction:\n"
45
+ "{instruction}\n\n"
46
+ "### Input:\n"
47
+ "{input}\n\n"
48
+ "### Response:")
49
+
50
+ prompt = "Please explain the following program."
51
+ extra_input = "send(to, from, count)
52
+ register short *to, *from;
53
+ register count;
54
+ {
55
+ register n = (count + 7) / 8;
56
+ switch (count % 8) {
57
+ case 0: do { *to = *from++;
58
+ case 7: *to = *from++;
59
+ case 6: *to = *from++;
60
+ case 5: *to = *from++;
61
+ case 4: *to = *from++;
62
+ case 3: *to = *from++;
63
+ case 2: *to = *from++;
64
+ case 1: *to = *from++;
65
+ } while (--n > 0);
66
+ }
67
+ }"
68
+ prompt = input_prompt.format_map({"instruction": prompt, "input": extra_input})
69
+
70
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
71
+ model = AutoModelForCausalLM.from_pretrained(checkpoint, trust_remote_code=True, torch_dtype=torch.float16).to(device)
72
+
73
+ inputs = tokenizer.encode(prompt, return_tensors="pt").to(device)
74
+ outputs = model.generate(inputs)
75
+ print(tokenizer.decode(outputs[0]))
76
+ ```
77
+
78
+ <details>
79
+ <summary> Example Outputs </summary>
80
+
81
+ *__Full Prompt:__*
82
+ ```
83
+ Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
84
+ ### Instruction:
85
+ What does this program do and how does it work?
86
+ ### Input:
87
+ send(to, from, count)
88
+ register short *to, *from;
89
+ register count;
90
+ {
91
+ register n = (count + 7) / 8;
92
+ switch (count % 8) {
93
+ case 0: *to = *from++;
94
+ case 7: *to = *from++;
95
+ case 6: *to = *from++;
96
+ case 5: *to = *from++;
97
+ case 4: *to = *from++;
98
+ case 3: *to = *from++;
99
+ case 2: *to = *from++;
100
+ case 1: *to = *from++;
101
+ }
102
+ while (--n > 0) {
103
+ *to = *from++;
104
+ *to = *from++;
105
+ *to = *from++;
106
+ *to = *from++;
107
+ *to = *from++;
108
+ *to = *from++;
109
+ *to = *from++;
110
+ *to = *from++;
111
+ }
112
+ }
113
+ ### Response:
114
+ ```
115
+
116
+ *__Response:__*
117
+ ```
118
+ This program is designed to efficiently copy bytes from one memory location to another. It copies 'count' bytes from the location pointed to by 'from' to the location pointed to by 'to', and works correctly regardless of address alignment. The function 'foo' is a wrapper function that initializes the 'to' and 'from' pointers, checks for proper memory bounds, and performs byte alignment if necessary.
119
+
120
+ To use this program, you must declare two pointer variables, 'to' and 'from', and then call the 'foo' function with the following parameters:
121
+
122
+ foo(to, from, count)
123
+ ```
124
+
125
+ </details>
126
+
127
+ ### Attribution & Other Requirements
128
+
129
+ The pretraining dataset of the model was filtered for permissive licenses only. Nevertheless, the model can generate source code verbatim from the dataset. The code's license might require attribution and/or other specific requirements that must be respected. The BigCode project provides a [search index](https://huggingface.co/spaces/bigcode/starcoder-search) that let's you search through the pretraining data to identify where generated code came from and apply the proper attribution to your code.
130
+
131
+ # Limitations
132
+
133
+ The model has been trained on source code from 80+ programming languages. The predominant language in source is English although other languages are also present. As such the model is capable of generating code snippets provided some context but the generated code is not guaranteed to work as intended. It can be inefficient, contain bugs or exploits. See [the original paper](https://drive.google.com/file/d/1cN-b9GnWtHzQRoE7M7gAEyivY0kl4BYs/view) for an in-depth discussion of the model limitations.
134
+ The fine-tuning process makes the model more responsive to direct user input, however this is an early attempt at instruction fine-tuning starcoder models and the results may not be representative of the model's full potential.
135
+
136
+ # Training
137
+
138
+ ## Model
139
+
140
+ - **Architecture:** GPT-2 model with multi-query attention and Fill-in-the-Middle objective
141
+ - **Pretraining steps:** 250k
142
+ - **Pretraining tokens:** 1 trillion
143
+ - **Precision:** bfloat16
144
+ - **Fine-Tuning Instruct-Response Pairs:** 4.5k
145
+ - **Fine-Tuning Context Length:** 1024
146
+ - **Fine-Tuning Epochs:** 3
147
+ - **Fine-Tuning LR:** 2e-5
148
+ - **Fine-Tuning Optimizations:** FSDP
149
+
150
+ ## Hardware
151
+
152
+ - **GPUs:** 8 Tesla A100
153
+ - **Training time:** 5 hours
154
+
155
+ # License
156
+ The model is licensed under the BigCode OpenRAIL-M v1 license agreement. You can find the full agreement [here](https://huggingface.co/spaces/bigcode/bigcode-model-license-agreement). This model was also fine-tuned using outputs from OpenAI's GPT-4, and as such it is additionally subject to [OpenAI's terms of service.](https://openai.com/policies/terms-of-use)
157
+
158
+ ## Citation [optional]
159
+
160
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
161
+ The base model HF repo can be found [here.](https://huggingface.co/bigcode/starcoder)
162
+ ```
163
+ # Awaiting citation for base model
164
+ ```