andstor/cvevc_commits
Viewer • Updated • 8.28M • 1.44k
How to use andstor/VulFixMiner-encoder with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("feature-extraction", model="andstor/VulFixMiner-encoder", trust_remote_code=True) # pip install -U transformers accelerate
# Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("andstor/VulFixMiner-encoder", trust_remote_code=True, device_map="auto")# pip install -U transformers accelerate
# Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("andstor/VulFixMiner-encoder", trust_remote_code=True, device_map="auto")A CodeBERT-based encoder for commit-diff embeddings.
This package provides a CodeBERT-based embedding model for code change snippets. It is designed to convert a diff or patch fragment into a dense semantic representation suitable for downstream security classification.
Fine-tuned on andstor/cvevc_commits. The encoder learns from individual file changes extracted from these commits.
from transformers import AutoTokenizer, AutoModel
import torch
model_name = "andstor/vulfixminer-encoder"
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
model = AutoModel.from_pretrained(model_name, trust_remote_code=True)
model.eval()
patch = """
@@ -1,3 +1,4 @@
- old_call()
+ fixed_call()
+ validate_input()
"""
inputs = tokenizer(patch, return_tensors="pt", truncation=True, max_length=256)
with torch.no_grad():
outputs = model(**inputs)
embedding = outputs.last_hidden_state[:, 0, :]
print(embedding.shape)
tokenizer.sep_token + deleted code. The raw-diff example above demonstrates the API, not this preprocessing.mean(dim=0, keepdim=True) to obtain a [1, 768] vector for andstor/vulfixminer-classifier.
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="andstor/VulFixMiner-encoder", trust_remote_code=True)