Update app.py
Browse files
app.py
CHANGED
@@ -15,6 +15,7 @@ DEFAULT_TEMPERATURE = 0.6
|
|
15 |
DEFAULT_CHUNK_SIZE = 500
|
16 |
DEFAULT_CHUNK_OVERLAP = 150
|
17 |
DEFAULT_MAX_NEW_TOKENS = 256
|
|
|
18 |
|
19 |
# Set up logging
|
20 |
logging.basicConfig(
|
@@ -23,7 +24,7 @@ logging.basicConfig(
|
|
23 |
|
24 |
# Initialize and load the RAG model
|
25 |
@st.cache_resource(show_spinner=False)
|
26 |
-
def load_model(chat_model_id, embed_model_id, text_path, k, top_k, top_p, temperature, chunk_size, chunk_overlap, hf_token, max_new_tokens, quantization):
|
27 |
rag_chain = BanglaRAGChain()
|
28 |
rag_chain.load(
|
29 |
chat_model_id=chat_model_id,
|
@@ -38,6 +39,7 @@ def load_model(chat_model_id, embed_model_id, text_path, k, top_k, top_p, temper
|
|
38 |
hf_token=hf_token,
|
39 |
max_new_tokens=max_new_tokens,
|
40 |
quantization=quantization,
|
|
|
41 |
)
|
42 |
return rag_chain
|
43 |
|
@@ -59,7 +61,7 @@ def main():
|
|
59 |
text_path = st.sidebar.text_input("Text File Path", "text.txt")
|
60 |
quantization = st.sidebar.checkbox("Enable Quantization (4-bit)", value=False)
|
61 |
show_context = st.sidebar.checkbox("Show Retrieved Context", value=False)
|
62 |
-
offload_dir = st.sidebar.text_input("Offload Directory",
|
63 |
|
64 |
# Load the model with the above configuration
|
65 |
rag_chain = load_model(
|
@@ -75,7 +77,7 @@ def main():
|
|
75 |
hf_token=None, # If you're not using HF API token, set it to None
|
76 |
max_new_tokens=max_new_tokens,
|
77 |
quantization=quantization,
|
78 |
-
offload_dir=offload_dir, # Pass
|
79 |
)
|
80 |
|
81 |
st.write("### Enter your question:")
|
|
|
15 |
DEFAULT_CHUNK_SIZE = 500
|
16 |
DEFAULT_CHUNK_OVERLAP = 150
|
17 |
DEFAULT_MAX_NEW_TOKENS = 256
|
18 |
+
DEFAULT_OFFLOAD_DIR = "/tmp"
|
19 |
|
20 |
# Set up logging
|
21 |
logging.basicConfig(
|
|
|
24 |
|
25 |
# Initialize and load the RAG model
|
26 |
@st.cache_resource(show_spinner=False)
|
27 |
+
def load_model(chat_model_id, embed_model_id, text_path, k, top_k, top_p, temperature, chunk_size, chunk_overlap, hf_token, max_new_tokens, quantization, offload_dir):
|
28 |
rag_chain = BanglaRAGChain()
|
29 |
rag_chain.load(
|
30 |
chat_model_id=chat_model_id,
|
|
|
39 |
hf_token=hf_token,
|
40 |
max_new_tokens=max_new_tokens,
|
41 |
quantization=quantization,
|
42 |
+
offload_dir=offload_dir, # Pass the offload_dir here
|
43 |
)
|
44 |
return rag_chain
|
45 |
|
|
|
61 |
text_path = st.sidebar.text_input("Text File Path", "text.txt")
|
62 |
quantization = st.sidebar.checkbox("Enable Quantization (4-bit)", value=False)
|
63 |
show_context = st.sidebar.checkbox("Show Retrieved Context", value=False)
|
64 |
+
offload_dir = st.sidebar.text_input("Offload Directory", DEFAULT_OFFLOAD_DIR) # Default to /tmp
|
65 |
|
66 |
# Load the model with the above configuration
|
67 |
rag_chain = load_model(
|
|
|
77 |
hf_token=None, # If you're not using HF API token, set it to None
|
78 |
max_new_tokens=max_new_tokens,
|
79 |
quantization=quantization,
|
80 |
+
offload_dir=offload_dir, # Pass the offload_dir here
|
81 |
)
|
82 |
|
83 |
st.write("### Enter your question:")
|