| # π§ Code Generation Model β Fine-Tuned `Salesforce/codegen-350M-multi` |
|
|
| This repository contains a fine-tuned version of the [`Salesforce/codegen-350M-multi`](https://huggingface.co/Salesforce/codegen-350M-multi) model. It generates code snippets based on natural language or function signature prompts. |
|
|
| --- |
|
|
| ## π¦ Base Model |
|
|
| - **Model**: `Salesforce/codegen-350M-multi` |
| - **Architecture**: Causal LM (Decoder-only Transformer) |
| - **Parameters**: ~350M |
| - **Supports**: Python, JavaScript, Java, and more |
| - **Quantized**: β
FP16 using `bitsandbytes` (optional) |
|
|
| --- |
|
|
| ## π Dataset |
|
|
| ### Dataset: [code_x_glue_cc_code_to_text](https://huggingface.co/datasets/code_x_glue_cc_code_to_text) |
|
|
| - **Source**: Hugging Face Datasets |
| - **Description**: Dataset of code snippets (in Python) and corresponding natural language docstrings. |
|
|
| ```python |
| from datasets import load_dataset |
| |
| dataset = load_dataset("code_x_glue_cc_code_to_text", "python") |
| ``` |
|
|
| # π Evaluation (Scoring) |
| Metric: BLEU or CodeBLEU (you can also use exact match, ROUGE, etc.) |
|
|
| ```python |
| |
| from datasets import load_metric |
| |
| bleu = load_metric("bleu") |
| bleu_score = bleu.compute(predictions=["generated_code"], references=["reference_code"]) |
| print("BLEU Score:", bleu_score) |
| ``` |
|
|
| # π Folder Structure |
|
|
| finetuned_codegen_350M/ |
| βββ config.json |
| βββ pytorch_model.bin |
| βββ tokenizer_config.json |
| βββ tokenizer.json |
| βββ special_tokens_map.json |
| βββ vocab.json |
| βββ merges.txt |
| βββ training_args.bin |
| βββ README.md |
| |
| # π¬ Inference Example |
| |
| ```python |
| |
| from transformers import pipeline |
| |
| pipe = pipeline("text-generation", model="./finetuned_codegen_350M", device=0) |
| |
| prompt = "def is_prime(n):" |
| result = pipe(prompt, max_length=100, do_sample=True) |
| print(result[0]["generated_text"]) |
|
|
|
|