|
--- |
|
language: en |
|
license: mit |
|
tags: |
|
- code |
|
- python |
|
- assistant |
|
- causal-lm |
|
- streamlit |
|
pipeline_tag: text-generation |
|
--- |
|
|
|
# π§ Python Code Assistant (Fine-tuned CodeGen 350M) |
|
|
|
This model is a fine-tuned version of `Salesforce/codegen-350M-multi` designed to assist with Python code generation based on natural language prompts. |
|
|
|
## π§ͺ Example Prompt |
|
|
|
``` |
|
Write a Python function to check if a number is prime. |
|
``` |
|
|
|
## β
Example Output |
|
|
|
```python |
|
def is_prime(n): |
|
if n < 2: |
|
return False |
|
for i in range(2, int(n ** 0.5) + 1): |
|
if n % i == 0: |
|
return False |
|
return True |
|
``` |
|
|
|
## π οΈ Intended Use |
|
|
|
- Educational coding help |
|
- Rapid prototyping in notebooks or IDEs |
|
- Integration with Streamlit apps |
|
|
|
> π« Not intended to replace formal code review or secure programming practices. |
|
|
|
## π Model Details |
|
|
|
- Base: `Salesforce/codegen-350M-multi` |
|
- Training: Fine-tuned on 500+ Python instruction-completion pairs |
|
- Format: causal LM |
|
|
|
## π§° How to Use |
|
|
|
```python |
|
from transformers import AutoModelForCausalLM, AutoTokenizer |
|
|
|
model = AutoModelForCausalLM.from_pretrained("AhsanFarabi/python-assistant") |
|
tokenizer = AutoTokenizer.from_pretrained("AhsanFarabi/python-assistant") |
|
|
|
prompt = "Write a function to reverse a string." |
|
inputs = tokenizer(prompt, return_tensors="pt") |
|
outputs = model.generate(**inputs, max_new_tokens=128) |
|
print(tokenizer.decode(outputs[0], skip_special_tokens=True)) |
|
``` |
|
|
|
--- |
|
|