Skip to content

Commit 000561b

Browse files
committed
docs: update Project A to Python stack
- Change language from TypeScript to Python - Add technology stack: Typer, Rich, questionary, Pydantic, uv - Update repo structure with Python package layout (src/qebench/) - Update prerequisites, getting started, resources sections - Add config.yaml for future language-agnostic extraction - Add extraction to tools-benchmark as summer milestone
1 parent 15bec41 commit 000561b

1 file changed

Lines changed: 74 additions & 40 deletions

File tree

docs/projects/PROJECT-A-BENCHMARK.md

Lines changed: 74 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Project A: Benchmark Dataset, CLI Tool & Results Website
22

33
> **Type**: Coding + data curation, gamified
4-
> **Ideal RA profile**: Comfortable with Python or TypeScript, interested in building tools, APIs, and data visualization
4+
> **Ideal RA profile**: Comfortable with Python, interested in building tools, APIs, and data visualization
55
> **Time**: 4-7 hrs/week for 12 weeks; potential summer extension
66
> **Repository**: `QuantEcon/benchmark.translate-zh-cn` (new, separate repo)
7-
> **Language**: TypeScript (recommended -- aligns with `action-translation`). Python is also fine if that's your strength.
7+
> **Language**: Python
8+
> **Stack**: Typer (CLI framework) · Rich (terminal UI) · questionary (interactive prompts) · Pydantic (data validation) · uv (package management)
89
910
## Goal
1011

@@ -234,7 +235,7 @@ Sends test data to LLM APIs and collects their translations. "Model" here just m
234235
qebench run --model claude-sonnet --level terms
235236

236237
# Compare two models on sentences
237-
qebench run --model claude-sonnet,gpt-4o --level sentences
238+
qebench run --model claude-sonnet --model gpt-4o --level sentences
238239

