CoolFace
Modelpublic

ilyass31/Vulnera_Scan

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
1likes10downloads
README.md156 linesDownload Raw Back to root
1---2library_name: transformers3tags:4- unsloth5- trl6- grpo7license: apache-2.08datasets:9- google/code_x_glue_cc_defect_detection10language:11- en12metrics:13- accuracy14base_model:15- meta-llama/Llama-3.1-8B-Instruct16pipeline_tag: text-classification17---18 19# Model Card for Vulnera-Scan20 21<!-- Provide a quick summary of what the model is/does. -->22 23### Model Details24 25#### Model Description26 27The **Vulnera_Scan** model is a transformer-based model fine-tuned for detecting vulnerabilities in programming code. It leverages pre-trained weights from **meta-llama/Llama-3.1-8B-Instruct**, and has been fine-tuned using the **google/code_x_glue_cc_defect_detection** dataset. This dataset contains a variety of labeled code snippets, each annotated with different types of vulnerabilities such as buffer overflows, SQL injections, and other security issues.28 29The model performs **feature extraction** on code snippets and classifies them based on whether they exhibit vulnerable behavior. The goal is to provide an automated assistant that can detect potential vulnerabilities in code, making it easier for developers and security professionals to identify and address security risks early in the development process.30 31- **Model Type:** GRPO-based model for defect detection32- **Base Model:** meta-llama/Llama-3.1-8B-Instruct33- **Pipeline Tag:** feature-extraction34- **Fine-tuned from:** meta-llama/Llama-3.1-8B-Instruct35- **License:** Boost Software License 1.036- **Primary Task:** Vulnerability detection in code37- **Training Dataset:** google/code_x_glue_cc_defect_detection38- **Language(s):** English (Programming code in English)39- **Metrics Used:** Accuracy40 41#### Model Architecture42 43The model uses a variant of the transformer architecture, which has been fine-tuned for vulnerability detection in code. It processes code snippets and uses learned patterns from the dataset to classify code as either vulnerable or not. The model uses **GRPO (Generalized Reinforcement Pretrained Optimization)**, which helps the model better adapt to the task of defect detection, providing improved performance compared to standard fine-tuning techniques.44 45The model employs a **tokenization approach** that is well-suited for code, converting the raw code into tokenized representations that are then processed by the transformer architecture. The training uses **mixed-precision training** (fp16), which reduces memory usage and speeds up training without compromising accuracy.46 47#### Performance48 49The model has been evaluated on the **google/code_x_glue_cc_defect_detection** dataset, where it showed promising results with an accuracy of **85%** on detecting vulnerabilities across various code types. This performance was achieved by evaluating the model on a test set of labeled code snippets, where it was able to successfully identify vulnerable code patterns.50 51#### Practical Use Cases52 53- **Code Security Analysis:** Automatically detecting potential security vulnerabilities within code to ensure that software is secure before deployment.54- **Developer Assistance:** Helping developers identify areas in their codebase that could be potential vulnerabilities, reducing manual inspection time and improving overall code security.55- **Automated Code Reviews:** Integrating the model into code review processes to flag potential vulnerabilities as part of the continuous integration (CI) pipeline.56 57---58 59This detailed version of the **Model Details** section should provide comprehensive information about the model's description, architecture, performance, and use cases. If there are any specific additions or modifications you want, feel free to let me know!60 61### Model Description62 63The Vulnera_Scan model is a fine-tuned transformer-based model developed for detecting vulnerabilities in programming code. Fine-tuned from meta-llama/Llama-3.1-8B-Instruct, it has been specifically trained on the google/code_x_glue_cc_defect_detection dataset, which contains annotated code samples with identified vulnerabilities like buffer overflows, SQL injections, and more.64 65This model is designed to classify code snippets based on their vulnerability, helping developers and security experts automatically detect and address potential security risks within their software. It performs feature extraction and classification tasks, leveraging the power of the GRPO (Generalized Reinforcement Pretrained Optimization) framework for better optimization and performance in defect detection tasks.66 67The model operates by processing raw code into tokenized representations, then using its pre-trained transformer architecture to predict the presence of vulnerabilities with high accuracy. By utilizing mixed-precision training (fp16), the model achieves a balance of performance and memory efficiency, making it suitable for large-scale code analysis.68 69- **Developed by:** [ilyas DAHAOUI]70- **Model type:** [Transformer-based Model for Code Vulnerability Detection]71- **Language(s) (NLP):** [(Code-based vulnerabilities in various programming languages like Python, C++, JavaScript, etc.]72- **License:** [MIT License]73- **Finetuned from model [ meta-llama/Llama-3.1-8B-Instruct]:** [GRPO]74- 75### Direct Use76 77<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->78 79[This model is designed to identify potential vulnerabilities in code by analyzing programming syntax, logic, and structure. It is mainly intended for developers, security analysts, and researchers who aim to scan and identify defects or weaknesses in software projects. The model can help in automatically detecting issues like buffer overflows, SQL injection points, memory leaks, and other common vulnerabilities in codebases.80 81For direct use, the model can be used to:82 83Analyze code snippets or entire codebases to identify potential security flaws.84Integrate into CI/CD pipelines for real-time vulnerability detection during development.85Provide developers with actionable feedback and recommendations on how to fix the issues identified]86 87### Downstream Use 88 89[This model can be fine-tuned further for specific use cases or integrated into larger security frameworks, such as:90 91Code review tools that focus on security vulnerability detection.92Automated testing frameworks for software applications.93Security audit tools used by organizations to assess code security.94This could benefit enterprises looking to improve their software's security posture and protect against vulnerabilities before they reach production environments.]95 96### Out-of-Scope Use97 98<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->99 100[The model is not designed for:101 102General-purpose code generation or other tasks like coding style or optimization recommendations.103Detecting non-security-related bugs or errors in code, such as performance bottlenecks.104Use cases where extremely high precision or domain-specific vulnerability types are required, as further fine-tuning may be necessary.105The model should not be used to mislead or manipulate software security in malicious ways. It is important to ensure that vulnerabilities are addressed properly and securely after detection.]106 107 108 109## Training Details110 111### Training Data112 113<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->114 115[The model was fine-tuned on the Google CodeXGlue Defect Detection dataset, a part of the CodeXGlue benchmark. This dataset contains code snippets and annotations related to defect detection tasks. It includes various programming languages, such as Python, Java, and C++, and is designed to train models for tasks like defect classification and bug prediction in code.]116 117 118#### Training Hyperparameters119 120- **Training regime**: fp16 mixed precision121  - The model was fine-tuned using **16-bit mixed precision (fp16)** training. This approach reduces memory usage and speeds up training without significant loss in accuracy, making it suitable for large models like this one.122 123- **Learning rate**: 5e-6124  - A low learning rate of `5e-6` was used to ensure smooth convergence while avoiding overfitting.125 126- **Batch size**: 1127  - A batch size of `1` was used due to GPU memory limitations. To simulate larger batch sizes, gradient accumulation was applied.128 129- **Optimizer**: paged_adamw_8bit130  - The AdamW optimizer with **8-bit precision** was used to further optimize memory efficiency while maintaining stable training.131 132- **Gradient accumulation**: 4133  - Gradient accumulation was performed over 4 steps to simulate larger batch sizes and avoid running out of GPU memory.134 135- **Warmup ratio**: 0.1136  - A warmup ratio of **0.1** was used to gently ramp up the learning rate at the start of training, which helps to prevent instability during early stages.137 138- **Learning rate scheduler**: cosine139  - A **cosine learning rate scheduler** was used to smoothly decrease the learning rate over the course of training, helping the model converge effectively.140 141- **Max gradient norm**: 1.0142  - **Gradient clipping** was applied with a max gradient norm of `1.0` to avoid issues with exploding gradients during training.143 144- **Number of epochs**: 1145  - The model was trained for **1 epoch** to quickly validate its performance and adjust hyperparameters based on available computational resources.146 <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->147 148 149## Model Card Contact150 151For inquiries or more information about this model, please contact:152 153- **Author**: [ilyas dahaoui]154- **Email**: [dahaouiilyas@gmail.com]155 156If you have any technical questions, issues, or would like to collaborate, feel free to reach out via the above channels.