Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: "multilingual"
|
3 |
+
thumbnail: "https://doesnotexist.codes/messlab.png"
|
4 |
+
tags:
|
5 |
+
- programming
|
6 |
+
- gpt2
|
7 |
+
- causal-lm
|
8 |
+
license: "Public Domain"
|
9 |
+
|
10 |
+
---
|
11 |
+
|
12 |
+
# GPT-CSRC
|
13 |
+
|
14 |
+
This is a GPT2 774M model trained on the C/C++ code of the top 10,000 most popular packages in Debian, according to the [Debian Popularity Contest](https://popcon.debian.org/). The source files were deduplicated using a process similar to the OpenWebText preprocessing (basically a locality-sensitive hash to detect near-duplicates). The model was originally trained using [NVIDIA's Megatron-LM](https://github.com/nvidia/Megatron-LM) but has been converted to Huggingface. Note that the tokenizer is *not* the standard GPT2 BPE vocab, but one that has been trained for this dataset; the tokenizer is also available from this repository.
|
15 |
+
|
16 |
+
The processed dataset (in JSON format) can be found here: [csrc\_dataset\_large.json.gz](https://moyix.net/~moyix/csrc_dataset_large.json.gz).
|
17 |
+
|
18 |
+
This model was used to generate snippets for the web site [This Code Does Not Exist](https://doesnotexist.codes/).
|
19 |
+
|
20 |
+
# Usage
|
21 |
+
|
22 |
+
```
|
23 |
+
>>> import torch
|
24 |
+
>>> from transformers import AutoModelForCausalLM, AutoTokenizer
|
25 |
+
>>> model = AutoModelForCausalLM.from_pretrained("moyix/csrc_774m")
|
26 |
+
>>> device = torch.device("cuda")
|
27 |
+
>>> model.to(device)
|
28 |
+
>>> tokenizer = AutoTokenizer.from_pretrained("moyix/csrc_774m")
|
29 |
+
>>> prompt = tokenizer.encode('// say hello\nvoid hello() {', return_tensors="pt")
|
30 |
+
>>> output = model.generate(input_ids=prompt.to(device), max_length=32, num_return_sequences=1, do_sample=True, num_beams=4)
|
31 |
+
>>> print(tokenizer.decode(output[0].tolist(),clean_up_tokenization_spaces=True))
|
32 |
+
// say hello
|
33 |
+
void hello() {
|
34 |
+
std::cout << "hello" << std::endl;
|
35 |
+
}
|
36 |
+
|
37 |
+
int main() {
|
38 |
+
|
39 |
+
```
|