From e7dc82ef27996898dba2b6125b78bf02e30f01bb Mon Sep 17 00:00:00 2001 From: Brejesh Balakrishnan Date: Sun, 11 Jan 2026 08:39:21 +0000 Subject: [PATCH 1/7] feat: add diagnostics panel and runtime config checker; ci: gate with compileall; docs: update README and add deploy_streamlit_cloud.md Co-authored-by: Cosine --- .github/workflows/ci.yml | 3 + README.md | 12 +- app/streamlit_app.py | 115 ++++++++++++++- docs/deploy_streamlit_cloud.md | 241 ++++++++++++++++++++++++++++++++ scripts/check_runtime_config.py | 196 ++++++++++++++++++++++++++ 5 files changed, 565 insertions(+), 2 deletions(-) create mode 100644 docs/deploy_streamlit_cloud.md create mode 100644 scripts/check_runtime_config.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db260f3..8ab6e24 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,9 @@ jobs: python -m pip install -r requirements.txt python -m pip install ruff + - name: Compile all Python files (syntax gate) + run: python -m compileall . + - name: Syntax check (compileall) run: python scripts/check_syntax.py diff --git a/README.md b/README.md index b6946d9..f314a14 100644 --- a/README.md +++ b/README.md @@ -258,6 +258,9 @@ For details, see [`docs/external_validation.md`](./docs/external_validation.md). For a quick local quality check before pushing changes, you can run: ```bash +# 0) Verify runtime configuration for HF / OpenAI providers +python scripts/check_runtime_config.py + # 1) Syntax validation across src/, scripts/, and app/ python scripts/check_syntax.py @@ -268,7 +271,9 @@ ruff check . pytest -q ``` -These commands are also wired into the CI workflow (`.github/workflows/ci.yml`). +These commands are also wired into the CI workflow (`.github/workflows/ci.yml`), +with an additional `python -m compileall .` safety gate to catch syntax errors +early. --- @@ -397,10 +402,15 @@ When deploying to Streamlit Cloud: - Add `HF_TOKEN`, `HF_ENDPOINT_URL`, and `HF_ADAPTER_ID` (or `HF_MODEL_ID` / `HF_PROVIDER` for the router fallback) to the app's **Secrets** in the Streamlit Cloud UI. +- Optionally configure `OPENAI_API_KEY` (and `OPENAI_FALLBACK_MODEL`, which + defaults to `gpt-5-nano`) to enable the OpenAI fallback path when HF + inference fails. - The app will automatically construct an `InferenceClient` from those values and use the dedicated endpoint when `HF_ENDPOINT_URL` is set. - No GPU is required on the Streamlit side; all heavy lifting is done by the remote Hugging Face Inference backend. +- For a step-by-step deployment walkthrough (including screenshots and + details on secrets), see [`docs/deploy_streamlit_cloud.md`](./docs/deploy_streamlit_cloud.md). --- diff --git a/app/streamlit_app.py b/app/streamlit_app.py index 8d07200..2d0122f 100644 --- a/app/streamlit_app.py +++ b/app/streamlit_app.py @@ -45,6 +45,7 @@ import json import logging import os +import time from typing import Any, Mapping, NamedTuple, Optional, Tuple import streamlit as st @@ -479,13 +480,43 @@ def _extract_sql_from_text(raw_text: str) -> str: return raw_text.strip() +def _update_last_request_diagnostics( + provider_label: str, + endpoint_paused: bool, + duration_ms: float, + max_tokens: int, +) -> None: + """ + Store lightweight diagnostics about the last inference request. + + Diagnostics are kept in Streamlit's session_state (when available) so that + the UI can render them in a dedicated Diagnostics panel without exposing + stack traces or raw exception objects. + """ + try: + state = st.session_state # type: ignore[attr-defined] + except Exception: # noqa: BLE001 + return + + try: + state["diagnostics_last_request"] = { + "provider": provider_label, + "endpoint_paused": bool(endpoint_paused), + "duration_ms": float(duration_ms), + "max_tokens": int(max_tokens), + } + except Exception: # noqa: BLE001 + # Diagnostics should never break the main app flow. + logger.debug("Failed to update diagnostics in session_state.", exc_info=True) + + def _call_model( client: InferenceClient, schema: str, question: str, temperature: float, max_tokens: int, - timeout_s: int = 45, + timeout_s: int = 45, # noqa: ARG001 adapter_id: Optional[str] = None, use_endpoint: bool = False, ) -> Tuple[Optional[str], str]: @@ -510,20 +541,29 @@ def _call_model( if use_endpoint and adapter_id: generation_kwargs["adapter_id"] = adapter_id + provider_label = "HF" + endpoint_paused = False + start = time.perf_counter() + try: response = client.text_generation(**generation_kwargs) except Exception as exc: # noqa: BLE001 message = str(exc) if exc is not None else "" lower_message = message.lower() if "endpoint is paused" in lower_message: + endpoint_paused = True logger.warning( "Hugging Face Inference endpoint is paused; using OpenAI fallback.", ) + # See HF Inference Endpoints docs on pausing/resuming endpoints: + # https://huggingface.co/docs/inference-endpoints/en/guides/pause_endpoint else: logger.exception( "Error while calling Hugging Face Inference API. " "Attempting OpenAI fallback if configured.", ) + + provider_label = "OpenAI fallback" try: raw_text = _call_openai_fallback( system_prompt=system_prompt, @@ -534,6 +574,13 @@ def _call_model( st.error( "The service is temporarily unavailable. Please try again in a moment." ) + duration_ms = (time.perf_counter() - start) * 1000.0 + _update_last_request_diagnostics( + provider_label=provider_label, + endpoint_paused=endpoint_paused, + duration_ms=duration_ms, + max_tokens=max_tokens, + ) return None, user_prompt if not raw_text.strip(): @@ -546,6 +593,13 @@ def _call_model( sql_text = raw_text.strip() st.caption("Using backup inference provider") + duration_ms = (time.perf_counter() - start) * 1000.0 + _update_last_request_diagnostics( + provider_label=provider_label, + endpoint_paused=endpoint_paused, + duration_ms=duration_ms, + max_tokens=max_tokens, + ) return sql_text, user_prompt # InferenceClient.text_generation may return a string, a dict, or a list. @@ -571,12 +625,67 @@ def _call_model( "Inference API. Please check your endpoint and model configuration." ) st.caption(f"Details: {exc}") + duration_ms = (time.perf_counter() - start) * 1000.0 + _update_last_request_diagnostics( + provider_label=provider_label, + endpoint_paused=endpoint_paused, + duration_ms=duration_ms, + max_tokens=max_tokens, + ) return None, user_prompt sql_text = (text or "").strip() + duration_ms = (time.perf_counter() - start) * 1000.0 + _update_last_request_diagnostics( + provider_label=provider_label, + endpoint_paused=endpoint_paused, + duration_ms=duration_ms, + max_tokens=max_tokens, + ) return sql_text, user_prompt +def _render_diagnostics_sidebar() -> None: + """Render a lightweight diagnostics panel in the sidebar.""" + try: + state = st.session_state # type: ignore[attr-defined] + diagnostics = state.get("diagnostics_last_request") # type: ignore[assignment] + except Exception: # noqa: BLE001 + diagnostics = None + + with st.sidebar.expander("Diagnostics", expanded=False): + if not isinstance(diagnostics, dict): + st.caption("Run a request to see diagnostics for the last call.") + return + + provider_label = diagnostics.get("provider") or "–" + duration_ms = diagnostics.get("duration_ms") + max_tokens = diagnostics.get("max_tokens") + endpoint_paused = bool(diagnostics.get("endpoint_paused")) + + st.markdown(f"**Active provider (last request):** {provider_label}") + + if duration_ms is not None: + try: + duration_val = float(duration_ms) + except Exception: # noqa: BLE001 + duration_val = None + if duration_val is not None: + st.markdown(f"**Request duration:** {duration_val:.0f} ms") + + if max_tokens is not None: + try: + max_tokens_val = int(max_tokens) + except Exception: # noqa: BLE001 + max_tokens_val = None + if max_tokens_val is not None: + st.markdown(f"**Max new tokens parameter:** {max_tokens_val}") + + if endpoint_paused: + # Friendly hint only; do not surface raw exception text or stack traces. + st.info("HF endpoint is paused; resume it in HF Endpoints → Overview.") + + def main() -> None: """Render the Streamlit UI.""" _configure_logging() @@ -633,9 +742,11 @@ def main() -> None: if generate_clicked: if not schema.strip(): st.warning("Please provide a database schema (DDL) before generating SQL.") + _render_diagnostics_sidebar() return if not question.strip(): st.warning("Please provide a natural-language question.") + _render_diagnostics_sidebar() return with st.spinner("Calling Hugging Face Inference API..."): @@ -663,6 +774,8 @@ def main() -> None: "inference endpoint. Please review the error message above." ) + _render_diagnostics_sidebar() + if __name__ == "__main__": main() \ No newline at end of file diff --git a/docs/deploy_streamlit_cloud.md b/docs/deploy_streamlit_cloud.md new file mode 100644 index 0000000..7e14e66 --- /dev/null +++ b/docs/deploy_streamlit_cloud.md @@ -0,0 +1,241 @@ +# Deploying the Streamlit App to Streamlit Community Cloud + +This guide walks through deploying the Analytics Copilot Streamlit UI to +**Streamlit Community Cloud** using this repository as the source of truth. + +The Streamlit app is UI-only and lives at: + +- `app/streamlit_app.py` + +It talks to remote inference backends (Hugging Face Inference + optional OpenAI +fallback) and does not require a GPU on the Streamlit side. + +--- + +## 1. Prerequisites + +Before creating the app on Streamlit Community Cloud: + +1. Push this repository to GitHub (public or private, depending on your plan). +2. Ensure the app runs locally: + + ```bash + # Create a virtualenv and install dependencies (see README for details) + python -m venv .venv + source .venv/bin/activate # Windows: .venv\Scripts\activate + + python -m pip install --upgrade pip + python -m pip install -r requirements.txt + + # Optional but recommended: check runtime config + python scripts/check_runtime_config.py + + # Start the Streamlit app + streamlit run app/streamlit_app.py + ``` + +3. Confirm the UI loads and you can see the input fields (schema + question). + +For more background on Streamlit secrets and `secrets.toml`, see the official +Streamlit docs: + +- Secrets management on Community Cloud + (see [`Secrets management` in the Streamlit docs][streamlit-secrets-docs]) +- Local `secrets.toml` file format + (see [`secrets.toml` reference][streamlit-secrets-toml-docs]) + +--- + +## 2. Create the app on Streamlit Community Cloud + +1. Sign in to Streamlit Community Cloud. +2. Click **New app** and choose **From existing repo**. +3. Select the GitHub repository that contains this project. +4. Choose the branch you want to deploy from (typically `main` or a feature branch). +5. Set the **Main file path** (entrypoint) to: + + ```text + app/streamlit_app.py + ``` + +6. Click **Deploy**. The app will build and start, but it will show + configuration errors until secrets are provided. + +--- + +## 3. Configure secrets (HF + OpenAI) in Streamlit Cloud + +The Streamlit app expects configuration via **Streamlit secrets** (with +environment variables as a secondary fallback). On Community Cloud, secrets are +managed entirely through the web UI. + +### 3.1 Local secrets file (for reference) + +Locally, secrets are stored in: + +```text +.streamlit/secrets.toml +``` + +This file is **ignored by git** (see `.gitignore`) and should never be +committed. The repository provides an example template: + +```text +.streamlit/secrets.toml.example +``` + +You can copy it locally: + +```bash +cp .streamlit/secrets.toml.example .streamlit/secrets.toml +``` + +Then edit `.streamlit/secrets.toml` and fill in the values for your environment. +The same keys and values are what you will paste into the Streamlit Cloud +**Secrets** UI. + +### 3.2 Preferred configuration: Hugging Face Inference Endpoint + adapter + +Recommended for production-like usage: + +```toml +HF_TOKEN = "hf_your_access_token_here" + +# Dedicated Inference Endpoint / TGI URL +HF_ENDPOINT_URL = "https://your-endpoint-1234.us-east-1.aws.endpoints.huggingface.cloud" + +# Adapter identifier configured in your endpoint's LORA_ADAPTERS +HF_ADAPTER_ID = "text2sql-qlora" +``` + +Notes: + +- `HF_TOKEN` should be a token with permission to call your Inference Endpoint. +- `HF_ENDPOINT_URL` points at a dedicated Text Generation Inference (TGI) + endpoint (often with Multi-LoRA configured). +- `HF_ADAPTER_ID` must match the adapter `id` you configured in the endpoint + `LORA_ADAPTERS` setting. + +The app also understands `HF_INFERENCE_BASE_URL` as an alias for +`HF_ENDPOINT_URL`. If both are set, `HF_ENDPOINT_URL` takes precedence. + +### 3.3 Fallback configuration: HF router with a merged model + +If you prefer to call a provider-managed merged model via the HF router (no +adapters), you can configure: + +```toml +HF_TOKEN = "hf_your_access_token_here" +HF_MODEL_ID = "your-username/your-merged-text2sql-model" +HF_PROVIDER = "auto" # optional provider hint +``` + +Notes: + +- Do **not** point `HF_MODEL_ID` at a pure adapter repo; most providers will + respond with `model_not_supported` in that case. +- For adapter-based inference, use the dedicated endpoint pattern above + (`HF_ENDPOINT_URL` + `HF_ADAPTER_ID`). + +### 3.4 Optional OpenAI fallback configuration + +When HF inference fails (for example, endpoint paused or network issues), +the app can automatically fall back to a cheap OpenAI model. + +To enable this, add: + +```toml +OPENAI_API_KEY = "sk_..." # required to use the fallback +OPENAI_FALLBACK_MODEL = "gpt-5-nano" # default if omitted +OPENAI_FALLBACK_STRICT_JSON = "false" # or "true" to request structured JSON +``` + +- If `OPENAI_API_KEY` is missing, the OpenAI fallback is disabled. +- `OPENAI_FALLBACK_MODEL` defaults to `"gpt-5-nano"` when not set, matching the + app’s internal default. +- When `OPENAI_FALLBACK_STRICT_JSON` is a truthy value (`"true"`, `"1"`, + `"yes"`, `"on"`), the app asks for a JSON object of the form + `{"sql": "SELECT ..."}` and tries to parse the `sql` field. + +### 3.5 Pasting secrets into Streamlit Cloud + +In the Streamlit Cloud UI: + +1. Open your deployed app. +2. Go to the app’s **Settings** → **Secrets** section. +3. Copy the contents of your local `.streamlit/secrets.toml` (or build it from + the example) and paste it into the secrets editor. +4. Save the secrets and restart the app if necessary. + +The format is exactly the same TOML syntax as +`.streamlit/secrets.toml.example`. + +--- + +## 4. Verify runtime configuration + +Before relying on the deployed app, you can validate your configuration locally +using the runtime config checker: + +```bash +python scripts/check_runtime_config.py +``` + +This script: + +- Looks for `.streamlit/secrets.toml` in the project root (if present). +- Checks environment variables as a fallback. +- Prints which keys are configured (masking sensitive values). +- Exits with a non-zero status if **neither**: + - a usable Hugging Face configuration (`HF_TOKEN` plus either + `HF_ENDPOINT_URL`/`HF_INFERENCE_BASE_URL` or `HF_MODEL_ID`), nor + - an `OPENAI_API_KEY` + is set. + +A successful run will report that at least one provider (HF and/or OpenAI) is +configured. + +--- + +## 5. Using the Diagnostics panel + +Once the app is deployed and secrets are configured: + +- Trigger a generation by providing a schema and question and clicking + **Generate SQL**. +- Open the **Diagnostics** section in the sidebar. + +The Diagnostics panel shows: + +- Which provider handled the last request (`HF` vs `OpenAI fallback`). +- Whether the last HF call reported that the endpoint is paused (with a hint + to resume it from the Hugging Face Inference Endpoint **Overview** page). +- The request duration (in milliseconds). +- The `max_new_tokens` value used for the last request. + +The diagnostics are intentionally lightweight and do **not** show stack traces +or detailed exception internals, to keep the UI clean and safe for end users. + +--- + +## 6. Summary + +To deploy this app on Streamlit Community Cloud: + +1. Push the repository to GitHub. +2. Create a new Streamlit app from that repo and set the main file to + `app/streamlit_app.py`. +3. Configure secrets in the Streamlit Cloud **Secrets** editor, using the keys + from `.streamlit/secrets.toml.example`. +4. (Optional) Run `python scripts/check_runtime_config.py` locally to validate + configuration before pushing changes. +5. Deploy and use the Diagnostics panel to verify which provider is serving + requests and whether your Hugging Face endpoint is healthy. + +With these steps, there should be no guesswork required to get a working +deployment on Streamlit Community Cloud. + +--- + +[streamlit-secrets-docs]: https://docs.streamlit.io/deploy/streamlit-community-cloud/deploy-your-app/secrets-management +[streamlit-secrets-toml-docs]: https://docs.streamlit.io/develop/api-reference/connections/secrets.toml \ No newline at end of file diff --git a/scripts/check_runtime_config.py b/scripts/check_runtime_config.py new file mode 100644 index 0000000..97b29fb --- /dev/null +++ b/scripts/check_runtime_config.py @@ -0,0 +1,196 @@ +from __future__ import annotations + +""" +Runtime configuration checker for the Streamlit app. + +This script inspects configuration for: + +- Hugging Face Inference (primary provider) +- OpenAI fallback (secondary provider) + +It looks for settings in: + +- .streamlit/secrets.toml (if present, takes precedence) +- Environment variables (fallback when secrets are missing) + +and reports: + +- Which keys are configured (with masked values for sensitive fields) +- Whether at least one provider is usable + +Exit codes: + +- 0: At least one provider is configured (HF and/or OpenAI) +- 1: Neither HF nor OpenAI fallback is configured + +The masking format for tokens/keys is similar to: `hf_****1234` +(i.e. keep a short prefix and the last 4 characters). +""" + +import os +from pathlib import Path +import sys +from typing import Any, Mapping, Tuple + +try: + import tomllib # Python 3.11+ +except Exception: # noqa: BLE001 + tomllib = None + + +def _load_secrets_file(project_root: Path) -> Mapping[str, Any]: + """ + Load .streamlit/secrets.toml if it exists and tomllib is available. + + Returns an empty dict when the file is missing or cannot be parsed. + """ + secrets_path = project_root / ".streamlit" / "secrets.toml" + if not secrets_path.is_file(): + return {} + + if tomllib is None: + print( + "WARNING: tomllib is not available; skipping .streamlit/secrets.toml " + "parsing and relying on environment variables only.", + ) + return {} + + try: + with secrets_path.open("rb") as f: + data = tomllib.load(f) + except Exception as exc: # noqa: BLE001 + print( + f"WARNING: Failed to parse {secrets_path} as TOML: {exc}. " + "Falling back to environment variables only.", + ) + return {} + + return data or {} + + +def _get_from_mapping(mapping: Mapping[str, Any], key: str) -> str: + """Return a trimmed string value from a generic mapping, or empty string.""" + try: + value = mapping.get(key) # type: ignore[attr-defined] + except Exception: # noqa: BLE001 + value = None + if value is None: + return "" + return str(value).strip() + + +def _mask_secret(value: str) -> str: + """ + Return a masked representation of a secret value. + + Example: + "hf_example_token_1234" -> "hf_****1234" + """ + if not value: + return "" + trimmed = value.strip() + if len(trimmed) <= 6: + return "*" * len(trimmed) + prefix = trimmed[:3] + suffix = trimmed[-4:] + return f"{prefix}****{suffix}" + + +def _resolve_value( + key: str, + secrets: Mapping[str, Any], + environ: Mapping[str, str], +) -> Tuple[str, str]: + """ + Resolve a value from secrets, then environment. + + Returns (value, source), where source is "secrets.toml", "env", or "". + """ + from_secrets = _get_from_mapping(secrets, key) + if from_secrets: + return from_secrets, "secrets.toml" + + from_env = environ.get(key, "").strip() + if from_env: + return from_env, "env" + + return "", "" + + +def main(argv: list[str] | None = None) -> int: # noqa: ARG001 + project_root = Path(__file__).resolve().parents[1] + secrets = _load_secrets_file(project_root) + environ = os.environ + + print("=== Runtime configuration check ===") + if secrets: + print(f"Loaded .streamlit/secrets.toml from: {project_root / '.streamlit/secrets.toml'}") + else: + print("No usable .streamlit/secrets.toml found; using environment variables only.") + print() + + # Resolve Hugging Face configuration. + hf_token, hf_token_src = _resolve_value("HF_TOKEN", secrets, environ) + + endpoint_url, endpoint_src = _resolve_value("HF_ENDPOINT_URL", secrets, environ) + if not endpoint_url: + # Backwards-compatible alias for HF_ENDPOINT_URL. + base_url, base_url_src = _resolve_value("HF_INFERENCE_BASE_URL", secrets, environ) + endpoint_url = base_url + endpoint_src = base_url_src + + model_id, model_src = _resolve_value("HF_MODEL_ID", secrets, environ) + adapter_id, adapter_src = _resolve_value("HF_ADAPTER_ID", secrets, environ) + + # Resolve OpenAI fallback configuration. + openai_key, openai_key_src = _resolve_value("OPENAI_API_KEY", secrets, environ) + openai_model, openai_model_src = _resolve_value("OPENAI_FALLBACK_MODEL", secrets, environ) + if not openai_model: + openai_model = "gpt-5-nano" + if not openai_key_src: + # Use "default" to indicate the value comes from the app's default, + # not from secrets or env. + openai_model_src = "default" + + def _print_field(name: str, value: str, source: str, mask: bool = False) -> None: + if not value: + print(f"{name:30s}: MISSING") + return + display = _mask_secret(value) if mask else value + origin = source or "-" + print(f"{name:30s}: {display} (from {origin})") + + print("Hugging Face configuration:") + _print_field("HF_TOKEN", hf_token, hf_token_src, mask=True) + _print_field("HF_ENDPOINT_URL / HF_INFERENCE_BASE_URL", endpoint_url, endpoint_src) + _print_field("HF_MODEL_ID", model_id, model_src) + _print_field("HF_ADAPTER_ID", adapter_id, adapter_src) + print() + + print("OpenAI fallback configuration:") + _print_field("OPENAI_API_KEY", openai_key, openai_key_src, mask=True) + _print_field("OPENAI_FALLBACK_MODEL", openai_model, openai_model_src) + print() + + hf_configured = bool(hf_token and (endpoint_url or model_id)) + openai_configured = bool(openai_key) + + if not hf_configured and not openai_configured: + print("ERROR: Neither Hugging Face nor OpenAI fallback is fully configured.") + print(" - To use Hugging Face Inference, set HF_TOKEN and either:") + print(" * HF_ENDPOINT_URL / HF_INFERENCE_BASE_URL, or") + print(" * HF_MODEL_ID (for router/provider-based inference).") + print(" - Or configure OPENAI_API_KEY (and optionally OPENAI_FALLBACK_MODEL)") + print(" for the OpenAI fallback path.") + return 1 + + print("At least one provider is configured:") + if hf_configured: + print(" - Hugging Face Inference (primary)") + if openai_configured: + print(" - OpenAI fallback (secondary)") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main(sys.argv[1:])) \ No newline at end of file From 33551af74a5e8dc127dc2791805a63a851a37e1e Mon Sep 17 00:00:00 2001 From: Brejesh Balakrishnan Date: Sun, 11 Jan 2026 08:45:40 +0000 Subject: [PATCH 2/7] refactor: remove duplicate imports and consolidate at top of check_runtime_config.py Co-authored-by: Cosine --- scripts/check_runtime_config.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/check_runtime_config.py b/scripts/check_runtime_config.py index 97b29fb..361dfcd 100644 --- a/scripts/check_runtime_config.py +++ b/scripts/check_runtime_config.py @@ -1,5 +1,10 @@ from __future__ import annotations +import os +from pathlib import Path +import sys +from typing import Any, Mapping, Tuple + """ Runtime configuration checker for the Streamlit app. @@ -27,11 +32,6 @@ (i.e. keep a short prefix and the last 4 characters). """ -import os -from pathlib import Path -import sys -from typing import Any, Mapping, Tuple - try: import tomllib # Python 3.11+ except Exception: # noqa: BLE001 From 3a6e02049a0a79c9f8a0d8e363253ae7af740d21 Mon Sep 17 00:00:00 2001 From: brej-29 Date: Sun, 11 Jan 2026 14:19:26 +0530 Subject: [PATCH 3/7] notebook updated --- .../finetune_mistral7b_qlora_text2sql.ipynb | 5490 +++++++++++++++-- notebooks/trainLLM.ipynb | 2564 ++++++++ 2 files changed, 7492 insertions(+), 562 deletions(-) create mode 100644 notebooks/trainLLM.ipynb diff --git a/notebooks/finetune_mistral7b_qlora_text2sql.ipynb b/notebooks/finetune_mistral7b_qlora_text2sql.ipynb index 5b1577c..b358731 100644 --- a/notebooks/finetune_mistral7b_qlora_text2sql.ipynb +++ b/notebooks/finetune_mistral7b_qlora_text2sql.ipynb @@ -1,565 +1,4931 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Finetune Mistral-7B-Instruct with QLoRA for Text-to-SQL\n", - "\n", - "This notebook walks through **end-to-end fine-tuning** of\n", - "`mistralai/Mistral-7B-Instruct-v0.1` for **Text-to-SQL** using:\n", - "\n", - "- The preprocessed instruction-tuning dataset in `data/processed/*.jsonl`.\n", - "- **QLoRA** (4-bit quantization + LoRA adapters).\n", - "- **Unsloth** + **bitsandbytes** for efficient training.\n", - "- **TRL**'s `SFTTrainer` for supervised fine-tuning.\n", - "\n", - "We assume you are running this in a GPU environment (e.g., Google Colab).\n", - "\n", - "## What you will learn\n", - "\n", - "1. How QLoRA works conceptually and why it is well-suited for 7B models.\n", - "2. How schema-grounded prompts (including `CREATE TABLE` context) help\n", - " reduce schema hallucinations in Text-to-SQL.\n", - "3. How to load and inspect the preprocessed dataset.\n", - "4. How to format prompts for supervised fine-tuning.\n", - "5. How to configure and run a QLoRA training loop using Unsloth + TRL.\n", - "6. How to save adapters and run a quick sanity check on generated SQL.\n", - "7. What the next steps are for external validation and deployment.\n" - ] + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "ZUy0aA4AUiDF" + }, + "source": [ + "# Finetune Mistral-7B-Instruct with QLoRA for Text-to-SQL\n", + "\n", + "This notebook walks through **end-to-end fine-tuning** of\n", + "`mistralai/Mistral-7B-Instruct-v0.1` for **Text-to-SQL** using:\n", + "\n", + "- The preprocessed instruction-tuning dataset in `data/processed/*.jsonl`.\n", + "- **QLoRA** (4-bit quantization + LoRA adapters).\n", + "- **Unsloth** + **bitsandbytes** for efficient training.\n", + "- **TRL**'s `SFTTrainer` for supervised fine-tuning.\n", + "\n", + "We assume you are running this in a GPU environment (e.g., Google Colab).\n", + "\n", + "## What you will learn\n", + "\n", + "1. How QLoRA works conceptually and why it is well-suited for 7B models.\n", + "2. How schema-grounded prompts (including `CREATE TABLE` context) help\n", + " reduce schema hallucinations in Text-to-SQL.\n", + "3. How to load and inspect the preprocessed dataset.\n", + "4. How to format prompts for supervised fine-tuning.\n", + "5. How to configure and run a QLoRA training loop using Unsloth + TRL.\n", + "6. How to save adapters and run a quick sanity check on generated SQL.\n", + "7. What the next steps are for external validation and deployment.\n" + ], + "id": "ZUy0aA4AUiDF" + }, + { + "cell_type": "markdown", + "metadata": { + "id": "KsG53U0oUiDI" + }, + "source": [ + "## A. Overview: QLoRA + Schema-Grounded Prompts\n", + "\n", + "**QLoRA** (Quantized LoRA) combines:\n", + "\n", + "- **4-bit quantization** of the base model weights (via bitsandbytes).\n", + "- **Low-Rank Adapters (LoRA)** that are trained while keeping the\n", + " quantized base model frozen.\n", + "\n", + "This dramatically reduces memory usage, allowing us to fine-tune 7B models\n", + "on a single GPU while still achieving strong performance.\n", + "\n", + "For **Text-to-SQL**, we want the model to be:\n", + "\n", + "- **Schema-aware**: It should use only the tables and columns that actually\n", + " exist.\n", + "- **Grounded**: The model should see the schema (e.g., `CREATE TABLE`)\n", + " alongside the question.\n", + "- **Cautious**: Avoid hallucinating non-existent tables/columns.\n", + "\n", + "To support this, our preprocessing pipeline constructs prompts like:\n", + "\n", + "```text\n", + "### Instruction:\n", + "Write a SQL query that answers the user's question using ONLY the tables and columns provided in the schema.\n", + "\n", + "### Input:\n", + "### Schema:\n", + "CREATE TABLE head (age INTEGER)\n", + "\n", + "### Question:\n", + "How many heads of the departments are older than 56 ?\n", + "\n", + "### Response:\n", + "SELECT COUNT(*) FROM head WHERE age > 56\n", + "```\n", + "\n", + "The **instruction** is fixed, the **input** combines schema + question, and\n", + "the **response** is the target SQL. We will train the model to map\n", + "instruction+input to response." + ], + "id": "KsG53U0oUiDI" + }, + { + "cell_type": "markdown", + "metadata": { + "id": "VfX18S68UiDK" + }, + "source": [ + "## B. Environment Setup\n", + "\n", + "This section installs dependencies (for Colab), checks GPU availability, and\n", + "sets random seeds for reproducibility.\n", + "\n", + "> If you are running locally with the repository already installed, you may\n", + "> skip the `pip install` step and simply import the libraries." + ], + "id": "VfX18S68UiDK" + }, + { + "cell_type": "code", + "source": [ + "from google.colab import drive\n", + "drive.mount('/content/drive')" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "goCje9zjU7LK", + "outputId": "f31b3a6c-641e-4724-9e2b-c7e3cf1a5e70" + }, + "id": "goCje9zjU7LK", + "execution_count": 1, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Mounted at /content/drive\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "import os\n", + "\n", + "# Define the target path\n", + "target_path = '/content/drive/MyDrive/Projects/analytics_copilot'\n", + "\n", + "# Change the directory\n", + "os.chdir(target_path)\n", + "\n", + "# Verify the change\n", + "print(f\"Current Working Directory: {os.getcwd()}\")" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "LF4yVNc4YNuN", + "outputId": "2f00b7e2-ee07-4745-887a-93bcb38f7317" + }, + "id": "LF4yVNc4YNuN", + "execution_count": 10, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Current Working Directory: /content/drive/MyDrive/Projects/analytics_copilot\n" + ] + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "7985d486" + }, + "source": [ + "pip install -q -r /content/drive/MyDrive/Projects/analytics_copilot/requirements.txt" + ], + "id": "7985d486", + "execution_count": 11, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "print(type(Path.cwd()))\n", + "print(Path.cwd())" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "elujAvcfXPhC", + "outputId": "42d2908f-3d9d-45ab-d5f8-a66cdffc1c96" + }, + "id": "elujAvcfXPhC", + "execution_count": 12, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "\n", + "/content/drive/MyDrive/Projects/analytics_copilot\n" + ] + } + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "id": "env-setup", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "2d0f0ac6-08c0-4e46-bcfd-d943c189258a" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Using device: cuda\n" + ] + } + ], + "source": [ + "# If running in Colab, uncomment the following lines to install dependencies.\n", + "# !pip install -q unsloth bitsandbytes accelerate transformers datasets trl peft\n", + "\n", + "import os\n", + "import json\n", + "import random\n", + "from pathlib import Path\n", + "\n", + "import torch\n", + "from datasets import Dataset\n", + "from trl import SFTConfig, SFTTrainer\n", + "from unsloth import FastLanguageModel\n", + "\n", + "BASE_DIR = Path.cwd()\n", + "DATA_DIR = BASE_DIR / \"data\" / \"processed\"\n", + "OUTPUT_DIR = BASE_DIR / \"outputs\"\n", + "OUTPUT_DIR.mkdir(parents=True, exist_ok=True)\n", + "\n", + "def set_seed(seed: int = 42):\n", + " random.seed(seed)\n", + " os.environ[\"PYTHONHASHSEED\"] = str(seed)\n", + " torch.manual_seed(seed)\n", + " if torch.cuda.is_available():\n", + " torch.cuda.manual_seed_all(seed)\n", + "\n", + "set_seed(42)\n", + "\n", + "print(f\"Using device: {'cuda' if torch.cuda.is_available() else 'cpu'}\")\n", + "if not torch.cuda.is_available():\n", + " print(\"WARNING: CUDA not available. Training a 7B model will not be feasible on CPU.\")" + ], + "id": "env-setup" + }, + { + "cell_type": "markdown", + "metadata": { + "id": "y140ssQQUiDM" + }, + "source": [ + "## C. Load Processed Dataset (train/val JSONL)\n", + "\n", + "The preprocessing step (`scripts/build_dataset.py`) produces two files:\n", + "\n", + "- `data/processed/train.jsonl`\n", + "- `data/processed/val.jsonl`\n", + "\n", + "Each line is an Alpaca-style record with keys: `id`, `instruction`, `input`,\n", + "`output`, `source`, and `meta`.\n", + "\n", + "We will load them into `datasets.Dataset` objects for use with TRL's\n", + "`SFTTrainer`." + ], + "id": "y140ssQQUiDM" + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "id": "load-dataset", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "bc4c89ff-86f0-406f-fea9-765b64149fc8" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Dataset({\n", + " features: ['id', 'instruction', 'input', 'output', 'source', 'meta'],\n", + " num_rows: 920\n", + "})\n", + "Dataset({\n", + " features: ['id', 'instruction', 'input', 'output', 'source', 'meta'],\n", + " num_rows: 80\n", + "})\n" + ] + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "{'id': 'sqlcc-train-000000',\n", + " 'instruction': \"Write a SQL query that answers the user's question using ONLY the tables and columns provided in the schema.\",\n", + " 'input': '### Schema:\\nCREATE TABLE genres (id VARCHAR, name VARCHAR); CREATE TABLE tracks (name VARCHAR, genre_id VARCHAR, media_type_id VARCHAR); CREATE TABLE media_types (id VARCHAR, name VARCHAR)\\n\\n### Question:\\nList the name of tracks belongs to genre Rock and whose media type is MPEG audio file.',\n", + " 'output': 'SELECT T2.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id JOIN media_types AS T3 ON T3.id = T2.media_type_id WHERE T1.name = \"Rock\" AND T3.name = \"MPEG audio file\"',\n", + " 'source': 'b-mc2/sql-create-context',\n", + " 'meta': {'from_local_input': False,\n", + " 'original_split': 'train',\n", + " 'row': 0,\n", + " 'seed': 42,\n", + " 'split': 'train',\n", + " 'val_ratio': 0.08}}" + ] + }, + "metadata": {}, + "execution_count": 14 + } + ], + "source": [ + "def load_alpaca_jsonl(path: Path) -> Dataset:\n", + " if not path.is_file():\n", + " raise FileNotFoundError(f\"JSONL file not found: {path}\")\n", + " records = []\n", + " with path.open(\"r\", encoding=\"utf-8\") as f:\n", + " for line in f:\n", + " line = line.strip()\n", + " if not line:\n", + " continue\n", + " records.append(json.loads(line))\n", + " return Dataset.from_list(records)\n", + "\n", + "train_path = DATA_DIR / \"train.jsonl\"\n", + "val_path = DATA_DIR / \"val.jsonl\"\n", + "\n", + "train_raw = load_alpaca_jsonl(train_path)\n", + "val_raw = load_alpaca_jsonl(val_path)\n", + "\n", + "print(train_raw)\n", + "print(val_raw)\n", + "\n", + "train_raw[0]" + ], + "id": "load-dataset" + }, + { + "cell_type": "markdown", + "metadata": { + "id": "i_bEP3qYUiDO" + }, + "source": [ + "## D. Prompt Formatting\n", + "\n", + "Our training format combines `instruction`, `input`, and `output` into a\n", + "single `text` field. The prompt structure is:\n", + "\n", + "```text\n", + "### Instruction:\n", + "\n", + "\n", + "### Input:\n", + "\n", + "\n", + "### Response:\n", + "\n", + "```\n", + "\n", + "We will implement two helpers mirroring the library code in\n", + "`src/text2sql/training/formatting.py`:\n", + "\n", + "- `build_prompt(instruction, input)` – builds the instruction + input + response header.\n", + "- `ensure_sql_only(output)` – normalizes whitespace and strips code fences.\n" + ], + "id": "i_bEP3qYUiDO" + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "id": "prompt-formatting", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "d7eb12ef-94f0-448f-9c5d-46c8db8f6d51" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "### Instruction:\n", + "Write a SQL query that answers the user's question using ONLY the tables and columns provided in the schema.\n", + "\n", + "### Input:\n", + "### Schema:\n", + "CREATE TABLE genres (id VARCHAR, name VARCHAR); CREATE TABLE tracks (name VARCHAR, genre_id VARCHAR, media_type_id VARCHAR); CREATE TABLE media_types (id VARCHAR, name VARCHAR)\n", + "\n", + "### Question:\n", + "List the name of tracks belongs to genre Rock and whose media type is MPEG audio file.\n", + "\n", + "### Response:\n", + "SELECT T2.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id JOIN media_types AS T3 ON T3.id = T2.media_type_id WHERE T1.name = \"Rock\" AND T3.name = \"MPEG audio file\"\n" + ] + } + ], + "source": [ + "import re\n", + "\n", + "PROMPT_TEMPLATE = \"\"\"### Instruction:\\n{instruction}\\n\\n### Input:\\n{input}\\n\\n### Response:\\n\"\"\"\n", + "\n", + "def build_prompt(instruction: str, input_text: str) -> str:\n", + " instruction = (instruction or \"\").strip()\n", + " input_text = (input_text or \"\").strip()\n", + " return PROMPT_TEMPLATE.format(instruction=instruction, input=input_text)\n", + "\n", + "def ensure_sql_only(output: str) -> str:\n", + " if output is None:\n", + " return \"\"\n", + " text = output.strip()\n", + " if text.startswith(\"```\"):\n", + " text = re.sub(r\"^```(?:sql)?\\s*\", \"\", text, flags=re.IGNORECASE)\n", + " text = re.sub(r\"\\s*```$\", \"\", text)\n", + " text = re.sub(r\"\\s+\", \" \", text)\n", + " return text\n", + "\n", + "def format_example(example):\n", + " prompt = build_prompt(example[\"instruction\"], example[\"input\"])\n", + " sql = ensure_sql_only(example[\"output\"])\n", + " return {\"text\": prompt + sql}\n", + "\n", + "formatted_sample = format_example(train_raw[0])\n", + "print(formatted_sample[\"text\"][:1000])" + ], + "id": "prompt-formatting" + }, + { + "cell_type": "markdown", + "metadata": { + "id": "0wDtJcolUiDR" + }, + "source": [ + "We can now apply this formatting to the entire dataset. During development,\n", + "it is often useful to use a **fast dev run** on a subset of the data." + ], + "id": "0wDtJcolUiDR" + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "id": "format-dataset", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 220, + "referenced_widgets": [ + "a9382da33c684948a0644dbee7fba13b", + "1b500bcfc5e845ea902f7fffc8e2a405", + "bd427f350cdd4a88a6cbed427f105875", + "78230a7c5bfb477c9e50f1105c2cb5e1", + "13f39e2e9afa4512860baee26e2a0703", + "102ff531d855459389cb7f117ec85f1d", + "ad8787717ef84ea0b7fd431dd729a2b3", + "4924f09870fb4c5494f2af1536730df5", + "94dfb2e7665c4ac29afa39706837fc14", + "57c03dfcff6c4edaa5b7db18166af288", + "4ca8b6208263485da740c963077bf429", + "06a8a0e8f95b40b9958094031128bad8", + "23f4df2d22be4b12896f5353ef1f95f5", + "3ee60f6aa7b34e87971d2126ed5fe5a0", + "e96d5ed2ec884bc799864665a8917b81", + "ca2cbfce59b64913b854fcb3dabddb80", + "63175e7c57de424bbc331f13fe3cc330", + "cb315dde435148e691651c4dfe678ac4", + "0ff2d753a4d048e99100ec6433754dbb", + "9e4ca4a45673479091a728132433424a", + "d6d22af2be524dbca6ad6644135898fd", + "a0610b64c1be4650a01a9f2ef9bd7096" + ] + }, + "outputId": "479a0c44-7088-4c1f-eaf9-5c11b89a06cf" + }, + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/plain": [ + "Map: 0%| | 0/512 [00:00" + ] + }, + "metadata": {}, + "execution_count": 20 + } + ], + "source": [ + "MAX_STEPS = 20 if FAST_DEV_RUN else 500\n", + "PER_DEVICE_TRAIN_BATCH_SIZE = 1\n", + "GRADIENT_ACCUMULATION_STEPS = 8\n", + "LEARNING_RATE = 2e-4\n", + "WARMUP_STEPS = 50\n", + "WEIGHT_DECAY = 0.0\n", + "\n", + "sft_config = SFTConfig(\n", + " output_dir=str(OUTPUT_DIR),\n", + " max_steps=MAX_STEPS,\n", + " per_device_train_batch_size=PER_DEVICE_TRAIN_BATCH_SIZE,\n", + " gradient_accumulation_steps=GRADIENT_ACCUMULATION_STEPS,\n", + " learning_rate=LEARNING_RATE,\n", + " warmup_steps=WARMUP_STEPS,\n", + " weight_decay=WEIGHT_DECAY,\n", + " logging_steps=10,\n", + " eval_strategy=\"steps\",\n", + " eval_steps=max(MAX_STEPS // 10, 1),\n", + " save_strategy=\"steps\",\n", + " save_steps=max(MAX_STEPS // 10, 1),\n", + " bf16=torch.cuda.is_bf16_supported(),\n", + ")\n", + "\n", + "trainer = SFTTrainer(\n", + " model=model,\n", + " tokenizer=tokenizer,\n", + " train_dataset=train_ds,\n", + " eval_dataset=val_ds,\n", + " dataset_text_field=\"text\",\n", + " args=sft_config,\n", + ")\n", + "\n", + "trainer" + ], + "id": "train-config" + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": { + "id": "run-training", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 580 + }, + "outputId": "ea5034f5-7865-4c46-9265-5f1117cec7a8" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stderr", + "text": [ + "The model is already on multiple devices. Skipping the move to device specified in `args`.\n", + "==((====))== Unsloth - 2x faster free finetuning | Num GPUs used = 1\n", + " \\\\ /| Num examples = 512 | Num Epochs = 1 | Total steps = 20\n", + "O^O/ \\_/ \\ Batch size per device = 1 | Gradient accumulation steps = 8\n", + "\\ / Data Parallel GPUs = 1 | Total batch size (1 x 8 x 1) = 8\n", + " \"-____-\" Trainable parameters = 41,943,040 of 7,283,675,136 (0.58% trained)\n" + ] + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "\n", + "
\n", + " \n", + " \n", + " [20/20 04:29, Epoch 0/1]\n", + "
\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
StepTraining LossValidation Loss
2No log1.851302
4No log1.795874
6No log1.685717
8No log1.540466
101.6401001.364707
121.6401001.161243
141.6401000.929596
161.6401000.784554
181.6401000.734083
200.9662000.690343

" + ] + }, + "metadata": {} + }, + { + "output_type": "stream", + "name": "stderr", + "text": [ + "Unsloth: Not an error, but MistralForCausalLM does not accept `num_items_in_batch`.\n", + "Using gradient accumulation will be very slightly less accurate.\n", + "Read more on gradient accumulation issues here: https://unsloth.ai/blog/gradient\n" + ] + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "TrainOutput(global_step=20, training_loss=1.3031651020050048, metrics={'train_runtime': 288.3895, 'train_samples_per_second': 0.555, 'train_steps_per_second': 0.069, 'total_flos': 866423428276224.0, 'train_loss': 1.3031651020050048, 'epoch': 0.3125})" + ] + }, + "metadata": {}, + "execution_count": 21 + } + ], + "source": [ + "train_output = trainer.train()\n", + "train_output" + ], + "id": "run-training" + }, + { + "cell_type": "markdown", + "metadata": { + "id": "xoWqdQd0UiDZ" + }, + "source": [ + "## G. Save Artifacts (Adapters + Metrics)\n", + "\n", + "After training, we save the LoRA adapters and simple metrics:\n", + "\n", + "- `outputs/adapters/` – adapter weights and tokenizer config.\n", + "- `outputs/run_meta.json` – run configuration and dataset sizes.\n", + "- `outputs/metrics.json` – train/eval losses and related metrics (if available)." + ], + "id": "xoWqdQd0UiDZ" + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": { + "id": "save-artifacts", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 228 + }, + "outputId": "7bab27cf-aa73-4330-e407-20c9d7fb9f04" + }, + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "\n", + "

\n", + " \n", + " \n", + " [20/20 00:09]\n", + "
\n", + " " + ] + }, + "metadata": {} + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "{'train_runtime': 288.3895,\n", + " 'train_samples_per_second': 0.555,\n", + " 'train_steps_per_second': 0.069,\n", + " 'total_flos': 866423428276224.0,\n", + " 'train_loss': 1.3031651020050048,\n", + " 'epoch': 0.3125,\n", + " 'eval_eval_loss': 0.6903432607650757,\n", + " 'eval_eval_runtime': 9.6483,\n", + " 'eval_eval_samples_per_second': 8.292,\n", + " 'eval_eval_steps_per_second': 2.073,\n", + " 'eval_epoch': 0.3125}" + ] + }, + "metadata": {}, + "execution_count": 22 + } + ], + "source": [ + "adapters_dir = OUTPUT_DIR / \"adapters\"\n", + "adapters_dir.mkdir(parents=True, exist_ok=True)\n", + "\n", + "trainer.model.save_pretrained(str(adapters_dir))\n", + "tokenizer.save_pretrained(str(adapters_dir))\n", + "\n", + "# Save run metadata\n", + "run_meta = {\n", + " \"base_model\": BASE_MODEL,\n", + " \"max_steps\": MAX_STEPS,\n", + " \"per_device_train_batch_size\": PER_DEVICE_TRAIN_BATCH_SIZE,\n", + " \"gradient_accumulation_steps\": GRADIENT_ACCUMULATION_STEPS,\n", + " \"learning_rate\": LEARNING_RATE,\n", + " \"max_seq_length\": MAX_SEQ_LENGTH,\n", + " \"lora_r\": LORA_R,\n", + " \"lora_alpha\": LORA_ALPHA,\n", + " \"lora_dropout\": LORA_DROPOUT,\n", + " \"fast_dev_run\": FAST_DEV_RUN,\n", + " \"num_train_examples\": len(train_ds),\n", + " \"num_val_examples\": len(val_ds),\n", + "}\n", + "\n", + "with (OUTPUT_DIR / \"run_meta.json\").open(\"w\", encoding=\"utf-8\") as f:\n", + " json.dump(run_meta, f, indent=2)\n", + "\n", + "# Save metrics if available\n", + "metrics = {}\n", + "if hasattr(train_output, \"metrics\") and train_output.metrics is not None:\n", + " metrics.update(train_output.metrics)\n", + "\n", + "try:\n", + " eval_metrics = trainer.evaluate()\n", + " metrics.update({f\"eval_{k}\": v for k, v in eval_metrics.items()})\n", + "except Exception as e: # noqa: BLE001\n", + " print(\"Evaluation failed or was skipped:\", e)\n", + "\n", + "with (OUTPUT_DIR / \"metrics.json\").open(\"w\", encoding=\"utf-8\") as f:\n", + " json.dump(metrics, f, indent=2)\n", + "\n", + "metrics" + ], + "id": "save-artifacts" + }, + { + "cell_type": "markdown", + "metadata": { + "id": "3CED-FbbUiDa" + }, + "source": [ + "## H. Quick Sanity Inference\n", + "\n", + "Finally, we perform a quick sanity check by generating SQL for a few\n", + "examples. This is a qualitative check to see if the model learned to\n", + "produce reasonable SQL given the schema and question." + ], + "id": "3CED-FbbUiDa" + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": { + "id": "sanity-inference", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "d2236b3c-b52f-4126-8960-0998659ad06e" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "=== Prompt ===\n", + "### Instruction:\n", + "Write a SQL query that answers the user's question using ONLY the tables and columns provided in the schema.\n", + "\n", + "### Input:\n", + "### Schema:\n", + "CREATE TABLE genres (id VARCHAR, name VARCHAR); CREATE TABLE tracks (name VARCHAR, genre_id VARCHAR, media_type_id VARCHAR); CREATE TABLE media_types (id VARCHAR, name VARCHAR)\n", + "\n", + "### Question:\n", + "List the name of tracks belongs to genre Rock and whose media type is MPEG audio file.\n", + "\n", + "### Response:\n", + "\n", + "=== Generated SQL ===\n", + " ### Instruction:\n", + "Write a SQL query that answers the user's question using ONLY the tables and columns provided in the schema.\n", + "\n", + "### Input:\n", + "### Schema:\n", + "CREATE TABLE genres (id VARCHAR, name VARCHAR); CREATE TABLE tracks (name VARCHAR, genre_id VARCHAR, media_type_id VARCHAR); CREATE TABLE media_types (id VARCHAR, name VARCHAR)\n", + "\n", + "### Question:\n", + "List the name of tracks belongs to genre Rock and whose media type is MPEG audio file.\n", + "\n", + "### Response:\n", + "SELECT tracks.name FROM tracks JOIN genres ON tracks.genre_id = genres.id JOIN media_types ON tracks.media_type_id = media_types.id WHERE genres.name = 'Rock' AND media_types.name = 'MPEG audio file'\n", + "\n", + "=================\n", + "\n", + "=== Prompt ===\n", + "### Instruction:\n", + "Write a SQL query that answers the user's question using ONLY the tables and columns provided in the schema.\n", + "\n", + "### Input:\n", + "### Schema:\n", + "CREATE TABLE Customers (customer_id VARCHAR); CREATE TABLE Accounts (customer_id VARCHAR)\n", + "\n", + "### Question:\n", + "Show the number of all customers without an account.\n", + "\n", + "### Response:\n", + "\n", + "=== Generated SQL ===\n", + " ### Instruction:\n", + "Write a SQL query that answers the user's question using ONLY the tables and columns provided in the schema.\n", + "\n", + "### Input:\n", + "### Schema:\n", + "CREATE TABLE Customers (customer_id VARCHAR); CREATE TABLE Accounts (customer_id VARCHAR)\n", + "\n", + "### Question:\n", + "Show the number of all customers without an account.\n", + "\n", + "### Response:\n", + "SELECT COUNT(*) FROM Customers WHERE customer_id NOT IN (SELECT customer_id FROM Accounts)\n", + "\n", + "=================\n", + "\n", + "=== Prompt ===\n", + "### Instruction:\n", + "Write a SQL query that answers the user's question using ONLY the tables and columns provided in the schema.\n", + "\n", + "### Input:\n", + "### Schema:\n", + "CREATE TABLE Genre (GenreID VARCHAR, Name VARCHAR); CREATE TABLE Track (AlbumId VARCHAR, GenreID VARCHAR); CREATE TABLE Album (Title VARCHAR, AlbumId VARCHAR)\n", + "\n", + "### Question:\n", + "What are the album titles for albums containing both 'Reggae' and 'Rock' genre tracks?\n", + "\n", + "### Response:\n", + "\n", + "=== Generated SQL ===\n", + " ### Instruction:\n", + "Write a SQL query that answers the user's question using ONLY the tables and columns provided in the schema.\n", + "\n", + "### Input:\n", + "### Schema:\n", + "CREATE TABLE Genre (GenreID VARCHAR, Name VARCHAR); CREATE TABLE Track (AlbumId VARCHAR, GenreID VARCHAR); CREATE TABLE Album (Title VARCHAR, AlbumId VARCHAR)\n", + "\n", + "### Question:\n", + "What are the album titles for albums containing both 'Reggae' and 'Rock' genre tracks?\n", + "\n", + "### Response:\n", + "SELECT T1.Title FROM Track AS T1 JOIN Genre AS G1 ON T1.GenreID = G1.GenreID JOIN Track AS T2 ON T1.AlbumId = T2.AlbumId JOIN Genre AS G2 ON T2.GenreID = G2.GenreID WHERE G1.Name = 'Reggae' AND G2.Name = 'Rock'\n", + "\n", + "=================\n", + "\n" + ] + } + ], + "source": [ + "from transformers import TextStreamer\n", + "\n", + "FastLanguageModel.for_inference(model)\n", + "\n", + "def generate_sql(example, max_new_tokens: int = 128):\n", + " prompt = build_prompt(example[\"instruction\"], example[\"input\"])\n", + " inputs = tokenizer(prompt, return_tensors=\"pt\").to(model.device)\n", + " streamer = TextStreamer(tokenizer)\n", + "\n", + " print(\"=== Prompt ===\")\n", + " print(prompt)\n", + " print(\"=== Generated SQL ===\")\n", + " _ = model.generate(\n", + " **inputs,\n", + " streamer=streamer,\n", + " max_new_tokens=max_new_tokens,\n", + " do_sample=True,\n", + " temperature=0.2,\n", + " top_p=0.9,\n", + " )\n", + " print(\"\\n=================\\n\")\n", + "\n", + "for i in range(3):\n", + " generate_sql(train_raw[i])" + ], + "id": "sanity-inference" + }, + { + "cell_type": "markdown", + "metadata": { + "id": "qR_IhaazUiDb" + }, + "source": [ + "## I. Next Steps\n", + "\n", + "You now have a QLoRA-finetuned Mistral-7B-Instruct model for Text-to-SQL.\n", + "The next steps for this project are:\n", + "\n", + "1. **External Validation on Spider dev (planned Task 4)**\n", + " - Evaluate the model on a harder, multi-table, cross-domain benchmark\n", + " such as `xlangai/spider`.\n", + " - Measure logical form accuracy and execution accuracy.\n", + " - See `docs/external_validation.md` for the high-level plan.\n", + "\n", + "2. **Push to Hugging Face Hub (planned Task 5)**\n", + " - Package the LoRA adapters and associated config.\n", + " - Publish a model card documenting training data, metrics, and usage.\n", + "\n", + "3. **Streamlit Remote Inference UI (planned Task 6)**\n", + " - Integrate the fine-tuned model into a Streamlit app.\n", + " - Allow users to connect to a database, ask natural-language questions,\n", + " and inspect / edit the generated SQL.\n", + "\n", + "These steps will complete the full loop from data → training → evaluation →\n", + "interactive Analytics Copilot experience." + ], + "id": "qR_IhaazUiDb" + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python", + "version": "3.11" + }, + "colab": { + "provenance": [], + "gpuType": "T4" + }, + "accelerator": "GPU", + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "a9382da33c684948a0644dbee7fba13b": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HBoxModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HBoxView", + "box_style": "", + "children": [ + "IPY_MODEL_1b500bcfc5e845ea902f7fffc8e2a405", + "IPY_MODEL_bd427f350cdd4a88a6cbed427f105875", + "IPY_MODEL_78230a7c5bfb477c9e50f1105c2cb5e1" + ], + "layout": "IPY_MODEL_13f39e2e9afa4512860baee26e2a0703" + } + }, + "1b500bcfc5e845ea902f7fffc8e2a405": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_102ff531d855459389cb7f117ec85f1d", + "placeholder": "​", + "style": "IPY_MODEL_ad8787717ef84ea0b7fd431dd729a2b3", + "value": "Map: 100%" + } + }, + "bd427f350cdd4a88a6cbed427f105875": { + "model_module": "@jupyter-widgets/controls", + "model_name": "FloatProgressModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "FloatProgressModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "ProgressView", + "bar_style": "success", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_4924f09870fb4c5494f2af1536730df5", + "max": 512, + "min": 0, + "orientation": "horizontal", + "style": "IPY_MODEL_94dfb2e7665c4ac29afa39706837fc14", + "value": 512 + } + }, + "78230a7c5bfb477c9e50f1105c2cb5e1": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_57c03dfcff6c4edaa5b7db18166af288", + "placeholder": "​", + "style": "IPY_MODEL_4ca8b6208263485da740c963077bf429", + "value": " 512/512 [00:00<00:00, 4854.65 examples/s]" + } + }, + "13f39e2e9afa4512860baee26e2a0703": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "102ff531d855459389cb7f117ec85f1d": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "ad8787717ef84ea0b7fd431dd729a2b3": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "4924f09870fb4c5494f2af1536730df5": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "94dfb2e7665c4ac29afa39706837fc14": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "ProgressStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "bar_color": null, + "description_width": "" + } + }, + "57c03dfcff6c4edaa5b7db18166af288": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "4ca8b6208263485da740c963077bf429": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "06a8a0e8f95b40b9958094031128bad8": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HBoxModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HBoxView", + "box_style": "", + "children": [ + "IPY_MODEL_23f4df2d22be4b12896f5353ef1f95f5", + "IPY_MODEL_3ee60f6aa7b34e87971d2126ed5fe5a0", + "IPY_MODEL_e96d5ed2ec884bc799864665a8917b81" + ], + "layout": "IPY_MODEL_ca2cbfce59b64913b854fcb3dabddb80" + } + }, + "23f4df2d22be4b12896f5353ef1f95f5": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_63175e7c57de424bbc331f13fe3cc330", + "placeholder": "​", + "style": "IPY_MODEL_cb315dde435148e691651c4dfe678ac4", + "value": "Map: 100%" + } + }, + "3ee60f6aa7b34e87971d2126ed5fe5a0": { + "model_module": "@jupyter-widgets/controls", + "model_name": "FloatProgressModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "FloatProgressModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "ProgressView", + "bar_style": "success", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_0ff2d753a4d048e99100ec6433754dbb", + "max": 80, + "min": 0, + "orientation": "horizontal", + "style": "IPY_MODEL_9e4ca4a45673479091a728132433424a", + "value": 80 + } + }, + "e96d5ed2ec884bc799864665a8917b81": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_d6d22af2be524dbca6ad6644135898fd", + "placeholder": "​", + "style": "IPY_MODEL_a0610b64c1be4650a01a9f2ef9bd7096", + "value": " 80/80 [00:00<00:00, 2333.36 examples/s]" + } + }, + "ca2cbfce59b64913b854fcb3dabddb80": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "63175e7c57de424bbc331f13fe3cc330": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "cb315dde435148e691651c4dfe678ac4": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "0ff2d753a4d048e99100ec6433754dbb": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "9e4ca4a45673479091a728132433424a": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "ProgressStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "bar_color": null, + "description_width": "" + } + }, + "d6d22af2be524dbca6ad6644135898fd": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "a0610b64c1be4650a01a9f2ef9bd7096": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "399191d1c73f4369a40ebcb175f245b5": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HBoxModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HBoxView", + "box_style": "", + "children": [ + "IPY_MODEL_987bebae545a49ecb098aebc4d9d64d3", + "IPY_MODEL_a0a09023605949d2aefeaafee9851466", + "IPY_MODEL_6161febb3f664d479b9b53d679bd8ade" + ], + "layout": "IPY_MODEL_27896176d1534bd19a269209de9c42d2" + } + }, + "987bebae545a49ecb098aebc4d9d64d3": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_911c84f720a948d8ba5bb3163b2a003d", + "placeholder": "​", + "style": "IPY_MODEL_9a4c0e8f5e314ad081f7b88519fb08f7", + "value": "model.safetensors: 100%" + } + }, + "a0a09023605949d2aefeaafee9851466": { + "model_module": "@jupyter-widgets/controls", + "model_name": "FloatProgressModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "FloatProgressModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "ProgressView", + "bar_style": "success", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_5c9d5dbc6b5d4fc0a22b681f061b1205", + "max": 4125687675, + "min": 0, + "orientation": "horizontal", + "style": "IPY_MODEL_56832551ef354933b9defbef8eb03e44", + "value": 4125687675 + } + }, + "6161febb3f664d479b9b53d679bd8ade": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_b7642c1ae96343beb4aba8aca871a8f8", + "placeholder": "​", + "style": "IPY_MODEL_80faad6409be4f2fb819adc26653d607", + "value": " 4.13G/4.13G [00:34<00:00, 289MB/s]" + } + }, + "27896176d1534bd19a269209de9c42d2": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "911c84f720a948d8ba5bb3163b2a003d": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "9a4c0e8f5e314ad081f7b88519fb08f7": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "5c9d5dbc6b5d4fc0a22b681f061b1205": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "56832551ef354933b9defbef8eb03e44": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "ProgressStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "bar_color": null, + "description_width": "" + } + }, + "b7642c1ae96343beb4aba8aca871a8f8": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "80faad6409be4f2fb819adc26653d607": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "4d800c6d69ab467e840930b24fe16831": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HBoxModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HBoxView", + "box_style": "", + "children": [ + "IPY_MODEL_68bbc3b16e994fceb285f295989140c1", + "IPY_MODEL_94dcf818b19e44aeb54bda9ce574e957", + "IPY_MODEL_82049f0d5e82499a8f70355a3dae68a2" + ], + "layout": "IPY_MODEL_28680783d7614f87af3a09d6e9afc833" + } + }, + "68bbc3b16e994fceb285f295989140c1": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_d7bdec1f4a664affbde9027ec54fb13d", + "placeholder": "​", + "style": "IPY_MODEL_80f4a385b29d42d58d3d956cbb23f338", + "value": "generation_config.json: 100%" + } + }, + "94dcf818b19e44aeb54bda9ce574e957": { + "model_module": "@jupyter-widgets/controls", + "model_name": "FloatProgressModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "FloatProgressModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "ProgressView", + "bar_style": "success", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_86ef9c4f069f4e99a42e5ea6c7676d88", + "max": 155, + "min": 0, + "orientation": "horizontal", + "style": "IPY_MODEL_08ba9f5cf51d4c2da7907440a4e2c458", + "value": 155 + } + }, + "82049f0d5e82499a8f70355a3dae68a2": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_6abd99c4c1714103ab37c26241deb2c9", + "placeholder": "​", + "style": "IPY_MODEL_7816d673c1f144a9893414f36008c0eb", + "value": " 155/155 [00:00<00:00, 16.3kB/s]" + } + }, + "28680783d7614f87af3a09d6e9afc833": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "d7bdec1f4a664affbde9027ec54fb13d": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "80f4a385b29d42d58d3d956cbb23f338": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "86ef9c4f069f4e99a42e5ea6c7676d88": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "08ba9f5cf51d4c2da7907440a4e2c458": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "ProgressStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "bar_color": null, + "description_width": "" + } + }, + "6abd99c4c1714103ab37c26241deb2c9": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "7816d673c1f144a9893414f36008c0eb": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "47520bcbc5cd4c0cad0c66f0a7d8424b": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HBoxModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HBoxView", + "box_style": "", + "children": [ + "IPY_MODEL_0c698e54450440f1b914c5a9a4dad0ab", + "IPY_MODEL_2e57a702db284f379a96e49380b1d5a1", + "IPY_MODEL_af722a319e524e30b2f48f6f101d29b9" + ], + "layout": "IPY_MODEL_26c2cd235b2e449aa8e2a3e516e41729" + } + }, + "0c698e54450440f1b914c5a9a4dad0ab": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_b02f95d1b3ae4960a70669e8bcb1a7f5", + "placeholder": "​", + "style": "IPY_MODEL_c96bdb7a72de440985078b9548496c04", + "value": "tokenizer_config.json: " + } + }, + "2e57a702db284f379a96e49380b1d5a1": { + "model_module": "@jupyter-widgets/controls", + "model_name": "FloatProgressModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "FloatProgressModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "ProgressView", + "bar_style": "success", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_b08d709fb0694ef7b54236b8c89d11d6", + "max": 1, + "min": 0, + "orientation": "horizontal", + "style": "IPY_MODEL_c03681b9dff244e2aed1ba8580008e4c", + "value": 1 + } + }, + "af722a319e524e30b2f48f6f101d29b9": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_102f80001fdd4b71a999cf63bd36d4e4", + "placeholder": "​", + "style": "IPY_MODEL_3d961a73a2754b2887212ee1901012f6", + "value": " 2.13k/? [00:00<00:00, 96.5kB/s]" + } + }, + "26c2cd235b2e449aa8e2a3e516e41729": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "b02f95d1b3ae4960a70669e8bcb1a7f5": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "c96bdb7a72de440985078b9548496c04": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "b08d709fb0694ef7b54236b8c89d11d6": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": "20px" + } + }, + "c03681b9dff244e2aed1ba8580008e4c": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "ProgressStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "bar_color": null, + "description_width": "" + } + }, + "102f80001fdd4b71a999cf63bd36d4e4": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "3d961a73a2754b2887212ee1901012f6": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "da06ca42f9c64c0d85e33d3eb05cd783": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HBoxModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HBoxView", + "box_style": "", + "children": [ + "IPY_MODEL_26911547c5dc43c8a7e4c6b1b8215dda", + "IPY_MODEL_56ca64d7161344f087f91bbe7ceec5e2", + "IPY_MODEL_d5dfc359f8144ece98ede97bdd8487dc" + ], + "layout": "IPY_MODEL_dd5f431c1a38471b936ffa51aab54076" + } + }, + "26911547c5dc43c8a7e4c6b1b8215dda": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_449a2f12742c4fd99b0d1d80e80195d0", + "placeholder": "​", + "style": "IPY_MODEL_26162406ab3b4ec092b3299ab34c0234", + "value": "tokenizer.model: 100%" + } + }, + "56ca64d7161344f087f91bbe7ceec5e2": { + "model_module": "@jupyter-widgets/controls", + "model_name": "FloatProgressModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "FloatProgressModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "ProgressView", + "bar_style": "success", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_d8d162ebf11a4b76ad94ec14ea99ce2c", + "max": 493443, + "min": 0, + "orientation": "horizontal", + "style": "IPY_MODEL_f958c034d4d14cc5bd9deec9024fc2dd", + "value": 493443 + } + }, + "d5dfc359f8144ece98ede97bdd8487dc": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_34a60bb227944f42a6ddc34d76d0279b", + "placeholder": "​", + "style": "IPY_MODEL_9ac7978136ea4e99bd10e762bea7857e", + "value": " 493k/493k [00:01<00:00, 277kB/s]" + } + }, + "dd5f431c1a38471b936ffa51aab54076": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "449a2f12742c4fd99b0d1d80e80195d0": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "26162406ab3b4ec092b3299ab34c0234": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "d8d162ebf11a4b76ad94ec14ea99ce2c": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "f958c034d4d14cc5bd9deec9024fc2dd": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "ProgressStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "bar_color": null, + "description_width": "" + } + }, + "34a60bb227944f42a6ddc34d76d0279b": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "9ac7978136ea4e99bd10e762bea7857e": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "d44152571a6145918aec5d641f9b7fc8": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HBoxModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HBoxView", + "box_style": "", + "children": [ + "IPY_MODEL_42e1379e86874cafa62cf49963a891c3", + "IPY_MODEL_0de63bae133945e2aac4b9fec83bb3ae", + "IPY_MODEL_49404301bb0b4960bd6c62480224b2fe" + ], + "layout": "IPY_MODEL_952409474b264871a3d36cdff657325f" + } + }, + "42e1379e86874cafa62cf49963a891c3": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_3f6dd376136349f1ab8964b2d0a8d38b", + "placeholder": "​", + "style": "IPY_MODEL_a1427f7ac4244cc8a00e537234a77ce1", + "value": "special_tokens_map.json: 100%" + } + }, + "0de63bae133945e2aac4b9fec83bb3ae": { + "model_module": "@jupyter-widgets/controls", + "model_name": "FloatProgressModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "FloatProgressModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "ProgressView", + "bar_style": "success", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_9c9d289624c24a06b7452ec721a0757f", + "max": 438, + "min": 0, + "orientation": "horizontal", + "style": "IPY_MODEL_27abf8d593b9439d8c26d1106a43b188", + "value": 438 + } + }, + "49404301bb0b4960bd6c62480224b2fe": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_11036df70acd4c0f9c4786acfb503789", + "placeholder": "​", + "style": "IPY_MODEL_54e60f327f3c4f578a32752101844cf1", + "value": " 438/438 [00:00<00:00, 41.3kB/s]" + } + }, + "952409474b264871a3d36cdff657325f": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "3f6dd376136349f1ab8964b2d0a8d38b": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "a1427f7ac4244cc8a00e537234a77ce1": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "9c9d289624c24a06b7452ec721a0757f": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "27abf8d593b9439d8c26d1106a43b188": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "ProgressStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "bar_color": null, + "description_width": "" + } + }, + "11036df70acd4c0f9c4786acfb503789": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "54e60f327f3c4f578a32752101844cf1": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "89e1e5b67d7441f3b8d8b0aeae9d57ac": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HBoxModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HBoxView", + "box_style": "", + "children": [ + "IPY_MODEL_075b8ae5b0db4829bb12bdbc59fc0e9a", + "IPY_MODEL_48d095cf13824115af89accf7dd95d97", + "IPY_MODEL_b80ee5ca191e4c2781576742724095f6" + ], + "layout": "IPY_MODEL_854141bdb5c248e9bc5f4f20ed778938" + } + }, + "075b8ae5b0db4829bb12bdbc59fc0e9a": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_9b39066c060f41edb4a0335aa557b79d", + "placeholder": "​", + "style": "IPY_MODEL_6f489610d4b64f24a96943a43f097461", + "value": "tokenizer.json: " + } + }, + "48d095cf13824115af89accf7dd95d97": { + "model_module": "@jupyter-widgets/controls", + "model_name": "FloatProgressModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "FloatProgressModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "ProgressView", + "bar_style": "success", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_6f77dc34889940cd8dde31e8736869c5", + "max": 1, + "min": 0, + "orientation": "horizontal", + "style": "IPY_MODEL_a214c3305a1d42ed957ecc209c2d1a2d", + "value": 1 + } + }, + "b80ee5ca191e4c2781576742724095f6": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_a8311cf9a7114db69c05c6b8c422f64f", + "placeholder": "​", + "style": "IPY_MODEL_649a5da776f443e7beef813facc2b5dd", + "value": " 1.80M/? [00:00<00:00, 37.6MB/s]" + } + }, + "854141bdb5c248e9bc5f4f20ed778938": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "9b39066c060f41edb4a0335aa557b79d": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "6f489610d4b64f24a96943a43f097461": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "6f77dc34889940cd8dde31e8736869c5": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": "20px" + } + }, + "a214c3305a1d42ed957ecc209c2d1a2d": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "ProgressStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "bar_color": null, + "description_width": "" + } + }, + "a8311cf9a7114db69c05c6b8c422f64f": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "649a5da776f443e7beef813facc2b5dd": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "a095792b16984a589a20710ab5115424": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HBoxModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HBoxView", + "box_style": "", + "children": [ + "IPY_MODEL_48053f773ac840b9b1f13e5cb63d16fe", + "IPY_MODEL_4e3d9561ca0e4ea6ab0a5b1dd07f250e", + "IPY_MODEL_e21de438e9c44a0ea338884b6b428a00" + ], + "layout": "IPY_MODEL_1bd38922ae97495a8d6ed334f8ce6846" + } + }, + "48053f773ac840b9b1f13e5cb63d16fe": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_8b6a854017014e45968438347e90e2a5", + "placeholder": "​", + "style": "IPY_MODEL_31c056a2d7ec4566b1148d7c9b08c380", + "value": "Unsloth: Tokenizing ["text"] (num_proc=4): 100%" + } + }, + "4e3d9561ca0e4ea6ab0a5b1dd07f250e": { + "model_module": "@jupyter-widgets/controls", + "model_name": "FloatProgressModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "FloatProgressModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "ProgressView", + "bar_style": "success", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_d0ec7021b7c54a2899f55178511d1c33", + "max": 512, + "min": 0, + "orientation": "horizontal", + "style": "IPY_MODEL_be354bf3bac040f7b2cafb3f71ef7ca2", + "value": 512 + } + }, + "e21de438e9c44a0ea338884b6b428a00": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_8b7d8116e9b2465396c2624877c16f8e", + "placeholder": "​", + "style": "IPY_MODEL_bd91b43f57ab46a7a7f2dc4f2132aeb2", + "value": " 512/512 [00:02<00:00, 363.32 examples/s]" + } + }, + "1bd38922ae97495a8d6ed334f8ce6846": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "8b6a854017014e45968438347e90e2a5": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "31c056a2d7ec4566b1148d7c9b08c380": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "d0ec7021b7c54a2899f55178511d1c33": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "be354bf3bac040f7b2cafb3f71ef7ca2": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "ProgressStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "bar_color": null, + "description_width": "" + } + }, + "8b7d8116e9b2465396c2624877c16f8e": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "bd91b43f57ab46a7a7f2dc4f2132aeb2": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "4eca9310357c478a84f625f1b88f28f5": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HBoxModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HBoxView", + "box_style": "", + "children": [ + "IPY_MODEL_40015b4456294f309be22d9341fe7f56", + "IPY_MODEL_29320f0a8c974ba7a82bfa1391847171", + "IPY_MODEL_8566593bb0e54793b6a6b7b189adfbeb" + ], + "layout": "IPY_MODEL_74834064e68b42b48da9459084e3712e" + } + }, + "40015b4456294f309be22d9341fe7f56": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_d96e567191bc4f8f83505881ee7e7cb1", + "placeholder": "​", + "style": "IPY_MODEL_d808cd6d981840d1a2f5264bf0c7cac3", + "value": "Unsloth: Tokenizing ["text"] (num_proc=4): 100%" + } + }, + "29320f0a8c974ba7a82bfa1391847171": { + "model_module": "@jupyter-widgets/controls", + "model_name": "FloatProgressModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "FloatProgressModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "ProgressView", + "bar_style": "success", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_1eba6b652dbd447b9a8e2e116e129ec8", + "max": 80, + "min": 0, + "orientation": "horizontal", + "style": "IPY_MODEL_7396a92d71494f42847c1f3ccd681fcf", + "value": 80 + } + }, + "8566593bb0e54793b6a6b7b189adfbeb": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_03f7216f921242f6b9392941921315e4", + "placeholder": "​", + "style": "IPY_MODEL_ab0f920a141c4319a4d4da3a42efdc64", + "value": " 80/80 [00:02<00:00, 36.56 examples/s]" + } + }, + "74834064e68b42b48da9459084e3712e": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "d96e567191bc4f8f83505881ee7e7cb1": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "d808cd6d981840d1a2f5264bf0c7cac3": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "1eba6b652dbd447b9a8e2e116e129ec8": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "7396a92d71494f42847c1f3ccd681fcf": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "ProgressStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "bar_color": null, + "description_width": "" + } + }, + "03f7216f921242f6b9392941921315e4": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "ab0f920a141c4319a4d4da3a42efdc64": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + } + } + } }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## A. Overview: QLoRA + Schema-Grounded Prompts\n", - "\n", - "**QLoRA** (Quantized LoRA) combines:\n", - "\n", - "- **4-bit quantization** of the base model weights (via bitsandbytes).\n", - "- **Low-Rank Adapters (LoRA)** that are trained while keeping the\n", - " quantized base model frozen.\n", - "\n", - "This dramatically reduces memory usage, allowing us to fine-tune 7B models\n", - "on a single GPU while still achieving strong performance.\n", - "\n", - "For **Text-to-SQL**, we want the model to be:\n", - "\n", - "- **Schema-aware**: It should use only the tables and columns that actually\n", - " exist.\n", - "- **Grounded**: The model should see the schema (e.g., `CREATE TABLE`)\n", - " alongside the question.\n", - "- **Cautious**: Avoid hallucinating non-existent tables/columns.\n", - "\n", - "To support this, our preprocessing pipeline constructs prompts like:\n", - "\n", - "```text\n", - "### Instruction:\n", - "Write a SQL query that answers the user's question using ONLY the tables and columns provided in the schema.\n", - "\n", - "### Input:\n", - "### Schema:\n", - "CREATE TABLE head (age INTEGER)\n", - "\n", - "### Question:\n", - "How many heads of the departments are older than 56 ?\n", - "\n", - "### Response:\n", - "SELECT COUNT(*) FROM head WHERE age > 56\n", - "```\n", - "\n", - "The **instruction** is fixed, the **input** combines schema + question, and\n", - "the **response** is the target SQL. We will train the model to map\n", - "instruction+input to response." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## B. Environment Setup\n", - "\n", - "This section installs dependencies (for Colab), checks GPU availability, and\n", - "sets random seeds for reproducibility.\n", - "\n", - "> If you are running locally with the repository already installed, you may\n", - "> skip the `pip install` step and simply import the libraries." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "env-setup" - }, - "outputs": [], - "source": [ - "# If running in Colab, uncomment the following lines to install dependencies.\n", - "# !pip install -q unsloth bitsandbytes accelerate transformers datasets trl peft\n", - "\n", - "import os\n", - "import json\n", - "import random\n", - "from pathlib import Path\n", - "\n", - "import torch\n", - "from datasets import Dataset\n", - "from trl import SFTConfig, SFTTrainer\n", - "from unsloth import FastLanguageModel\n", - "\n", - "BASE_DIR = Path.cwd()\n", - "DATA_DIR = BASE_DIR / \"data\" / \"processed\"\n", - "OUTPUT_DIR = BASE_DIR / \"outputs\"\n", - "OUTPUT_DIR.mkdir(parents=True, exist_ok=True)\n", - "\n", - "def set_seed(seed: int = 42):\n", - " random.seed(seed)\n", - " os.environ[\"PYTHONHASHSEED\"] = str(seed)\n", - " torch.manual_seed(seed)\n", - " if torch.cuda.is_available():\n", - " torch.cuda.manual_seed_all(seed)\n", - "\n", - "set_seed(42)\n", - "\n", - "print(f\"Using device: {'cuda' if torch.cuda.is_available() else 'cpu'}\")\n", - "if not torch.cuda.is_available():\n", - " print(\"WARNING: CUDA not available. Training a 7B model will not be feasible on CPU.\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## C. Load Processed Dataset (train/val JSONL)\n", - "\n", - "The preprocessing step (`scripts/build_dataset.py`) produces two files:\n", - "\n", - "- `data/processed/train.jsonl`\n", - "- `data/processed/val.jsonl`\n", - "\n", - "Each line is an Alpaca-style record with keys: `id`, `instruction`, `input`,\n", - "`output`, `source`, and `meta`.\n", - "\n", - "We will load them into `datasets.Dataset` objects for use with TRL's\n", - "`SFTTrainer`." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "load-dataset" - }, - "outputs": [], - "source": [ - "def load_alpaca_jsonl(path: Path) -> Dataset:\n", - " if not path.is_file():\n", - " raise FileNotFoundError(f\"JSONL file not found: {path}\")\n", - " records = []\n", - " with path.open(\"r\", encoding=\"utf-8\") as f:\n", - " for line in f:\n", - " line = line.strip()\n", - " if not line:\n", - " continue\n", - " records.append(json.loads(line))\n", - " return Dataset.from_list(records)\n", - "\n", - "train_path = DATA_DIR / \"train.jsonl\"\n", - "val_path = DATA_DIR / \"val.jsonl\"\n", - "\n", - "train_raw = load_alpaca_jsonl(train_path)\n", - "val_raw = load_alpaca_jsonl(val_path)\n", - "\n", - "print(train_raw)\n", - "print(val_raw)\n", - "\n", - "train_raw[0]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## D. Prompt Formatting\n", - "\n", - "Our training format combines `instruction`, `input`, and `output` into a\n", - "single `text` field. The prompt structure is:\n", - "\n", - "```text\n", - "### Instruction:\n", - "\n", - "\n", - "### Input:\n", - "\n", - "\n", - "### Response:\n", - "\n", - "```\n", - "\n", - "We will implement two helpers mirroring the library code in\n", - "`src/text2sql/training/formatting.py`:\n", - "\n", - "- `build_prompt(instruction, input)` – builds the instruction + input + response header.\n", - "- `ensure_sql_only(output)` – normalizes whitespace and strips code fences.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "prompt-formatting" - }, - "outputs": [], - "source": [ - "import re\n", - "\n", - "PROMPT_TEMPLATE = \"\"\"### Instruction:\\n{instruction}\\n\\n### Input:\\n{input}\\n\\n### Response:\\n\"\"\"\n", - "\n", - "def build_prompt(instruction: str, input_text: str) -> str:\n", - " instruction = (instruction or \"\").strip()\n", - " input_text = (input_text or \"\").strip()\n", - " return PROMPT_TEMPLATE.format(instruction=instruction, input=input_text)\n", - "\n", - "def ensure_sql_only(output: str) -> str:\n", - " if output is None:\n", - " return \"\"\n", - " text = output.strip()\n", - " if text.startswith(\"```\"):\n", - " text = re.sub(r\"^```(?:sql)?\\s*\", \"\", text, flags=re.IGNORECASE)\n", - " text = re.sub(r\"\\s*```$\", \"\", text)\n", - " text = re.sub(r\"\\s+\", \" \", text)\n", - " return text\n", - "\n", - "def format_example(example):\n", - " prompt = build_prompt(example[\"instruction\"], example[\"input\"])\n", - " sql = ensure_sql_only(example[\"output\"])\n", - " return {\"text\": prompt + sql}\n", - "\n", - "formatted_sample = format_example(train_raw[0])\n", - "print(formatted_sample[\"text\"][:1000])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We can now apply this formatting to the entire dataset. During development,\n", - "it is often useful to use a **fast dev run** on a subset of the data." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "format-dataset" - }, - "outputs": [], - "source": [ - "FAST_DEV_RUN = True # Set to False for full training\n", - "MAX_DEV_SAMPLES = 512\n", - "\n", - "if FAST_DEV_RUN:\n", - " train_raw_sliced = train_raw.select(range(min(MAX_DEV_SAMPLES, train_raw.num_rows)))\n", - " val_raw_sliced = val_raw.select(range(min(MAX_DEV_SAMPLES, val_raw.num_rows)))\n", - "else:\n", - " train_raw_sliced = train_raw\n", - " val_raw_sliced = val_raw\n", - "\n", - "train_ds = train_raw_sliced.map(format_example, remove_columns=train_raw_sliced.column_names)\n", - "val_ds = val_raw_sliced.map(format_example, remove_columns=val_raw_sliced.column_names)\n", - "\n", - "print(train_ds)\n", - "print(val_ds)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## E. Load Base Model in 4-Bit & Apply LoRA Adapters\n", - "\n", - "We now load `mistralai/Mistral-7B-Instruct-v0.1` using Unsloth's\n", - "`FastLanguageModel` in 4-bit mode and attach LoRA adapters.\n", - "\n", - "Key hyperparameters:\n", - "\n", - "- `r` (LoRA rank): capacity of the adapter (typical range: 8–64).\n", - "- `alpha`: scale factor for the adapter.\n", - "- `dropout`: dropout applied to the adapter; often 0.0 or small.\n", - "- `target_modules`: which projection layers receive LoRA (q_proj, k_proj, etc.).\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "load-model" - }, - "outputs": [], - "source": [ - "BASE_MODEL = \"mistralai/Mistral-7B-Instruct-v0.1\"\n", - "MAX_SEQ_LENGTH = 2048\n", - "LORA_R = 16\n", - "LORA_ALPHA = 16\n", - "LORA_DROPOUT = 0.0\n", - "\n", - "if not torch.cuda.is_available():\n", - " print(\"CUDA is not available. The following cell will likely OOM on CPU.\")\n", - "\n", - "dtype = None # Let Unsloth choose bf16/fp16\n", - "load_in_4bit = True\n", - "\n", - "model, tokenizer = FastLanguageModel.from_pretrained(\n", - " model_name=BASE_MODEL,\n", - " max_seq_length=MAX_SEQ_LENGTH,\n", - " dtype=dtype,\n", - " load_in_4bit=load_in_4bit,\n", - ")\n", - "\n", - "model = FastLanguageModel.get_peft_model(\n", - " model,\n", - " r=LORA_R,\n", - " target_modules=[\n", - " \"q_proj\",\n", - " \"k_proj\",\n", - " \"v_proj\",\n", - " \"o_proj\",\n", - " \"gate_proj\",\n", - " \"up_proj\",\n", - " \"down_proj\",\n", - " ],\n", - " lora_alpha=LORA_ALPHA,\n", - " lora_dropout=LORA_DROPOUT,\n", - " bias=\"none\",\n", - " use_gradient_checkpointing=\"unsloth\",\n", - " random_state=42,\n", - " use_rslora=False,\n", - " loftq_config=None,\n", - ")\n", - "\n", - "model" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## F. Training Loop with TRL's SFTTrainer\n", - "\n", - "We will now configure and run supervised fine-tuning with TRL's `SFTTrainer`.\n", - "\n", - "For **fast dev runs**, we will:\n", - "\n", - "- Limit the number of steps (e.g., `max_steps=20`).\n", - "- Use a small subset of the data.\n", - "\n", - "Once everything works, you can disable `FAST_DEV_RUN` and increase\n", - "`max_steps` for a proper training run." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "train-config" - }, - "outputs": [], - "source": [ - "MAX_STEPS = 20 if FAST_DEV_RUN else 500\n", - "PER_DEVICE_TRAIN_BATCH_SIZE = 1\n", - "GRADIENT_ACCUMULATION_STEPS = 8\n", - "LEARNING_RATE = 2e-4\n", - "WARMUP_STEPS = 50\n", - "WEIGHT_DECAY = 0.0\n", - "\n", - "sft_config = SFTConfig(\n", - " output_dir=str(OUTPUT_DIR),\n", - " max_steps=MAX_STEPS,\n", - " per_device_train_batch_size=PER_DEVICE_TRAIN_BATCH_SIZE,\n", - " gradient_accumulation_steps=GRADIENT_ACCUMULATION_STEPS,\n", - " learning_rate=LEARNING_RATE,\n", - " warmup_steps=WARMUP_STEPS,\n", - " weight_decay=WEIGHT_DECAY,\n", - " logging_steps=10,\n", - " evaluation_strategy=\"steps\",\n", - " eval_steps=max(MAX_STEPS // 10, 1),\n", - " save_strategy=\"steps\",\n", - " save_steps=max(MAX_STEPS // 10, 1),\n", - " bf16=torch.cuda.is_bf16_supported(),\n", - ")\n", - "\n", - "trainer = SFTTrainer(\n", - " model=model,\n", - " tokenizer=tokenizer,\n", - " train_dataset=train_ds,\n", - " eval_dataset=val_ds,\n", - " dataset_text_field=\"text\",\n", - " args=sft_config,\n", - ")\n", - "\n", - "trainer" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "run-training" - }, - "outputs": [], - "source": [ - "train_output = trainer.train()\n", - "train_output" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## G. Save Artifacts (Adapters + Metrics)\n", - "\n", - "After training, we save the LoRA adapters and simple metrics:\n", - "\n", - "- `outputs/adapters/` – adapter weights and tokenizer config.\n", - "- `outputs/run_meta.json` – run configuration and dataset sizes.\n", - "- `outputs/metrics.json` – train/eval losses and related metrics (if available)." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "save-artifacts" - }, - "outputs": [], - "source": [ - "adapters_dir = OUTPUT_DIR / \"adapters\"\n", - "adapters_dir.mkdir(parents=True, exist_ok=True)\n", - "\n", - "trainer.model.save_pretrained(str(adapters_dir))\n", - "tokenizer.save_pretrained(str(adapters_dir))\n", - "\n", - "# Save run metadata\n", - "run_meta = {\n", - " \"base_model\": BASE_MODEL,\n", - " \"max_steps\": MAX_STEPS,\n", - " \"per_device_train_batch_size\": PER_DEVICE_TRAIN_BATCH_SIZE,\n", - " \"gradient_accumulation_steps\": GRADIENT_ACCUMULATION_STEPS,\n", - " \"learning_rate\": LEARNING_RATE,\n", - " \"max_seq_length\": MAX_SEQ_LENGTH,\n", - " \"lora_r\": LORA_R,\n", - " \"lora_alpha\": LORA_ALPHA,\n", - " \"lora_dropout\": LORA_DROPOUT,\n", - " \"fast_dev_run\": FAST_DEV_RUN,\n", - " \"num_train_examples\": len(train_ds),\n", - " \"num_val_examples\": len(val_ds),\n", - "}\n", - "\n", - "with (OUTPUT_DIR / \"run_meta.json\").open(\"w\", encoding=\"utf-8\") as f:\n", - " json.dump(run_meta, f, indent=2)\n", - "\n", - "# Save metrics if available\n", - "metrics = {}\n", - "if hasattr(train_output, \"metrics\") and train_output.metrics is not None:\n", - " metrics.update(train_output.metrics)\n", - "\n", - "try:\n", - " eval_metrics = trainer.evaluate()\n", - " metrics.update({f\"eval_{k}\": v for k, v in eval_metrics.items()})\n", - "except Exception as e: # noqa: BLE001\n", - " print(\"Evaluation failed or was skipped:\", e)\n", - "\n", - "with (OUTPUT_DIR / \"metrics.json\").open(\"w\", encoding=\"utf-8\") as f:\n", - " json.dump(metrics, f, indent=2)\n", - "\n", - "metrics" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## H. Quick Sanity Inference\n", - "\n", - "Finally, we perform a quick sanity check by generating SQL for a few\n", - "examples. This is a qualitative check to see if the model learned to\n", - "produce reasonable SQL given the schema and question." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "sanity-inference" - }, - "outputs": [], - "source": [ - "from transformers import TextStreamer\n", - "\n", - "FastLanguageModel.for_inference(model)\n", - "\n", - "def generate_sql(example, max_new_tokens: int = 128):\n", - " prompt = build_prompt(example[\"instruction\"], example[\"input\"])\n", - " inputs = tokenizer(prompt, return_tensors=\"pt\").to(model.device)\n", - " streamer = TextStreamer(tokenizer)\n", - "\n", - " print(\"=== Prompt ===\")\n", - " print(prompt)\n", - " print(\"=== Generated SQL ===\")\n", - " _ = model.generate(\n", - " **inputs,\n", - " streamer=streamer,\n", - " max_new_tokens=max_new_tokens,\n", - " do_sample=True,\n", - " temperature=0.2,\n", - " top_p=0.9,\n", - " )\n", - " print(\"\\n=================\\n\")\n", - "\n", - "for i in range(3):\n", - " generate_sql(train_raw[i])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## I. Next Steps\n", - "\n", - "You now have a QLoRA-finetuned Mistral-7B-Instruct model for Text-to-SQL.\n", - "The next steps for this project are:\n", - "\n", - "1. **External Validation on Spider dev (planned Task 4)**\n", - " - Evaluate the model on a harder, multi-table, cross-domain benchmark\n", - " such as `xlangai/spider`.\n", - " - Measure logical form accuracy and execution accuracy.\n", - " - See `docs/external_validation.md` for the high-level plan.\n", - "\n", - "2. **Push to Hugging Face Hub (planned Task 5)**\n", - " - Package the LoRA adapters and associated config.\n", - " - Publish a model card documenting training data, metrics, and usage.\n", - "\n", - "3. **Streamlit Remote Inference UI (planned Task 6)**\n", - " - Integrate the fine-tuned model into a Streamlit app.\n", - " - Allow users to connect to a database, ask natural-language questions,\n", - " and inspect / edit the generated SQL.\n", - "\n", - "These steps will complete the full loop from data → training → evaluation →\n", - "interactive Analytics Copilot experience." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "name": "python", - "version": "3.11" - } - }, - "nbformat": 4, - "nbformat_minor": 5 + "nbformat": 4, + "nbformat_minor": 5 } \ No newline at end of file diff --git a/notebooks/trainLLM.ipynb b/notebooks/trainLLM.ipynb new file mode 100644 index 0000000..1637642 --- /dev/null +++ b/notebooks/trainLLM.ipynb @@ -0,0 +1,2564 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [], + "gpuType": "T4" + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + }, + "accelerator": "GPU", + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "70cc4204cdad4c209c8906729e99467b": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HBoxModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HBoxView", + "box_style": "", + "children": [ + "IPY_MODEL_1777b683e9344cb2ad270a58578f4e18", + "IPY_MODEL_2ee16cf6b9ae4e8a82c88d759a15f015", + "IPY_MODEL_136c4b9d5dba4f53b00f9ac0a4b00e61" + ], + "layout": "IPY_MODEL_3cb01a3366e045e1a1f1608c3e56688e" + } + }, + "1777b683e9344cb2ad270a58578f4e18": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_252abfa1fe3b41fb94e10e30924c34fa", + "placeholder": "​", + "style": "IPY_MODEL_3d52ee945dba44cd9e2c0f7cdf1dbb81", + "value": "Processing Files (2 / 2)      : 100%" + } + }, + "2ee16cf6b9ae4e8a82c88d759a15f015": { + "model_module": "@jupyter-widgets/controls", + "model_name": "FloatProgressModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "FloatProgressModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "ProgressView", + "bar_style": "success", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_67c5b6014b3d495786cfe3aeec321e9c", + "max": 1, + "min": 0, + "orientation": "horizontal", + "style": "IPY_MODEL_3f56d826eee0422a9c1f1d8025443392", + "value": 1 + } + }, + "136c4b9d5dba4f53b00f9ac0a4b00e61": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_44d14039fcb94bb18aa2485cd27922a6", + "placeholder": "​", + "style": "IPY_MODEL_e92eb345e1e54978894cc79367564999", + "value": "  168MB /  168MB, 18.5MB/s  " + } + }, + "3cb01a3366e045e1a1f1608c3e56688e": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "252abfa1fe3b41fb94e10e30924c34fa": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "3d52ee945dba44cd9e2c0f7cdf1dbb81": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "67c5b6014b3d495786cfe3aeec321e9c": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": "20px" + } + }, + "3f56d826eee0422a9c1f1d8025443392": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "ProgressStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "bar_color": null, + "description_width": "" + } + }, + "44d14039fcb94bb18aa2485cd27922a6": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "e92eb345e1e54978894cc79367564999": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "061bf6cc6bd946a986861565bf2ebcd9": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HBoxModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HBoxView", + "box_style": "", + "children": [ + "IPY_MODEL_c41abffae772456fa1fdb80cf542873a", + "IPY_MODEL_4f588fadd07747b3a9f365e1e970dee5", + "IPY_MODEL_27d53f12a7d1415d89bd1f3b104a2ef3" + ], + "layout": "IPY_MODEL_8688befecc05457abcff5c66ec84a99a" + } + }, + "c41abffae772456fa1fdb80cf542873a": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_4c685c7b5f6d488891f6396b04cdcd6e", + "placeholder": "​", + "style": "IPY_MODEL_3c7bde7afa094b04afb49afcf12ab7cf", + "value": "New Data Upload               : 100%" + } + }, + "4f588fadd07747b3a9f365e1e970dee5": { + "model_module": "@jupyter-widgets/controls", + "model_name": "FloatProgressModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "FloatProgressModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "ProgressView", + "bar_style": "success", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_919588d68ea84235bd9e4c7086856944", + "max": 1, + "min": 0, + "orientation": "horizontal", + "style": "IPY_MODEL_14b0d4fad2db47a5bb5e61cf87c83c4f", + "value": 1 + } + }, + "27d53f12a7d1415d89bd1f3b104a2ef3": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_5978f8471308459a94e1f8f67e295665", + "placeholder": "​", + "style": "IPY_MODEL_f965cf54e57a45279ca5f9507dc33c66", + "value": "  168MB /  168MB, 18.5MB/s  " + } + }, + "8688befecc05457abcff5c66ec84a99a": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "4c685c7b5f6d488891f6396b04cdcd6e": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "3c7bde7afa094b04afb49afcf12ab7cf": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "919588d68ea84235bd9e4c7086856944": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": "20px" + } + }, + "14b0d4fad2db47a5bb5e61cf87c83c4f": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "ProgressStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "bar_color": null, + "description_width": "" + } + }, + "5978f8471308459a94e1f8f67e295665": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "f965cf54e57a45279ca5f9507dc33c66": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "d0724fb2bd5c4a79b285e1a9bd6e5cb3": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HBoxModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HBoxView", + "box_style": "", + "children": [ + "IPY_MODEL_264e3577977843afb83fcdf9df069958", + "IPY_MODEL_6f59a2449da84a10bcab14223777ead4", + "IPY_MODEL_00f9e56abed94779894ce14a060f84dc" + ], + "layout": "IPY_MODEL_e0710cbbecfc42e5be9ab590765076bf" + } + }, + "264e3577977843afb83fcdf9df069958": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_11a940cc9ee246f8b505c1e26a1e330f", + "placeholder": "​", + "style": "IPY_MODEL_d2be786fb1a3435a9823baf1ca1405f3", + "value": "  .../adapters/tokenizer.model: 100%" + } + }, + "6f59a2449da84a10bcab14223777ead4": { + "model_module": "@jupyter-widgets/controls", + "model_name": "FloatProgressModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "FloatProgressModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "ProgressView", + "bar_style": "success", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_b0c36c6fdbb5441889463865d618b371", + "max": 493443, + "min": 0, + "orientation": "horizontal", + "style": "IPY_MODEL_c1e2ad7bfb064a6682db162aaeb97c7b", + "value": 493443 + } + }, + "00f9e56abed94779894ce14a060f84dc": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_aa468ea9df84402ab98998efd3b92445", + "placeholder": "​", + "style": "IPY_MODEL_723898a8b93d49ea9d723851eba1d0f4", + "value": "  493kB /  493kB            " + } + }, + "e0710cbbecfc42e5be9ab590765076bf": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "11a940cc9ee246f8b505c1e26a1e330f": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "d2be786fb1a3435a9823baf1ca1405f3": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "b0c36c6fdbb5441889463865d618b371": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "c1e2ad7bfb064a6682db162aaeb97c7b": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "ProgressStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "bar_color": null, + "description_width": "" + } + }, + "aa468ea9df84402ab98998efd3b92445": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "723898a8b93d49ea9d723851eba1d0f4": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "ee1e30d650f34dd98efff844fcc7be61": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HBoxModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HBoxView", + "box_style": "", + "children": [ + "IPY_MODEL_7040006621e947d5b082ab1c85e11468", + "IPY_MODEL_dac777938bad4723a5995dffa8bae74b", + "IPY_MODEL_6c0eca0cd70447f4ae2bd30793546890" + ], + "layout": "IPY_MODEL_4d0fc204ce9d47779972155840d1ad70" + } + }, + "7040006621e947d5b082ab1c85e11468": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_9d1e4b8808314cfa8bc8d476f87f33ac", + "placeholder": "​", + "style": "IPY_MODEL_56ace8bfec814648a32065f293524840", + "value": "  ...adapter_model.safetensors: 100%" + } + }, + "dac777938bad4723a5995dffa8bae74b": { + "model_module": "@jupyter-widgets/controls", + "model_name": "FloatProgressModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "FloatProgressModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "ProgressView", + "bar_style": "success", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_69f36cb1b6c742209238f17fe0b63afd", + "max": 167832240, + "min": 0, + "orientation": "horizontal", + "style": "IPY_MODEL_4acb50b31fbb40f4a3fb066e333dc92a", + "value": 167832240 + } + }, + "6c0eca0cd70447f4ae2bd30793546890": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "model_module_version": "1.5.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_563583f499a34df99d5e8700b401f61d", + "placeholder": "​", + "style": "IPY_MODEL_14403ab2014e4361b973189b16b7536c", + "value": "  168MB /  168MB            " + } + }, + "4d0fc204ce9d47779972155840d1ad70": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "9d1e4b8808314cfa8bc8d476f87f33ac": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "56ace8bfec814648a32065f293524840": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "69f36cb1b6c742209238f17fe0b63afd": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "4acb50b31fbb40f4a3fb066e333dc92a": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "ProgressStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "bar_color": null, + "description_width": "" + } + }, + "563583f499a34df99d5e8700b401f61d": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "14403ab2014e4361b973189b16b7536c": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + } + } + } + }, + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "TLYYGL9ZrdtR", + "outputId": "21178cbc-dbf9-44ae-b529-e2bcc6ddfaf2" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Sun Jan 11 04:19:46 2026 \n", + "+-----------------------------------------------------------------------------------------+\n", + "| NVIDIA-SMI 550.54.15 Driver Version: 550.54.15 CUDA Version: 12.4 |\n", + "|-----------------------------------------+------------------------+----------------------+\n", + "| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |\n", + "| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |\n", + "| | | MIG M. |\n", + "|=========================================+========================+======================|\n", + "| 0 Tesla T4 Off | 00000000:00:04.0 Off | 0 |\n", + "| N/A 40C P8 11W / 70W | 0MiB / 15360MiB | 0% Default |\n", + "| | | N/A |\n", + "+-----------------------------------------+------------------------+----------------------+\n", + " \n", + "+-----------------------------------------------------------------------------------------+\n", + "| Processes: |\n", + "| GPU GI CI PID Type Process name GPU Memory |\n", + "| ID ID Usage |\n", + "|=========================================================================================|\n", + "| No running processes found |\n", + "+-----------------------------------------------------------------------------------------+\n" + ] + } + ], + "source": [ + "!nvidia-smi" + ] + }, + { + "cell_type": "code", + "source": [ + "from google.colab import drive\n", + "drive.mount('/content/drive')" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "DN_RapA5ryaz", + "outputId": "eed12779-a340-4d1c-c110-64806ef2afd2" + }, + "execution_count": 2, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Mounted at /content/drive\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "import os\n", + "\n", + "# Define the target path\n", + "target_path = 'your_target_path'\n", + "\n", + "# Change the directory\n", + "os.chdir(target_path)\n", + "\n", + "# Verify the change\n", + "print(f\"Current Working Directory: {os.getcwd()}\")" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "oZWtu2aGr-Io", + "outputId": "d454a723-014b-42bd-b078-18bfcccc74db" + }, + "execution_count": 3, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Current Working Directory: /content/drive/MyDrive/Projects/analytics_copilot\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "!git clone https://github.com/brej-29/analytics-copilot-text2sql.git" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "aadkNR4tsGis", + "outputId": "c7d7f27b-4198-470a-abfe-219adc8727f6" + }, + "execution_count": 4, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "fatal: destination path 'analytics-copilot-text2sql' already exists and is not an empty directory.\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "%cd analytics-copilot-text2sql" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "fERZgNXnsU72", + "outputId": "3646ec7f-3997-4644-87e9-3f3c2347e8e5" + }, + "execution_count": 5, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "/content/drive/MyDrive/Projects/analytics_copilot/analytics-copilot-text2sql\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "!pip -q install -r requirements.txt" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "3C6GaYnasZuq", + "outputId": "1cb19d86-a055-4839-efc7-d22dff453e3c" + }, + "execution_count": 10, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m66.6/66.6 kB\u001b[0m \u001b[31m6.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m9.0/9.0 MB\u001b[0m \u001b[31m123.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m381.1/381.1 kB\u001b[0m \u001b[31m37.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m506.8/506.8 kB\u001b[0m \u001b[31m46.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m423.1/423.1 kB\u001b[0m \u001b[31m40.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m59.1/59.1 MB\u001b[0m \u001b[31m16.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m561.1/561.1 kB\u001b[0m \u001b[31m48.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m47.7/47.7 MB\u001b[0m \u001b[31m15.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m6.9/6.9 MB\u001b[0m \u001b[31m77.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m295.7/295.7 kB\u001b[0m \u001b[31m27.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m122.9/122.9 MB\u001b[0m \u001b[31m7.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m899.7/899.7 MB\u001b[0m \u001b[31m1.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m594.3/594.3 MB\u001b[0m \u001b[31m1.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m10.2/10.2 MB\u001b[0m \u001b[31m123.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m88.0/88.0 MB\u001b[0m \u001b[31m9.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m954.8/954.8 kB\u001b[0m \u001b[31m69.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m193.1/193.1 MB\u001b[0m \u001b[31m6.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.2/1.2 MB\u001b[0m \u001b[31m44.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m63.6/63.6 MB\u001b[0m \u001b[31m12.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m267.5/267.5 MB\u001b[0m \u001b[31m4.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m288.2/288.2 MB\u001b[0m \u001b[31m4.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m39.3/39.3 MB\u001b[0m \u001b[31m18.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m90.0/90.0 kB\u001b[0m \u001b[31m9.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m170.5/170.5 MB\u001b[0m \u001b[31m5.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m8.0/8.0 MB\u001b[0m \u001b[31m82.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m180.7/180.7 kB\u001b[0m \u001b[31m12.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7.2/7.2 MB\u001b[0m \u001b[31m101.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m224.9/224.9 kB\u001b[0m \u001b[31m15.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25h\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n", + "torchaudio 2.9.0+cu126 requires torch==2.9.0, but you have torch 2.9.1 which is incompatible.\n", + "ibis-framework 9.5.0 requires sqlglot<25.21,>=23.4, but you have sqlglot 28.5.0 which is incompatible.\u001b[0m\u001b[31m\n", + "\u001b[0m" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "!python scripts/evaluate_internal.py --adapter_dir outputs/adapters --device cuda --max_examples 200 --load_in_4bit" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "QRLxbr48sdDq", + "outputId": "c03d8705-f2ee-425f-e476-85615055f4bb" + }, + "execution_count": 11, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "[2026-01-11 04:30:22,771] [INFO] __main__ - Loaded 80 validation records from data/processed/val.jsonl (max_examples=200, smoke=False).\n", + "[2026-01-11 04:30:26,544] [INFO] __main__ - 4-bit loading configuration: load_in_4bit=True, bnb_4bit_quant_type=nf4, bnb_4bit_compute_dtype=bfloat16, bnb_4bit_use_double_quant=True\n", + "[2026-01-11 04:30:36,298] [INFO] numexpr.utils - NumExpr defaulting to 2 threads.\n", + "WARNING: All log messages before absl::InitializeLog() is called are written to STDERR\n", + "E0000 00:00:1768105839.654388 3634 cuda_dnn.cc:8579] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n", + "E0000 00:00:1768105839.723092 3634 cuda_blas.cc:1407] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n", + "W0000 00:00:1768105840.225907 3634 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n", + "W0000 00:00:1768105840.225950 3634 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n", + "W0000 00:00:1768105840.225955 3634 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n", + "W0000 00:00:1768105840.225960 3634 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n", + "[2026-01-11 04:30:48,321] [INFO] __main__ - Loading model for inference with base_model=mistralai/Mistral-7B-Instruct-v0.1, adapter_dir=outputs/adapters, device=cuda, load_in_4bit=True, dtype=auto, bnb_4bit_quant_type=nf4, bnb_4bit_compute_dtype=bfloat16, bnb_4bit_use_double_quant=True\n", + "[2026-01-11 04:30:48,321] [INFO] text2sql.infer - Loading model for inference: base_model=mistralai/Mistral-7B-Instruct-v0.1, adapter_dir=outputs/adapters, device=cuda, load_in_4bit=True, dtype=auto, bnb_compute_dtype=bfloat16, bnb_4bit_quant_type=nf4, bnb_4bit_use_double_quant=True\n", + "[2026-01-11 04:30:51,164] [INFO] text2sql.infer - Using 4-bit quantization for base model with torch_dtype=torch.float16, compute_dtype=torch.bfloat16, quant_type=nf4, double_quant=True.\n", + "config.json: 100% 571/571 [00:00<00:00, 4.70MB/s]\n", + "`torch_dtype` is deprecated! Use `dtype` instead!\n", + "model.safetensors.index.json: 25.1kB [00:00, 95.7MB/s]\n", + "Fetching 2 files: 0% 0/2 [00:00 2:\n", + " response_sql = parts[1].strip()\n", + " # Clean up the escaped quotes just in case the model used them (e.g., \\\\\")\n", + " response_sql = response_sql.replace('\\\\\"', '\"')\n", + " else:\n", + " response_sql = \"Could not parse response section using regex.\"\n", + "\n", + "except Exception as e:\n", + " response_sql = f\"An error occurred: {e}\"\n", + "print(\"--- Analytics Copilot Output ---\")\n", + "\n", + "# Present the full text in a readable form\n", + "print(\"\\n### Full Parsed Text:\")\n", + "print(generated_text.replace('\\\\n', '\\n'))\n", + "\n", + "# Present ONLY the response\n", + "print(\"\\n### Extracted SQL Response:\")\n", + "print(response_sql.replace('\\\\\"', '\"'))\n", + "\n", + "print(\"--------------------------------\")" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "S4iKK7cL3nhG", + "outputId": "fe1eb8f9-a0e1-42e0-9cd7-995f4e60491f" + }, + "execution_count": 26, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "--- Analytics Copilot Output ---\n", + "\n", + "### Full Parsed Text:\n", + "### Instruction:\n", + "Write a SQL query that answers the user's question using ONLY the tables and columns provided in the schema.\n", + "\n", + "### Input:\n", + "### Schema:\n", + "CREATE TABLE Customers (customer_id VARCHAR); CREATE TABLE Accounts (customer_id VARCHAR)\n", + "\n", + "### Question:\n", + "Show the number of all customers without an account.\n", + "\n", + "### Response:\n", + "SELECT COUNT(*) AS \"Number of Customers without an Account\" FROM Customers WHERE customer_id NOT IN (SELECT customer_id FROM Accounts);\n", + "\n", + "### Explanation:\n", + "\n", + "### Complexity:\n", + "\n", + "### Tags:\n", + "\n", + "### Extracted SQL Response:\n", + "SELECT COUNT(*) AS \"Number of Customers without an Account\" FROM Customers WHERE customer_id NOT IN (SELECT customer_id FROM Accounts);\n", + "--------------------------------\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [], + "metadata": { + "id": "GQeXEn9Sldll" + }, + "execution_count": null, + "outputs": [] + } + ] +} \ No newline at end of file From ea366434829424f097a224ee91ad31aef9cadab6 Mon Sep 17 00:00:00 2001 From: Brejesh Balakrishnan Date: Sun, 11 Jan 2026 08:53:07 +0000 Subject: [PATCH 4/7] docs: add centered intro header and badges to README Co-authored-by: Cosine --- README.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/README.md b/README.md index f314a14..58b95d6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,40 @@ +
+

Analytics Copilot (Text-to-SQL) – Mistral-7B QLoRA

+

End-to-end scaffolding for a Text-to-SQL copilot — Mistral-7B QLoRA fine-tuning → dataset + training pipeline → evaluation → remote inference via Hugging Face Inference → Streamlit UI ready for Streamlit Community Cloud

+
+ +
+ +
+ CI + Language + Model + Serving + UI +
+ + + +
+ +
+
+ Built with: +

+ Python | + PyTorch | + Transformers | + PEFT / QLoRA | + Hugging Face Datasets | + Hugging Face Hub | + Streamlit | + pytest +
+ +--- + # Analytics Copilot (Text-to-SQL) – Mistral-7B QLoRA ## Overview From ebec4db60be17f4e0a15d8bdbd2e1335560832b2 Mon Sep 17 00:00:00 2001 From: Brejesh Balakrishnan Date: Sun, 11 Jan 2026 08:54:49 +0000 Subject: [PATCH 5/7] chore: add ruff.toml with extend-exclude for notebooks Co-authored-by: Cosine --- ruff.toml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 ruff.toml diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000..d30e976 --- /dev/null +++ b/ruff.toml @@ -0,0 +1,7 @@ +# Ruff configuration +# See: https://docs.astral.sh/ruff/configuration/ + +# Keep all default excludes, but also ignore the Jupyter notebooks folder. +extend-exclude = [ + "notebooks", +] \ No newline at end of file From d22d8713683e57647079a4dbaf90b14680105a6a Mon Sep 17 00:00:00 2001 From: brej-29 Date: Sun, 11 Jan 2026 15:05:06 +0530 Subject: [PATCH 6/7] minor readme fix --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 58b95d6..54573f0 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,13 @@
- CI + CI Language Model Serving UI
- + From a0b2e72c190f5d8c537c4310065e540a2f403ded Mon Sep 17 00:00:00 2001 From: brej-29 Date: Sun, 11 Jan 2026 15:12:57 +0530 Subject: [PATCH 7/7] minor readme fix --- README.md | 134 +++++++++++++++++++++++++++++------------------------- 1 file changed, 73 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index 54573f0..fec9f7a 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,72 @@ --- +## Repo Structure + +Current high-level layout: + +```text +. +├── app/ # Streamlit UI (remote inference via HF InferenceClient) +│ └── streamlit_app.py +├── docs/ # Documentation, design notes, evaluation reports +│ ├── dataset.md +│ ├── training.md +│ ├── evaluation.md +│ └── external_validation.md +├── notebooks/ # Jupyter/Colab notebooks for experimentation +├── scripts/ # CLI scripts (dataset, training, evaluation, utilities) +│ ├── build_dataset.py +│ ├── check_syntax.py +│ ├── smoke_load_dataset.py +│ ├── smoke_infer_endpoint.py +│ ├── train_qlora.py +│ ├── evaluate_internal.py +│ ├── evaluate_spider_external.py +│ └── publish_to_hub.py +├── src/ +│ └── text2sql/ # Core Python package +│ ├── __init__.py +│ ├── data_prep.py +│ ├── infer.py +│ ├── training/ +│ │ ├── __init__.py +│ │ ├── config.py +│ │ └── formatting.py +│ └── eval/ +│ ├── __init__.py +│ ├── normalize.py +│ ├── schema.py +│ ├── metrics.py +│ └── spider.py +├── tests/ +│ ├── fixtures/ +│ │ ├── sql_create_context_sample.jsonl +│ │ ├── eval_internal_sample.jsonl +│ │ ├── spider_sample.jsonl +│ │ └── spider_schema_sample.jsonl +│ ├── test_repo_smoke.py +│ ├── test_build_dataset_offline.py +│ ├── test_data_prep.py +│ ├── test_eval_cli_args.py +│ ├── test_infer_quantization.py +│ ├── test_prompt_formatting.py +│ ├── test_normalize_sql.py +│ ├── test_schema_adherence.py +│ └── test_metrics_aggregate.py +├── .env.example # Example environment file +├── .gitignore +├── context.md # Persistent project context & decisions +├── LICENSE +├── README.md +└── requirements.txt +``` + +As the project progresses, this structure will be refined and additional modules, +scripts, and documentation will be added. + +--- + # Analytics Copilot (Text-to-SQL) – Mistral-7B QLoRA ## Overview @@ -451,66 +517,12 @@ When deploying to Streamlit Cloud: --- -## Repo Structure - -Current high-level layout: +## **License** +This project is licensed under the MIT License. See the LICENSE file for details. -```text -. -├── app/ # Streamlit UI (remote inference via HF InferenceClient) -│ └── streamlit_app.py -├── docs/ # Documentation, design notes, evaluation reports -│ ├── dataset.md -│ ├── training.md -│ ├── evaluation.md -│ └── external_validation.md -├── notebooks/ # Jupyter/Colab notebooks for experimentation -├── scripts/ # CLI scripts (dataset, training, evaluation, utilities) -│ ├── build_dataset.py -│ ├── check_syntax.py -│ ├── smoke_load_dataset.py -│ ├── smoke_infer_endpoint.py -│ ├── train_qlora.py -│ ├── evaluate_internal.py -│ ├── evaluate_spider_external.py -│ └── publish_to_hub.py -├── src/ -│ └── text2sql/ # Core Python package -│ ├── __init__.py -│ ├── data_prep.py -│ ├── infer.py -│ ├── training/ -│ │ ├── __init__.py -│ │ ├── config.py -│ │ └── formatting.py -│ └── eval/ -│ ├── __init__.py -│ ├── normalize.py -│ ├── schema.py -│ ├── metrics.py -│ └── spider.py -├── tests/ -│ ├── fixtures/ -│ │ ├── sql_create_context_sample.jsonl -│ │ ├── eval_internal_sample.jsonl -│ │ ├── spider_sample.jsonl -│ │ └── spider_schema_sample.jsonl -│ ├── test_repo_smoke.py -│ ├── test_build_dataset_offline.py -│ ├── test_data_prep.py -│ ├── test_eval_cli_args.py -│ ├── test_infer_quantization.py -│ ├── test_prompt_formatting.py -│ ├── test_normalize_sql.py -│ ├── test_schema_adherence.py -│ └── test_metrics_aggregate.py -├── .env.example # Example environment file -├── .gitignore -├── context.md # Persistent project context & decisions -├── LICENSE -├── README.md -└── requirements.txt -``` +--- -As the project progresses, this structure will be refined and additional modules, -scripts, and documentation will be added. \ No newline at end of file +## **Contact** +- Live App: +- For issues/feature requests: open a GitHub Issue in this repository. +- For questions or feedback, connect with me on [LinkedIn](https://www.linkedin.com/in/brejesh-balakrishnan-7855051b9/) \ No newline at end of file