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 lines171819202021227 unmodified lines303132343334353613 unmodified lines505152545354555628 unmodified lines8586878988899091929394959697989910010110210310410516 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"""""" Shell configuration"""
from transformers.configuration_utils import PretrainedConfigfrom transformers.utils import logging13 unmodified lines Args: 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`]. `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 large just in case (e.g., 512 or 1024 or 2048).28 unmodified lines Whether 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