sureal01 commited on
Commit
c56660a
Β·
verified Β·
1 Parent(s): 893b2c2

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +52 -0
README.md ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - javascript
4
+ - code-generation
5
+ - transformers
6
+ - fine-tuned
7
+ - distilgpt2
8
+ license: mit
9
+ library_name: transformers
10
+ ---
11
+
12
+ # πŸš€ DistilGPT-2 Code Generator (Explanation β†’ JavaScript Code)
13
+
14
+ This model is a **fine-tuned version of `distilgpt2`** trained to generate **JavaScript code** from natural language explanations.
15
+
16
+ It was trained on a dataset containing **explanation-code pairs**, making it useful for:
17
+ βœ… **Code generation from text descriptions**
18
+ βœ… **Learning JavaScript syntax & patterns**
19
+ βœ… **Automated coding assistance**
20
+
21
+ ---
22
+
23
+ ## **πŸ›  Model Details**
24
+ - **Base Model:** `distilgpt2` (6x smaller than GPT-2)
25
+ - **Dataset:** JavaScript explanations + corresponding functions
26
+ - **Fine-tuning:** Trained using **LoRA (memory-efficient adaptation)**
27
+ - **Training Environment:** Google Colab (T4 GPU)
28
+ - **Optimization:** FP16 precision for faster training
29
+
30
+ ---
31
+
32
+ ## **πŸ“Š Example Usage**
33
+ Load the model and generate JavaScript code from explanations:
34
+
35
+ ```python
36
+ from transformers import AutoModelForCausalLM, AutoTokenizer
37
+
38
+ model_name = "sureal01/distilgpt2-code-generator" # Replace with your username
39
+ model = AutoModelForCausalLM.from_pretrained(model_name)
40
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
41
+
42
+ def generate_code(explanation):
43
+ input_text = f"### Explanation:\n{explanation}\n\n### Generate JavaScript code:\n"
44
+ inputs = tokenizer(input_text, return_tensors="pt")
45
+
46
+ output = model.generate(**inputs, max_length=150, temperature=0.5, top_p=0.9, repetition_penalty=1.5)
47
+ return tokenizer.decode(output[0], skip_special_tokens=True)
48
+
49
+ # Example
50
+ test_explanation = "This function takes a name as input and returns a greeting message."
51
+ generated_code = generate_code(test_explanation)
52
+ print("\nπŸ”Ή **Generated Code:**\n", generated_code)