Instructions to use PointGuardAI/programming-language-identification with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use PointGuardAI/programming-language-identification with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="PointGuardAI/programming-language-identification")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("PointGuardAI/programming-language-identification") model = AutoModelForSequenceClassification.from_pretrained("PointGuardAI/programming-language-identification", device_map="auto") - Notebooks
- Google Colab
- Kaggle
PointGuardAI mirror. This repository redistributes the unmodified model artifacts from
philomath-1209/programming-language-identificationat source revision9090d38e7333a2c6ff00f154ab981a549842c20ffor reproducible AISEC runtime deployments. The model was created by its upstream authors, not retrained by PointGuardAI, and remains available under the WTFPL license.
This Model is a fine-tuned version of huggingface/CodeBERTa-small-v1 on cakiki/rosetta-code Dataset for 26 Programming Languages as mentioned below.
Training Details:
Model is trained for 25 epochs on Azure for nearly 26000 Datapoints for above Mentioned 26 Programming Languages
extracted from Dataset having 1006 of total Programming Language.
Programming Languages this model is able to detect vs Examples used for training
- 'ARM Assembly':
- 'AppleScript'
- 'C'
- 'C#'
- 'C++'
- 'COBOL'
- 'Erlang'
- 'Fortran'
- 'Go'
- 'Java'
- 'JavaScript'
- 'Kotlin'
- 'Lua
- 'Mathematica/Wolfram Language'
- 'PHP'
- 'Pascal'
- 'Perl'
- 'PowerShell'
- 'Python'
- 'R
- 'Ruby'
- 'Rust'
- 'Scala'
- 'Swift'
- 'Visual Basic .NET'
- 'jq'
Below is the Training Result for 25 epochs.
- Training Computer Configuration:
- GPU:1xNvidia Tesla T4,
- VRam: 16GB,
- Ram:112GB,
- Cores:6 Cores
- Training Time taken: exactly 7 hours for 25 epochs
- Training Hyper-parameters:
Inference Code
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification, TextClassificationPipeline
model_name = 'philomath-1209/programming-language-identification'
loaded_tokenizer = AutoTokenizer.from_pretrained(model_name)
loaded_model = AutoModelForSequenceClassification.from_pretrained(model_name)
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
text = """
PROGRAM Triangle
IMPLICIT NONE
REAL :: a, b, c, Area
PRINT *, 'Welcome, please enter the&
&lengths of the 3 sides.'
READ *, a, b, c
PRINT *, 'Triangle''s area: ', Area(a,b,c)
END PROGRAM Triangle
FUNCTION Area(x,y,z)
IMPLICIT NONE
REAL :: Area ! function type
REAL, INTENT( IN ) :: x, y, z
REAL :: theta, height
theta = ACOS((x**2+y**2-z**2)/(2.0*x*y))
height = x*SIN(theta); Area = 0.5*y*height
END FUNCTION Area
"""
inputs = loaded_tokenizer(text, return_tensors="pt",truncation=True)
with torch.no_grad():
logits = loaded_model(**inputs).logits
predicted_class_id = logits.argmax().item()
loaded_model.config.id2label[predicted_class_id]
Optimum with ONNX inference
Loading the model requires the 🤗 Optimum library installed.
pip install transformers optimum[onnxruntime] optimum
model_path = "philomath-1209/programming-language-identification"
import torch
from transformers import pipeline, AutoTokenizer
from optimum.onnxruntime import ORTModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained(model_path, subfolder="onnx")
model = ORTModelForSequenceClassification.from_pretrained(model_path, export=False, subfolder="onnx")
text = """
PROGRAM Triangle
IMPLICIT NONE
REAL :: a, b, c, Area
PRINT *, 'Welcome, please enter the&
&lengths of the 3 sides.'
READ *, a, b, c
PRINT *, 'Triangle''s area: ', Area(a,b,c)
END PROGRAM Triangle
FUNCTION Area(x,y,z)
IMPLICIT NONE
REAL :: Area ! function type
REAL, INTENT( IN ) :: x, y, z
REAL :: theta, height
theta = ACOS((x**2+y**2-z**2)/(2.0*x*y))
height = x*SIN(theta); Area = 0.5*y*height
END FUNCTION Area
"""
inputs = tokenizer(text, return_tensors="pt",truncation=True)
with torch.no_grad():
logits = model(**inputs).logits
predicted_class_id = logits.argmax().item()
model.config.id2label[predicted_class_id]
- Downloads last month
- 13
Model tree for PointGuardAI/programming-language-identification
Base model
huggingface/CodeBERTa-small-v1
