Nebulixlabs commited on
Commit
5d8e13d
·
verified ·
1 Parent(s): a79d98f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -16,7 +16,13 @@ import bm25s
16
  import aiohttp
17
  from bs4 import BeautifulSoup
18
 
19
- # 🔥 NEW INCLUDES FOR ONNX & ULTRA-SMALL MODEL
 
 
 
 
 
 
20
  from transformers import AutoTokenizer, pipeline
21
  from optimum.onnxruntime import ORTModelForCausalLM
22
  import onnxruntime as ort
@@ -120,7 +126,7 @@ def load_ai_models():
120
  try:
121
  model_id = "HuggingFaceTB/SmolLM2-135M-Instruct"
122
 
123
- # Strictly configure ONNX to use exactly the allowed 40% CPU cores
124
  sess_options = ort.SessionOptions()
125
  sess_options.intra_op_num_threads = AI_CORES
126
  sess_options.inter_op_num_threads = 1
 
16
  import aiohttp
17
  from bs4 import BeautifulSoup
18
 
19
+ # 🔥 CRITICAL HOTFIX: Prevents Optimum from crashing on newer Transformers versions
20
+ import transformers.utils
21
+ if not hasattr(transformers.utils, 'is_tf_available'):
22
+ transformers.utils.is_tf_available = lambda: False
23
+ if not hasattr(transformers.utils, 'is_torch_available'):
24
+ transformers.utils.is_torch_available = lambda: True
25
+
26
  from transformers import AutoTokenizer, pipeline
27
  from optimum.onnxruntime import ORTModelForCausalLM
28
  import onnxruntime as ort
 
126
  try:
127
  model_id = "HuggingFaceTB/SmolLM2-135M-Instruct"
128
 
129
+ # Strictly configure ONNX to use exactly the allowed CPU cores
130
  sess_options = ort.SessionOptions()
131
  sess_options.intra_op_num_threads = AI_CORES
132
  sess_options.inter_op_num_threads = 1