MCPcopy Create free account
hub / github.com/OpenBMB/ToolBench / VicunaAdapter

Class VicunaAdapter

toolbench/model/model_adapter.py:218–246  ·  view source on GitHub ↗

Model adapater for vicuna-v1.1

Source from the content-addressed store, hash-verified

216
217
218class VicunaAdapter(BaseAdapter):
219 "Model adapater for vicuna-v1.1"
220
221 def match(self, model_path: str):
222 return "vicuna" in model_path
223
224 def load_model(self, model_path: str, from_pretrained_kwargs: dict):
225 tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False)
226 model = AutoModelForCausalLM.from_pretrained(
227 model_path,
228 low_cpu_mem_usage=True,
229 **from_pretrained_kwargs,
230 )
231 self.raise_warning_for_old_weights(model)
232 return model, tokenizer
233
234 def get_default_conv_template(self, model_path: str) -> Conversation:
235 return get_conv_template("vicuna-v1.1")
236
237 def raise_warning_for_old_weights(self, model):
238 if isinstance(model, LlamaForCausalLM) and model.model.vocab_size > 32000:
239 warnings.warn(
240 "\nYou are probably using the old Vicuna-v0 model, "
241 "which will generate unexpected results with the "
242 "current toolbench.\nYou can try one of the following methods:\n"
243 "1. Upgrade your weights to the new Vicuna-v1.1: https://github.com/lm-sys/FastChat#vicuna-weights.\n"
244 "2. Use the old conversation template by `python3 -m toolbench.serve.cli --model-path /path/to/vicuna-v0 --conv-template conv_one_shot`\n"
245 "3. Downgrade fschat to fschat==0.1.10 (Not recommonded).\n"
246 )
247
248
249class ToolLlamaAdapter(BaseAdapter):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected