Alexandr "MrSteyk" German
commited on
Commit
·
73ae988
1
Parent(s):
cdb0880
remove array
Browse files
app.py
CHANGED
@@ -110,12 +110,11 @@ def classify_fn_inner2(inpt, clas):
|
|
110 |
for i in tokens:
|
111 |
model.forward_token_preproc(i, state)
|
112 |
|
113 |
-
logits = []
|
114 |
tokens = tokenizer.encode(f" {inpt}\n").ids
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
loss = -
|
119 |
|
120 |
return loss
|
121 |
|
|
|
110 |
for i in tokens:
|
111 |
model.forward_token_preproc(i, state)
|
112 |
|
|
|
113 |
tokens = tokenizer.encode(f" {inpt}\n").ids
|
114 |
+
loss = 0
|
115 |
+
for i in range(len(tokens)-1):
|
116 |
+
loss += np.log(softmax(model.forward_token(tokens[i], state)))[tokens[i+1]]
|
117 |
+
loss = -loss / (len(tokens)-1)
|
118 |
|
119 |
return loss
|
120 |
|