File size: 2,167 Bytes
1257056
 
1d85a86
 
 
 
 
 
 
 
 
1257056
 
 
 
1d85a86
1257056
1d85a86
 
 
 
 
1257056
5895508
1257056
 
 
5895508
1d85a86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1257056
 
 
 
 
 
 
1d85a86
 
1257056
1d85a86
1257056
1d85a86
1257056
1d85a86
1257056
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
69
70
71
72
73
74
75
76
77
78
---
library_name: transformers
tags:
- OUAF
- Oracle
- 4GL
license: mit
language:
- en
base_model:
- microsoft/phi-2
---

### Model Description

Generate 4GL Scripts from english prompts

- **Developed by:** Amith Sourya Sadineni
- **Model type:** Text Generation
- **Language(s):** Python
- **License:** MIT
- **Finetuned from model:** microsoft/phi-2

### Model Sources

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

- **Repository:** https://huggingface.co/amithsourya/Script-Generate-4GL-V2.0/blob/main/adapter_model.safetensors
- **Demo:**
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel, PeftConfig

lora_path = "amithsourya/Script-Generate-4GL-V2.0"
peft_config = PeftConfig.from_pretrained(lora_path)

base_model = AutoModelForCausalLM.from_pretrained(
    peft_config.base_model_name_or_path,
    device_map="auto",
    torch_dtype="auto"
)

model = PeftModel.from_pretrained(base_model, lora_path)
tokenizer = AutoTokenizer.from_pretrained(peft_config.base_model_name_or_path)

import re
def clean_output(text):
    return re.sub(r'""([^""]+)""', r'"\1"', text)

from transformers import pipeline
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer, device_map="auto")

prompt = "Invoke a Service Script using Save point dispatcher"
output = pipe(
    prompt,
    max_new_tokens=256,
    eos_token_id=tokenizer.eos_token_id,
    return_full_text=False
)
print(clean_output(output[0]["generated_text"]))
```

## Environmental Impact

<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->

Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).

- **Hardware Type:** T4 GPU
- **Hours used:** 2H:30M

## Example

![image/png](https://cdn-uploads.huggingface.co/production/uploads/682b328fb814376780257a17/JyCAflY-N1QQe0BWeplTa.png)

![image/png](https://cdn-uploads.huggingface.co/production/uploads/682b328fb814376780257a17/kteVhgJZluGYKwg5bxG_m.png)