Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
---
|
| 4 |
+
# 🧠 CodeGen-Alpaca-1B
|
| 5 |
+
|
| 6 |
+
This is a fine-tuned version of `StarCoderBase-1B` using the **CodeAlpaca (2k subset)** dataset.
|
| 7 |
+
It has been trained with **QLoRA** on Google Colab for lightweight, memory-efficient code generation.
|
| 8 |
+
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
## ✨ Model Capabilities
|
| 12 |
+
|
| 13 |
+
This model understands **instruction-style prompts** for generating code in multiple programming languages, especially Python.
|
| 14 |
+
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
## 📦 How to Use
|
| 18 |
+
|
| 19 |
+
```python
|
| 20 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 21 |
+
import torch
|
| 22 |
+
|
| 23 |
+
model_id = "key-life/codegen-alpaca-1b"
|
| 24 |
+
|
| 25 |
+
# Load model & tokenizer
|
| 26 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 27 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
|
| 28 |
+
|
| 29 |
+
# Example prompt
|
| 30 |
+
prompt = "### Instruction:\nWrite a Python function to check if a number is prime.\n\n### Response:\n"
|
| 31 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 32 |
+
|
| 33 |
+
# Generate code
|
| 34 |
+
outputs = model.generate(**inputs, max_new_tokens=128)
|
| 35 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|