michaelfeil commited on
Commit
3dffcc8
1 Parent(s): 5052a2f

Upload Salesforce/codegen2-1B ctranslate fp16 weights

Browse files
Files changed (4) hide show
  1. README.md +128 -0
  2. config.json +27 -0
  3. generation_config.json +6 -0
  4. pytorch_model.bin +3 -0
README.md ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ ---
3
+ tags:
4
+ - fauxpilot
5
+ - gpt-j
6
+ - float16
7
+
8
+ license: apache-2.0
9
+ ---
10
+ # Conversion for FauxPilot, Codegen-2 as GPT-J
11
+
12
+ ```
13
+ Converted on 2023-05-22 using
14
+ ```
15
+ python /home/michael/fauxpilot/converter/codegen_gptj_convert.py --code_model Salesforce/codegen2-1B /home/michael/tmp-codegen2-1B-gptj
16
+ ```
17
+
18
+ # Licence and other remarks:
19
+ This is just a quantized version. Licence conditions are intended to be idential to original huggingface repo.
20
+
21
+ # Original description
22
+
23
+
24
+ # CodeGen2 (CodeGen2-16B)
25
+
26
+ ## Model description
27
+
28
+ [CodeGen2](https://github.com/salesforce/CodeGen2) is a family of autoregressive language models for **program synthesis**, introduced in the paper:
29
+
30
+ [CodeGen2: Lessons for Training LLMs on Programming and Natural Languages](https://arxiv.org/abs/2305.02309) by Erik Nijkamp\*, Hiroaki Hayashi\*, Caiming Xiong, Silvio Savarese, Yingbo Zhou.
31
+
32
+ Unlike the original CodeGen model family (i.e., CodeGen1), CodeGen2 is capable of infilling, and supports more programming languages.
33
+
34
+ Four model sizes are released: `1B`, `3.7B`, `7B`, `16B`.
35
+
36
+ ## How to use
37
+
38
+ This model can be easily loaded using the `AutoModelForCausalLM` functionality.
39
+
40
+ ### Causal sampling
41
+
42
+ For regular causal sampling, simply generate completions given the context:
43
+ ```python
44
+ from transformers import AutoTokenizer, AutoModelForCausalLM
45
+ tokenizer = AutoTokenizer.from_pretrained("Salesforce/codegen2-16B")
46
+ model = AutoModelForCausalLM.from_pretrained("Salesforce/codegen2-16B", trust_remote_code=True, revision="main")
47
+
48
+ text = "def hello_world():"
49
+ input_ids = tokenizer(text, return_tensors="pt").input_ids
50
+ generated_ids = model.generate(input_ids, max_length=128)
51
+ print(tokenizer.decode(generated_ids[0], skip_special_tokens=True))
52
+ ```
53
+
54
+ ### Infill sampling
55
+
56
+ For **infill** sampling, we introduce three new special token types:
57
+
58
+ * `<mask_N>`: N-th span to be masked. In practice, use `<mask_1>` to where you want to sample infill.
59
+ * `<sep>`: Seperator token between the suffix and the infilled sample. See below.
60
+ * `<eom>`: "End-Of-Mask" token that model will output at the end of infilling. You may use this token to truncate the output.
61
+
62
+ For example, if we want to generate infill for the following cursor position of a function:
63
+ ```python
64
+ def hello_world():
65
+ |
66
+ return name
67
+ ```
68
+ we construct an input to the model by
69
+
70
+ 1. Inserting `<mask_1>` token in place of cursor position
71
+ 2. Append `<sep>` token to indicate the boundary
72
+ 3. Insert another `<mask_1>` to indicate which mask we want to infill.
73
+
74
+ The final snippet looks as follows:
75
+
76
+ ```python
77
+ from transformers import AutoTokenizer, AutoModelForCausalLM
78
+ tokenizer = AutoTokenizer.from_pretrained("Salesforce/codegen2-16B")
79
+ model = AutoModelForCausalLM.from_pretrained("Salesforce/codegen2-16B", trust_remote_code=True, revision="main")
80
+
81
+
82
+ def format(prefix, suffix):
83
+ return prefix + "<mask_1>" + suffix + "<|endoftext|>" + "<sep>" + "<mask_1>"
84
+
85
+
86
+ prefix = "def hello_world():
87
+ "
88
+ suffix = " return name"
89
+ text = format(prefix, suffix)
90
+ input_ids = tokenizer(text, return_tensors="pt").input_ids
91
+ generated_ids = model.generate(input_ids, max_length=128)
92
+ print(tokenizer.decode(generated_ids[0], skip_special_tokens=False)[len(text):])
93
+ ```
94
+
95
+ You might want to truncate the model output with `<eom>`.
96
+
97
+ ## Training data
98
+
99
+ This checkpoint is trained on the stricter permissive subset of [the deduplicated version of the Stack dataset (v1.1)](https://huggingface.co/datasets/bigcode/the-stack-dedup). Supported languages (and frameworks) are as follows:
100
+ `c`, `c++`, `c-sharp`, `dart`, `go`, `java`, `javascript`, `kotlin`, `lua`, `php`, `python`, `ruby`, `rust`, `scala`, `shell`, `sql`, `swift`, `typescript`, `vue`.
101
+
102
+ ## Training procedure
103
+
104
+ CodeGen2 was trained using cross-entropy loss to maximize the likelihood of sequential inputs.
105
+ The input sequences are formatted in two ways: (1) causal language modeling and (2) file-level span corruption.
106
+ Please refer to the paper for more details.
107
+
108
+ ## Evaluation results
109
+
110
+ We evaluate our models on HumanEval and HumanEval-Infill. Please refer to the [paper](https://arxiv.org/abs/2305.02309) for more details.
111
+
112
+ ## Intended use and limitations
113
+
114
+ As an autoregressive language model, CodeGen2 is capable of extracting features from given natural language and programming language texts, and calculating the likelihood of them.
115
+ However, the model is intended for and best at **program synthesis**, that is, generating executable code given English prompts, where the prompts should be in the form of a comment string. The model can complete partially-generated code as well.
116
+
117
+
118
+ ## BibTeX entry and citation info
119
+
120
+ ```bibtex
121
+ @article{Nijkamp2023codegen2,
122
+ title={CodeGen2: Lessons for Training LLMs on Programming and Natural Languages},
123
+ author={Nijkamp, Erik and Hayashi, Hiroaki and Xiong, Caiming and Savarese, Silvio and Zhou, Yingbo},
124
+ journal={arXiv preprint},
125
+ year={2023}
126
+ }
127
+ ```
128
+
config.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "activation_function": "gelu_new",
3
+ "architectures": [
4
+ "GPTJForCausalLM"
5
+ ],
6
+ "attn_pdrop": 0.0,
7
+ "bos_token_id": 1,
8
+ "embd_pdrop": 0.0,
9
+ "eos_token_id": 2,
10
+ "initializer_range": 0.02,
11
+ "layer_norm_epsilon": 1e-05,
12
+ "model_type": "gptj",
13
+ "n_embd": 2048,
14
+ "n_head": 16,
15
+ "n_inner": null,
16
+ "n_layer": 16,
17
+ "n_positions": 2048,
18
+ "resid_pdrop": 0.0,
19
+ "rotary_dim": 64,
20
+ "scale_attn_weights": true,
21
+ "tie_word_embeddings": false,
22
+ "tokenizer_class": "CodeGenTokenizer",
23
+ "torch_dtype": "float16",
24
+ "transformers_version": "4.28.1",
25
+ "use_cache": true,
26
+ "vocab_size": 51200
27
+ }
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "transformers_version": "4.28.1"
6
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fb8befdeaa929fa9c00a6946deed6788b4b939c6c07e1067c8a0a910ddd355f0
3
+ size 2097783137