239240
# Run with a specific prompt variation
240241
qebench run --model claude-sonnet --prompt prompts/v2-glossary-emphasis.txt
@@ -339,28 +340,40 @@ benchmark.translate-zh-cn/
339340
│ │ └── theorems.json
340341
│ ├── paragraphs/
341342
│ │ └── quantecon-extracts.json
342-
│ └── schema/
343-
│ └── schema.json # JSON Schema for validation
344-
├── src/ # CLI tool source
345-
│ ├── cli.ts # CLI entry point & command routing
346-
│ ├── translate.ts # "translate" mode
347-
│ ├── judge.ts # "judge" mode
348-
│ ├── add.ts # "add" mode
349-
│ ├── run.ts # benchmark runner
350-
│ ├── stats.ts # stats display
351-
│ ├── export.ts # export for website
352-
│ ├── providers/ # LLM API wrappers
353-
│ │ ├── base.ts
354-
│ │ ├── claude.ts
355-
│ │ ├── openai.ts
356-
│ │ └── local.ts # Ollama/local LLM support
357-
│ ├── scoring/
358-
│ │ ├── glossary.ts # Glossary compliance check
359-
│ │ ├── elo.ts # Elo rating calculations
360-
│ │ └── xp.ts # XP calculations
361-
│ └── utils/
362-
│ ├── display.ts # Terminal UI formatting
363-
│ └── dataset.ts # Data loading/saving
343+
│ └── schema/ # Pydantic models (auto-generate JSON Schema)
344+
│ └── models.py
345+
├── src/
346+
│ └── qebench/ # Python package
347+
│ ├── __init__.py
348+
│ ├── cli.py # Typer app — command routing
349+
│ ├── commands/
350+
│ │ ├── __init__.py
351+
│ │ ├── translate.py # "translate" mode
352+
│ │ ├── judge.py # "judge" mode
353+
│ │ ├── add.py # "add" mode
354+
│ │ ├── run.py # benchmark runner
355+
│ │ ├── stats.py # stats display (Rich tables/panels)
356+
│ │ └── export.py # export for website
357+
│ ├── providers/ # LLM API wrappers
358+
│ │ ├── __init__.py
359+
│ │ ├── base.py # Abstract provider interface
360+
│ │ ├── claude.py # Anthropic SDK
361+
│ │ ├── openai.py # OpenAI SDK
362+
│ │ └── local.py # Ollama/local LLM support
363+
│ ├── scoring/
364+
│ │ ├── __init__.py
365+
│ │ ├── glossary.py # Glossary compliance check
366+
│ │ ├── elo.py # Elo rating calculations
367+
│ │ └── xp.py # XP calculations
368+
│ └── utils/
369+
│ ├── __init__.py
370+
│ ├── display.py # Rich console helpers
371+
│ └── dataset.py # Data loading/saving (Pydantic)
372+
├── tests/ # pytest test suite
373+
│ ├── conftest.py
374+
│ ├── test_dataset.py
375+
│ ├── test_scoring.py
376+
│ └── test_providers.py
364377
├── results/
365378
│ ├── translations/ # Human translations from "translate" mode
366379
│ │ └── {username}-{date}.json
@@ -390,23 +403,27 @@ benchmark.translate-zh-cn/
390403
│ └── (symlink or copy of results/)
391404
├── .github/
392405
│ └── workflows/
393-
│ ├── validate.yml # PR validation (schema check)
406+
│ ├── validate.yml # PR validation (schema check, pytest)
394407
│ └── deploy-site.yml # Build + deploy site on push
408+
├── config.yaml # Language-specific settings (glossary, domains)
395409
├── CONTRIBUTING.md
396-
├── package.json
410+
├── pyproject.toml # Project metadata, dependencies, [tool.uv]
397411
└── README.md
398412
```
399413

414+
> **Design note**: The tool code lives in `src/qebench/` and the zh-cn dataset lives in `data/`. This separation means the CLI tool can be extracted into a standalone `tools-benchmark` package later if the project is successful — `data/` stays here, `src/qebench/` moves to the new repo, and this repo installs it as a dependency. A `config.yaml` at the root holds language-specific settings (glossary path, language pair, domain list) so the tool itself stays language-agnostic in design.
415+
400416
## Week-by-Week Plan
401417

402418
### Weeks 1-2: Repo Setup, Schema & Seed Data
403419

404420
- [ ] Create the `benchmark.translate-zh-cn` repository
405-
- [ ] Design JSON schemas for terms, sentences, paragraphs
421+
- [ ] Set up Python project: `pyproject.toml`, uv, pytest, linting
422+
- [ ] Define Pydantic models for terms, sentences, paragraphs (auto-generates JSON Schema)
406423
- [ ] Write a schema validation script
407424
- [ ] Set up CI to validate data on every PR
408425
- [ ] Seed 50 terms from the existing `glossary/zh-cn.json` (357 terms)
409-
- [ ] Scaffold the CLI tool with `qebench stats` (read-only, shows dataset state)
426+
- [ ] Scaffold the CLI tool with Typer: `qebench stats` (read-only, shows dataset state with Rich tables)
410427

411428
### Weeks 3-5: CLI Core & First Dataset
412429

@@ -448,10 +465,11 @@ benchmark.translate-zh-cn/
448465

449466
- Scale dataset to 1,000+ terms, 500+ sentences, 100+ paragraphs
450467
- Systematic whole-doc vs. section-by-section translation testing across full lecture files
451-
- Add automated metrics (BLEU, COMET/XCOMET via Python)
468+
- Add automated metrics (BLEU via `sacrebleu`, COMET/XCOMET via `unbabel-comet`)
452469
- Full 4+ model comparison (including local LLMs via Ollama)
453470
- Prompt optimization experiments: glossary injection, domain context, instruction style
454471
- Interactive dashboard with historical trend tracking
472+
- Extract `qebench` into a standalone `tools-benchmark` package for reuse across language pairs
455473
- Possible academic paper draft on benchmark results
456474

457475
## Coding Side-Projects
@@ -463,7 +481,7 @@ These are optional explorations for technically-inclined RAs. They use the bench
463481
| **Model comparison** | Add new providers to `qebench run` (Gemini, DeepSeek, Mistral) | API integration |
464482
| **Context experiments** | Compare sentence vs. section vs. whole-document translation quality | Experiment design |
465483
| **Local LLM testing** | Add Ollama/llama.cpp support, benchmark open-weight models | DevOps, ML |
466-
| **Automated metrics** | Implement BLEU/COMET scoring alongside human judgments | Python ML |
484+
| **Automated metrics** | Implement BLEU/COMET scoring alongside human judgments | Python, `sacrebleu`, `unbabel-comet` |
467485
| **Prompt A/B testing** | Design experiments varying glossary injection, domain context, instruction style | Prompt engineering |
468486
| **Git reproducibility** | Test how different translation strategies affect diff quality for version control | Git, analysis |
469487

@@ -491,35 +509,51 @@ These side-projects produce results that feed into the main website and dataset.
491509

492510
## Skills You'll Practice
493511

494-
- **CLI development**: Building an interactive command-line tool
512+
- **Python CLI development**: Building an interactive command-line tool with Typer, Rich, and questionary
495513
- **API integration**: Working with LLM APIs (Anthropic, OpenAI, Google)
514+
- **Data modelling**: Pydantic schemas, JSON data validation, dataset management
496515
- **Web development**: Static site generation, data visualization with Chart.js
497-
- **Data engineering**: Designing schemas, validating data, managing JSON datasets
498516
- **CI/CD**: GitHub Actions for validation and deployment
499517
- **Scientific methodology**: Controlled comparisons, Elo rating systems, reproducible experiments
500518

501519
## Prerequisites
502520

503-
- **Node.js** (v20+) and npm -- for building the CLI and website
521+
- **Python** (3.11+) and [**uv**](https://docs.astral.sh/uv/) -- for package management and running the CLI
504522
- **Git** and a **GitHub** account with access to the QuantEcon org
505523
- **API keys** -- we'll provide Anthropic and OpenAI keys for the project
506-
- **VS Code** (recommended) -- for editing JSON data and TypeScript
524+
- **VS Code** (recommended) -- for editing JSON data and Python
507525

508526
## Getting Started
509527

510528
1. Read the `action-translation` [README](../../README.md) to understand what the tool does
511529
2. Look at the existing glossary: `glossary/zh-cn.json` (357 terms) -- this is your seed data
512530
3. Browse a QuantEcon lecture series and pick one that interests you
513-
4. Set up the new repo and start with the schema design
514-
5. Build `qebench stats` first (simplest command, proves the data layer works)
515-
6. Then build `qebench translate` (the main fun loop)
531+
4. Set up the new repo: `uv init`, add dependencies (`typer`, `rich`, `questionary`, `pydantic`)
532+
5. Define Pydantic models for terms/sentences/paragraphs and write the seed script
533+
6. Build `qebench stats` first (simplest command, proves the data layer works)
534+
7. Then build `qebench translate` (the main fun loop)
535+
536+
## Technology Stack
537+
538+
| Role | Library | Why |
539+
|---|---|---|
540+
| CLI framework | [Typer](https://typer.tiangolo.com/) | Type-hint driven, auto help/completion, built on Click |
541+
| Terminal UI | [Rich](https://rich.readthedocs.io/) | Panels, tables, progress bars, styled text — all the mockup layouts |
542+
| Interactive prompts | [questionary](https://questionary.readthedocs.io/) | Select, input, confirm — mature, used by 20k+ projects |
543+
| Data validation | [Pydantic](https://docs.pydantic.dev/) | Type-safe models, auto JSON Schema generation |
544+
| LLM providers | `anthropic`, `openai` | First-class Python SDKs |
545+
| Testing | [pytest](https://pytest.org/) | Standard Python test framework |
546+
| Package management | [uv](https://docs.astral.sh/uv/) | Fast, modern Python packaging |
516547

517548
## Resources
518549

550+
- [Typer docs](https://typer.tiangolo.com/) -- CLI framework (tutorial is excellent)
551+
- [Rich docs](https://rich.readthedocs.io/) -- terminal formatting library
552+
- [questionary docs](https://questionary.readthedocs.io/) -- interactive prompts
553+
- [Pydantic docs](https://docs.pydantic.dev/) -- data validation and JSON Schema
519554
- [Anthropic API docs](https://docs.anthropic.com/)
520555
- [OpenAI API docs](https://platform.openai.com/docs/)
521556
- [Chart.js](https://www.chartjs.org/) -- charts for the website
522-
- [JSON Schema](https://json-schema.org/) -- data validation
523557
- [Elo rating system](https://en.wikipedia.org/wiki/Elo_rating_system) -- for model rankings
524558
- [COMET metric](https://github.com/Unbabel/COMET) -- for summer phase
525-
- [Ink (React for CLI)](https://github.com/vadimdemedes/ink) -- optional: rich terminal UI
559+
- [uv docs](https://docs.astral.sh/uv/) -- Python package management

0 commit comments

Comments
 (0)