Update handler.py
Browse files- handler.py +6 -24
handler.py
CHANGED
@@ -1,26 +1,8 @@
|
|
1 |
-
|
2 |
-
import
|
3 |
-
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
model = AutoModelForSequenceClassification.from_pretrained("AIRider/Ko-Llama3-Luxia-8B-Q4_K_M-GGUF")
|
8 |
-
tokenizer = AutoTokenizer.from_pretrained("AIRider/Ko-Llama3-Luxia-8B-Q4_K_M-GGUF")
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
inputs = tokenizer.encode_plus(
|
13 |
-
input_text,
|
14 |
-
add_special_tokens=True,
|
15 |
-
max_length=512,
|
16 |
-
return_attention_mask=True,
|
17 |
-
return_tensors="pt",
|
18 |
-
)
|
19 |
-
|
20 |
-
# 모델 추론
|
21 |
-
outputs = model(inputs["input_ids"], attention_mask=inputs["attention_mask"])
|
22 |
-
logits = outputs.logits
|
23 |
-
|
24 |
-
# 결과 반환
|
25 |
-
result = torch.argmax(logits).item()
|
26 |
-
return {"result": result}
|
|
|
1 |
+
from huggingfacehub import HuggingfaceHubModelregistry
|
2 |
+
from transformers import AutoModelorSequenceClassification
|
|
|
3 |
|
4 |
+
# AIider/o-Llama3-Luxia-8B-Q4M-GG 모델을 로드합니다
|
5 |
+
model = AutoModelorSequenceClassification.frompretrained("AIRider/Ko-Llama3-Luxia-8B-Q4_K_M-GGUF")
|
|
|
|
|
6 |
|
7 |
+
# HuggingfaceHubModelregistry를 사용하여 모델을 등록합니다
|
8 |
+
HuggingfaceHubModelregistry.register(model)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|