🧠 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

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

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))

Downloads last month
93
Safetensors
Model size
357M params
Tensor type
F32
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support