(tokenizer, prompt, tokenizer_max_length=None)
| 769 | |
| 770 | |
| 771 | def tokenize_prompt(tokenizer, prompt, tokenizer_max_length=None): |
| 772 | if tokenizer_max_length is not None: |
| 773 | max_length = tokenizer_max_length |
| 774 | else: |
| 775 | max_length = tokenizer.model_max_length |
| 776 | |
| 777 | text_inputs = tokenizer( |
| 778 | prompt, |
| 779 | truncation=True, |
| 780 | padding="max_length", |
| 781 | max_length=max_length, |
| 782 | return_tensors="pt", |
| 783 | ) |
| 784 | |
| 785 | return text_inputs |
| 786 | |
| 787 | |
| 788 | def encode_prompt(text_encoder, input_ids, attention_mask, text_encoder_use_attention_mask=None): |
no outgoing calls
no test coverage detected