Spaces:
Sleeping
Sleeping
Commit
·
ac528df
1
Parent(s):
96069d0
Enhance logging in load_model function
Browse files
app.py
CHANGED
@@ -24,16 +24,22 @@ def load_model():
|
|
24 |
peft_model_path = "yitzashapiro/FDA-guidance-zephyr-7b-beta-PEFT"
|
25 |
|
26 |
try:
|
|
|
|
|
27 |
tokenizer = AutoTokenizer.from_pretrained(
|
28 |
model_path,
|
29 |
-
trust_remote_code=True
|
|
|
30 |
)
|
|
|
31 |
model = AutoModelForCausalLM.from_pretrained(
|
32 |
model_path,
|
33 |
device_map="auto",
|
34 |
-
torch_dtype=torch.float16,
|
35 |
-
trust_remote_code=True
|
|
|
36 |
).eval()
|
|
|
37 |
model.load_adapter(peft_model_path)
|
38 |
st.success("Model loaded successfully.")
|
39 |
except Exception as e:
|
@@ -83,12 +89,12 @@ def generate_response(tokenizer, model, user_input):
|
|
83 |
def main():
|
84 |
apply_custom_css()
|
85 |
|
86 |
-
st.title("FDA
|
87 |
-
st.write("
|
88 |
|
89 |
tokenizer, model = load_model()
|
90 |
|
91 |
-
user_input = st.text_input("Enter your question:", "
|
92 |
|
93 |
if st.button("Generate Response"):
|
94 |
if user_input.strip() == "":
|
@@ -103,4 +109,4 @@ def main():
|
|
103 |
st.error(f"An error occurred: {e}")
|
104 |
|
105 |
if __name__ == "__main__":
|
106 |
-
main()
|
|
|
24 |
peft_model_path = "yitzashapiro/FDA-guidance-zephyr-7b-beta-PEFT"
|
25 |
|
26 |
try:
|
27 |
+
HF_API_TOKEN = os.getenv("HF_API_TOKEN")
|
28 |
+
st.write("Loading tokenizer...")
|
29 |
tokenizer = AutoTokenizer.from_pretrained(
|
30 |
model_path,
|
31 |
+
trust_remote_code=True,
|
32 |
+
use_auth_token=HF_API_TOKEN # Use token for private models
|
33 |
)
|
34 |
+
st.write("Loading model...")
|
35 |
model = AutoModelForCausalLM.from_pretrained(
|
36 |
model_path,
|
37 |
device_map="auto",
|
38 |
+
torch_dtype=torch.float16,
|
39 |
+
trust_remote_code=True,
|
40 |
+
use_auth_token=HF_API_TOKEN # Use token for private models
|
41 |
).eval()
|
42 |
+
st.write("Loading PEFT adapter...")
|
43 |
model.load_adapter(peft_model_path)
|
44 |
st.success("Model loaded successfully.")
|
45 |
except Exception as e:
|
|
|
89 |
def main():
|
90 |
apply_custom_css()
|
91 |
|
92 |
+
st.title("FDA NDA Submission Assistant")
|
93 |
+
st.write("Ask the model about submitting an NDA to the FDA.")
|
94 |
|
95 |
tokenizer, model = load_model()
|
96 |
|
97 |
+
user_input = st.text_input("Enter your question:", "What's the best way to submit an NDA to the FDA?")
|
98 |
|
99 |
if st.button("Generate Response"):
|
100 |
if user_input.strip() == "":
|
|
|
109 |
st.error(f"An error occurred: {e}")
|
110 |
|
111 |
if __name__ == "__main__":
|
112 |
+
main()
|