Team Ai
Modelpublic

akshaybharadwaj96/nl-code-gen-python

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes26downloads
README.md145 linesDownload Raw Back to root
1---2base_model: Salesforce/codegen-350M-mono3library_name: peft4license: mit5datasets:6- google/code_x_glue_ct_code_to_text7language:8- en9pipeline_tag: text-generation10---11 12# CodeGen-ft-python13 14<!-- Provide a quick summary of what the model is/does. -->15Generate python code from natural language prompts.16 17 18## Model Details19 20### Model Description21 22<!-- Provide a longer summary of what this model is. -->23This model is a fine-tuned variant of Salesforce/codegen-350M-mono, 24specialized for natural language to code generation in Python. 25It takes natural language instructions (e.g., “check MySQL database connection”) 26and generates the corresponding Python code snippet. 27The model was trained on a curated text-to-code dataset containing diverse 28programming instructions and function-level examples to improve semantic and syntactic accuracy.29 30 31- **Developed by:** Akshay Bharadwaj32 33- **Model type:** Transformer-based Causal Language Model34- **Language(s) (NLP):** English (Prompts) and Python (Code Outputs)35- **License:** MIT License36- **Finetuned from model [optional]:** Salesforce/codegen-350M-mono37 38## Uses39 40<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->41 42### Direct Use43 44<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->45 46The model can be used for:47 48* Translating natural language prompts into functional Python code.49 50* Assisting in code autocompletion or boilerplate generation.51 52* Supporting educational and prototyping environments.53 54### Downstream Use55 56<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->57 58Can be integrated into:59 60* Developer tools (IDE plugins or assistants).61 62* Chatbots for code assistance or educational coding tutors.63 64* LLM pipelines for multi-step reasoning or coding workflows.65 66### Out-of-Scope Use67 68<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->69 70* Generating production-level code without human review.71 72* Security-critical or real-time applications (e.g., code execution automation).73 74* Generation of malicious or unsafe code.75 76## Bias, Risks, and Limitations77 78<!-- This section is meant to convey both technical and sociotechnical limitations. -->79 80* The model may produce incomplete or syntactically incorrect code for ambiguous prompts.81 82* It can misinterpret vague natural language queries (semantic drift).83 84* Potential bias toward common Python idioms and limited handling of rare libraries or APIs.85 86 87## How to Get Started with the Model88 89Use the code below to get started with the model.90```91from transformers import AutoTokenizer, AutoModelForCausalLM92 93model_id = "akshayb/nl-code-gen-python"94tokenizer = AutoTokenizer.from_pretrained(model_id)95model = AutoModelForCausalLM.from_pretrained(model_id)96 97prompt = "write a python function to check mysql database connection"98inputs = tokenizer(prompt, return_tensors="pt")99outputs = model.generate(**inputs, max_new_tokens=256)100print(tokenizer.decode(outputs[0], skip_special_tokens=True))101```102 103## Training Details104 105### Training Data106 107<!-- 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. -->108 109The dataset contains paired natural language descriptions 110and Python function implementations, collected and cleaned 111from public code repositories and text-to-code benchmarks (e.g., CodeXGLUE). 112Preprocessing involved deduplication, tokenization, and removal of incomplete code samples.113 114## Evaluation115 116<!-- This section describes the evaluation protocols and provides the results. -->117 118#### Metrics119 120<!-- These are the evaluation metrics being used, ideally with a description of why. -->121For Comparison between Base Model and Fine-tuned model, we use the following metrics:122 123| Metric           | Focus                          | Strength                                  |124| ---------------- | ------------------------------ | ----------------------------------------- |125| **BLEU**         | Token-level similarity         | Measures fluency and lexical accuracy     |126| **CodeBLEU**     | Lexical + syntactic + semantic | Captures holistic code quality            |127| **Exact Match**  | String equality                | Strict correctness measure                |128| **Syntax Match** | AST structure                  | Validates syntactic and logical integrity |129 130 131## Citation [optional]132 133<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->134 135**BibTeX:**136```137@misc{akshay2025nlcodegen,138  title={Natural Language to Code Generation (Fine-tuned CodeGen-350M)},139  author={Akshay Bharadwaj},140  year={2025},141  howpublished={\url{https://huggingface.co/akshayb/nl-code-gen-python}}142}143```144 145- PEFT 0.7.2.dev0