Instructions to use ammarnasr/codegen2-1B-react with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ammarnasr/codegen2-1B-react with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ammarnasr/codegen2-1B-react", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ammarnasr/codegen2-1B-react", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("ammarnasr/codegen2-1B-react", trust_remote_code=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ammarnasr/codegen2-1B-react with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ammarnasr/codegen2-1B-react" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ammarnasr/codegen2-1B-react", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ammarnasr/codegen2-1B-react
- SGLang
How to use ammarnasr/codegen2-1B-react 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 "ammarnasr/codegen2-1B-react" \ --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": "ammarnasr/codegen2-1B-react", "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 "ammarnasr/codegen2-1B-react" \ --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": "ammarnasr/codegen2-1B-react", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ammarnasr/codegen2-1B-react with Docker Model Runner:
docker model run hf.co/ammarnasr/codegen2-1B-react
Update config.json
Browse files- config.json +7 -7
config.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
| 1 |
{
|
| 2 |
-
"_name_or_path": "
|
| 3 |
"activation_function": "gelu_new",
|
| 4 |
"architectures": [
|
| 5 |
"CodeGenForCausalLM"
|
| 6 |
],
|
| 7 |
"attn_pdrop": 0.0,
|
| 8 |
"auto_map": {
|
| 9 |
-
"AutoConfig": "
|
| 10 |
-
"AutoModel": "
|
| 11 |
-
"AutoModelForCausalLM": "
|
| 12 |
},
|
| 13 |
"bos_token_id": 1,
|
| 14 |
"embd_pdrop": 0.0,
|
|
@@ -26,6 +26,7 @@
|
|
| 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,
|
|
@@ -42,8 +43,7 @@
|
|
| 42 |
"tie_word_embeddings": false,
|
| 43 |
"tokenizer_class": "GPT2Tokenizer",
|
| 44 |
"torch_dtype": "float32",
|
| 45 |
-
"transformers_version": "4.
|
| 46 |
-
"trust_remote_code": true,
|
| 47 |
"use_cache": true,
|
| 48 |
"vocab_size": 51200
|
| 49 |
-
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"_name_or_path": "checkpoints/codegen2-1B/",
|
| 3 |
"activation_function": "gelu_new",
|
| 4 |
"architectures": [
|
| 5 |
"CodeGenForCausalLM"
|
| 6 |
],
|
| 7 |
"attn_pdrop": 0.0,
|
| 8 |
"auto_map": {
|
| 9 |
+
"AutoConfig": "configuration_codegen.CodeGenConfig",
|
| 10 |
+
"AutoModel": "modeling_codegen.CodeGenModel",
|
| 11 |
+
"AutoModelForCausalLM": "modeling_codegen.CodeGenForCausalLM"
|
| 12 |
},
|
| 13 |
"bos_token_id": 1,
|
| 14 |
"embd_pdrop": 0.0,
|
|
|
|
| 26 |
"n_positions": 2048,
|
| 27 |
"resid_pdrop": 0.0,
|
| 28 |
"rotary_dim": 64,
|
| 29 |
+
"trust_remote_code":true,
|
| 30 |
"scale_attn_weights": true,
|
| 31 |
"summary_activation": null,
|
| 32 |
"summary_first_dropout": 0.1,
|
|
|
|
| 43 |
"tie_word_embeddings": false,
|
| 44 |
"tokenizer_class": "GPT2Tokenizer",
|
| 45 |
"torch_dtype": "float32",
|
| 46 |
+
"transformers_version": "4.25.1",
|
|
|
|
| 47 |
"use_cache": true,
|
| 48 |
"vocab_size": 51200
|
| 49 |
+
}
|