Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -45,13 +45,18 @@ def create_custom_index():
|
|
45 |
dataset_path = "icici_bank_dataset"
|
46 |
index_path = "icici_bank_index"
|
47 |
dataset.save_to_disk(dataset_path)
|
|
|
|
|
|
|
48 |
dataset.add_faiss_index("text")
|
49 |
dataset.get_index("text").save(index_path)
|
|
|
50 |
|
51 |
return dataset_path, index_path
|
52 |
|
53 |
# Load the fine-tuned RAG model and tokenizer
|
54 |
tokenizer = RagTokenizer.from_pretrained("facebook/rag-sequence-base")
|
|
|
55 |
|
56 |
try:
|
57 |
# Create and save the custom index
|
@@ -64,9 +69,11 @@ try:
|
|
64 |
passages_path=dataset_path,
|
65 |
index_path=index_path
|
66 |
)
|
|
|
67 |
|
68 |
# Load the RAG model
|
69 |
model = RagSequenceForGeneration.from_pretrained("facebook/rag-sequence-base", retriever=retriever)
|
|
|
70 |
except Exception as e:
|
71 |
print(f"Error initializing model or retriever: {e}")
|
72 |
retriever = None
|
|
|
45 |
dataset_path = "icici_bank_dataset"
|
46 |
index_path = "icici_bank_index"
|
47 |
dataset.save_to_disk(dataset_path)
|
48 |
+
print(f"Dataset saved to {dataset_path}")
|
49 |
+
|
50 |
+
# Add FAISS index
|
51 |
dataset.add_faiss_index("text")
|
52 |
dataset.get_index("text").save(index_path)
|
53 |
+
print(f"FAISS index saved to {index_path}")
|
54 |
|
55 |
return dataset_path, index_path
|
56 |
|
57 |
# Load the fine-tuned RAG model and tokenizer
|
58 |
tokenizer = RagTokenizer.from_pretrained("facebook/rag-sequence-base")
|
59 |
+
print("Tokenizer loaded successfully.")
|
60 |
|
61 |
try:
|
62 |
# Create and save the custom index
|
|
|
69 |
passages_path=dataset_path,
|
70 |
index_path=index_path
|
71 |
)
|
72 |
+
print("Retriever loaded successfully.")
|
73 |
|
74 |
# Load the RAG model
|
75 |
model = RagSequenceForGeneration.from_pretrained("facebook/rag-sequence-base", retriever=retriever)
|
76 |
+
print("Model loaded successfully.")
|
77 |
except Exception as e:
|
78 |
print(f"Error initializing model or retriever: {e}")
|
79 |
retriever = None
|