DeathReaper0965 commited on
Commit
1c256f5
1 Parent(s): 0b223ab

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +68 -0
README.md ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ datasets:
4
+ - codeparrot/codeparrot-clean
5
+ tags:
6
+ - text-generation
7
+ - code-generation
8
+ - gpt2-large
9
+ widget:
10
+ - text: >-
11
+ def hello_world():
12
+ example_title: Code Generation Example 1
13
+ - text: >-
14
+
15
+ example_title: Code Generation Example 2
16
+ pipeline_tag: text-generation
17
+ inference:
18
+ parameters:
19
+ max_new_tokens: 30
20
+ temperature: 0.5
21
+ num_return_sequences: 1
22
+ do_sample: true
23
+ ---
24
+
25
+ # Code Generation using GPT2-Large
26
+ This is a GPT2-large model that's further fine-tuned on the Codeparrot clean dataset with a custom metric focused on code generation. <br>
27
+ I've further trained the tokenizer initialized from the GPT2-large on the same dataset to better align the tokenization for generating code.
28
+
29
+ ## Model description
30
+ This Model has the same architecture and Parameters as the GPT2-large model. Please refer to this [link](https://d4mucfpksywv.cloudfront.net/better-language-models/language-models.pdf) to know more about the model details.
31
+
32
+ ## Intended Use & Limitations
33
+ This model is intended to generate code for the required function based on a small description of the output required.<br>
34
+
35
+ **Note:** The model is primarily trained with an objective of code generation.
36
+
37
+ ## Usage
38
+
39
+ You can use this model directly to get the summaries:
40
+
41
+ ```python
42
+ import torch
43
+ from transformers import AutoTokenizer, AutoModelForCausalLM
44
+
45
+ # Load Code Generator LLM and tokenizer from checkpoint
46
+ tokenizer = AutoTokenizer.from_pretrained("DeathReaper0965/gpt2_large_code_generator/", )
47
+ model = AutoModelForCausalLM.from_pretrained("DeathReaper0965/gpt2_large_code_generator/")
48
+
49
+ model = model.to("cuda" if torch.cuda.is_available() else "cpu")
50
+
51
+ inputs = tokenizer("def hello_world():", return_tensors="pt").to("cuda")
52
+ outputs = model.generate(**inputs,
53
+ max_new_tokens= 30,
54
+ temperature= 0.5,
55
+ num_return_sequences= 1)
56
+
57
+ print(tokenizer.batch_decode(outputs)[0])
58
+
59
+ ###########OUTPUT###########
60
+ def hello_world():
61
+ return "Hello World!"
62
+
63
+ @app.route("/hello_world")
64
+ def hello_world():
65
+ return "Hello World!"
66
+ ```
67
+
68
+ > Designed and Developed with <span style="color: #e25555;">&hearts;</span> by [Praneet](https://deathreaper0965.github.io/) | [LinkedIn](http://linkedin.com/in/deathreaper0965) | [GitHub](https://github.com/DeathReaper0965/)