Update app.py
Browse files
app.py
CHANGED
@@ -11,13 +11,6 @@ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
|
|
11 |
logging.basicConfig(level=logging.DEBUG)
|
12 |
|
13 |
def load_faiss_index(index_path):
|
14 |
-
"""
|
15 |
-
Load a FAISS index from a specified path.
|
16 |
-
Parameters:
|
17 |
-
- index_path (str): Path to the FAISS index file.
|
18 |
-
Returns:
|
19 |
-
- faiss.Index: Loaded FAISS index object.
|
20 |
-
"""
|
21 |
if not os.path.exists(index_path):
|
22 |
logging.error(f"FAISS index not found at {index_path}. Please create the index first.")
|
23 |
st.error(f"FAISS index not found at {index_path}. Please create the index first.")
|
@@ -34,9 +27,6 @@ def load_faiss_index(index_path):
|
|
34 |
raise
|
35 |
|
36 |
def load_llm():
|
37 |
-
"""
|
38 |
-
Load the HuggingFace model for generating responses.
|
39 |
-
"""
|
40 |
checkpoint = "LaMini-T5-738M"
|
41 |
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
42 |
model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint)
|
@@ -52,13 +42,6 @@ def load_llm():
|
|
52 |
return pipe
|
53 |
|
54 |
def process_answer(question):
|
55 |
-
"""
|
56 |
-
Process the user's question using the FAISS index and LLM.
|
57 |
-
Parameters:
|
58 |
-
- question (str): User's question to be processed.
|
59 |
-
Returns:
|
60 |
-
- str: The answer generated by the LLM.
|
61 |
-
"""
|
62 |
index_path = 'faiss_index/index.faiss'
|
63 |
embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
|
64 |
try:
|
|
|
11 |
logging.basicConfig(level=logging.DEBUG)
|
12 |
|
13 |
def load_faiss_index(index_path):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
if not os.path.exists(index_path):
|
15 |
logging.error(f"FAISS index not found at {index_path}. Please create the index first.")
|
16 |
st.error(f"FAISS index not found at {index_path}. Please create the index first.")
|
|
|
27 |
raise
|
28 |
|
29 |
def load_llm():
|
|
|
|
|
|
|
30 |
checkpoint = "LaMini-T5-738M"
|
31 |
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
32 |
model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint)
|
|
|
42 |
return pipe
|
43 |
|
44 |
def process_answer(question):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
index_path = 'faiss_index/index.faiss'
|
46 |
embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
|
47 |
try:
|