Instructions to use kunjcr2/gpt2_conv with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use kunjcr2/gpt2_conv with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("openai-community/gpt2-medium") model = PeftModel.from_pretrained(base_model, "kunjcr2/gpt2_conv") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,79 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
datasets:
|
| 4 |
+
- SohamGhadge/casual-conversation
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
base_model:
|
| 8 |
+
- openai-community/gpt2-medium
|
| 9 |
+
pipeline_tag: question-answering
|
| 10 |
+
tags:
|
| 11 |
+
- transformers
|
| 12 |
+
- peft
|
| 13 |
+
- gpt2
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
## 🧠 Fine-Tuned GPT-2 Medium for Conversational AI
|
| 17 |
+
This project fine-tunes the `gpt2-medium` language model to support natural, casual **conversational dialogue** using **PEFT + LoRA**.
|
| 18 |
+
---
|
| 19 |
+
### 🚀 Model Summary
|
| 20 |
+
* **Base model**: `gpt2-medium`
|
| 21 |
+
* **Objective**: Enable natural question-answering and dialogue
|
| 22 |
+
* **Training method**: Supervised Fine-Tuning (SFT) using PEFT with LoRA adapters
|
| 23 |
+
* **Tokenizer**: `gpt2` (same as base model)
|
| 24 |
+
---
|
| 25 |
+
### 📈 Training Metrics
|
| 26 |
+
| Metric | Value |
|
| 27 |
+
| ------------------- | -------------- |
|
| 28 |
+
| Global Steps | 2611 |
|
| 29 |
+
| Final Training Loss | 2.185 |
|
| 30 |
+
| Training Runtime | 430.61 seconds |
|
| 31 |
+
| Samples/sec | 138.41 |
|
| 32 |
+
| Steps/sec | 17.32 |
|
| 33 |
+
| Total FLOPs | 1.12 × 10¹⁵ |
|
| 34 |
+
| Epochs | 7.0 |
|
| 35 |
+
> These metrics reflect final performance after complete training.
|
| 36 |
+
---
|
| 37 |
+
### 💬 Inference Script
|
| 38 |
+
Chat with the model using the `talk()` function below:
|
| 39 |
+
```python
|
| 40 |
+
def talk(model=peft_model, tokenizer=tokenizer, device=device):
|
| 41 |
+
print("Start chatting with the bot! Type 'exit' to stop.\n")
|
| 42 |
+
while True:
|
| 43 |
+
question = input("You: ")
|
| 44 |
+
if question.lower() == "exit":
|
| 45 |
+
print("Goodbye!")
|
| 46 |
+
break
|
| 47 |
+
|
| 48 |
+
prompt = f"User: {question}\nBot:"
|
| 49 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(device)
|
| 50 |
+
|
| 51 |
+
with torch.no_grad():
|
| 52 |
+
outputs = model.generate(
|
| 53 |
+
**inputs,
|
| 54 |
+
max_new_tokens=20,
|
| 55 |
+
do_sample=True,
|
| 56 |
+
temperature=0.7,
|
| 57 |
+
top_p=0.9,
|
| 58 |
+
pad_token_id=tokenizer.eos_token_id
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
response = tokenizer.decode(
|
| 62 |
+
outputs[0][inputs["input_ids"].shape[-1]:],
|
| 63 |
+
skip_special_tokens=True
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
+
# Clean response
|
| 67 |
+
response = response.split(".")
|
| 68 |
+
response = ".".join(response[:-1]) + "."
|
| 69 |
+
print("Bot:", response.strip())
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
* 🤖 **Stateless**: No memory across turns (yet).
|
| 73 |
+
* 🌱 **Future idea**: Add memory/context for multi-turn dialogue.
|
| 74 |
+
---
|
| 75 |
+
### ⚙️ Quick Setup
|
| 76 |
+
To use this model locally:
|
| 77 |
+
```bash
|
| 78 |
+
pip install transformers peft accelerate
|
| 79 |
+
```
|