Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- demo.py +9 -3
- requirements.txt +1 -1
demo.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
-
from transformers import AutoModelForCausalLM,
|
4 |
import logging
|
5 |
|
6 |
# Setup logging
|
@@ -10,13 +10,19 @@ logger = logging.getLogger(__name__)
|
|
10 |
def load_model():
|
11 |
"""Load fine-tuned model without quantization for CPU compatibility."""
|
12 |
logger.info("Loading model...")
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
# Load model in the most compatible way for Spaces
|
16 |
model = AutoModelForCausalLM.from_pretrained(
|
17 |
"Zwounds/boolean-search-model",
|
18 |
low_cpu_mem_usage=True,
|
19 |
-
torch_dtype=torch.float32 # Use standard floating point for CPU
|
|
|
20 |
)
|
21 |
return model, tokenizer
|
22 |
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
+
from transformers import AutoModelForCausalLM, LlamaTokenizer
|
4 |
import logging
|
5 |
|
6 |
# Setup logging
|
|
|
10 |
def load_model():
|
11 |
"""Load fine-tuned model without quantization for CPU compatibility."""
|
12 |
logger.info("Loading model...")
|
13 |
+
|
14 |
+
# Use explicit LlamaTokenizer instead of AutoTokenizer
|
15 |
+
tokenizer = LlamaTokenizer.from_pretrained(
|
16 |
+
"Zwounds/boolean-search-model",
|
17 |
+
trust_remote_code=True
|
18 |
+
)
|
19 |
|
20 |
# Load model in the most compatible way for Spaces
|
21 |
model = AutoModelForCausalLM.from_pretrained(
|
22 |
"Zwounds/boolean-search-model",
|
23 |
low_cpu_mem_usage=True,
|
24 |
+
torch_dtype=torch.float32, # Use standard floating point for CPU
|
25 |
+
trust_remote_code=True
|
26 |
)
|
27 |
return model, tokenizer
|
28 |
|
requirements.txt
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
torch==2.0.1
|
2 |
-
transformers==4.
|
3 |
gradio>=4.0.0
|
|
|
1 |
torch==2.0.1
|
2 |
+
transformers==4.37.2
|
3 |
gradio>=4.0.0
|