File size: 2,833 Bytes
9302cc6
 
 
 
 
 
 
 
 
 
 
 
 
 
a256c6d
 
5d37320
a256c6d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5d37320
a256c6d
 
5d37320
a256c6d
 
 
 
 
 
 
5d37320
a256c6d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5d37320
a256c6d
 
 
 
 
5d37320
a256c6d
5d37320
a256c6d
5d37320
a256c6d
5d37320
a256c6d
5d37320
a256c6d
5d37320
a256c6d
 
 
 
 
5d37320
a256c6d
 
 
 
 
 
5d37320
a256c6d
 
 
 
 
 
 
5d37320
 
a256c6d
 
 
 
 
9302cc6
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
---
license: mit
datasets:
- facebook/natural_reasoning
language:
- en
base_model:
- distilbert/distilgpt2
pipeline_tag: text2text-generation
tags:
- Resoning
- Maths
- physics
---
# Natural Reasoning Bot πŸ€–

A lightweight QA chatbot built using Hugging Face's `facebook/natural_questions` dataset and a fine-tuned `distilgpt2` model. This project provides a simple Streamlit interface to interact with the model in a clean, animated UI.

---

## ✨ Features

* Reasoning-based natural language answers
* Animated Streamlit UI with gradient layout
* Fine-tuned GPT-style language model
* Clean prompt formatting with context handling
* Ready for deployment on GitHub or Streamlit Cloud

---

## πŸŽ“ Example Questions That Work Best

Use questions that require factual understanding, calculation, or reasoning:

| Question Example                                     | Why It Works                    |
| ---------------------------------------------------- | ------------------------------- |
| What is the total work done on an object lifted 5m?  | Physics-based factual reasoning |
| Why is work zero in circular motion?                 | Conceptual explanation          |
| If a car moves 60km/h for 2 hours, what is distance? | Simple arithmetic reasoning     |

> Avoid vague or one-word questions like "gravity" or "work".

Always format your prompt like this:

```txt
### Question: <your question>
### Answer:
```

---

## πŸ“Š Accuracy Evaluation (Optional)

To evaluate model performance, you can measure accuracy or BLEU/ROUGE scores if using a validation dataset. Here's a simple accuracy graph generation using matplotlib:

```python
import matplotlib.pyplot as plt

# Sample accuracy values per epoch
epochs = [1, 2, 3, 4, 5]
train_acc = [0.52, 0.65, 0.72, 0.78, 0.81]
val_acc = [0.50, 0.63, 0.70, 0.75, 0.79]

plt.plot(epochs, train_acc, label='Train Accuracy', marker='o')
plt.plot(epochs, val_acc, label='Validation Accuracy', marker='x')
plt.xlabel("Epoch")
plt.ylabel("Accuracy")
plt.title("Training vs Validation Accuracy")
plt.legend()
plt.grid(True)
plt.show()
```

---

## πŸš€ How to Run

1. **Install requirements**

```bash
pip install -r requirements.txt
```

2. **Run Streamlit App**

```bash
streamlit run app.py
```

---

## 🌐 Folder Structure

```
project/
β”œβ”€β”€ app.py               # Streamlit UI app
β”œβ”€β”€ model/               # Fine-tuned model directory
β”œβ”€β”€ utils.py             # Utility functions for prompt formatting
β”œβ”€β”€ requirements.txt    # Dependencies
└── README.md            # Project readme
```

---

## πŸ’ͺ Credits

* Hugging Face Transformers
* Streamlit
* Dataset: `facebook/natural_questions`
* Model: `distilgpt2`

---

For deployment on GitHub/Streamlit Cloud, keep model size small and test on CPU mode.

**Made with ❀️ by \[Vardaan Shukla]**