Update README.md
Browse files
README.md
CHANGED
@@ -28,50 +28,38 @@ Generate Python code that accomplishes the task instructed.
|
|
28 |
|
29 |
Parameter Efficient Finetuning(PEFT) a 4bit quantized Llama-2-7b-Chat from TheBloke/Llama-2-7b-Chat-GPTQ on flytech/python-codes-25k dataset.
|
30 |
|
31 |
-
|
32 |
-
- **Model type:**
|
33 |
- **Language(s) (NLP):** English
|
34 |
- **License:** openrail
|
35 |
-
- **
|
36 |
-
- **
|
|
|
|
|
37 |
|
38 |
## Intended uses & limitations
|
39 |
|
40 |
-
Addressing the
|
41 |
|
42 |
### How to use
|
43 |
|
44 |
-
|
45 |
-
query_question_with_context = """sql_prompt: Which economic diversification efforts in
|
46 |
-
the 'diversification' table have a higher budget than the average budget for all economic diversification efforts in the 'budget' table?
|
47 |
-
sql_context: CREATE TABLE diversification (id INT, effort VARCHAR(50), budget FLOAT); CREATE TABLE
|
48 |
-
budget (diversification_id INT, diversification_effort VARCHAR(50), amount FLOAT);"""
|
49 |
-
```
|
50 |
|
51 |
-
# Use a pipeline as a high-level helper
|
52 |
```python
|
53 |
-
|
54 |
-
|
55 |
-
sql_generator = pipeline("text2text-generation", model="SwastikM/bart-large-nl2sql")
|
56 |
-
|
57 |
-
sql = sql_generator(query_question_with_context)[0]['generated_text']
|
58 |
-
|
59 |
-
print(sql)
|
60 |
```
|
61 |
-
|
62 |
-
# Load model directly
|
63 |
-
|
64 |
```python
|
65 |
-
from
|
|
|
66 |
|
67 |
-
|
68 |
-
model =
|
|
|
|
|
69 |
|
70 |
-
inputs = tokenizer(
|
71 |
-
outputs = model.generate(inputs, max_new_tokens=
|
|
|
72 |
|
73 |
-
|
74 |
-
print(sql)
|
75 |
```
|
76 |
|
77 |
|
|
|
28 |
|
29 |
Parameter Efficient Finetuning(PEFT) a 4bit quantized Llama-2-7b-Chat from TheBloke/Llama-2-7b-Chat-GPTQ on flytech/python-codes-25k dataset.
|
30 |
|
|
|
|
|
31 |
- **Language(s) (NLP):** English
|
32 |
- **License:** openrail
|
33 |
+
- **Qunatization:** GPTQ 4bit
|
34 |
+
- **PEFT:** LoRA
|
35 |
+
- **Finetuned from model [TheBloke/Llama-2-7b-Chat-GPTQ](https://huggingface.co/TheBloke/Llama-2-7B-Chat-GPTQ)**
|
36 |
+
- **Dataset:** [flytech/python-codes-25k](https://huggingface.co/datasets/flytech/python-codes-25k)
|
37 |
|
38 |
## Intended uses & limitations
|
39 |
|
40 |
+
Addressing the efficay of Quantization and PEFT. Implemented as a personal Project.
|
41 |
|
42 |
### How to use
|
43 |
|
44 |
+
The quantized model is finetuned as PEFT. We have the trained Adapter. <br>The trained adpated needs to be merged with Base Model on which it was trained.
|
|
|
|
|
|
|
|
|
|
|
45 |
|
|
|
46 |
```python
|
47 |
+
instruction = """model_input = "Help me set up my daily to-do list!""""
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
```
|
|
|
|
|
|
|
49 |
```python
|
50 |
+
from peft import PeftModel, PeftConfig
|
51 |
+
from transformers import AutoModelForCausalLM
|
52 |
|
53 |
+
config = PeftConfig.from_pretrained("SwastikM/Llama-2-7B-Chat-text2code")
|
54 |
+
model = AutoModelForCausalLM.from_pretrained("TheBloke/Llama-2-7b-Chat-GPTQ")
|
55 |
+
model = PeftModel.from_pretrained(model, "SwastikM/Llama-2-7B-Chat-text2code")
|
56 |
+
tokenizer = AutoTokenizer.from_pretrained("SwastikM/Llama-2-7B-Chat-text2code")
|
57 |
|
58 |
+
inputs = tokenizer(instruction, return_tensors="pt").input_ids.to('cuda')
|
59 |
+
outputs = model.generate(inputs, max_new_tokens=500, do_sample=False, num_beams=1)
|
60 |
+
code = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
61 |
|
62 |
+
print(code)
|
|
|
63 |
```
|
64 |
|
65 |
|