CodeBERTa-language-id: The World’s fanciest programming language identification algo 🤯
To demonstrate the usefulness of our CodeBERTa pretrained model on downstream tasks beyond language modeling, we fine-tune the
CodeBERTa-small-v1
checkpoint on the task of classifying a sample of code into the programming language it's written in (
programming language identification
).
We add a sequence classification head on top of the model.
On the evaluation dataset, we attain an eval accuracy and F1 > 0.999 which is not surprising given that the task of language identification is relatively easy (see an intuition why, below).
Quick start: using the raw model
CODEBERTA_LANGUAGE_ID = "huggingface/CodeBERTa-language-id"
tokenizer = RobertaTokenizer.from_pretrained(CODEBERTA_LANGUAGE_ID)
model = RobertaForSequenceClassification.from_pretrained(CODEBERTA_LANGUAGE_ID)
input_ids = tokenizer.encode(CODE_TO_IDENTIFY)
logits = model(input_ids)[0]
language_idx = logits.argmax() # index for the resulting label
Why is the problem of language identification so easy (with the correct toolkit)? Because code's syntax is rigid, and simple tokens such as
:=
(the assignment operator in Go) are perfect predictors of the underlying language:
By the way, because we trained our own custom tokenizer on the
CodeSearchNet
dataset, and it handles streams of bytes in a very generic way, syntactic constructs such
:=
are represented by a single token:
CodeBERTa-language-id huggingface.co is an AI model on huggingface.co that provides CodeBERTa-language-id's model effect (), which can be used instantly with this huggingface CodeBERTa-language-id model. huggingface.co supports a free trial of the CodeBERTa-language-id model, and also provides paid use of the CodeBERTa-language-id. Support call CodeBERTa-language-id model through api, including Node.js, Python, http.
CodeBERTa-language-id huggingface.co is an online trial and call api platform, which integrates CodeBERTa-language-id's modeling effects, including api services, and provides a free online trial of CodeBERTa-language-id, you can try CodeBERTa-language-id online for free by clicking the link below.
huggingface CodeBERTa-language-id online free url in huggingface.co:
CodeBERTa-language-id is an open source model from GitHub that offers a free installation service, and any user can find CodeBERTa-language-id on GitHub to install. At the same time, huggingface.co provides the effect of CodeBERTa-language-id install, users can directly use CodeBERTa-language-id installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
CodeBERTa-language-id install url in huggingface.co: