Salesforce / codegen2-3_7B_P

huggingface.co
Total runs: 71
24-hour runs: -4
7-day runs: -44
30-day runs: -100
Model's Last Updated: July 06 2023
text-generation

Introduction of codegen2-3_7B_P

Model Details of codegen2-3_7B_P

CodeGen2 (CodeGen2-3.7B)

Model description

CodeGen2 is a family of autoregressive language models for program synthesis , introduced in the paper:

CodeGen2: Lessons for Training LLMs on Programming and Natural Languages by Erik Nijkamp*, Hiroaki Hayashi*, Caiming Xiong, Silvio Savarese, Yingbo Zhou.

Unlike the original CodeGen model family (i.e., CodeGen1), CodeGen2 is capable of infilling, and supports more programming languages.

Four model sizes are released: 1B , 3.7B , 7B , 16B .

How to use

This model can be easily loaded using the AutoModelForCausalLM functionality.

Causal sampling

For regular causal sampling, simply generate completions given the context:

from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("Salesforce/codegen2-3_7B")
model = AutoModelForCausalLM.from_pretrained("Salesforce/codegen2-3_7B", trust_remote_code=True, revision="main")

text = "def hello_world():"
input_ids = tokenizer(text, return_tensors="pt").input_ids
generated_ids = model.generate(input_ids, max_length=128)
print(tokenizer.decode(generated_ids[0], skip_special_tokens=True))
Infill sampling

For infill sampling, we introduce three new special token types:

  • <mask_N> : N-th span to be masked. In practice, use <mask_1> to where you want to sample infill.
  • <sep> : Separator token between the suffix and the infilled sample. See below.
  • <eom> : "End-Of-Mask" token that model will output at the end of infilling. You may use this token to truncate the output.

For example, if we want to generate infill for the following cursor position of a function:

def hello_world():
    |
    return name

we construct an input to the model by

  1. Inserting <mask_1> token in place of cursor position
  2. Append <sep> token to indicate the boundary
  3. Insert another <mask_1> to indicate which mask we want to infill.

The final snippet looks as follows:

from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("Salesforce/codegen2-3_7B")
model = AutoModelForCausalLM.from_pretrained("Salesforce/codegen2-3_7B", trust_remote_code=True, revision="main")


def format(prefix, suffix):
  return prefix + "<mask_1>" + suffix + "<|endoftext|>" + "<sep>" + "<mask_1>"


prefix = "def hello_world():\n    "
suffix = "    return name"
text = format(prefix, suffix)
input_ids = tokenizer(text, return_tensors="pt").input_ids
generated_ids = model.generate(input_ids, max_length=128)
print(tokenizer.decode(generated_ids[0], skip_special_tokens=False)[len(text):])

You might want to truncate the model output with <eom> .

Training data

This checkpoint is trained on the stricter permissive subset of the deduplicated version of the Stack dataset (v1.1) . Supported languages (and frameworks) are as follows: c , c++ , c-sharp , dart , go , java , javascript , kotlin , lua , php , python , ruby , rust , scala , shell , sql , swift , typescript , vue .

Training procedure

CodeGen2 was trained using cross-entropy loss to maximize the likelihood of sequential inputs. The input sequences are formatted in two ways: (1) causal language modeling and (2) file-level span corruption. Please refer to the paper for more details.

Evaluation results

We evaluate our models on HumanEval and HumanEval-Infill. Please refer to the paper for more details.

Intended use and limitations

As an autoregressive language model, CodeGen2 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.

BibTeX entry and citation info
@article{Nijkamp2023codegen2,
  title={CodeGen2: Lessons for Training LLMs on Programming and Natural Languages},
  author={Nijkamp, Erik and Hayashi, Hiroaki and Xiong, Caiming and Savarese, Silvio and Zhou, Yingbo},
  journal={arXiv preprint},
  year={2023}
}

Runs of Salesforce codegen2-3_7B_P on huggingface.co

71
Total runs
-4
24-hour runs
-29
3-day runs
-44
7-day runs
-100
30-day runs

More Information About codegen2-3_7B_P huggingface.co Model

More codegen2-3_7B_P license Visit here:

https://choosealicense.com/licenses/apache-2.0

codegen2-3_7B_P huggingface.co

codegen2-3_7B_P huggingface.co is an AI model on huggingface.co that provides codegen2-3_7B_P's model effect (), which can be used instantly with this Salesforce codegen2-3_7B_P model. huggingface.co supports a free trial of the codegen2-3_7B_P model, and also provides paid use of the codegen2-3_7B_P. Support call codegen2-3_7B_P model through api, including Node.js, Python, http.

codegen2-3_7B_P huggingface.co Url

https://huggingface.co/Salesforce/codegen2-3_7B_P

Salesforce codegen2-3_7B_P online free

codegen2-3_7B_P huggingface.co is an online trial and call api platform, which integrates codegen2-3_7B_P's modeling effects, including api services, and provides a free online trial of codegen2-3_7B_P, you can try codegen2-3_7B_P online for free by clicking the link below.

Salesforce codegen2-3_7B_P online free url in huggingface.co:

https://huggingface.co/Salesforce/codegen2-3_7B_P

codegen2-3_7B_P install

codegen2-3_7B_P is an open source model from GitHub that offers a free installation service, and any user can find codegen2-3_7B_P on GitHub to install. At the same time, huggingface.co provides the effect of codegen2-3_7B_P install, users can directly use codegen2-3_7B_P installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

codegen2-3_7B_P install url in huggingface.co:

https://huggingface.co/Salesforce/codegen2-3_7B_P

Url of codegen2-3_7B_P

codegen2-3_7B_P huggingface.co Url

Provider of codegen2-3_7B_P huggingface.co

Salesforce
ORGANIZATIONS

Other API from Salesforce

huggingface.co

Total runs: 42.2K
Run Growth: 23.3K
Growth Rate: 55.30%
Updated: November 23 2021
huggingface.co

Total runs: 35.8K
Run Growth: -56.7K
Growth Rate: -158.24%
Updated: November 23 2021
huggingface.co

Total runs: 7.4K
Run Growth: 1.3K
Growth Rate: 17.09%
Updated: February 19 2024
huggingface.co

Total runs: 931
Run Growth: 358
Growth Rate: 38.45%
Updated: October 19 2021
huggingface.co

Total runs: 850
Run Growth: -1.1K
Growth Rate: -131.41%
Updated: August 04 2023
huggingface.co

Total runs: 370
Run Growth: -56
Growth Rate: -15.14%
Updated: August 04 2023
huggingface.co

Total runs: 178
Run Growth: -207
Growth Rate: -118.97%
Updated: September 24 2024
huggingface.co

Total runs: 16
Run Growth: -8
Growth Rate: -50.00%
Updated: November 11 2022