gameresearch commited on
Commit
e7fb7cf
·
verified ·
1 Parent(s): 4f042fe

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +30 -30
README.md CHANGED
@@ -57,36 +57,36 @@ Always evaluate the model on your target domain.
57
 
58
  ## How to Get Started with the Model
59
 
60
- from transformers import AutoTokenizer, AutoModelForSequenceClassification
61
- import torch
62
-
63
- model_id = "gameresearch/modernbert-eie-2048"
64
- threshold = 0.2 # optimized decision threshold for EIE
65
-
66
- tokenizer = AutoTokenizer.from_pretrained(model_id)
67
- model = AutoModelForSequenceClassification.from_pretrained(model_id)
68
-
69
- def predict_eie(review_text: str):
70
- inputs = tokenizer(
71
- review_text,
72
- truncation=True,
73
- padding="max_length",
74
- max_length=2048,
75
- return_tensors="pt"
76
- )
77
- with torch.no_grad():
78
- outputs = model(**inputs)
79
- logits = outputs.logits.squeeze()
80
- probs = torch.softmax(logits, dim=-1)
81
- prob_eie = probs[1].item()
82
- label = int(prob_eie >= threshold)
83
- return {
84
- "prob_eie": prob_eie,
85
- "label": label # 1 = EIE present, 0 = EIE absent
86
- }
87
-
88
- example = "This game absolutely destroyed me emotionally. I still think about the ending."
89
- print(predict_eie(example))
90
 
91
 
92
  ## Training Details
 
57
 
58
  ## How to Get Started with the Model
59
 
60
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
61
+ import torch
62
+
63
+ model_id = "gameresearch/modernbert-eie-2048"
64
+ threshold = 0.2 # optimized decision threshold for EIE
65
+
66
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
67
+ model = AutoModelForSequenceClassification.from_pretrained(model_id)
68
+
69
+ def predict_eie(review_text: str):
70
+ inputs = tokenizer(
71
+ review_text,
72
+ truncation=True,
73
+ padding="max_length",
74
+ max_length=2048,
75
+ return_tensors="pt"
76
+ )
77
+ with torch.no_grad():
78
+ outputs = model(**inputs)
79
+ logits = outputs.logits.squeeze()
80
+ probs = torch.softmax(logits, dim=-1)
81
+ prob_eie = probs[1].item()
82
+ label = int(prob_eie >= threshold)
83
+ return {
84
+ "prob_eie": prob_eie,
85
+ "label": label # 1 = EIE present, 0 = EIE absent
86
+ }
87
+
88
+ example = "This game absolutely destroyed me emotionally. I still think about the ending."
89
+ print(predict_eie(example))
90
 
91
 
92
  ## Training Details