File size: 941 Bytes
88c9095
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""The model card's Python example: one invented support ticket, single-label and multi-label.

Run from the repository root: python examples/run_example.py
"""
import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parents[1]))

from gliclass_litert import GliclassLiteRT  # noqa: E402

text = (
    "The Zorvik X2 router from Tallowmere Networks keeps dropping the connection every evening "
    "around 9 pm. I have restarted it and reset it to factory settings, but the status light "
    "still blinks orange."
)
labels = ["connectivity problem", "hardware defect", "billing issue", "feature request",
          "installation help"]

with GliclassLiteRT(Path(__file__).resolve().parents[1]) as classifier:
    for mode in ("single-label", "multi-label"):
        result = classifier.classify(text, labels, classification_type=mode)
        print(mode, [(r["label"], round(r["score"], 3)) for r in result])