Text Classification
Transformers
Safetensors
roberta
code
programming-language-identification
text-embeddings-inference
Instructions to use pecan-anon/graphcodebert-pecan with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use pecan-anon/graphcodebert-pecan with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="pecan-anon/graphcodebert-pecan")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("pecan-anon/graphcodebert-pecan") model = AutoModelForSequenceClassification.from_pretrained("pecan-anon/graphcodebert-pecan", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Model card: label casing, exact base model
Browse files
README.md
CHANGED
|
@@ -17,7 +17,7 @@ tags:
|
|
| 17 |
|
| 18 |
`microsoft/graphcodebert-base` fine-tuned on the [PECAN benchmark](https://huggingface.co/datasets/pecan-anon/pecan-anon) to
|
| 19 |
identify the programming language of a raw code fragment of at most 512 bytes, with no file name,
|
| 20 |
-
extension, or repository context. It predicts one of 319 languages (`config.id2label`).
|
| 21 |
|
| 22 |
Artifact repository (code, scoring, all results): https://anonymous.4open.science/r/pecan-benchmark
|
| 23 |
|
|
@@ -62,7 +62,7 @@ fragment = "def add(a, b):\n return a + b\n"
|
|
| 62 |
inputs = tok(fragment, truncation=True, max_length=512, return_tensors="pt")
|
| 63 |
with torch.no_grad():
|
| 64 |
logits = model(**inputs).logits
|
| 65 |
-
print(model.config.id2label[int(logits.argmax())])
|
| 66 |
```
|
| 67 |
|
| 68 |
To evaluate on the benchmark, write one prediction per test fragment and score it with
|
|
|
|
| 17 |
|
| 18 |
`microsoft/graphcodebert-base` fine-tuned on the [PECAN benchmark](https://huggingface.co/datasets/pecan-anon/pecan-anon) to
|
| 19 |
identify the programming language of a raw code fragment of at most 512 bytes, with no file name,
|
| 20 |
+
extension, or repository context. It predicts one of 319 languages (`config.id2label`; lowercased, these are exactly the PECAN labels).
|
| 21 |
|
| 22 |
Artifact repository (code, scoring, all results): https://anonymous.4open.science/r/pecan-benchmark
|
| 23 |
|
|
|
|
| 62 |
inputs = tok(fragment, truncation=True, max_length=512, return_tensors="pt")
|
| 63 |
with torch.no_grad():
|
| 64 |
logits = model(**inputs).logits
|
| 65 |
+
print(model.config.id2label[int(logits.argmax())].lower()) # PECAN labels are lowercase
|
| 66 |
```
|
| 67 |
|
| 68 |
To evaluate on the benchmark, write one prediction per test fragment and score it with
|