Run this model with HF Jobs
Run Salesforce/codegen-6B-nl on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/Salesforce/codegen-6B-nl. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/Salesforce/codegen-6B-nl on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/Salesforce/codegen-6B-nl. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/Salesforce/codegen-6B-nl. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use Salesforce/codegen-6B-nl with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Salesforce/codegen-6B-nl with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Salesforce/codegen-6B-nl")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Salesforce/codegen-6B-nl") model = AutoModelForCausalLM.from_pretrained("Salesforce/codegen-6B-nl", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Salesforce/codegen-6B-nl with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Salesforce/codegen-6B-nl" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Salesforce/codegen-6B-nl", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Salesforce/codegen-6B-nl
- SGLang
How to use Salesforce/codegen-6B-nl 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 "Salesforce/codegen-6B-nl" \ --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": "Salesforce/codegen-6B-nl", "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 "Salesforce/codegen-6B-nl" \ --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": "Salesforce/codegen-6B-nl", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Salesforce/codegen-6B-nl with Docker Model Runner:
docker model run hf.co/Salesforce/codegen-6B-nl
Initial commit
Browse filesFiles changed (8)
- README.md+53
- config.jsonAdded+41
- merges.txtAdded
- pytorch_model.binAdded+3
- special_tokens_map.jsonAdded+1
- tokenizer.jsonAdded
- tokenizer_config.jsonAdded+1
- vocab.jsonAdded
123---license: bsd-3-clause---1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556---license: bsd-3-clause---# CodeGen (CodeGen-NL 6B)## Model descriptionCodeGen is a family of autoregressive language models for **program synthesis** from the paper: [A Conversational Paradigm for Program Synthesis](https://arxiv.org/abs/2203.13474) by Erik Nijkamp, Bo Pang, Hiroaki Hayashi, Lifu Tu, Huan Wang, Yingbo Zhou, Silvio Savarese, Caiming Xiong. The models are originally released in [this repository](https://github.com/salesforce/CodeGen), under 3 pre-training data variants (`NL`, `Multi`, `Mono`) and 4 model size variants (`350M`, `2B`, `6B`, `16B`).The checkpoint included in this repository is denoted as **CodeGen-NL 6B** in the paper, where "NL" means it is pre-trained on the Pile and "6B" refers to the number of trainable parameters.## Training dataThis checkpoint (CodeGen-NL 6B) was pre-trained on [the Pile](https://github.com/EleutherAI/the-pile), a large-scale curated dataset created by [EleutherAI](https://www.eleuther.ai/). Parts of the dataset include code data.## Training procedureCodeGen was trained using cross-entropy loss to maximize the likelihood of sequential inputs.The family of models are trained using 4 TPU-v4 chips by Google, leveraging data and model parallelism.See Section 2.3 of the [paper](https://arxiv.org/abs/2203.13474) for more details.## Evaluation resultsWe evaluate our models on two code generation benchmark: HumanEval and MTPB. Please refer to the [paper](https://arxiv.org/abs/2203.13474) for more details.## Intended Use and LimitationsAs an autoregressive language model, CodeGen is capable of extracting features from given natural language and programming language texts, and calculating the likelihood of them.However, the model is intended for and best at **program synthesis**, that is, generating executable code given English prompts, where the prompts should be in the form of a comment string. The model can complete partially-generated code as well.## How to useThis model can be easily loaded using the `AutoModelForCausalLM` functionality:```pythonfrom transformers import AutoTokenizer, AutoModelForCausalLMtokenizer = AutoTokenizer.from_pretrained('Salesforce/codegen-6B-nl')model = AutoModelForCausalLM.from_pretrained('Salesforce/codegen-6B-nl')text = "def hello_world():"input_ids = tokenizer(text, return_tensors="pt").input_idsgenerated_ids = model.generate(input_ids, max_length=128)print(tokenizer.decode(generated_ids[0], skip_special_tokens=True))```## BibTeX entry and citation info```bibtex@article{Nijkamp2022ACP,title={A Conversational Paradigm for Program Synthesis},author={Nijkamp, Erik and Pang, Bo and Hayashi, Hiroaki and Tu, Lifu and Wang, Huan and Zhou, Yingbo and Savarese, Silvio and Xiong, Caiming},journal={arXiv preprint},year={2022}}```
1234567891011121314151617181920212223242526272829303132333435363738394041{ "_name_or_path": "codegen-6B-nl", "activation_function": "gelu_new", "architectures": [ "CodeGenForCausalLM" ], "attn_pdrop": 0.0, "bos_token_id": 1, "embd_pdrop": 0.0, "eos_token_id": 2, "gradient_checkpointing": false, "initializer_range": 0.02, "layer_norm_epsilon": 1e-05, "model_type": "codegen", "n_ctx": 2048, "n_embd": 4096, "n_head": 16, "n_inner": null, "n_layer": 33, "n_positions": 2048, "resid_pdrop": 0.0, "rotary_dim": 64, "scale_attn_weights": true, "summary_activation": null, "summary_first_dropout": 0.1, "summary_proj_to_labels": true, "summary_type": "cls_index", "summary_use_proj": true, "task_specific_params": { "text-generation": { "do_sample": true, "max_length": 50, "temperature": 1.0 } }, "tokenizer_class": "GPT2Tokenizer", "torch_dtype": "float16", "transformers_version": "4.16.2", "use_cache": true, "vocab_size": 51200}123version https://git-lfs.github.com/spec/v1oid sha256:fe50e2bcbd63fd4a06f2af033761435ceb5c34ba7ef2fe95149c070f9ee3705bsize 141327322791{"bos_token": "<|endoftext|>", "eos_token": "<|endoftext|>", "unk_token": "<|endoftext|>"}1{"unk_token": "<|endoftext|>", "bos_token": "<|endoftext|>", "eos_token": "<|endoftext|>", "add_prefix_space": false, "model_max_length": 1024, "special_tokens_map_file": null, "name_or_path": "gpt2", "tokenizer_class": "GPT2Tokenizer"}README.md+53
config.jsonAdded+41
merges.txtAdded
pytorch_model.binAdded+3
special_tokens_map.jsonAdded+1
tokenizer.jsonAdded
tokenizer_config.jsonAdded+1
vocab.jsonAdded