Salesforce / codegen25-7b-mono_P

huggingface.co
Total runs: 134
24-hour runs: 0
7-day runs: -41
30-day runs: -305
Model's Last Updated: February 01 2024
text-generation

Introduction of codegen25-7b-mono_P

Model Details of codegen25-7b-mono_P

CodeGen2.5-7B-mono

Title: CodeGen2.5: Small, but mighty

Authors: Erik Nijkamp *, Hiroaki Hayashi *, Yingbo Zhou, Caiming Xiong

(* equal contribution)

Model description

CodeGen2.5 is a family of autoregressive language models for program synthesis .

Building upon CodeGen2 , the model is trained on StarCoderData for 1.4T tokens, achieving competitive results compared to StarCoderBase-15.5B with less than half the size.

Like CodeGen2, this model is capable of infilling, and supports multiple programming languages.

We then further train on Python, then on instruction data. We release all the models as follows:

  • CodeGen2.5-7B-multi : Trained on StarCoderData. Licensed under Apache-2.0.
  • CodeGen2.5-7B-mono (this repo): Further trained on additional Python tokens. Licensed under Apache-2.0.
  • CodeGen2.5-7B-instruct : Further trained from CodeGen2.5-7B-mono on instruction data. Research purposes only .
How to use

This model can be easily loaded using the AutoModelForCausalLM functionality.

Pre-requisite

Please install OpenAI tiktoken for the tokenizer.

pip install tiktoken==0.4.0
Causal sampling (code autocompletion)

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

from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("Salesforce/codegen25-7b-mono", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("Salesforce/codegen25-7b-mono")

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 follow the CodeGen2 format:

  • <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/codegen25-7b-mono", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("Salesforce/codegen25-7b-mono")


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> .

Evaluation results

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

Intended use and limitations

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

Attribution & Other Requirements

The pretraining dataset of the model was filtered for permissive licenses only. Nevertheless, the model can generate source code verbatim from the dataset. The code's license might require attribution and/or other specific requirements that must be respected. The data provider BigCode provides a search index that lets you search through the pretraining data to identify where generated code came from and apply the proper attribution to your code.

BibTeX entry and citation info

Please cite CodeGen2 paper:

@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 codegen25-7b-mono_P on huggingface.co

134
Total runs
0
24-hour runs
-19
3-day runs
-41
7-day runs
-305
30-day runs

More Information About codegen25-7b-mono_P huggingface.co Model

More codegen25-7b-mono_P license Visit here:

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

codegen25-7b-mono_P huggingface.co

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

codegen25-7b-mono_P huggingface.co Url

https://huggingface.co/Salesforce/codegen25-7b-mono_P

Salesforce codegen25-7b-mono_P online free

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

Salesforce codegen25-7b-mono_P online free url in huggingface.co:

https://huggingface.co/Salesforce/codegen25-7b-mono_P

codegen25-7b-mono_P install

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

codegen25-7b-mono_P install url in huggingface.co:

https://huggingface.co/Salesforce/codegen25-7b-mono_P

Url of codegen25-7b-mono_P

codegen25-7b-mono_P huggingface.co Url

Provider of codegen25-7b-mono_P huggingface.co

Salesforce
ORGANIZATIONS

Other API from Salesforce

huggingface.co

Total runs: 41.7K
Run Growth: -9.1K
Growth Rate: -21.92%
Updated: January 21 2025
huggingface.co

Total runs: 8.5K
Run Growth: 1.2K
Growth Rate: 15.14%
Updated: February 19 2024
huggingface.co

Total runs: 3.3K
Run Growth: 1.1K
Growth Rate: 32.37%
Updated: January 25 2025
huggingface.co

Total runs: 586
Run Growth: 510
Growth Rate: 87.03%
Updated: January 21 2025
huggingface.co

Total runs: 542
Run Growth: 265
Growth Rate: 46.01%
Updated: January 21 2025
huggingface.co

Total runs: 290
Run Growth: -31
Growth Rate: -12.02%
Updated: January 15 2025
huggingface.co

Total runs: 50
Run Growth: -58
Growth Rate: -116.00%
Updated: January 15 2025