File size: 1,491 Bytes
cff0b81
 
 
26df4ed
cff0b81
 
 
26df4ed
4346eac
26df4ed
 
 
 
 
 
b52f8cb
 
3221792
 
 
 
 
 
b52f8cb
3221792
 
 
 
 
b52f8cb
26df4ed
 
 
 
b52f8cb
 
 
3221792
 
86c8fee
3221792
 
 
 
 
 
 
 
 
 
 
 
 
26df4ed
 
3221792
26df4ed
4346eac
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
---
language:
- en
pipeline_tag: text2text-generation
metrics:
- f1
tags:
- english
- sql
---

This is a fine-tuned version of LLAMA2 trained (7b) on spider, sql-create-context.

To initialize the model:


    bnb_config = BitsAndBytesConfig(
    load_in_4bit=use_4bit,
    bnb_4bit_quant_type=bnb_4bit_quant_type,
    bnb_4bit_compute_dtype=compute_dtype,
    bnb_4bit_use_double_quant=use_nested_quant,
)

    model = AutoModelForCausalLM.from_pretrained(
    model_name,
    quantization_config=bnb_config,
    device_map=device_map,
    trust_remote_code=True
)

    
Use the tokenizer:

    
    tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
    tokenizer.pad_token = tokenizer.eos_token
    tokenizer.padding_side = "right"

To get the prompt:

    dataset = dataset.map(
    lambda example: {
        "input": "### Instruction: \nYou are a powerful text-to-SQL model.   \
                    Your job is to answer questions about a database. You are given \
                    a question and context regarding one or more tables. \n\nYou must \
                    output the SQL query that answers the question.   \
                    \n\n \
                    ### Dialect:\n\nsqlite\n\n \
                    ### question:\n\n"+ example["question"]+" \
                    \n\n### Context:\n\n"+example["context"],
        "answer": example["answer"]
    }
    )


To generate text using the model:

    output = model.generate(input["input_ids"])