pavankumarbalijepalli/phi2-sqlcoder

Hugging Face
TEXT GENERATIONConcurrency Cost:1Model Size:3BQuant:BF16Ctx Length:2kPublished:Feb 21, 2024License:mitArchitecture:Transformer0.0K Open Weights Warm

pavankumarbalijepalli/phi2-sqlcoder is a 3 billion parameter causal language model, fine-tuned from Microsoft's Phi-2 architecture. Optimized for Natural Language to SQL (NL2SQL) tasks, it translates natural language questions and database schemas into PostgreSQL queries. This model offers significantly faster inference times and higher execution success rates compared to larger alternatives like SQLCoder-7b-2, making it efficient for CPU-bound environments, though it has a limited context window of 2048 tokens.

Loading preview...

Model Overview

pavankumarbalijepalli/phi2-sqlcoder is a 3 billion parameter causal language model, fine-tuned from microsoft/phi-2 specifically for Natural Language to SQL (NL2SQL) tasks. It leverages the b-mc2/sql-create-context dataset to generate SQL queries from natural language questions and database schemas.

Key Capabilities & Performance

This model demonstrates notable efficiency and accuracy for NL2SQL:

  • Faster Inference: Achieves 41% faster inference times compared to defog/sqlcoder-7b-2 on CPU machines, averaging 24 seconds per query.
  • Higher Execution Success: Shows a 29% higher execution success rate than defog/sqlcoder-7b-2 on holdback datasets.
  • Optimized for CPU: Designed to perform well on CPU machines with limited RAM, making it suitable for deployment on lower-powered devices.
  • PostgreSQL Output: Generates SQL queries specifically for PostgreSQL syntax.

Limitations & Considerations

  • Context Window: Has a limited context window of 2048 tokens, requiring careful input engineering for complex queries.
  • Complexity: While competitive on easy and medium queries, it may face challenges with highly intricate SQL tasks compared to larger models.
  • Security Risks: Like other NL2SQL models, it can be susceptible to SQL injection attacks if not properly secured.
  • Out-of-Scope Use: Not intended for generating critical production code without human oversight or for SQL dialects other than PostgreSQL.

Use Cases

  • Translating natural language questions into SQL queries for database interaction.
  • Applications requiring efficient, on-device SQL generation where context length can be managed.
  • Educational tools or prototypes for demonstrating NL2SQL capabilities.