TymaaHammouda commited on
Commit
4da1971
·
verified ·
1 Parent(s): 24eadb0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -24,7 +24,7 @@ class ConflictDetectionRequest(BaseModel):
24
  # -----------------------------
25
  def build_prompt(req1, req2, prompt_type="zero-shot"):
26
  if prompt_type == "zero-shot":
27
- return f"Do the following sentences contradict each other, answer with just yes or no: 1.{req1} 2.{req2}"
28
  elif prompt_type == "few-shot":
29
  examples = (
30
  "Example 1:\n"
@@ -38,20 +38,23 @@ def build_prompt(req1, req2, prompt_type="zero-shot"):
38
  )
39
  return examples + f"Now answer: Do the following sentences contradict each other? 1.{req1} 2.{req2}"
40
  else:
41
- return f"Do the following sentences contradict each other, answer with just yes or no: 1.{req1} 2.{req2}"
42
 
43
  # -----------------------------
44
  # Startup: load DeepSeek once
45
  # -----------------------------
46
  @app.on_event("startup")
47
  def load_models():
48
- print("Loading smaller DeepSeek model into memory...")
49
- deepseek_name = "deepseek-ai/deepseek-coder-1.3b-base" # smaller, supported model
50
- app.state.deepseek_tokenizer = AutoTokenizer.from_pretrained(deepseek_name)
51
  app.state.deepseek_tokenizer.pad_token = app.state.deepseek_tokenizer.eos_token
 
52
  app.state.deepseek_model = AutoModelForCausalLM.from_pretrained(
53
- deepseek_name,
54
- torch_dtype=torch.float32 # CPU only
 
 
55
  )
56
 
57
 
 
24
  # -----------------------------
25
  def build_prompt(req1, req2, prompt_type="zero-shot"):
26
  if prompt_type == "zero-shot":
27
+ return f"Do the following sentences contradict each other, yes or no: 1.{req1} 2.{req2}"
28
  elif prompt_type == "few-shot":
29
  examples = (
30
  "Example 1:\n"
 
38
  )
39
  return examples + f"Now answer: Do the following sentences contradict each other? 1.{req1} 2.{req2}"
40
  else:
41
+ return f"Do the following sentences contradict each other, yes or no: 1.{req1} 2.{req2}"
42
 
43
  # -----------------------------
44
  # Startup: load DeepSeek once
45
  # -----------------------------
46
  @app.on_event("startup")
47
  def load_models():
48
+ print("Loading DeepSeek model into memory...")
49
+ model_name = "deepseek-ai/DeepSeek-R1-Distill-Llama-8B"
50
+ app.state.deepseek_tokenizer = AutoTokenizer.from_pretrained(model_name)
51
  app.state.deepseek_tokenizer.pad_token = app.state.deepseek_tokenizer.eos_token
52
+
53
  app.state.deepseek_model = AutoModelForCausalLM.from_pretrained(
54
+ model_name,
55
+ torch_dtype="auto",
56
+ device_map="auto",
57
+ offload_folder="offload" # folder to store offloaded weights
58
  )
59
 
60