Instructions to use bigcode/starcoderplus with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use bigcode/starcoderplus with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="bigcode/starcoderplus")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("bigcode/starcoderplus") model = AutoModelForCausalLM.from_pretrained("bigcode/starcoderplus", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use bigcode/starcoderplus with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "bigcode/starcoderplus" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bigcode/starcoderplus", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/bigcode/starcoderplus
- SGLang
How to use bigcode/starcoderplus with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "bigcode/starcoderplus" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bigcode/starcoderplus", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "bigcode/starcoderplus" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bigcode/starcoderplus", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use bigcode/starcoderplus with Docker Model Runner:
docker model run hf.co/bigcode/starcoderplus
Bug in loading model
#4
by tginart - opened
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In[4], line 9
6 device = "cuda" # for GPU usage or "cpu" for CPU usage
8 tokenizer = AutoTokenizer.from_pretrained(checkpoint)
----> 9 model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
11 inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to(device)
12 outputs = model.generate(inputs)
File /usr/lib/python3/dist-packages/transformers/models/auto/auto_factory.py:434, in _BaseAutoModelClass.from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
432 hub_kwargs = {name: kwargs.pop(name) for name in hub_kwargs_names if name in kwargs}
433 if not isinstance(config, PretrainedConfig):
--> 434 config, kwargs = AutoConfig.from_pretrained(
435 pretrained_model_name_or_path,
436 return_unused_kwargs=True,
437 trust_remote_code=trust_remote_code,
438 **hub_kwargs,
439 **kwargs,
440 )
441 if hasattr(config, "auto_map") and cls.__name__ in config.auto_map:
442 if not trust_remote_code:
File /usr/lib/python3/dist-packages/transformers/models/auto/configuration_auto.py:873, in AutoConfig.from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
871 return config_class.from_pretrained(pretrained_model_name_or_path, **kwargs)
872 elif "model_type" in config_dict:
--> 873 config_class = CONFIG_MAPPING[config_dict["model_type"]]
874 return config_class.from_dict(config_dict, **unused_kwargs)
875 else:
876 # Fallback: use pattern matching on the string.
877 # We go from longer names to shorter names to catch roberta before bert (for instance)
File /usr/lib/python3/dist-packages/transformers/models/auto/configuration_auto.py:579, in _LazyConfigMapping.__getitem__(self, key)
577 return self._extra_content[key]
578 if key not in self._mapping:
--> 579 raise KeyError(key)
580 value = self._mapping[key]
581 module_name = model_type_to_module_name(key)
KeyError: 'gpt_bigcode'
@tginart May I know your transformers' version? You should upgrade it to the latest version to make it work with gpt_bigcode.
Like Qian suggested, you need transformers>=4.28.1 to be able to load the model
Thank you!
tginart changed discussion status to closed