MCPcopy
hub / github.com/lm-sys/FastChat / load_model

Method load_model

fastchat/model/model_adapter.py:1761–1776  ·  view source on GitHub ↗
(self, model_path: str, from_pretrained_kwargs: dict)

Source from the content-addressed store, hash-verified

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")

Callers 10

load_modelFunction · 0.45
load_modelMethod · 0.45
load_modelMethod · 0.45
load_modelMethod · 0.45
load_modelMethod · 0.45
load_modelMethod · 0.45
load_modelMethod · 0.45
load_modelMethod · 0.45
load_modelMethod · 0.45
load_modelMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected