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