Update app.py
Browse files
app.py
CHANGED
@@ -62,6 +62,29 @@ llm_model = None
|
|
62 |
|
63 |
def trans(text):
|
64 |
text = "γγγ«γ‘γ―"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
# γγγΉγγ«θ¨θͺγΏγ°γδ»δΈγγγγ€γεγ«ε€ζ
|
67 |
input_text = f"<2ja>{text}".encode('utf-8')
|
|
|
62 |
|
63 |
def trans(text):
|
64 |
text = "γγγ«γ‘γ―"
|
65 |
+
|
66 |
+
# γγγΉγγ«θ¨θͺγΏγ°γδ»δΈγγγγ€γεγ«ε€ζ
|
67 |
+
input_text = f"<2ja>{text}".encode('utf-8')
|
68 |
+
|
69 |
+
# γγΌγ―γγ€γΊ
|
70 |
+
tokens = llm.tokenize(input_text)
|
71 |
+
print("Tokens:", tokens)
|
72 |
+
|
73 |
+
# BOSγγΌγ―γ³γεεΎγγη’Ίθͺ
|
74 |
+
bos_token = llm.token_bos()
|
75 |
+
print("BOS Token:", bos_token)
|
76 |
+
initial_tokens = [bos_token]
|
77 |
+
print("Initial Tokens:", initial_tokens)
|
78 |
+
|
79 |
+
# ηζ
|
80 |
+
buf = ""
|
81 |
+
for token in llm.generate(initial_tokens, top_p=0.95, temp=0.0, repeat_penalty=1.0):
|
82 |
+
decoded = llm.detokenize([token]).decode('utf-8', errors='ignore')
|
83 |
+
buf += decoded
|
84 |
+
if token == llm.token_eos():
|
85 |
+
break
|
86 |
+
|
87 |
+
return buf
|
88 |
|
89 |
# γγγΉγγ«θ¨θͺγΏγ°γδ»δΈγγγγ€γεγ«ε€ζ
|
90 |
input_text = f"<2ja>{text}".encode('utf-8')
|