Update README.md
Browse files
README.md
CHANGED
@@ -14,27 +14,45 @@ This is a fine-tuned version of LLAMA2 trained (7b) on spider, sql-create-contex
|
|
14 |
|
15 |
To initialize the model:
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
|
22 |
Use the tokenizer:
|
23 |
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
-
To generate text using the model:
|
31 |
-
|
32 |
-
#output = model.generate(input["input_ids"],attention_mask=input["attention_mask"],
|
33 |
-
# forced_bos_token_id=tokenizer_it.lang_code_to_id["en_XX"])
|
34 |
|
|
|
35 |
|
36 |
-
|
37 |
|
38 |
-
#h.logits, h.loss = model(input_ids=input["input_ids"],
|
39 |
-
# attention_mask=input["attention_mask"],
|
40 |
-
# labels=input["labels"])
|
|
|
14 |
|
15 |
To initialize the model:
|
16 |
|
17 |
+
bnb_config = BitsAndBytesConfig(
|
18 |
+
load_in_4bit=use_4bit,
|
19 |
+
bnb_4bit_quant_type=bnb_4bit_quant_type,
|
20 |
+
bnb_4bit_compute_dtype=compute_dtype,
|
21 |
+
bnb_4bit_use_double_quant=use_nested_quant,
|
22 |
+
)
|
23 |
+
|
24 |
+
model = AutoModelForCausalLM.from_pretrained(
|
25 |
+
model_name,
|
26 |
+
quantization_config=bnb_config,
|
27 |
+
device_map=device_map,
|
28 |
+
trust_remote_code=True
|
29 |
+
)
|
30 |
|
31 |
|
32 |
Use the tokenizer:
|
33 |
|
34 |
|
35 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
36 |
+
tokenizer.pad_token = tokenizer.eos_token
|
37 |
+
tokenizer.padding_side = "right"
|
38 |
+
|
39 |
+
To get the prompt:
|
40 |
+
dataset = dataset.map(
|
41 |
+
lambda example: {
|
42 |
+
"input": "### Instruction: \nYou are a powerful text-to-SQL model. \
|
43 |
+
Your job is to answer questions about a database. You are given \
|
44 |
+
a question and context regarding one or more tables. \n\nYou must \
|
45 |
+
output the SQL query that answers the question. \
|
46 |
+
\n\n \
|
47 |
+
### Dialect:\n\nsqlite\n\n \
|
48 |
+
### question:\n\n"+ example["question"]+" \
|
49 |
+
\n\n### Context:\n\n"+example["context"],
|
50 |
+
"answer": example["answer"]
|
51 |
+
}
|
52 |
+
)
|
53 |
|
|
|
|
|
|
|
|
|
54 |
|
55 |
+
To generate text using the model:
|
56 |
|
57 |
+
output = model.generate(input["input_ids"])
|
58 |
|
|
|
|
|
|