local-repo-coder-v0 / README.md
reshinthadith's picture
Update README.md
4287a63 verified
|
raw
history blame
2.24 kB
metadata
library_name: transformers
license: apache-2.0
base_model:
  - Qwen/Qwen2.5-Coder-3B-Instruct

Model Card for Model ID

Generates and Edits minimal multi-file python code. Right now consistently generates upto 2-3 files with a runner.sh bash script that orchestrates the file. Maintains the PEP-8 style.

Model Details

Model Description

  • Developed by: Reshinth Adithyan
  • License: Apache 2.0

Model Sources [optional]

Generated Format

The model generates the repository in the following format, Code to parse it and make a repository is also given below

<libs>pytorch,wandb</libs>
<planning>PLANNING AS MARKDOWN FORMAT</planning>
<requirements>>CONTENT FOR THE REQS FILE HERE</requirements>
<output><file1>src/dataset.py<content>YOUR PYTHON CODE HERE</content></file1>
<file2>src/model.py<content>YOUR PYTHON CODE HERE</content></file2>
<bashfile>run.sh<content>python3 src/model.py</content></bashfile></output>

Usage

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
import fire


def main(model_path:str="./models_dir/repo_coder_v1"):
    input_prompt =  "###Instruction: {prompt}".format(prompt="Generate a small python repo for matplotlib to visualize timeseries data to read from timeseries.csv file using pandas.")

    def load_model(model_path):
        """
        Load the model and tokenizer from the specified path.
        """
        tokenizer = AutoTokenizer.from_pretrained(model_path)
        model = AutoModelForCausalLM.from_pretrained(model_path, torch_dtype="auto")
        return model, tokenizer


    model, tokenizer = load_model(model_path)
    print(f"Loaded model from {model_path}.")

    input = tokenizer(input_prompt, return_tensors="pt").to(model.device)
    print(input)
    with torch.no_grad():
        output = model.generate(**input, max_length=1024, do_sample=True, temperature=0.9, top_p=0.95, top_k=50)
        output_text = tokenizer.decode(output[0], skip_special_tokens=True)
        print(f"Generated text: {output_text}")

if __name__ == "__main__":
    fire.Fire(main)