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
Upload folder using huggingface_hub
Browse filesFiles changed (5)
98 unmodified lines991001011021031041051061071081093 unmodified lines11311411511611711811912098 unmodified linesdef __init__(self,vocab_size=50257,n_positions=1024,n_embd=768,n_layer=12,n_head=12,n_inner=None,activation_function="gelu_pytorch_tanh",resid_pdrop=0.1,3 unmodified linesinitializer_range=0.02,scale_attn_weights=True,use_cache=True,bos_token_id=50256,eos_token_id=50256,attention_softmax_in_fp32=True,scale_attention_softmax_in_fp32=True,group_query_attention=True,98 unmodified lines991001011021031041051061071081093 unmodified lines11311411511611711811912098 unmodified linesdef __init__(self,vocab_size=70144,n_positions=8192,n_embd=4096,n_layer=42,n_head=32,n_inner=None,activation_function="gelu_pytorch_tanh",resid_pdrop=0.1,3 unmodified linesinitializer_range=0.02,scale_attn_weights=True,use_cache=True,bos_token_id=70000,eos_token_id=70000,attention_softmax_in_fp32=True,scale_attention_softmax_in_fp32=True,group_query_attention=True,
123version https://git-lfs.github.com/spec/v1oid sha256:35affc26417d78eaaeaeb0dad037c4d1b7632018413b742892ea4bd72aac18fdsize 9955659648123version https://git-lfs.github.com/spec/v1oid sha256:911eb9034a0be6d4dde83bb2957d89bb0dcf3ad153737e6a58e455f0c05c071asize 9955659648
123version https://git-lfs.github.com/spec/v1oid sha256:24eb05f7e6c43d3bb2d3cd51d14bf6063fd8b37e6df3d193423ba3c10c1d3da5size 5420501688123version https://git-lfs.github.com/spec/v1oid sha256:19377de31c1b367d59a3470329b2e1b09ab5eda4f4dafbaba03ed8a4095060a3size 5420501688
123try:import bitsandbytes as bnbfrom bitsandbytes.nn.modules import Params4bit, Int8Params123456789101112131415161718# coding=utf-8# Copyright 2023 WisdomShell Inc. All Rights Reserved.# Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# 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.try:import bitsandbytes as bnbfrom bitsandbytes.nn.modules import Params4bit, Int8Params
configuration_codeshell.py+7-7
merges.txtAdded
model-00001-of-00002.safetensors+1-1
model-00002-of-00002.safetensors+1-1
quantizer.py+15