Update app.py
Browse files
app.py
CHANGED
|
@@ -146,13 +146,11 @@ def create_vector_db(final_items):
|
|
| 146 |
|
| 147 |
|
| 148 |
documents = []
|
| 149 |
-
|
| 150 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
|
| 151 |
-
|
| 152 |
-
quantization_config = BitsAndBytesConfig(load_in_8bit=True)
|
| 153 |
checkpoint = "HuggingFaceTB/SmolLM-135M"
|
|
|
|
| 154 |
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
| 155 |
-
model = AutoModelForCausalLM.from_pretrained(checkpoint
|
| 156 |
|
| 157 |
for item in final_items:
|
| 158 |
prompt = f"""
|
|
@@ -164,7 +162,7 @@ def create_vector_db(final_items):
|
|
| 164 |
|
| 165 |
Here is the antimony segment to summarize: {item}
|
| 166 |
"""
|
| 167 |
-
inputs = tokenizer.encode(prompt, return_tensors="pt").to(
|
| 168 |
response = model.generate(inputs)
|
| 169 |
documents.append(tokenizer.decode(response[0]))
|
| 170 |
|
|
@@ -230,7 +228,8 @@ def streamlit_app():
|
|
| 230 |
model_ids = list(models.keys())
|
| 231 |
selected_models = st.multiselect(
|
| 232 |
"Select biomodels to analyze",
|
| 233 |
-
options=model_ids
|
|
|
|
| 234 |
)
|
| 235 |
|
| 236 |
if st.button("Analyze Selected Models"):
|
|
|
|
| 146 |
|
| 147 |
|
| 148 |
documents = []
|
| 149 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
|
|
|
|
|
|
| 150 |
checkpoint = "HuggingFaceTB/SmolLM-135M"
|
| 151 |
+
device = "cpu"
|
| 152 |
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
| 153 |
+
model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
|
| 154 |
|
| 155 |
for item in final_items:
|
| 156 |
prompt = f"""
|
|
|
|
| 162 |
|
| 163 |
Here is the antimony segment to summarize: {item}
|
| 164 |
"""
|
| 165 |
+
inputs = tokenizer.encode(prompt, return_tensors="pt").to(device)
|
| 166 |
response = model.generate(inputs)
|
| 167 |
documents.append(tokenizer.decode(response[0]))
|
| 168 |
|
|
|
|
| 228 |
model_ids = list(models.keys())
|
| 229 |
selected_models = st.multiselect(
|
| 230 |
"Select biomodels to analyze",
|
| 231 |
+
options=model_ids,
|
| 232 |
+
default=[model_ids[0]]
|
| 233 |
)
|
| 234 |
|
| 235 |
if st.button("Analyze Selected Models"):
|