This model predicts similarity between problem prompts and Ballerina code completions.
Use Case: Given a coding problem prompt, evaluate how well a Ballerina solution matches the requirements.
Training:
Based on CodeRankEmbed with a binary similarity head.
import torch
from sentence_transformers import SentenceTransformer
from transformers import AutoTokenizer
# Load tokenizer
tokenizer = AutoTokenizer.from_pretrained("nomic-ai/CodeRankEmbed", trust_remote_code=True)
# Load your trained model
# (You'll need to load the SimilarityModel class and state dict)
# Example inference
code1 = "..."
code2 = "..."
# Tokenize
enc1 = tokenizer(code1, return_tensors='pt', padding=True, truncation=True, max_length=512)
enc2 = tokenizer(code2, return_tensors='pt', padding=True, truncation=True, max_length=512)
# Compute similarity
with torch.no_grad():
similarity = model(enc1['input_ids'], enc1['attention_mask'],
enc2['input_ids'], enc2['attention_mask'])
print(f"Similarity: {similarity.item():.3f}")
# > 0.7: High similarity (likely to pass)
# < 0.3: Low similarity (likely to fail)
@misc{coderankembed2024,
title={CodeRankEmbed: Code Similarity Learning},
author={Nomic AI},
year={2024},
url={https://huggingface.co/nomic-ai/CodeRankEmbed}
}
Have the files? Publish a torrent.
Publish a torrentHave the complete files and permission to share them? Replace the example folder path. The script checks the files, makes a torrent and submits its magnet and checksums. Keep your torrent client seeding. Get your community key from your settings, and read the script before running it.
curl -fsSL https://pirateface.co/package.sh | bash -s -- --repo didula-wso2/prompt-similarity-model ./model-foldernomic-ai/CodeRankEmbed