(self, model_path: str, from_pretrained_kwargs: dict)
| 1759 | return "e5-" in model_path.lower() |
| 1760 | |
| 1761 | def load_model(self, model_path: str, from_pretrained_kwargs: dict): |
| 1762 | revision = from_pretrained_kwargs.get("revision", "main") |
| 1763 | model = AutoModel.from_pretrained( |
| 1764 | model_path, |
| 1765 | **from_pretrained_kwargs, |
| 1766 | ) |
| 1767 | tokenizer = AutoTokenizer.from_pretrained( |
| 1768 | model_path, trust_remote_code=True, revision=revision |
| 1769 | ) |
| 1770 | if hasattr(model.config, "max_position_embeddings") and hasattr( |
| 1771 | tokenizer, "model_max_length" |
| 1772 | ): |
| 1773 | model.config.max_sequence_length = min( |
| 1774 | model.config.max_position_embeddings, tokenizer.model_max_length |
| 1775 | ) |
| 1776 | return model, tokenizer |
| 1777 | |
| 1778 | def get_default_conv_template(self, model_path: str) -> Conversation: |
| 1779 | return get_conv_template("one_shot") |
no outgoing calls
no test coverage detected