https://github.com/amazon-science/codesage

CodeSage: Code Representation Learning At Scale (ICLR 2024)

https://github.com/amazon-science/codesage

Science Score: 33.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Committers with academic emails
    1 of 5 committers (20.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.0%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

CodeSage: Code Representation Learning At Scale (ICLR 2024)

Basic Info
Statistics
  • Stars: 107
  • Watchers: 5
  • Forks: 4
  • Open Issues: 5
  • Releases: 0
Created over 2 years ago · Last pushed over 1 year ago
Metadata Files
Readme Contributing License Code of conduct

README.md

CodeSage: Code Representation Learning At Scale

This repository contains the data and inference code of the ICLR 2024 paper "CodeSage: Code Representation Learning At Scale."

Work done by Dejiao Zhang, Wasi Uddin Ahmad, Ming Tan, Hantian Ding, Ramesh Nallapati, Dan Roth, Xiaofei Ma, Bing Xiang (* indicates equal contribution).

Overview

An overview of the key ingredients of CodeSage for code representation learning.

Environment Setup

conda create -n codesage_eval python=3.10 conda activate codesage_eval pip install -r requirements.txt

Note

CodeSage has been trained with block-attention. It requires appending the EOS token at the end of each sequence to ensure good performance. Below is an example of downloading the model and tokenizer.

```angular2html model = AutoModel.frompretrained("codesage/codesage-small", trustremotecode=True) tokenizer = AutoTokenizer("codesage/codesage-small", addeostoken=True, trustremote_code=True)

inputs = tokenizer.encode("def printhelloworld():\tprint('Hello World!')", return_tensors="pt").to(device)

embedding = model(inputs)[0]

print(f'Dimension of the embedding: {embedding[0].size()}')

Dimension of the embedding: torch.Size([14, 1024])

```

Run Evaluation

Code-to-Code Search

See data preparation before running evaluation scripts.

bash scripts/run_code2code_search.sh MODEL_NAME SRC_LANG TGT_LANG

where

  • MODEL_NAME = [codesage-small|codesage-base|codesage-large]
  • SRCLANG and TGTLANG = [python|java|c|c++|csharp|ruby|php|go|javascript|typescript]

Text-to-Code Search

See data preparation before running evaluation scripts.

bash scripts/run_nl2code_search.sh MODEL_NAME DATASET_NAME

where

  • MODEL_NAME = [codesage-small|codesage-base|codesage-large]
  • SRCLANG and TGTLANG = [cosqa|advTest|csn]

Code Classification

```

clone detection

bash scripts/runclonedetection.sh

complexity prediction

bash scripts/runcomplexityprediction.sh

defect prediction

bash scripts/rundefectprediction.sh

runtime error prediction

bash scripts/runruntimeerror_prediction.sh ```

Benchmark

Wanna compare CodeSage against the latest embedding model? Check out our code for benchmarking

Citation

@inproceedings{ zhang2024code, title={{CODE} {REPRESENTATION} {LEARNING} {AT} {SCALE}}, author={Dejiao Zhang and Wasi Uddin Ahmad and Ming Tan and Hantian Ding and Ramesh Nallapati and Dan Roth and Xiaofei Ma and Bing Xiang}, booktitle={The Twelfth International Conference on Learning Representations}, year={2024}, url={https://openreview.net/forum?id=vfzRRjumpX} }

Contact

If you have any question regarding our paper or code, please feel free to start an issue or email Dejiao Zhang (dejiaozhang@gmail.com) and Wasi Ahmad (wasicse90@gmail.com).

Security

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.

Owner

  • Name: Amazon Science
  • Login: amazon-science
  • Kind: organization

GitHub Events

Total
  • Issues event: 1
  • Watch event: 34
  • Push event: 1
  • Fork event: 1
Last Year
  • Issues event: 1
  • Watch event: 34
  • Push event: 1
  • Fork event: 1

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 26
  • Total Committers: 5
  • Avg Commits per committer: 5.2
  • Development Distribution Score (DDS): 0.308
Past Year
  • Commits: 8
  • Committers: 3
  • Avg Commits per committer: 2.667
  • Development Distribution Score (DDS): 0.5
Top Committers
Name Email Commits
Dejiao2018 d****g@g****m 18
wasiahmad w****d@u****u 3
wuahmad w****d@a****m 2
Zhang d****z@b****m 2
Amazon GitHub Automation 5****o 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: about 1 year ago

All Time
  • Total issues: 8
  • Total pull requests: 8
  • Average time to close issues: 28 days
  • Average time to close pull requests: 11 days
  • Total issue authors: 7
  • Total pull request authors: 3
  • Average comments per issue: 0.75
  • Average comments per pull request: 0.13
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 3
Past Year
  • Issues: 4
  • Pull requests: 3
  • Average time to close issues: 2 days
  • Average time to close pull requests: about 3 hours
  • Issue authors: 4
  • Pull request authors: 2
  • Average comments per issue: 0.5
  • Average comments per pull request: 0.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • tehranixyz (1)
  • sxthunder (1)
  • skye95git (1)
  • Pengwei-Jin (1)
  • unclemusclez (1)
  • iNeil77 (1)
  • zanussbaum (1)
Pull Request Authors
  • wasiahmad (5)
  • dependabot[bot] (5)
  • Dejiao2018 (3)
Top Labels
Issue Labels
Pull Request Labels
dependencies (5)

Dependencies

requirements.txt pypi
  • datasets *
  • prettytable *
  • scikit-learn *
  • sentencepiece *
  • torch ==1.13.0
  • tqdm *
  • transformers ==4.28.1