| 63 | return model, tokenizer, device |
| 64 | |
| 65 | def preprocess_input(tokenizer, system_prompt, initial_query): |
| 66 | combined_input = f"{system_prompt}\n\nUser: {initial_query}" |
| 67 | encoding = tokenizer.encode_plus( |
| 68 | combined_input, |
| 69 | add_special_tokens=True, |
| 70 | max_length=MAX_LENGTH, |
| 71 | padding='max_length', |
| 72 | truncation=True, |
| 73 | return_attention_mask=True, |
| 74 | return_tensors='pt' |
| 75 | ) |
| 76 | return encoding['input_ids'], encoding['attention_mask'] |
| 77 | |
| 78 | def predict_approach(model, input_ids, attention_mask, device, effort=0.7): |
| 79 | model.eval() |