Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -15,15 +15,15 @@ def extract_text_from_pdf(uploaded_file):
|
|
15 |
pdf_text += page.extract_text()
|
16 |
return pdf_text
|
17 |
|
18 |
-
# Initialize the tokenizer and model
|
19 |
tokenizer = AutoTokenizer.from_pretrained("ricepaper/vi-gemma-2b-RAG")
|
|
|
20 |
model = AutoModelForCausalLM.from_pretrained(
|
21 |
"ricepaper/vi-gemma-2b-RAG",
|
22 |
-
device_map="auto",
|
23 |
torch_dtype=torch.bfloat16
|
24 |
)
|
25 |
|
26 |
-
#
|
27 |
if torch.cuda.is_available():
|
28 |
model.to("cuda")
|
29 |
|
|
|
15 |
pdf_text += page.extract_text()
|
16 |
return pdf_text
|
17 |
|
18 |
+
# Initialize the tokenizer and model on CPU first
|
19 |
tokenizer = AutoTokenizer.from_pretrained("ricepaper/vi-gemma-2b-RAG")
|
20 |
+
|
21 |
model = AutoModelForCausalLM.from_pretrained(
|
22 |
"ricepaper/vi-gemma-2b-RAG",
|
|
|
23 |
torch_dtype=torch.bfloat16
|
24 |
)
|
25 |
|
26 |
+
# Move model to GPU if available
|
27 |
if torch.cuda.is_available():
|
28 |
model.to("cuda")
|
29 |
|