File size: 4,323 Bytes
03fba61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# Mistral Technical Interview QA (LoRA + RAG)

## 📌 Overview

This model is a fine-tuned version of **Mistral-7B-Instruct** designed to answer **technical interview questions** in core Computer Science domains. It is trained on a curated dataset of technical question–answer pairs and evaluated under multiple experimental setups including vanilla LLM, fine-tuning, Retrieval-Augmented Generation (RAG), and hybrid approaches.

The goal of this project is to investigate the effectiveness of **parameter-efficient fine-tuning and retrieval augmentation** for improving technical question answering in low-resource settings.

---

## 🚀 Key Features

* Fine-tuned using **LoRA (Low-Rank Adaptation)** for memory-efficient training
* Supports **Retrieval-Augmented Generation (RAG)**
* Focused on Computer Science domains:

  * Data Structures and Algorithms
  * Operating Systems
  * Computer Networks
  * Databases
  * OOP and Core CS fundamentals
* Lightweight adapter weights for fast deployment
* Evaluated using BLEU, ROUGE, BERTScore, and Exact Match

---

## 🧠 Base Model

* Model: `mistralai/Mistral-7B-Instruct-v0.2`
* Architecture: Decoder-only transformer
* Training method: Supervised fine-tuning with LoRA

---

## 📚 Dataset

The dataset consists of approximately **2,000 technical question–answer pairs** covering multiple Computer Science domains.

### Dataset preparation:

* Initial seed dataset manually curated
* Extended using synthetic augmentation
* Duplicate and semantic filtering applied
* Train / validation / test splits created
* Format: JSONL

⚠️ Note: Some data samples were generated using LLM-based augmentation and manually filtered for quality.

---

## ⚙️ Training Details

### Fine-tuning approach:

* Parameter-efficient LoRA tuning
* Frozen base model weights
* Adapter-only training

### Configuration:

* LoRA rank: 8
* Learning rate: 1e-4
* Epochs: 3
* Sequence length: 384
* Precision: FP16
* Gradient accumulation used

Training was performed on an NVIDIA RTX 3090 (24GB VRAM).

---

## 🔍 Retrieval-Augmented Generation (RAG)

A semantic retriever was implemented using:

* Sentence Transformers (`all-MiniLM-L6-v2`)
* FAISS vector database
* Top-k semantic search

Retrieved context is injected into the prompt before generation.

---

## 📊 Evaluation

The model was evaluated under four experimental settings:

1. Vanilla Mistral
2. RAG + Vanilla
3. Fine-tuned Mistral
4. RAG + Fine-tuned

Metrics used:

* BLEU-4
* ROUGE-L
* BERTScore
* Exact Match

Results showed that:

* Fine-tuning improves answer quality and domain specificity
* RAG improves factual grounding
* The hybrid approach provides the best performance

---

## 🧪 Intended Use

This model is designed for:

* Interview preparation
* Educational tools
* Technical tutoring
* Research in retrieval-augmented systems

It is not intended for:

* Medical or legal decision-making
* Safety-critical systems

---

## ⚠️ Limitations

* Dataset size is relatively small
* Synthetic data may introduce bias
* Performance may vary for unseen or highly specialized domains
* Retrieval quality depends on the vector database

---

## 🔐 Ethical Considerations

The dataset does not contain personally identifiable or sensitive information. The model may generate incorrect or outdated information and should be used with human oversight.

---

## 📦 How to Use

### Load merged model:

```python
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained("yourusername/repo-name")
tokenizer = AutoTokenizer.from_pretrained("yourusername/repo-name")
```

### Load LoRA version:

```python
from transformers import AutoModelForCausalLM
from peft import PeftModel

base = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-Instruct-v0.2")
model = PeftModel.from_pretrained(base, "yourusername/repo-name")
```

---

## 📈 Future Work

* Larger and more diverse dataset
* Multi-hop retrieval
* Improved retriever training
* Reinforcement learning for answer quality
* Human evaluation

## hookup

## 👨‍💻 Author

Final-year Computer Science project focused on applied LLM systems, parameter-efficient fine-tuning, and retrieval-augmented generation.

---

## 📜 License

Please refer to the base model license (Mistral AI).