Spaces:
Running
on
L4
Running
on
L4
Commit
·
35f0bee
1
Parent(s):
0f9d3df
download private data
Browse files
app.py
CHANGED
@@ -33,10 +33,31 @@ st.markdown("""
|
|
33 |
# ---------------------------------------
|
34 |
# paths
|
35 |
# ---------------------------------------
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
base_model_path = "meta-llama/Llama-3.2-11B-Vision-Instruct"
|
38 |
base_model_path_3B = "meta-llama/Llama-3.2-3B-Instruct"
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
st.title(":red[AI University] :gray[/] FEM")
|
42 |
# st.markdown("### Finite Element Method")
|
@@ -169,7 +190,7 @@ with col1:
|
|
169 |
with col2:
|
170 |
if st.button("Random Question"):
|
171 |
while True:
|
172 |
-
random_question = get_random_question(
|
173 |
if random_question != st.session_state.question:
|
174 |
break
|
175 |
st.session_state.question = random_question
|
@@ -203,9 +224,9 @@ with st.spinner("Loading LLaMA-3.2-3B..."):
|
|
203 |
st.session_state.llama_tokenizer_3B = llama_tokenizer_3B
|
204 |
|
205 |
# Load YouTube and LaTeX data
|
206 |
-
text_data_YT, context_embeddings_YT = load_youtube_data(
|
207 |
-
text_data_Latex, context_embeddings_Latex = load_book_data(
|
208 |
-
summary = load_summary('
|
209 |
|
210 |
if 'question_answered' not in st.session_state:
|
211 |
st.session_state.question_answered = False
|
|
|
33 |
# ---------------------------------------
|
34 |
# paths
|
35 |
# ---------------------------------------
|
36 |
+
HOME = "/home/user/app"
|
37 |
+
|
38 |
+
data_dir = HOME +"/data"
|
39 |
+
private_data_dir = HOME + "/private_data" # Relative path in your Space
|
40 |
+
|
41 |
+
# getting private data
|
42 |
+
os.makedirs(private_data_dir, exist_ok=True)
|
43 |
+
token = os.getenv("data")
|
44 |
+
local_repo_path = snapshot_download(
|
45 |
+
repo_id="my-ai-university/data",
|
46 |
+
use_auth_token=token,
|
47 |
+
repo_type="dataset",
|
48 |
+
local_dir=private_data_dir,
|
49 |
+
)
|
50 |
+
|
51 |
+
adapter_path = HOME + "/LLaMA-TOMMI-1.0/"
|
52 |
+
|
53 |
base_model_path = "meta-llama/Llama-3.2-11B-Vision-Instruct"
|
54 |
base_model_path_3B = "meta-llama/Llama-3.2-3B-Instruct"
|
55 |
+
|
56 |
+
|
57 |
+
# base_path = "data/"
|
58 |
+
# base_model_path = "meta-llama/Llama-3.2-11B-Vision-Instruct"
|
59 |
+
# base_model_path_3B = "meta-llama/Llama-3.2-3B-Instruct"
|
60 |
+
# adapter_path = "./LLaMA-TOMMI-1.0/"
|
61 |
|
62 |
st.title(":red[AI University] :gray[/] FEM")
|
63 |
# st.markdown("### Finite Element Method")
|
|
|
190 |
with col2:
|
191 |
if st.button("Random Question"):
|
192 |
while True:
|
193 |
+
random_question = get_random_question(data_dir + "/questions.txt")
|
194 |
if random_question != st.session_state.question:
|
195 |
break
|
196 |
st.session_state.question = random_question
|
|
|
224 |
st.session_state.llama_tokenizer_3B = llama_tokenizer_3B
|
225 |
|
226 |
# Load YouTube and LaTeX data
|
227 |
+
text_data_YT, context_embeddings_YT = load_youtube_data(data_dir, embedding_model, yt_chunk_tokens, yt_overlap_tokens)
|
228 |
+
text_data_Latex, context_embeddings_Latex = load_book_data(private_data_dir, embedding_model, latex_chunk_tokens, latex_overlap_tokens)
|
229 |
+
summary = load_summary(data_dir + '/KG_FEM_summary.json')
|
230 |
|
231 |
if 'question_answered' not in st.session_state:
|
232 |
st.session_state.question_answered = False
|