Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CI

on:
push:
pull_request:

permissions:
contents: read

jobs:
test:
name: Node ${{ matrix.node-version }} / Python 3.12
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [22.x, 24.x]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Require packaged workbench assets
run: |
test -f dist/index.html
test -f dist/assets/engine.js
test -f dist/data/procurement-demo.json
test -f dist/data/demo.json
- name: Install Python packages
run: python -m pip install -r requirements-dev.txt
- name: Browser modules
run: npm test
- name: Python engine and API
run: python -m unittest discover -s tests -p 'test_*.py' -v
- name: Demo evaluation entry points
run: |
python -m datalens evaluate
python -m datalens evaluate dist/data/demo.json
35 changes: 35 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: GitHub Pages

on:
push:
branches: [main]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: pages
cancel-in-progress: true

jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Require packaged workbench
run: |
test -f dist/index.html
test -f dist/assets/engine.js
test -f dist/data/procurement-demo.json
- uses: actions/configure-pages@v5
- uses: actions/upload-pages-artifact@v3
with:
path: dist
- id: deployment
uses: actions/deploy-pages@v4
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.venv/
__pycache__/
*.pyc
.pytest_cache/
node_modules/
dist/downloads/
.datalens-ai/
*.sqlite3
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 plii05

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
104 changes: 104 additions & 0 deletions README.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# DataLens AI

[简体中文](README.md)

DataLens AI is a workbench for training-data selection and delivery acceptance. In the default procurement case, the cheapest supplier has 70% of usable records already present in inventory. The workspace puts historical overlap, evaluation leakage, post-remediation net-new yield, and quotes side by side so a team can decide which batches to buy.

