Spaces:
Paused
Paused
Arturo Jiménez de los Galanes Reguillos
commited on
Commit
·
0a193bf
1
Parent(s):
b9f87ba
Refactor to fit model recomended usage
Browse files
app.py
CHANGED
@@ -33,8 +33,15 @@ streamer = TextIteratorStreamer(tokenizer)
|
|
33 |
|
34 |
cplusplus = None
|
35 |
def translate(python):
|
36 |
-
inputs = tokenizer(messages_for(python), return_tensors="pt")
|
37 |
-
generation_kwargs = dict(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
thread = Thread(target=model.generate, kwargs=generation_kwargs)
|
39 |
thread.start()
|
40 |
cplusplus = ""
|
|
|
33 |
|
34 |
cplusplus = None
|
35 |
def translate(python):
|
36 |
+
inputs = tokenizer.apply_chat_template(messages_for(python), return_tensors="pt").to(model.device)
|
37 |
+
generation_kwargs = dict(
|
38 |
+
inputs,
|
39 |
+
streamer=streamer,
|
40 |
+
max_new_tokens=1024,
|
41 |
+
do_sample=False,
|
42 |
+
pad_token_id=tokenizer.eos_token_id,
|
43 |
+
eos_token_id=tokenizer.eos_token_id
|
44 |
+
)
|
45 |
thread = Thread(target=model.generate, kwargs=generation_kwargs)
|
46 |
thread.start()
|
47 |
cplusplus = ""
|