Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Stock Market QA Chatbot with Text-to-Text Transfer Transformer(T5)
|
2 |
+
|
3 |
+
## π Overview
|
4 |
+
|
5 |
+
This repository hosts the quantized version of the T5 model fine-tuned for question-answer tasks related to stock market. The model has been trained on the stock_trading_QA dataset from Hugging Face. The model is quantized to Float16 (FP16) to optimize inference speed and efficiency while maintaining high performance.
|
6 |
+
|
7 |
+
## π Model Details
|
8 |
+
|
9 |
+
- **Model Architecture:** t5-base
|
10 |
+
- **Task:** QA Chatbot for Stock Market
|
11 |
+
- **Dataset:** Hugging Face's `stock_trading_QA`
|
12 |
+
- **Quantization:** Float16 (FP16) for optimized inference
|
13 |
+
- **Fine-tuning Framework:** Hugging Face Transformers
|
14 |
+
|
15 |
+
## π Usage
|
16 |
+
|
17 |
+
### Installation
|
18 |
+
|
19 |
+
```bash
|
20 |
+
pip install transformers torch
|
21 |
+
```
|
22 |
+
|
23 |
+
### Loading the Model
|
24 |
+
|
25 |
+
```python
|
26 |
+
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
27 |
+
import torch
|
28 |
+
|
29 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
30 |
+
|
31 |
+
model_name = "AventIQ-AI/t5-stockmarket-qa-chatbot"
|
32 |
+
model = T5ForConditionalGeneration.from_pretrained(model_name).to(device)
|
33 |
+
tokenizer = T5Tokenizer.from_pretrained(model_name)
|
34 |
+
```
|
35 |
+
|
36 |
+
### Question Answer Example
|
37 |
+
|
38 |
+
```python
|
39 |
+
question = "How can I start investing in stocks?"
|
40 |
+
input_text = "question: " + question
|
41 |
+
input_ids = tokenizer.encode(input_text, return_tensors="pt").to(model.device)
|
42 |
+
|
43 |
+
with torch.no_grad():
|
44 |
+
outputs = model.generate(input_ids, max_length=50)
|
45 |
+
answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
46 |
+
|
47 |
+
print(f"Question: {question}")
|
48 |
+
print(f"Predicted Answer: {answer}")
|
49 |
+
```
|
50 |
+
|
51 |
+
## π Evaluation Metric: BLEU Score
|
52 |
+
|
53 |
+
For question answer tasks, a high BLEU score indicates that the modelβs corrected sentences closely match human-annotated corrections.
|
54 |
+
|
55 |
+
## **Interpreting Our BLEU Score**
|
56 |
+
Our model achieved a **BLEU score of 0.7888**, which indicates:
|
57 |
+
β
**Good answer generating ability**
|
58 |
+
β
**Moderate sentence fluency**
|
59 |
+
|
60 |
+
BLEU is computed by comparing the **1-gram, 2-gram, 3-gram, and 4-gram overlaps** between the modelβs output and the reference sentence while applying a **brevity penalty** if the model generates shorter sentences.
|
61 |
+
|
62 |
+
### **BLEU Score Ranges for Chatbot**
|
63 |
+
|
64 |
+
| BLEU Score | Interpretation |
|
65 |
+
| --- | --- |
|
66 |
+
| **0.8 - 1.0** | Near-perfect corrections, closely matching human annotations. |
|
67 |
+
| **0.7 - 0.8** | High-quality corrections, minor variations in phrasing. |
|
68 |
+
| **0.6 - 0.7** | Good corrections, but with some grammatical errors or missing words. |
|
69 |
+
| **0.5 - 0.6** | Decent corrections, noticeable mistakes, lacks fluency. |
|
70 |
+
| **Below 0.5** | Needs improvement, frequent incorrect corrections. |
|
71 |
+
|
72 |
+
|
73 |
+
## β‘ Quantization Details
|
74 |
+
|
75 |
+
Post-training quantization was applied using PyTorch's built-in quantization framework. The model was quantized to Float16 (FP16) to reduce model size and improve inference efficiency while balancing accuracy.
|
76 |
+
|
77 |
+
## π Repository Structure
|
78 |
+
|
79 |
+
```
|
80 |
+
.
|
81 |
+
βββ model/ # Contains the quantized model files
|
82 |
+
βββ tokenizer_config/ # Tokenizer configuration and vocabulary files
|
83 |
+
βββ model.safetensors/ # Quantized Model
|
84 |
+
βββ README.md # Model documentation
|
85 |
+
```
|
86 |
+
|
87 |
+
## β οΈ Limitations
|
88 |
+
|
89 |
+
- The model may struggle with highly ambiguous sentences.
|
90 |
+
- Quantization may lead to slight degradation in accuracy compared to full-precision models.
|
91 |
+
- Performance may vary across different writing styles and sentence structures.
|
92 |
+
|
93 |
+
## π€ Contributing
|
94 |
+
|
95 |
+
Contributions are welcome! Feel free to open an issue or submit a pull request if you have suggestions or improvements.
|