Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -768,13 +768,14 @@ def respond_pkb(
|
|
| 768 |
if type(model) == CrossEncoder:
|
| 769 |
sentence_pairs = [[message, v[6:]] for v in codes]
|
| 770 |
scores = model.predict(sentence_pairs, convert_to_tensor=True)
|
| 771 |
-
|
| 772 |
else:
|
| 773 |
text_emb = model.encode(message)
|
| 774 |
scores = cos_sim(codes_emb, text_emb).mean(axis=-1)#[:,0]
|
| 775 |
-
|
| 776 |
|
| 777 |
-
|
|
|
|
| 778 |
|
| 779 |
|
| 780 |
out = ""
|
|
@@ -802,19 +803,22 @@ def respond_pkb(
|
|
| 802 |
|
| 803 |
out += "\n--"
|
| 804 |
|
| 805 |
-
if scores[0]
|
|
|
|
|
|
|
|
|
|
| 806 |
out += "\nRumus Bea Balik Nama Kendaraan Bermotor (BBNKB) : TARIF x NJKB x PENGENAAN"
|
| 807 |
out += f"\nKalkulasi : 10% x Rp{int(nilai_jual):,} x 100%"
|
| 808 |
out += f"\nTotal Pembayaran : Rp{int(bbnkb):,}\n"
|
| 809 |
-
if scores[1] >
|
| 810 |
out += "\nRumus Pokok Pajak Kendaraan Bermotor (PKB) : TARIF * NJKB * BOBOT * PENGENAAN"
|
| 811 |
out += f"\nKalkulasi : 1% * Rp{int(nilai_jual):,} * {bobot} * 100%"
|
| 812 |
out += f"\nTotal Pembayaran : Rp{int(pkb):,}\n"
|
| 813 |
|
| 814 |
-
if not out:
|
| 815 |
-
if scores[0] >
|
| 816 |
out += "\nRumus Bea Balik Nama Kendaraan Bermotor (BBNKB) : TARIF x NJKB x PENGENAAN"
|
| 817 |
-
if scores[1] >
|
| 818 |
out += "\nRumus Pokok Pajak Kendaraan Bermotor (PKB) : TARIF * NJKB * BOBOT * PENGENAAN"
|
| 819 |
|
| 820 |
return out
|
|
|
|
| 768 |
if type(model) == CrossEncoder:
|
| 769 |
sentence_pairs = [[message, v[6:]] for v in codes]
|
| 770 |
scores = model.predict(sentence_pairs, convert_to_tensor=True)
|
| 771 |
+
weights = [1,1]
|
| 772 |
else:
|
| 773 |
text_emb = model.encode(message)
|
| 774 |
scores = cos_sim(codes_emb, text_emb).mean(axis=-1)#[:,0]
|
| 775 |
+
weights = [19,8]
|
| 776 |
|
| 777 |
+
scores_argsort = scores.argsort(descending=True)
|
| 778 |
+
w_avg = np.average(scores[scores_argsort].numpy(), weights=weights)
|
| 779 |
|
| 780 |
|
| 781 |
out = ""
|
|
|
|
| 803 |
|
| 804 |
out += "\n--"
|
| 805 |
|
| 806 |
+
if scores[scores_argsort[0]] < threshold:
|
| 807 |
+
continue
|
| 808 |
+
|
| 809 |
+
if scores[0] > w_avg:
|
| 810 |
out += "\nRumus Bea Balik Nama Kendaraan Bermotor (BBNKB) : TARIF x NJKB x PENGENAAN"
|
| 811 |
out += f"\nKalkulasi : 10% x Rp{int(nilai_jual):,} x 100%"
|
| 812 |
out += f"\nTotal Pembayaran : Rp{int(bbnkb):,}\n"
|
| 813 |
+
if scores[1] > w_avg:
|
| 814 |
out += "\nRumus Pokok Pajak Kendaraan Bermotor (PKB) : TARIF * NJKB * BOBOT * PENGENAAN"
|
| 815 |
out += f"\nKalkulasi : 1% * Rp{int(nilai_jual):,} * {bobot} * 100%"
|
| 816 |
out += f"\nTotal Pembayaran : Rp{int(pkb):,}\n"
|
| 817 |
|
| 818 |
+
if not out and scores[scores_argsort[0]] >= threshold:
|
| 819 |
+
if scores[0] > w_avg:
|
| 820 |
out += "\nRumus Bea Balik Nama Kendaraan Bermotor (BBNKB) : TARIF x NJKB x PENGENAAN"
|
| 821 |
+
if scores[1] > w_avg:
|
| 822 |
out += "\nRumus Pokok Pajak Kendaraan Bermotor (PKB) : TARIF * NJKB * BOBOT * PENGENAAN"
|
| 823 |
|
| 824 |
return out
|