feat: add ML inference, scoring, and training pipeline (pkg/ml)
Port LEM scoring/training pipeline into CoreGo as pkg/ml with:
- Inference abstraction with HTTP, llama-server, and Ollama backends
- 3-tier scoring engine (heuristic, exact, LLM judge)
- Capability and content probes for model evaluation
- GGUF/safetensors format converters, MLX to PEFT adapter conversion
- DuckDB integration for training data pipeline
- InfluxDB metrics for lab dashboard
- Training data export (JSONL + Parquet)
- Expansion generation pipeline with distributed workers
- 10 CLI commands under 'core ml' (score, probe, export, expand, status, gguf, convert, agent, worker)
- 5 MCP tools (ml_generate, ml_score, ml_probe, ml_status, ml_backends)
All 37 ML tests passing. Binary builds at 138MB with all commands.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 00:34:53 +00:00
|
|
|
// Package ml provides ML inference, scoring, and training pipeline commands.
|
|
|
|
|
//
|
|
|
|
|
// Commands:
|
|
|
|
|
// - core ml score: Score responses with heuristic and LLM judges
|
|
|
|
|
// - core ml probe: Run capability and content probes against a model
|
|
|
|
|
// - core ml export: Export golden set to training JSONL/Parquet
|
|
|
|
|
// - core ml expand: Generate expansion responses
|
|
|
|
|
// - core ml status: Show training and generation progress
|
|
|
|
|
// - core ml gguf: Convert MLX LoRA adapter to GGUF format
|
|
|
|
|
// - core ml convert: Convert MLX LoRA adapter to PEFT format
|
|
|
|
|
// - core ml agent: Run the scoring agent daemon
|
|
|
|
|
// - core ml worker: Run a distributed worker node
|
2026-02-16 01:19:04 +00:00
|
|
|
// - core ml serve: Start OpenAI-compatible inference server
|
feat: port 11 LEM data management commands into core ml
Ports all remaining LEM pipeline commands from pkg/lem into core ml,
eliminating the standalone LEM CLI dependency. Each command is split
into reusable business logic (pkg/ml/) and a thin cobra wrapper
(internal/cmd/ml/).
New commands: query, inventory, metrics, ingest, normalize, seed-influx,
consolidate, import-all, approve, publish, coverage.
Adds Path(), Exec(), QueryRowScan() convenience methods to DB type.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 04:02:28 +00:00
|
|
|
// - core ml inventory: Show DuckDB table inventory with stats
|
|
|
|
|
// - core ml query: Run ad-hoc SQL against DuckDB
|
|
|
|
|
// - core ml metrics: Push golden set stats to InfluxDB
|
|
|
|
|
// - core ml ingest: Ingest benchmark scores and training logs to InfluxDB
|
|
|
|
|
// - core ml normalize: Deduplicate seeds into expansion prompts
|
|
|
|
|
// - core ml seed-influx: Migrate golden set from DuckDB to InfluxDB
|
|
|
|
|
// - core ml consolidate: Pull and merge response JSONL files from M3
|
|
|
|
|
// - core ml import-all: Import all LEM data into DuckDB
|
|
|
|
|
// - core ml approve: Filter scored expansions into training JSONL
|
|
|
|
|
// - core ml publish: Upload Parquet dataset to HuggingFace Hub
|
|
|
|
|
// - core ml coverage: Analyze seed coverage by region and domain
|
2026-02-17 19:53:07 +00:00
|
|
|
// - core ml live: Show live generation progress from InfluxDB
|
|
|
|
|
// - core ml expand-status: Show expansion pipeline progress
|
feat: add ML inference, scoring, and training pipeline (pkg/ml)
Port LEM scoring/training pipeline into CoreGo as pkg/ml with:
- Inference abstraction with HTTP, llama-server, and Ollama backends
- 3-tier scoring engine (heuristic, exact, LLM judge)
- Capability and content probes for model evaluation
- GGUF/safetensors format converters, MLX to PEFT adapter conversion
- DuckDB integration for training data pipeline
- InfluxDB metrics for lab dashboard
- Training data export (JSONL + Parquet)
- Expansion generation pipeline with distributed workers
- 10 CLI commands under 'core ml' (score, probe, export, expand, status, gguf, convert, agent, worker)
- 5 MCP tools (ml_generate, ml_score, ml_probe, ml_status, ml_backends)
All 37 ML tests passing. Binary builds at 138MB with all commands.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 00:34:53 +00:00
|
|
|
package ml
|
|
|
|
|
|
|
|
|
|
import (
|
2026-02-16 14:24:37 +00:00
|
|
|
"forge.lthn.ai/core/go/pkg/cli"
|
feat: add ML inference, scoring, and training pipeline (pkg/ml)
Port LEM scoring/training pipeline into CoreGo as pkg/ml with:
- Inference abstraction with HTTP, llama-server, and Ollama backends
- 3-tier scoring engine (heuristic, exact, LLM judge)
- Capability and content probes for model evaluation
- GGUF/safetensors format converters, MLX to PEFT adapter conversion
- DuckDB integration for training data pipeline
- InfluxDB metrics for lab dashboard
- Training data export (JSONL + Parquet)
- Expansion generation pipeline with distributed workers
- 10 CLI commands under 'core ml' (score, probe, export, expand, status, gguf, convert, agent, worker)
- 5 MCP tools (ml_generate, ml_score, ml_probe, ml_status, ml_backends)
All 37 ML tests passing. Binary builds at 138MB with all commands.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 00:34:53 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
cli.RegisterCommands(AddMLCommands)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var mlCmd = &cli.Command{
|
|
|
|
|
Use: "ml",
|
|
|
|
|
Short: "ML inference, scoring, and training pipeline",
|
|
|
|
|
Long: "Commands for ML model scoring, probe evaluation, data export, and format conversion.",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// AddMLCommands registers the 'ml' command and all subcommands.
|
|
|
|
|
func AddMLCommands(root *cli.Command) {
|
|
|
|
|
initFlags()
|
|
|
|
|
mlCmd.AddCommand(scoreCmd)
|
|
|
|
|
mlCmd.AddCommand(probeCmd)
|
|
|
|
|
mlCmd.AddCommand(exportCmd)
|
|
|
|
|
mlCmd.AddCommand(expandCmd)
|
|
|
|
|
mlCmd.AddCommand(statusCmd)
|
|
|
|
|
mlCmd.AddCommand(ggufCmd)
|
|
|
|
|
mlCmd.AddCommand(convertCmd)
|
|
|
|
|
mlCmd.AddCommand(agentCmd)
|
|
|
|
|
mlCmd.AddCommand(workerCmd)
|
2026-02-16 01:19:04 +00:00
|
|
|
mlCmd.AddCommand(serveCmd)
|
feat: port 11 LEM data management commands into core ml
Ports all remaining LEM pipeline commands from pkg/lem into core ml,
eliminating the standalone LEM CLI dependency. Each command is split
into reusable business logic (pkg/ml/) and a thin cobra wrapper
(internal/cmd/ml/).
New commands: query, inventory, metrics, ingest, normalize, seed-influx,
consolidate, import-all, approve, publish, coverage.
Adds Path(), Exec(), QueryRowScan() convenience methods to DB type.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 04:02:28 +00:00
|
|
|
mlCmd.AddCommand(inventoryCmd)
|
|
|
|
|
mlCmd.AddCommand(queryCmd)
|
|
|
|
|
mlCmd.AddCommand(metricsCmd)
|
|
|
|
|
mlCmd.AddCommand(ingestCmd)
|
|
|
|
|
mlCmd.AddCommand(normalizeCmd)
|
|
|
|
|
mlCmd.AddCommand(seedInfluxCmd)
|
|
|
|
|
mlCmd.AddCommand(consolidateCmd)
|
|
|
|
|
mlCmd.AddCommand(importCmd)
|
|
|
|
|
mlCmd.AddCommand(approveCmd)
|
|
|
|
|
mlCmd.AddCommand(publishCmd)
|
|
|
|
|
mlCmd.AddCommand(coverageCmd)
|
2026-02-17 19:53:07 +00:00
|
|
|
mlCmd.AddCommand(liveCmd)
|
|
|
|
|
mlCmd.AddCommand(expandStatusCmd)
|
feat: add ML inference, scoring, and training pipeline (pkg/ml)
Port LEM scoring/training pipeline into CoreGo as pkg/ml with:
- Inference abstraction with HTTP, llama-server, and Ollama backends
- 3-tier scoring engine (heuristic, exact, LLM judge)
- Capability and content probes for model evaluation
- GGUF/safetensors format converters, MLX to PEFT adapter conversion
- DuckDB integration for training data pipeline
- InfluxDB metrics for lab dashboard
- Training data export (JSONL + Parquet)
- Expansion generation pipeline with distributed workers
- 10 CLI commands under 'core ml' (score, probe, export, expand, status, gguf, convert, agent, worker)
- 5 MCP tools (ml_generate, ml_score, ml_probe, ml_status, ml_backends)
All 37 ML tests passing. Binary builds at 138MB with all commands.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 00:34:53 +00:00
|
|
|
root.AddCommand(mlCmd)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Shared persistent flags.
|
|
|
|
|
var (
|
|
|
|
|
apiURL string
|
|
|
|
|
judgeURL string
|
|
|
|
|
judgeModel string
|
|
|
|
|
influxURL string
|
|
|
|
|
influxDB string
|
|
|
|
|
dbPath string
|
|
|
|
|
modelName string
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func initFlags() {
|
|
|
|
|
mlCmd.PersistentFlags().StringVar(&apiURL, "api-url", "http://10.69.69.108:8090", "OpenAI-compatible API URL")
|
|
|
|
|
mlCmd.PersistentFlags().StringVar(&judgeURL, "judge-url", "http://10.69.69.108:11434", "Judge model API URL (Ollama)")
|
|
|
|
|
mlCmd.PersistentFlags().StringVar(&judgeModel, "judge-model", "gemma3:27b", "Judge model name")
|
|
|
|
|
mlCmd.PersistentFlags().StringVar(&influxURL, "influx", "", "InfluxDB URL (default http://10.69.69.165:8181)")
|
|
|
|
|
mlCmd.PersistentFlags().StringVar(&influxDB, "influx-db", "", "InfluxDB database (default training)")
|
|
|
|
|
mlCmd.PersistentFlags().StringVar(&dbPath, "db", "", "DuckDB database path (or set LEM_DB env)")
|
|
|
|
|
mlCmd.PersistentFlags().StringVar(&modelName, "model", "", "Model name for API")
|
|
|
|
|
}
|