varshamishra commited on
Commit
37c4a3d
Β·
verified Β·
1 Parent(s): 928d6e3

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +80 -0
README.md ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # T5-Base Fine-Tuned Model for Question Answering
2
+
3
+ This repository hosts a fine-tuned version of the **T5-Base** model optimized for question-answering tasks using the [SQuAD] dataset. The model is designed to efficiently perform question answering while maintaining high accuracy.
4
+
5
+ ## Model Details
6
+ - **Model Architecture**:AventIQ-AI/t5-qa-chatbot
7
+ - **Task**: Question Answering (QA-Chatbot)
8
+ - **Dataset**: [SQuAD]
9
+ - **Quantization**: FP16
10
+ - **Fine-tuning Framework**: Hugging Face Transformers
11
+
12
+ ## πŸš€ Usage
13
+
14
+ ### Installation
15
+
16
+ ```bash
17
+ pip install transformers torch
18
+ ```
19
+
20
+ ### Loading the Model
21
+
22
+ ```python
23
+ from transformers import T5Tokenizer, T5ForConditionalGeneration
24
+ import torch
25
+
26
+ device = "cuda" if torch.cuda.is_available() else "cpu"
27
+
28
+ model_name = "t5-small"
29
+ tokenizer = T5Tokenizer.from_pretrained(model_name)
30
+ model = T5ForConditionalGeneration.from_pretrained(model_name).to(device)
31
+ ```
32
+
33
+ ### Chatbot Inference
34
+
35
+ ```python
36
+ def answer_question(question, context):
37
+ input_text = f"question: {question} context: {context}"
38
+ inputs = tokenizer(input_text, return_tensors="pt", truncation=True, padding="max_length", max_length=512)
39
+
40
+ # Move input tensors to the same device as the model
41
+ inputs = {key: value.to(device) for key, value in inputs.items()}
42
+
43
+ # Generate answer
44
+ with torch.no_grad():
45
+ output = model.generate(**inputs, max_length=150)
46
+
47
+ # Decode and return answer
48
+ return tokenizer.decode(output[0], skip_special_tokens=True)
49
+
50
+ # Test Case
51
+ question = "What is overfitting in machine learning?"
52
+ context = "Overfitting occurs when a model learns the training data too well, capturing noise instead of actual patterns.
53
+ predicted_answer = answer_question(question, context)
54
+ print(f"Predicted Answer: {predicted_answer}")
55
+
56
+ ```
57
+
58
+ ## ⚑ Quantization Details
59
+
60
+ 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.
61
+
62
+ ## πŸ“‚ Repository Structure
63
+
64
+ ```
65
+ .
66
+ β”œβ”€β”€ model/ # Contains the quantized model files
67
+ β”œβ”€β”€ tokenizer_config/ # Tokenizer configuration and vocabulary files
68
+ β”œβ”€β”€ model.safetensors/ # Quantized Model
69
+ β”œβ”€β”€ README.md # Model documentation
70
+ ```
71
+
72
+ ## ⚠️ Limitations
73
+
74
+ - The model may struggle with highly ambiguous sentences.
75
+ - Quantization may lead to slight degradation in accuracy compared to full-precision models.
76
+ - Performance may vary across different writing styles and sentence structures.
77
+
78
+ ## 🀝 Contributing
79
+
80
+ Contributions are welcome! Feel free to open an issue or submit a pull request if you have suggestions or improvements.