Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 7 min read How-to mediumAdept

Text2SQL using Hugging Face Dataset Viewer API and Motherduck DuckDB-NSQL-7B

DuckDB-NSQL-7B, a Llama-2-7B model fine-tuned on general SQL and then DuckDB text-to-SQL pairs, can turn plain-language questions into DuckDB SQL that runs directly against Hugging Face datasets. The pipeline fetches a dataset's auto-converted parquet URL from the Dataset Viewer API and derives a CREATE TABLE schema by loading one row into DuckDB. It then prompts the quantized GGUF model through llama.cpp with the schema and question, rewrites the table name to the parquet URL, and executes the query in DuckDB. On the world-cities-geo dataset the generated query matches the results of the Viewer's search and filter APIs.

Related posts

  • Introducing the SQL Console on Datasets

    Hugging Face mediumAdept

    Hugging Face Hub datasets now have a one-click SQL Console that runs DuckDB WASM entirely in the browser against each dataset's Parquet files, with views created per split and config. Non-Parquet datasets have their first 5GB auto-converted. A simple filter over a 12.6M-row dataset returns in under 3 seconds, but memory is capped at roughly 3GB and DuckDB WASM lacks some DuckDB features such as the hf:// protocol. A worked example uses struct_pack to convert an Alpaca dataset into conversational format for LLM fine-tuning and exports the results to Parquet.

  • DuckDB: analyze 50,000+ datasets stored on the Hugging Face Hub

    Hugging Face mediumAdept

    Every public dataset on the Hugging Face Hub is now automatically converted to Parquet by the dataset viewer and can be queried with SQL through DuckDB. Parquet file URLs come from the datasets-server `/parquet` HTTP endpoint, and DuckDB's `httpfs` extension then runs analytical queries directly against those remote files. Large datasets are sharded into 500MB Parquet chunks, which DuckDB can query together as multiple files.

  • Building a RAG pipeline for Google Analytics with ClickHouse and Amazon Bedrock

    ClickHouse mediumAdept

    A natural language interface over raw Google Analytics data stored in ClickHouse is built as a multi-step RAG pipeline that generates SQL from user questions using Amazon Bedrock models. Drawing on text-to-SQL research such as DAIL-SQL from the Spider benchmark, the design retrieves similar example questions and their SQL via vector embeddings, because concepts like "returning users" cannot be inferred from the schema alone. Embeddings come from a Python executable-pool UDF calling Titan embeddings, with retries and backoff for Bedrock quotas, and are invoked at query or insert time. ClickHouse serves as both the vector store and the analytics database, and specific settings are given to parallelize embedding generation on small tables.

  • Visualizing BlueSky data with Evidence.dev

    ClickHouse mediumAdept

    Evidence.dev builds dashboards from SQL and markdown, running queries at build time rather than at request time. Query results are stored as Parquet files and queried in the browser with DuckDB WASM, which gives up data freshness in exchange for fast page loads. The walkthrough installs a community ClickHouse connector, points it at the public BlueSky dataset, and writes one query per .sql file. It then runs `npm run sources`, renders a BarChart component in a markdown page, and deploys the result as a static site or to Evidence Cloud with scheduled refreshes.

  • Generate embeddings with Neon AI Gateway

    Neon mediumAdept

    Neon AI Gateway now serves embedding models on its OpenAI-compatible /v1/embeddings endpoint using the same branch-scoped credential as chat, accepting up to 150 inputs per request. Two models launch: qwen3-embedding-0-6b (1024 configurable dimensions, normalized, $0.02 per 1M tokens) and gte-large-en (1024 dimensions, unnormalized, $0.13 per 1M tokens), with qwen recommended unless matching existing vectors. Combined with Object Storage triggers, Functions, Lakebase Postgres and the lakebase_vector/lakebase_text search extensions, a full RAG pipeline (ingest, embed, store, hybrid retrieve, generate) runs inside one Neon branch, letting teams re-embed and evaluate model or chunking changes against production data without duplicating storage.

The quest for software engineering knowledge.

Look:
Layout: