ngrigg commited on
Commit
784fe5f
1 Parent(s): 1232177

Fix attention mask and padding token ID warning

Browse files
Files changed (1) hide show
  1. llama_models.py +6 -2
llama_models.py CHANGED
@@ -19,8 +19,12 @@ def load_model(model_name):
19
  return tokenizer, model
20
 
21
  async def process_text_local(model_name, text):
 
22
  tokenizer, model = load_model(model_name)
23
- inputs = tokenizer.encode(text, return_tensors="pt")
24
- outputs = model.generate(inputs, max_length=512)
 
 
 
25
  result = tokenizer.decode(outputs[0], skip_special_tokens=True)
26
  return result
 
19
  return tokenizer, model
20
 
21
  async def process_text_local(model_name, text):
22
+ print("Loading model and tokenizer...")
23
  tokenizer, model = load_model(model_name)
24
+ print("Encoding text...")
25
+ inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
26
+ print("Generating output...")
27
+ outputs = model.generate(**inputs, max_length=512)
28
+ print("Decoding output...")
29
  result = tokenizer.decode(outputs[0], skip_special_tokens=True)
30
  return result