|
--- |
|
license: mit |
|
datasets: |
|
- Vezora/Tested-143k-Python-Alpaca |
|
language: |
|
- en |
|
pipeline_tag: text2text-generation |
|
tags: |
|
- code |
|
inference: |
|
parameters: |
|
max_new_tokens: 100 |
|
do_sample: false |
|
--- |
|
# Gemma-2B Fine-Tuned Python Model |
|
|
|
## Overview |
|
Gemma-2B Fine-Tuned Python Model is based on the Gemma-2B architecture,fine-tuned using the Qlora technique specifically for Python programming tasks. This model is designed to understand Python code and assist developers by providing suggestions, completing code snippets, or offering corrections toimprove code quality and efficiency. |
|
|
|
## Model Details |
|
- **Model Name**: Gemma-2B Fine-Tuned Python Model |
|
- **Base Model**: Gemma-2B |
|
- **Language**: Python |
|
- **Task**: Python Code Understanding and Assistance |
|
|
|
## Example Use Cases |
|
- Code completion: Automatically completing code snippets based on partial inputs. |
|
- Syntax correction: Identifying and suggesting corrections for syntax errors in Python code. |
|
- Code quality improvement: Providing suggestions to enhance code readability, efficiency, and maintainability. |
|
- Debugging assistance: Offering insights and suggestions to debug Python code by identifying potential errors or inefficiencies. |
|
|
|
## How to Use |
|
1. **Install Gemma Python Package**: |
|
```bash |
|
pip install transformers |
|
``` |
|
|
|
## Inference |
|
```python |
|
# Load model directly |
|
from transformers import AutoTokenizer, AutoModelForCausalLM |
|
|
|
tokenizer = AutoTokenizer.from_pretrained("suriya7/Gemma-2B-Finetuned-Python-Model") |
|
model = AutoModelForCausalLM.from_pretrained("suriya7/Gemma-2B-Finetuned-Python-Model") |
|
|
|
query = input('enter a query:') |
|
prompt_template = f""" |
|
<start_of_turn>user based on given instruction create a solution\n\nhere are the instruction {query} |
|
<end_of_turn>\n<start_of_turn>model |
|
""" |
|
prompt = prompt_template |
|
encodeds = tokenizer(prompt, return_tensors="pt", add_special_tokens=True) |
|
|
|
model_inputs = encodeds.to('cuda') |
|
|
|
# Increase max_new_tokens if needed |
|
generated_ids = merged_model.generate(**model_inputs, max_new_tokens=1000, do_sample=False, pad_token_id=tokenizer.eos_token_id) |
|
output = '' |
|
for i in tokenizer.decode(generated_ids[0], skip_special_tokens=True).split('<end_of_turn>')[:2]:# extracting model response |
|
ans+=i |
|
cleaned_output = output.replace('<start_of_turn>', '') |
|
print(cleaned_output) |
|
``` |