All models

CodeSage

An encoder that turns source code into 1024-dimensional embeddings for code understanding and search.

Language · 1,065 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (13 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
354.7M
Operations
1,065
Framework
PyTorch
Recurrent
No
Published
ICLR 2024
Cited by
2 (as of 28 October 2026)
Authors
Dejiao Zhang, Wasi Ahmad, Ming Tan and others
License
Apache-2.0
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m15361
Graph hash
2a636a96af875b74f7f60ec4c1e79e747d8ad1b3e3168beb3f414e189446036e
Skeleton hash
8c44968266d6a7ad2a70280cc31432f4aa31245062f11fb370d9294b64088707
Architecture hash
7774d8f41e997a8e2598c5ab07d84531cbfd9a518ee3b248fecdab4b1b2da9ba
Diagram SHA-256
1ade85b4d52417b23246d2c1e2bb1abb345fac430fa3a92ec0f6b2a245287135
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

CodeSage is a family of open code embedding models with an encoder architecture, meant to support a wide range of source code understanding tasks. The paper starts from the observation that most earlier work on code representation learning trained models at a hundred million parameter scale on very limited pretraining corpora.

Pretraining runs in two stages on a large amount of code data. The encoders are first trained with a mix that uses both the randomness of masked language modeling and the structural side of programming languages. The representations are then improved with contrastive learning on hard negatives and hard positives constructed without supervision.

The CodeSage-Base checkpoint is trained on the Stack data and supports 9 languages: c, c-sharp, go, java, javascript, typescript, php, python and ruby. Its model card describes an encoder of 356M parameters that yields code embeddings of 1024 dimensions. The authors note that CodeSage was trained with block-attention and needs the EOS token appended to each sequence for good performance.

Key idea. The paper trains code encoders on a vast amount of code with two-stage pretraining: masked language modeling, then contrastive learning with hard negatives and hard positives.

  • CodeSage
  • codesage-base
  • code embedding
  • code representation learning
  • code search
  • code encoder
  • source code understanding
  • text-to-code search
  • contrastive learning

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{zhang2024coderepresentationlearningscale,
      title={Code Representation Learning At Scale}, 
      author={Dejiao Zhang and Wasi Ahmad and Ming Tan and Hantian Ding and Ramesh Nallapati and Dan Roth and Xiaofei Ma and Bing Xiang},
      year={2024},
      eprint={2402.01935},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2402.01935}, 
}