Abstract base class for large language models.
| 26 | |
| 27 | |
| 28 | class LLM(ABC): |
| 29 | """Abstract base class for large language models.""" |
| 30 | |
| 31 | @abstractmethod |
| 32 | def generate_text(self, prompt): |
| 33 | """Generates text from the model. |
| 34 | Parameters: |
| 35 | prompt: The prompt to use. This can be a string or a list of strings. |
| 36 | Returns: |
| 37 | A list of strings. |
| 38 | """ |
| 39 | pass |
| 40 | |
| 41 | @abstractmethod |
| 42 | def log_probs(self, text, log_prob_range): |
| 43 | """Returns the log probs of the text. |
| 44 | Parameters: |
| 45 | text: The text to get the log probs of. This can be a string or a list of strings. |
| 46 | log_prob_range: The range of characters within each string to get the log_probs of. |
| 47 | This is a list of tuples of the form (start, end). |
| 48 | Returns: |
| 49 | A list of log probs. |
| 50 | """ |
| 51 | pass |
| 52 | |
| 53 | |
| 54 | class GPT_Forward(LLM): |