Instructions to use hsultanbey/codegen2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hsultanbey/codegen2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="hsultanbey/codegen2", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("hsultanbey/codegen2", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("hsultanbey/codegen2", trust_remote_code=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use hsultanbey/codegen2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "hsultanbey/codegen2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hsultanbey/codegen2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/hsultanbey/codegen2
- SGLang
How to use hsultanbey/codegen2 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 "hsultanbey/codegen2" \ --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": "hsultanbey/codegen2", "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 "hsultanbey/codegen2" \ --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": "hsultanbey/codegen2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use hsultanbey/codegen2 with Docker Model Runner:
docker model run hf.co/hsultanbey/codegen2
Commit ·
36f713f
1
Parent(s): dba126f
Upload CodeGenForCausalLM
Browse files- config.json +49 -0
- generation_config.json +6 -0
- pytorch_model.bin +3 -0
config.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "Salesforce/codegen2-1B",
|
| 3 |
+
"activation_function": "gelu_new",
|
| 4 |
+
"architectures": [
|
| 5 |
+
"CodeGenForCausalLM"
|
| 6 |
+
],
|
| 7 |
+
"attn_pdrop": 0.0,
|
| 8 |
+
"auto_map": {
|
| 9 |
+
"AutoConfig": "Salesforce/codegen2-1B--configuration_codegen.CodeGenConfig",
|
| 10 |
+
"AutoModel": "Salesforce/codegen2-1B--modeling_codegen.CodeGenModel",
|
| 11 |
+
"AutoModelForCausalLM": "Salesforce/codegen2-1B--modeling_codegen.CodeGenForCausalLM"
|
| 12 |
+
},
|
| 13 |
+
"bos_token_id": 1,
|
| 14 |
+
"embd_pdrop": 0.0,
|
| 15 |
+
"eos_token_id": 2,
|
| 16 |
+
"gradient_checkpointing": false,
|
| 17 |
+
"head_dim": 128,
|
| 18 |
+
"initializer_range": 0.02,
|
| 19 |
+
"layer_norm_epsilon": 1e-05,
|
| 20 |
+
"model_type": "codegen",
|
| 21 |
+
"n_ctx": 2048,
|
| 22 |
+
"n_embd": 2048,
|
| 23 |
+
"n_head": 16,
|
| 24 |
+
"n_inner": null,
|
| 25 |
+
"n_layer": 16,
|
| 26 |
+
"n_positions": 2048,
|
| 27 |
+
"resid_pdrop": 0.0,
|
| 28 |
+
"rotary_dim": 64,
|
| 29 |
+
"scale_attn_weights": true,
|
| 30 |
+
"summary_activation": null,
|
| 31 |
+
"summary_first_dropout": 0.1,
|
| 32 |
+
"summary_proj_to_labels": true,
|
| 33 |
+
"summary_type": "cls_index",
|
| 34 |
+
"summary_use_proj": true,
|
| 35 |
+
"task_specific_params": {
|
| 36 |
+
"text-generation": {
|
| 37 |
+
"do_sample": true,
|
| 38 |
+
"max_length": 50,
|
| 39 |
+
"temperature": 1.0
|
| 40 |
+
}
|
| 41 |
+
},
|
| 42 |
+
"tie_word_embeddings": false,
|
| 43 |
+
"tokenizer_class": "GPT2Tokenizer",
|
| 44 |
+
"torch_dtype": "float32",
|
| 45 |
+
"transformers_version": "4.31.0.dev0",
|
| 46 |
+
"trust_remote_code": true,
|
| 47 |
+
"use_cache": true,
|
| 48 |
+
"vocab_size": 51200
|
| 49 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 1,
|
| 4 |
+
"eos_token_id": 2,
|
| 5 |
+
"transformers_version": "4.31.0.dev0"
|
| 6 |
+
}
|
pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:93dfc7e2d5018ef54b8ff5b86d2d26bffa3eb9b39d62579467a1f4a2f691a587
|
| 3 |
+
size 4128382753
|