File size: 1,800 Bytes
328056f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# π§ 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"])
|