Run this model with HF Jobs
Run sjiang1/codecse 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 to fine-tune https://huggingface.co/sjiang1/codecse. 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/sjiang1/codecse 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.
Instructions to use sjiang1/codecse with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sjiang1/codecse with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="sjiang1/codecse")# pip install -U transformers accelerate # Load model directly from transformers import GraphCodeBERTForCL model = GraphCodeBERTForCL.from_pretrained("sjiang1/codecse", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Model Card for CodeCSE
A simple pre-trained model for code and comment sentence embeddings using contrastive learning. This model was pretrained using CodeSearchNet.
Please clone the CodeCSE repository to get GraphCodeBERTForCL and other dependencies to use this pretrained model. https://github.com/emu-se/CodeCSE
Detailed instructions are listed in the repository's README.md. Overall, you will need:
- GraphCodeBERT (CodeCSE uses GraphCodeBERT's input format for code)
- GraphCodeBERTForCL defined in codecse/codecse
Inference example
NL input example: example_nl.json
{
"original_string": "",
"docstring_tokens": ["Save", "model", "to", "a", "pickle", "located", "at", "path"],
"url": "https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/deepq/deepq.py#L55-L72"
}
Code snippet to get the embedding of an NL document (link to complete code):
nl_json = load_example("example_nl.json")
batch = prepare_inputs(nl_json, tokenizer, args)
nl_inputs = batch[3]
with torch.no_grad():
nl_vec = model(input_ids=nl_inputs, sent_emb="nl")[1]
- Downloads last month
- 58