Skip to content

Commit b3676a6

Browse files
committed
reformat utils.py
1 parent d45325c commit b3676a6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

fastchat/serve/monitor/classify/utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,16 @@ def chat_completion_openai(model, messages, temperature, max_tokens, api_dict=No
6666
class HuggingFaceClassifier:
6767
def __init__(self, model_path, device=None):
6868
print("Loading model and tokenizer...")
69-
self.device = device or torch.device("cuda" if torch.cuda.is_available() else "cpu")
69+
self.device = device or torch.device(
70+
"cuda" if torch.cuda.is_available() else "cpu"
71+
)
7072
self.pipeline = pipeline(
7173
"text-classification",
7274
model=model_path,
7375
tokenizer=model_path,
74-
device=self.device
76+
device=self.device,
7577
)
7678

7779
def classify_batch(self, input_texts, batch_size=8):
7880
results = self.pipeline(input_texts, batch_size=batch_size, truncation=True)
79-
return [res['label'] == "LABEL_1" for res in results]
80-
81+
return [res["label"] == "LABEL_1" for res in results]

0 commit comments

Comments
 (0)