File size: 2,236 Bytes
8639f09
 
c70bb0f
 
 
8639f09
 
 
 
c70bb0f
8639f09
 
 
 
 
 
c70bb0f
 
8639f09
 
 
 
 
c70bb0f
4287a63
 
 
 
 
 
 
 
 
 
 
 
f304736
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
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]

<!-- Provide the basic links for the model. -->

- **Repository:** https://github.com/reshinthadithyan/repo-level-code/tree/main

### Generated Format
The model generates the repository in the following format, Code to parse it and make a repository is also given below
```txt
<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
```python
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)
```