seapoe1809 commited on
Commit
f90b079
·
verified ·
1 Parent(s): e98ccdd

Update darnabot.py

Browse files
Files changed (1) hide show
  1. darnabot.py +6 -5
darnabot.py CHANGED
@@ -72,15 +72,16 @@ import spaces
72
  MODEL_LIST = ["mistralai/Mistral-Nemo-Instruct-2407"]
73
  HF_TOKEN = os.environ.get("HF_TOKEN", None)
74
  MODEL = os.environ.get("MODEL_ID")
75
- device = "cuda" if torch.cuda.is_available() else "cpu" # Use GPU if available, otherwise CPU
 
76
 
77
  tokenizer = AutoTokenizer.from_pretrained(MODEL)
78
  model = AutoModelForCausalLM.from_pretrained(
79
  MODEL,
80
- torch_dtype=torch.bfloat16, # Using bf16 precision
81
- device_map="auto", # Automatically map model to available devices
82
- ignore_mismatched_sizes=True # Allows some flexibility if dimensions don't match
83
- ).to(device)
84
 
85
  async def chat(messages):
86
  # Convert messages to the format required for the model
 
72
  MODEL_LIST = ["mistralai/Mistral-Nemo-Instruct-2407"]
73
  HF_TOKEN = os.environ.get("HF_TOKEN", None)
74
  MODEL = os.environ.get("MODEL_ID")
75
+
76
+ device = "cuda"
77
 
78
  tokenizer = AutoTokenizer.from_pretrained(MODEL)
79
  model = AutoModelForCausalLM.from_pretrained(
80
  MODEL,
81
+ torch_dtype=torch.bfloat16,
82
+ device_map="auto",
83
+ ignore_mismatched_sizes=True)
84
+
85
 
86
  async def chat(messages):
87
  # Convert messages to the format required for the model