File size: 1,513 Bytes
6cf6a92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
Main Execution Script for Retrieval-based Medical QA Chatbot
============================================================

This script handles:
1. Query preprocessing
2. Information retrieval
3. Answer generation
"""

import warnings
warnings.filterwarnings("ignore", category=UserWarning)

from Query_processing import preprocess_query
from Retrieval import Retrieval_averagedQP
from Answer_Generation import answer_generation
from Retrieval import Embed_and_FAISS

# -------------------------------
# Optional: Embed and Store FAISS Index
# -------------------------------
# Uncomment the below line to generate embeddings and build the FAISS index if not already done.
# Embed_and_FAISS()

# -------------------------------
# Define User Question
# -------------------------------

Question = "how much dosage of ibuprofen should be taken for treatment of fever?"

# -------------------------------
# Step 1: Query Preprocessing
# -------------------------------

intent, entities = preprocess_query(Question)

# -------------------------------
# Step 2: Retrieve Relevant Chunks
# -------------------------------

top_chunks = Retrieval_averagedQP(Question, intent, entities, top_k=10, alpha=0.8)

# -------------------------------
# Step 3: Answer Generation
# -------------------------------

Generated_answer = answer_generation(Question, top_chunks, top_k=3)

# -------------------------------
# Display Generated Answer
# -------------------------------

print("Generated Answer:", Generated_answer)