Text Generation
Transformers
PyTorch
Safetensors
Chinese
English
kclgpt
codeshell
wisdomshell
pku-kcl
openbankai
custom_code
Instructions to use WisdomShell/CodeShell-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use WisdomShell/CodeShell-7B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="WisdomShell/CodeShell-7B", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("WisdomShell/CodeShell-7B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use WisdomShell/CodeShell-7B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "WisdomShell/CodeShell-7B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "WisdomShell/CodeShell-7B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/WisdomShell/CodeShell-7B
- SGLang
How to use WisdomShell/CodeShell-7B 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 "WisdomShell/CodeShell-7B" \ --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": "WisdomShell/CodeShell-7B", "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 "WisdomShell/CodeShell-7B" \ --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": "WisdomShell/CodeShell-7B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use WisdomShell/CodeShell-7B with Docker Model Runner:
docker model run hf.co/WisdomShell/CodeShell-7B
Update configuration_codeshell.py
Browse files16 unmodified lines171819202122237 unmodified lines3132333435363713 unmodified lines5152535455565728 unmodified lines8687888990919216 unmodified lines# its original forms to accommodate minor architectural differences compared to# GPTBigCode Configuration that trained the model.# coding=utf-8# Copyright 2023 The BigCode team and HuggingFace Inc. team.## Licensed under the Apache License, Version 2.0 (the "License");7 unmodified lines# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.""" CodeShell configuration"""from transformers.configuration_utils import PretrainedConfigfrom transformers.utils import logging13 unmodified linesArgs:vocab_size (`int`, *optional*, defaults to 50257):Vocabulary size of the GPT-2 model. Defines the number of different tokens that can be represented by the`inputs_ids` passed when calling [`CodeShellModel`].n_positions (`int`, *optional*, defaults to 1024):The maximum sequence length that this model might ever be used with. Typically set this to something largejust in case (e.g., 512 or 1024 or 2048).28 unmodified linesWhether to scale the attention softmax in float32.attention_type (`bool`, *optional*, defaults to `True`):Whether to use Multi-Query Attion (`True`) or Multi-Head Attention (`False`)."""model_type = "codeshell"keys_to_ignore_at_inference = ["past_key_values"]16 unmodified lines1718192021227 unmodified lines3031323334353613 unmodified lines5051525354555628 unmodified lines85868788899091929394959697989910010110210310410516 unmodified lines# its original forms to accommodate minor architectural differences compared to# GPTBigCode Configuration that trained the model.# Copyright 2023 The BigCode team and HuggingFace Inc. team.## Licensed under the Apache License, Version 2.0 (the "License");7 unmodified lines# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.""" Shell configuration"""from transformers.configuration_utils import PretrainedConfigfrom transformers.utils import logging13 unmodified linesArgs:vocab_size (`int`, *optional*, defaults to 50257):Vocabulary size of the GPT-2 model. Defines the number of different tokens that can be represented by the`inputs_ids` passed when calling [`ShellModel`].n_positions (`int`, *optional*, defaults to 1024):The maximum sequence length that this model might ever be used with. Typically set this to something largejust in case (e.g., 512 or 1024 or 2048).28 unmodified linesWhether to scale the attention softmax in float32.attention_type (`bool`, *optional*, defaults to `True`):Whether to use Multi-Query Attion (`True`) or Multi-Head Attention (`False`).Example:```python>>> from configuration_codeshell import CodeShellConfig>>> from modeling_codeshell import CodeShellForCausalLM>>> # Initializing a CodeShell configuration>>> configuration = CodeShellConfig()>>> # Initializing a model (with random weights) from the configuration>>> model = CodeShellForCausalLM(configuration)>>> # Accessing the model configuration>>> configuration = model.config```"""model_type = "codeshell"keys_to_ignore_at_inference = ["past_key_values"]
configuration_codeshell.py+17-4