Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -38,7 +38,15 @@ def load_model():
|
|
38 |
def clean_text(text):
|
39 |
model, tokenizer = load_model()
|
40 |
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
inputs = {k: v.cuda() for k, v in inputs.items()}
|
43 |
|
44 |
# Enable streaming
|
|
|
38 |
def clean_text(text):
|
39 |
model, tokenizer = load_model()
|
40 |
|
41 |
+
# Apply chat template
|
42 |
+
messages = [
|
43 |
+
{"role": "user", "content": text}
|
44 |
+
]
|
45 |
+
|
46 |
+
# Apply the chat template
|
47 |
+
formatted_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
48 |
+
|
49 |
+
inputs = tokenizer(formatted_text, return_tensors="pt", max_length=4096, truncation=True)
|
50 |
inputs = {k: v.cuda() for k, v in inputs.items()}
|
51 |
|
52 |
# Enable streaming
|