[Open the hosted procurement demo](https://plii05.github.io/DataLens-AI/) · [Case data and acceptance criteria](docs/demo.md)

> After the first merge to `main`, enable **Settings → Pages → Build and deployment → Source: GitHub Actions**. Until that Pages site is live, the previous hosted demo remains at [chatgpt.site](https://datalens-ai-workbench-k8m4.bushyolive1024.chatgpt.site).

## Walk the procurement decision

| Candidate | Input | Decision you can verify |
|---|---|---|
| Batch-A · Value Desk | $20 for 20 rows; 14 already in history; 3 hit eval prompts | After removing eval overlap and rechecking, only 3 of 17 accepted rows are net-new. |
| Batch-B · Route Desk | $44 for 8 logistics rows; 1 contains a sample phone | Open deep QA from the overview, preview masking, save a new version. After it passes, it can fill 8 of 10 logistics gaps. |
| Batch-C · Account Escalations | $90 for 6 account-escalation samples | The first version already passes. It can cover the remaining 6 account gaps and be compared on marginal cost with remediated A and B. |

New workspaces load this case by default. Existing workspaces can append one run from **Decision overview → Open procurement case**. Switch budget or purchase goals under **Mix fill** to recompute. When every remediation passes and quotes are unchanged, the lowest total that covers all goals is **$154**.

The three home-page tours open B’s tiered quote, evidence for record #1, and a budget sandbox after sample remediation. Tours use temporary demo data; return to the workspace for your own work.

## From delivery quotes to a training set

| Page | What you can do |
|---|---|
| Procurement compare | Keep a package quote and a progressive quote billed on net-new rows. Demo B is $44 packaged; the same 8 net-new rows settle at $6 for the first 5 and $5 for the last 3 ($45). |
| Issues & recheck | Download a supplier remediation ZIP with a notice, row-numbered issue list, and masked examples. The procurement page summarizes first-delivery duplicate rate, eval overlap, and first-pass rate. |
| Requirements / deep QA | Set per-scene floors for basic QA, multi-condition reasoning, and correction samples. Supplier difficulty labels are kept; unlabeled rows get a rule estimate for acceptance layering only. |
| Mix fill | Drag budget, include remediated batches, compare coverage and incremental cost, sample by scene weight, and export ChatML, ShareGPT, or Alpaca train/val sets with manifests and `lineage.jsonl`. |
| Model review | Inspect documented demo scores, or score through an OpenAI-compatible endpoint / Ollama. Keys stay in page memory. |
| Evidence Q&A | Ask for `Batch-A #3` or eval overlap for a batch; open cited rows in the side panel. |

## Where data and compute live

| Mode | Storage / compute | Workflow |
|---|---|---|
| **Cloud Demo Mode** | Files, clean versions, and tasks stay in this browser. Precomputed support vectors ship with the site; DuckDB-Wasm loads in a worker. | Import, zero-shot scene match, filters, cleanup diffs, quotes, mix solve, synthetic-share warnings, browser scoring, calibration import, training export. |
| **Local Full Mode** | Same UI against FastAPI + SQLite. Optional sentence embeddings, local LLMs, and streaming JSONL CLI. | Everything above, plus re-encode corpora, topics, stratified sampling, blind gold review, and draft generation for gaps. |

The UI supports Chinese, English, and light/dark themes. Model and sample sources are labeled on each page.

## Methods and auditable metrics

| Module | Business question | Implementation |
|---|---|---|
| Scene labeling | How to measure coverage without reliable labels? | Prototype matching from task descriptions; cloud demo uses precomputed LSA + terms; local mode can use SentenceTransformer. [classification](docs/classification.md) |
| Deep QA | Duplicate purchase? Eval leakage? | Normalized exact keys, MinHash/LSH near-dup, 13-gram eval overlap; streaming CLI uses SHA-256 + on-disk SQLite. [cloud](docs/cloud.md) |
| Cleanup & recheck | What changed, and can we replay it? | Immutable snapshots with parent IDs, rule version, source line, and the same acceptance gates. |
| Model review | Rare scenes covered? Do humans agree? | Stratified samples, four-dimension rubric, Cohen’s κ with bootstrap intervals. [models](docs/models.md) |
| Synthetic tracking | Is one scene over-dependent on synthetic data? | Known synthetic share and unknown-origin upper bound; default threshold 20%. [provenance](docs/provenance.md) |
| Procurement / expansion | How much new coverage for a fixed budget? | Exact subset search up to 8 lots; greedy marginal gain beyond that. [solver](docs/solver.md) |

### 10k-row deep-scan benchmark

With rule `quality-scan/1.1` and Node.js 24.22.3, three independent processes on the same 10,000-row (1,547,165 byte) synthetic JSONL plus 5 eval prompts took **1,372 / 752 / 1,018 ms (median 1,018)**. Reproduce with `python scripts/bench_jsonl.py sample.jsonl --rows 10000` then `node scripts/bench_deep.mjs sample.jsonl`.

### Large files

The streaming CLI parsed 100,000 synthetic JSONL rows in 3.03 s at 38.84 MiB peak RSS in an earlier Linux run (startup + rule gates, no model inference). See [stream](docs/stream.md).

```bash
docker build -t datalens-ai . && docker run --rm -p 127.0.0.1:8000:8000 datalens-ai
```

## Local start

Python 3.10+. From the project root:

```bash
python -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
python -m datalens serve
```

Open http://127.0.0.1:8000. SQLite defaults to `~/.datalens-ai/workspace.sqlite3` (`DATALENS_DB` overrides). Offline evaluation needs no third-party packages beyond the stdlib path used by the engine itself when dependencies are present for the API:

```bash
python -m datalens evaluate --out report.json
python -m datalens evaluate dist/data/demo.json --out report.json
python -m datalens experiment
```

Pure frontend mode: `python -m http.server 8000 --directory dist`. Hosted browser state is IndexedDB-only and does not sync with the local SQLite workspace.

## Import contract

UTF-8 CSV, JSON arrays, JSON with `rows`/`data`, or JSONL. Limits: 12 MiB per file, 50,000 logical rows. Custom field maps supported. Multiturn `messages` keep prior turns as context and use the last user/assistant pair as instruction/response.

## Repository layout

| Path | Contents |
|---|---|
| `dist/` | Static workbench, demo data, browser decision modules |
| `datalens/` | Python engine, FastAPI, streaming CLI |
| `tests/` | Browser/Python parity tests |
| `docs/` | Classification, QA, solver, provenance, model-review notes |

`dist/` is part of the product, not build cache. Generated self-packaging zips go to `dist/downloads/` (gitignored).

## License and topics

Released under the [MIT License](LICENSE). Suggested GitHub topics: `llm`, `training-data`, `data-quality`, `procurement`, `evaluation`, `fastapi`.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# DataLens AI

[English](README.en.md)

DataLens AI 用于训练数据选型与交付验收。默认采购案例中,最便宜的供应商有 70% 的可用记录与已有库存重复。工作台把历史重合、评测泄漏、整改后的真实增量和报价放在一起,供团队决定应该购买哪些批次。

[打开在线采购案例](https://datalens-ai-workbench-k8m4.bushyolive1024.chatgpt.site) · [案例数据与验证口径](docs/demo.md)
[打开 GitHub Pages 采购案例](https://plii05.github.io/DataLens-AI/) · [案例数据与验证口径](docs/demo.md)

> 合并到 `main` 后,在仓库 **Settings → Pages → Build and deployment** 将 Source 设为 **GitHub Actions**,站点才会首次发布。启用前仍可使用[原托管演示](https://datalens-ai-workbench-k8m4.bushyolive1024.chatgpt.site)。建议在仓库 About 中把 Homepage 设为 Pages 地址,并添加 topics:`llm`、`training-data`、`data-quality`、`procurement`、`evaluation`、`fastapi`。

## 先跑一遍采购决策

Expand Down Expand Up @@ -123,3 +127,18 @@ node --test tests/*.test.mjs
```

测试需要 Node.js 22 或更高版本,包含浏览器与 Python 两套实现的全部样例指标和逐行问题对照。FastAPI 接口说明在本机服务的 `/docs`。标准化输入格式见 `dist/data/demo.json`,API 接收相同结构。项目提供浏览器模块、Python 决策引擎、FastAPI、SQLite,以及合成数据和生成脚本。

## 仓库内容

| 路径 | 内容 |
|---|---|
| `dist/` | 静态工作台、演示数据与浏览器决策模块;克隆后即可 `python -m datalens serve` 或 `python -m http.server 8000 --directory dist` |
| `datalens/` | Python 决策引擎、FastAPI、流式 CLI |
| `tests/` | 浏览器模块与 Python 引擎对照测试 |
| `docs/` | 归类、质检、求解、来源与模型评审说明 |

`dist/` 是可运行工作台的一部分,不是构建缓存。缺少该目录时,页面、Docker 镜像和大部分 Node 测试都无法运行。生成的自打包文件写在 `dist/downloads/`,已加入 `.gitignore`。

## 许可

本项目以 [MIT License](LICENSE) 发布。
Loading
Loading