Sai-Nandu commited on
Commit
092272c
·
verified ·
1 Parent(s): 3df771a

updated readme

Browse files
Files changed (1) hide show
  1. README.md +128 -8
README.md CHANGED
@@ -1,9 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
- license: mit
3
- datasets:
4
- - google/code_x_glue_cc_code_completion_line
5
- language:
6
- - en
7
- base_model:
8
- - openai-community/gpt2
9
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GPT-2 Fine-Tuned for Python Code Completion
2
+
3
+ This repository contains a fine-tuned **GPT-2** model for **Python source code completion**. The model was trained on the **CodeXGLUE Python Code Completion** dataset using the Hugging Face Transformers library and PyTorch.
4
+
5
+ ## Model Description
6
+
7
+ This model is designed to predict the next tokens in Python source code, enabling intelligent code completion for software development tasks.
8
+
9
+ - **Base Model:** GPT-2
10
+ - **Task:** Causal Language Modeling
11
+ - **Language:** Python
12
+ - **Framework:** PyTorch
13
+ - **Library:** Hugging Face Transformers
14
+
15
  ---
16
+
17
+ ## Dataset
18
+
19
+ **Dataset:** CodeXGLUE – Python Code Completion
20
+
21
+ The dataset contains Python source code snippets used to train language models for next-token code prediction.
22
+
23
+ Note: A subset of approximately 13,000 training samples from the CodeXGLUE Python dataset was used for fine-tuning.
24
+
25
+ ---
26
+
27
+ ## Training Configuration
28
+
29
+ | Parameter | Value |
30
+ |-----------|--------|
31
+ | Model | GPT-2 |
32
+ | Epochs | 3 |
33
+ | Learning Rate | 2e-4 |
34
+ | Batch Size | 4 |
35
+ | Gradient Accumulation | 4 |
36
+ | Weight Decay | 0.01 |
37
+ | Max Sequence Length | 512 |
38
+ | Optimizer | AdamW |
39
+ | Framework | PyTorch |
40
+
41
+ Training was performed using the Hugging Face `Trainer` API.
42
+
43
+ ---
44
+
45
+ ## Evaluation Results
46
+
47
+ | Metric | Value |
48
+ |---------|---------|
49
+ | Validation Loss | **1.1869** |
50
+ | Perplexity | **3.28** |
51
+
52
+ The decreasing validation loss throughout training indicates successful adaptation of GPT-2 to the Python code completion task.
53
+
54
+ ---
55
+
56
+ ## Training Progress
57
+
58
+ | Step | Training Loss | Validation Loss |
59
+ |------|---------------|----------------|
60
+ |100|1.5613|1.3592|
61
+ |200|1.3962|1.2877|
62
+ |300|1.3317|1.2537|
63
+ |400|1.2437|1.2308|
64
+ |500|1.2253|1.2142|
65
+ |600|1.2014|1.2000|
66
+ |Final|—|**1.1869**|
67
+
68
+ ---
69
+
70
+ ## Usage
71
+
72
+ ```python
73
+ from transformers import AutoTokenizer, AutoModelForCausalLM
74
+
75
+ tokenizer = AutoTokenizer.from_pretrained("YOUR_USERNAME/MODEL_NAME")
76
+ model = AutoModelForCausalLM.from_pretrained("YOUR_USERNAME/MODEL_NAME")
77
+
78
+ prompt = "def fibonacci(n):"
79
+
80
+ inputs = tokenizer(prompt, return_tensors="pt")
81
+
82
+ outputs = model.generate(
83
+ **inputs,
84
+ max_new_tokens=50,
85
+ do_sample=True,
86
+ temperature=0.7
87
+ )
88
+
89
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
90
+ ```
91
+
92
+ ---
93
+
94
+ ## Limitations
95
+
96
+ - Trained only on Python source code.
97
+ - Intended for research and educational purposes.
98
+ - May generate syntactically incorrect or incomplete code.
99
+ - Does not guarantee production-quality code suggestions.
100
+
101
+ ---
102
+
103
+ ## Technologies Used
104
+
105
+ - Python
106
+ - PyTorch
107
+ - Hugging Face Transformers
108
+ - Hugging Face Datasets
109
+ - CodeXGLUE Dataset
110
+
111
+ ---
112
+
113
+ ## Future Improvements
114
+
115
+ - Fine-tune larger transformer models.
116
+ - Train on larger subsets of CodeXGLUE.
117
+ - Evaluate using additional code generation metrics.
118
+ - Support multiple programming languages.
119
+ - Deploy as an inference API.
120
+
121
+ ---
122
+
123
+ ## Author
124
+
125
+ **Sai Nandu Vajhala**
126
+
127
+ GitHub: https://github.com/SaiNanduVajhala
128
+
129
+ LinkedIn: https://www.linkedin.com/in/sai-nandu-vajhala