Defog’s SQLCoder is a state-of-the-art LLM for converting natural language questions to SQL queries.

SQLCoder-34B is a 34B parameter model that outperforms gpt-4 and gpt-4-turbo for natural language to SQL generation tasks on our sql-eval framework, and significantly outperforms all popular open-source models.

https://huggingface.co/defog/sqlcoder-34b-alpha

SQLCoder-34B is fine-tuned on a base CodeLlama model.

Results on novel datasets not seen in training

model perc_correct

defog-sqlcoder-34b 84.0%

gpt4-turbo-2023-11-09 82.5%

gpt4-2023-11-09 82.5%

defog-sqlcoder2 77.5%

gpt4-2023-08-28 74.0%

defog-sqlcoder-7b 71.0%

gpt-3.5-2023-10-04 66.0%

claude-2 64.5%

gpt-3.5-2023-08-28 61.0%

claude_instant_1 61.0%

text-davinci-003 52.5%

Defog was trained on more than 20,000 human-curated questions. These questions were based on 10 different schemas. None of the schemas in the training data were included in our evaluation framework.

You can read more about our training approach and evaluation framework.

SQLCoder-34B has been tested on a 4xA10 GPU with float16 weights. You can also load an 8-bit and 4-bit quantized version of the model on consumer GPUs with 20GB or more of memory – like RTX 4090, RTX 3090, and Apple M2 Pro, M2 Max, or M2 Ultra Chips with 20GB or more of memory.

  • jubjub07@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    10 months ago

    I’m not quite understanding something - when I run the example colab code linked, it actually loads a different model (model_name = “codellama/CodeLlama-34b-hf”) which I can load fine.

    When I search for THIS model (defog/sqlcoder-34b-hf) and find it on HF, I tried to load it locally on my 2x3090 system and I get out of memory - same error with 8-bit and 4-bit set per the Notebook.

    So… which is the correct model? The one mentioned here in the post or the one in the Colab demo?

    Assuming the HF repository for defog/sqlcoder-34b-alpha is the correct one… I have run into the following problem:

    Using the colab notebook, but changing to the correct model mentioned in this post…

    Download of model is fine, loads to GPUs and shows about 1/2 of my memory is used… (with the 4-bit option set)…

    However, when I run the model.generate I get out-of-memory error…

    Code Cell:

    inputs = tokenizer(prompt, return_tensors=“pt”).to(“cuda”)

    generated_ids = model.generate(

    **inputs,

    num_return_sequences=1,

    eos_token_id=eos_token_id,

    pad_token_id=eos_token_id,

    max_new_tokens=400,

    do_sample=False,

    num_beams=1,

    )

    OutOfMemoryError: CUDA out of memory. Tried to allocate 14.41 GiB. GPU 0 has a total capacty of 23.69 GiB of which 6.11 GiB is free. Process 3797 has 306.20 MiB memory in use. Including non-PyTorch memory, this process has 17.26 GiB memory in use. Of the allocated memory 16.02 GiB is allocated by PyTorch, and 958.46 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

    From the model card.

    "Hardware Requirements

    SQLCoder-34B has been tested on a 4xA10 GPU with float16
    weights. You can also load an 8-bit and 4-bit quantized version of the model on consumer GPUs with 20GB or more of memory – like RTX 4090, RTX 3090, and Apple M2 Pro, M2 Max, or M2 Ultra Chips with 20GB or more of memory."

    Any thoughts appreciated.

  • staring_at_keyboard@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    10 months ago

    I looked at your eval framework. I have adopted a similar subset / superset result set matching approach in some of my research. One word of caution is that result set matching cannot prove semantic equivalence; so you may want to consider adding multiple database instances to reduce false positives. False positives are particularly prevalent when gold queries generate scalar values or empty result sets.

    Are you planning on submitting SQLCoder-34b to other NL-to-SQL benchmarks like Spider or its other derivatives?

  • YearZero@alien.topB
    link
    fedilink
    English
    arrow-up
    0
    ·
    10 months ago

    I’d love to see a comparison with DeepseekCoder instruct 34b as well, as I think this is the open source SOTA.

    • SomeOddCodeGuy@alien.topB
      link
      fedilink
      English
      arrow-up
      1
      ·
      10 months ago

      Deepseek-coder-33b-instruct is current open source coding SOTA?

      I’m interested to know how people are using it, because someone mentioned that it was a Llama 1 with 2048 context, and generally for development I need a lot more than that. I’m not sure how I’d be able to make use of a 2048 context coding model. :(

      • kryptkpr@alien.topB
        link
        fedilink
        English
        arrow-up
        1
        ·
        10 months ago

        DeepSeek is not based on any llama training, it’s a 2T token pretrain of their own. 16k context. All this info is at the top of their model card.

        • SomeOddCodeGuy@alien.topB
          link
          fedilink
          English
          arrow-up
          1
          ·
          10 months ago

          Ahhh I apologize, I didn’t realize that it’s a totally new base model, and not built off of any Llama base. I could have sworn I read that it was, but it would appear I was incorrect.

          Thanks!