code-search-net/code_search_net
Viewer • Updated • 4.14M • 25.4k • 329
How to use protectai/CodeBERTa-language-id-onnx with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="protectai/CodeBERTa-language-id-onnx") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("protectai/CodeBERTa-language-id-onnx")
model = AutoModelForSequenceClassification.from_pretrained("protectai/CodeBERTa-language-id-onnx")This model is conversion of huggingface/CodeBERTa-language-id to ONNX. The model was converted to ONNX using the 🤗 Optimum library.
Base Model: CodeBERTa, a variant of the RoBERTa model trained specifically for programming languages.
Modifications: No changes except for the conversion.
Loading the model requires the 🤗 Optimum library installed.
from optimum.onnxruntime import ORTModelForSequenceClassification
from transformers import AutoTokenizer, pipeline
tokenizer = AutoTokenizer.from_pretrained("laiyer/CodeBERTa-language-id")
model = ORTModelForSequenceClassification.from_pretrained("laiyer/CodeBERTa-language-id")
classifier = pipeline(
task="text-classification",
model=model,
tokenizer=tokenizer,
)
print(classifier("""
def f(x):
return x**2
"""))
Join our Slack to give us feedback, connect with the maintainers and fellow users, ask questions, or engage in discussions about LLM security!
Base model
huggingface/CodeBERTa-small-v1