jenniferhk008 commited on
Commit
5e57e5c
·
verified ·
1 Parent(s): 0a7d017

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +4 -3
agent.py CHANGED
@@ -7,9 +7,10 @@ emoji_tokenizer = AutoTokenizer.from_pretrained(emoji_model_id, trust_remote_cod
7
  emoji_model = AutoModelForCausalLM.from_pretrained(
8
  emoji_model_id,
9
  trust_remote_code=True,
10
- torch_dtype=torch.float16
11
- ).to("cuda" if torch.cuda.is_available() else "cpu")
12
- emoji_model.eval()
 
13
 
14
  # ✅ Step 2: 冒犯性文本识别模型
15
  classifier = pipeline("text-classification", model="unitary/toxic-bert", device=0 if torch.cuda.is_available() else -1)
 
7
  emoji_model = AutoModelForCausalLM.from_pretrained(
8
  emoji_model_id,
9
  trust_remote_code=True,
10
+ torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
11
+ device_map="auto"
12
+ )
13
+
14
 
15
  # ✅ Step 2: 冒犯性文本识别模型
16
  classifier = pipeline("text-classification", model="unitary/toxic-bert", device=0 if torch.cuda.is_available() else -1)