惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Stack Overflow Blog
Stack Overflow Blog
Simon Willison's Weblog
Simon Willison's Weblog
B
Blog
V
Visual Studio Blog
G
Google Developers Blog
云风的 BLOG
云风的 BLOG
S
SegmentFault 最新的问题
博客园 - 司徒正美
博客园 - 【当耐特】
T
Tenable Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
宝玉的分享
宝玉的分享
N
Netflix TechBlog - Medium
S
Secure Thoughts
Hugging Face - Blog
Hugging Face - Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
IT之家
IT之家
Google DeepMind News
Google DeepMind News
Last Week in AI
Last Week in AI
大猫的无限游戏
大猫的无限游戏
PCI Perspectives
PCI Perspectives
H
Hackread – Cybersecurity News, Data Breaches, AI and More
阮一峰的网络日志
阮一峰的网络日志
P
Privacy International News Feed
N
News and Events Feed by Topic
H
Hacker News: Front Page
MongoDB | Blog
MongoDB | Blog
Google DeepMind News
Google DeepMind News
F
Full Disclosure
Google Online Security Blog
Google Online Security Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
H
Heimdal Security Blog
Project Zero
Project Zero
C
CERT Recently Published Vulnerability Notes
MyScale Blog
MyScale Blog
AI
AI
月光博客
月光博客
C
Cyber Attacks, Cyber Crime and Cyber Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
WordPress大学
WordPress大学
L
Lohrmann on Cybersecurity
TaoSecurity Blog
TaoSecurity Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
C
CXSECURITY Database RSS Feed - CXSecurity.com
Spread Privacy
Spread Privacy
Apple Machine Learning Research
Apple Machine Learning Research
GbyAI
GbyAI
SecWiki News
SecWiki News
C
Cisco Blogs
The Last Watchdog
The Last Watchdog

Hacker News - Newest: "LLM"

GitHub - lechmazur/position_bias: A benchmark for testing whether LLM judges keep the same preference when two lightly edited versions of the same story are shown in opposite orders. Flex routing (EU and EFTA) Dark Factories: Retooling for LLM Velocity Ask HN: What would be the impact of a LLM output injection attack? GitHub - AronDaron/dataset-generator: No-code desktop app for generating high-quality synthetic datasets to fine-tune LLMs — plan-then-execute pipeline, LLM-as-judge, HuggingFace upload. GitHub - Oaklight/llm-rosetta: Production-ready LLM API translation layer for Python — bidirectional conversion between OpenAI, Anthropic & Google formats via hub-and-spoke IR. Optional API gateway. Streaming & non-streaming. Zero core deps. Contributions welcome! GitHub - browser-use/browser-harness: Self-healing browser harness that enables LLMs to complete any task. GitHub - moeen-mahmud/remen: Remen turns thoughts into something you can return to Analyzing 156 LLM Launch Posts on Hacker News ChatGPT vs Gemini vs Claude: The Best LLM Subscription You Should Buy GitHub - salaamalykum/quran-semantic-search: High-density RAG Semantic Search Engine & Quran Corpus (GEO/SEO Architecture) GitHub - NVIDIA/TensorRT-LLM: TensorRT LLM provides users with an easy-to-use Python API to define Large Language Models (LLMs) and supports state-of-the-art optimizations to perform inference efficiently on NVIDIA GPUs. TensorRT LLM also contains components to create Python and C++ runtimes that orchestrate the inference execution in a performant way. The State of LLM Bug Bounties in 2026 Operational Readiness Criteria for Tool-Using LLM Agents Meshcore: Architecture for a Decentralized P2P LLM Inference Network How an LLM becomes more coherent as we train it GitHub - seetrex-ai/laimark GitHub - Jossifresben/BibCrit: AI-assited biblical textual criticism GitHub - wastedcode/memex: File system based wiki, maintained by Claude 99helpers.com GitHub - cliver-project/AITrigram GitHub - unbody-io/adapt: A self-evolving memory layer for AI agents. GitHub - hb20007/awesome-gen-ai-fails: A list of incidents where reliance on generative AI and LLMs resulted in harm to companies, individuals, or society GitHub - nevenkordic/localmind: Run any local LLM with persistent memory and context. CLI agent over Ollama with SQLite-backed hybrid recall. No cloud. Ask HN: What are the machine requirements for a LLM like Llama-3.1-8B? Faster LLM Inference via Sequential Monte Carlo grpo explained: group relative policy optimization for llm finetuning - cgft Stop comparing price per million tokens: the hidden LLM API costs · TensorZero Andrej Karpathy's LLM Wiki Is a Bad Idea GitHub - GG-QandV/mnemostroma: Offline RAM-first cognitive leer/coprocessor for AI agents and robotics. Solves "Context Abandonment" with 20-80ms latency using a dual-thread biomimetic memory architecture (ONNX + SQLite WAL). mempalace/agent at agent · skorotkiewicz/mempalace GitHub - Nyquest-ai/nyquest-rust-fullstack-pub: Nyquest — Semantic Compression Proxy for LLMs. 350+ rules, local LLM stage, 15-75% token savings. Full Rust stack. GitHub - TheoV823/mneme: Enforce architectural decisions in AI-assisted development. GitHub - klemenvod/TokenBrawl: A 1v1 Bomberman-style game where two LLM agents play autonomously against each other. No human plays — you watch the AIs fight. Each agent receives a text description of the board state, reasons about it, and outputs a move as JSON. The game engine executes it. Introducing the Common AI Provider: LLM and AI Agent Support for Apache Airflow Power Circuit AI: Designing Power Electronic Circuits for Motor Drives with Generative Artificial Intelligence Ask HN: How to program with IDE and LLM on CPU locally? Show HN: Agent-cache – Multi-tier LLM/tool/session caching for Valkey and Redis Bonsai 1-bit WebGPU - a Hugging Face Space by webml-community The LLM Fallacy: Misattribution in AI-Assisted Cognitive Workflows Ask HN: Simple tooling for local LLM code critique without IDE integration? Can a General LLM Diagnose a DICOM Slice? A 10-Case Public Benchmark Charts-of-Thought: Enhancing LLM Visualization Literacy (PDF, 2026) GitHub - Mesh-LLM/mesh-llm: Distributed AI/LLM for the people. Share compute privately or publicly to power your agents and chat. GitHub - seamus-brady/springdrift: A persistent runtime for long-lived LLM agents Writing an LLM from scratch, part 32k -- Interventions: training a better model locally with gradient accumulation Ask HN: Which LLM model and agentic CLI are you using for local development? GitHub - wayneColt/modelcascade: Route local. Escalate smart. Never overspend. Open-source multi-model cascade routing for autonomous agents. LLM pricing is 100x harder than you think GitHub - asakin/llm-primer: Pre-warmed Claude Code sessions in tmux. No startup wait. GitHub - EggerMarc/chat-rs: A multi-provider LLM framework for Rust. GitHub - SynapseKit/SynapseKit: Minimal, async-first Python framework for production LLM apps- 2 hard deps, no magic, no SaaS. A Claude Skill that Makes LLM Paragraphs More Bearable Does Gas Town 'steal' usage from users' LLM credits & paid services to improve itself? What's Claude Code Actually Doing? Open the Black Box with the Arthur Engine Milla Jovovich's New Open Source LLM Memory App and the Dark Code Problem Your intuition of LLM token usage might be wrong Show HN: Bloomberg Terminal for LLM ops – free and open source GitHub - 0xchamin/mcptube: Transform YouTube videos into a compounding knowledge base with transcripts, vision analysis, and agentic search. Works as an MCP server for Claude, Copilot & more. Show HN: Open KB: Open LLM Knowledge Base Your LLM is a compiler, not a runtime GitHub - sapountzis/Unslop: A Web Feed That Deserves You crates.io: Rust Package Registry Beyond Karpathy's LLM-Wiki: The Necessity of Cognitive Governance GitHub - amitshekhariitbhu/llm-internals: Learn LLM internals step by step - from tokenization to attention to inference optimization. GitHub - parallem-ai/parallem: An expressive library for running agents with the Batch API. GitHub - stfurkan/pi-llm LLM-Wiki Show HN: Formal – Formal verification for AI-generated code using Lean 4 LRTS – Regression testing for LLM prompts (open source, local-first) LLM Wiki Skill: Build a Second Brain with Claude Code and Obsidian I built an LLM Wiki and RAG solution: here's a demo for a security KB The biggest advance in AI since the LLM Predict-Rlm: The LLM Runtime That Lets Models Write Their Own Control Flow the-synthetic-library/the-synthetic-mind at main · joshferrer1/the-synthetic-library GitHub - yisding/reviewwiggum GitHub - Donnyb369/mcp-spine: Context Minifier & State Guard — Local-first MCP middleware proxy GitHub - Beledarian/wgpu-llm: A from-scratch LLM inference engine that uses wgpu (the cross-platform WebGPU implementation) to dispatch WGSL compute shaders for every math operation a Transformer needs. No CUDA. No Python. No massive framework dependencies. Just Rust, raw shaders, and your GPU. GitHub - anitiue/Hindsight: An experience-driven self-improvement framework for LLM agents — 基于经验的 LLM Agent 自我改进框架 GitHub - stef41/lmscan: 🔍 Detect AI-generated text and fingerprint which LLM wrote it. Open-source GPTZero alternative. Zero dependencies, works offline. GitHub - alainnothere/AmdPerformanceTesting: Amd Performance Testing Ask HN: Is a purely Markdown-based CRM a terrible idea? Optimized for LLM agents Context Engineering - LLM Memory and Retrieval for AI Agents | Weaviate little_helper_tui/letter.md at main · sleepyeldrazi/little_helper_tui GitHub - EvanZhouDev/umr: The Unified Model Registry for all your local AI apps. GitHub - JordanCT/VigIA-Orchestrator Your Agent Is Mine: Measuring Malicious Intermediary Attacks on the LLM Supply Chain A Taxonomy of RL Environments for LLM Agents Llama LLM Network Feture GitHub - genedeng-ca/ai-mac-migration: AI-powered Mac-to-Mac migration tool - replace Apple Migration Assistant with intelligent, selective transfer using local LLMs GitHub - lunargate-ai/gateway: High-performance self-hosted AI gateway (OpenAI-compatible) with routing, retries, and streaming GitHub - AuthBits/webmcp: A lightweight, prompt-driven MCP web research server for high-quality LLM powered information extraction. Externalization in LLM Agents: A Unified Review of Memory, Skills, Protocols and Harness Engineering Springdrift: An Auditable Persistent Runtime for LLM Agents with Case-Based Memory, Normative Safety, and Ambient Self-Perception High-Stakes Personalization: Rethinking LLM Customization for Individual Investor Decision-Making From Static Templates to Dynamic Runtime Graphs: A Survey of Workflow Optimization for LLM Agents HUOZIIME: An On-Device LLM-enhanced Input Method for Deep Personalization TIDE: Token-Informed Depth Execution for Per-Token Early Exit in LLM Inference Characterizing WebGPU Dispatch Overhead for LLM Inference Across Four GPU Vendors, Three Backends, and Three Browsers LLM Targeted Underperformance Disproportionately Impacts Vulnerable Users
GitHub - yuvhaim-gif/LLM_InSight: This my home rig testing process for creating evaluation metric, testing models, automating prompt creation in accordance to the evaluation results of last run and reviewing logs. its local first, independent of any specific tool and logs locally.
yuvalhaim · 2026-05-04 · via Hacker News - Newest: "LLM"

LLM InSights

A local-first testing and optimization harness for iterative content creation — run multi-model A/B tests, refine prompts automatically with rubric-based grading, calibrate the grader to your own taste, and export training-ready datasets. Built for brand content workflows, prompt engineering, LLM evaluation, and dataset curation on your own hardware.

Python 3.10+ License: MIT

Walkthrough Walkthrough (~1.5 min)


What It Does

You write a prompt — a piece of brand copy, a product description, a creative brief, or any content task. The tool sends it to two competing LLM models, grades both answers against a configurable rubric, optionally rewrites the prompt using grader feedback, and repeats the cycle — keeping the best answer each round. Every variable is controlled from the UI: which models compete, what the rubric measures, how categories are weighted, and when the loop stops.

The pipeline runs locally by default using Ollama, with optional cloud API support (Mistral, Google Gemini) for hybrid setups. No data leaves your machine unless you choose a cloud provider.

Each run produces a structured record of prompts, answers, scores, token counts, and model metadata — useful as refined synthetic data, prompt optimization logs, or content quality benchmarks.

When you want the grader to match your judgment, Preference Studio closes the loop: you judge answer pairs head-to-head, watch live alignment metrics (pairwise accuracy, Cohen's κ, Spearman) on the calibration panel, re-fit weights or re-grade until the grader agrees with you, and then export curated, training-ready JSONL datasets — for either the production model (SFT / DPO / KTO) or a trainable pass/fail judge.


Key Capabilities

  • Custom Grading Rubrics — Define up to 8 grading categories, each with its own free-text rubric description, dedicated grader model, and weight. The default rubric covers accuracy, clarity, conciseness, creativity, and structure. Save named configurations and switch between them at any time.
  • Automatic Prompt Optimization — The system rewrites your prompt after each iteration using grader feedback, category weights, and best answers as context. Techniques are applied automatically while preserving the original intent, including Zero-Shot Prompting, Few-Shot Prompting, Chain-of-Thought (CoT), Self-Consistency, Least-to-Most Prompting, Tree of Thoughts (ToT), Directional Stimulus Prompting, Role Prompting, Generated Knowledge Prompting, Chain-of-Verification (CoVe), and Skeleton-of-Thought.
  • Multi-Model A/B Testing — Assign different models to each answering slot and compare their outputs head-to-head. The Advanced panel supports per-iteration model assignments for systematic cross-model comparisons.
  • Parallel Multi-Category Grading — Layer 3 grades each category in parallel using a thread pool, grouped by grader model. Failed graders fall back to a default score without stopping the pipeline. Retries with backoff are built in.
  • Synthetic Data Generation — Every run produces structured (prompt, answer, multi-dimensional scores) tuples and (original prompt, improved prompt) pairs. The JSONL ledger records prompts, replies, models, scores, and token counts. Multi-prompt sessions chain the best answer from the previous prompt as context into the next.
  • Token Tracking — Input, output, and total token counts are recorded per model per layer per iteration and aggregated by provider. Token usage is visible in the deeper analysis charts.
  • Tie Detection — When multiple iterations produce the same best score, the system identifies tied answers, deduplicates by text similarity, and reports alternatives.
  • Session Review and Analysis — Browse, load, and analyze past runs with per-prompt iteration stats, score grids, and an in-depth analysis modal featuring average grade bar charts, radar overlays, per-category score breakdowns, token usage charts, runtime comparisons, and adjustable weight sliders for live what-if recalculation.
  • Preference Studio (Human-in-the-Loop) — A unified /arena + /dataset page to judge answer pairs (which is better, a tie, or both bad), give your own 1–100 grades, pin ground truth, write gold answers, and blacklist bad answers. An active-learning queue surfaces the hardest / most-uncertain pairs first.
  • Grader Calibration — A calibration panel (on Config Graders) measures, live, how well the current grader reproduces your judgments (pairwise accuracy, Cohen's κ, Spearman, per-attribute alignment). Re-fit weights instantly (no model calls) or run a full re-grade with a candidate config, then apply and save.
  • Conflicts Report — A per-chat reconciliation (opened from each source row in Preference Studio) that lists exactly where your decisive judgments disagree with the grader's picks, with pairwise accuracy and Cohen's κ for the chat. A grading-version selector switches between the Original grading and later re-grade runs (newest auto-selected), and your chosen version is persisted per chat.
  • Training-Dataset Export — Build curated pools from exactly the sources you pick and export training-ready JSONL for a production model (sft, preference/DPO, kto) or a trainable pass/fail judge (preference/reward, judge_cls, judge_gen), each with a provenance sidecar and a summary card. All state is isolated from the live session.
  • REST API — All UI actions are backed by JSON endpoints — analysis (/iteration, /is-processing, /get_backup_data, /update_weights, /save_advanced_models, /grader_settings, /grader_setting/<name>) and Preference Studio (/api/arena/*, /api/calibrate/*, /api/dataset/*). Programmatic access to model selection, weight management, grader configuration, session backup, judging, calibration, and dataset export is available out of the box.

How the Pipeline Works

flowchart LR
    L0["Layer 0\n(brainstorm, optional)"] --> loop
    subgraph loop ["Repeat × N iterations"]
        direction LR
        L1A["Layer 1A\n(answer)"] --> G1["Layer 3\n(grade)"]
        G1 --> L2["Layer 2\n(rewrite prompt)"]
        L2 --> L1B["Layer 1B\n(answer)"]
        L1B --> G2["Layer 3\n(grade)"]
        G2 --> W["Pick winner"]
    end
Loading
Layer Role
Layer 0 Optional brainstorming step. Generates concise alternative ideas or directions before the loop begins.
Layer 1A / 1B Two competing answer models. Each produces a full response to the prompt (or improved prompt).
Layer 2 Prompt improver. Rewrites the prompt using grader feedback, best answers, and micro-replies as context.
Layer 3 Multi-category grader. Each category is evaluated independently by its own small LLM in parallel, scores are weighted and combined. Failed categories receive a default score so the pipeline continues.

Stop Conditions

The loop ends when the first of these is met:

  1. The best score reaches the target grade (default: 100).
  2. Degradation break is enabled and the score drops from the previous iteration.
  3. The maximum number of iterations is reached (default: 5).

Pages

Page Path Purpose
Login /login Simple authentication with an animated background
Main Analysis / Run experiments, configure models and toggles, view live results and charts
Config Graders /config_graders Create and edit grading rubrics — categories, rubric text, grader models, weights. Also hosts the Calibration panel (see Preference Studio)
Review History /review_chats Browse saved runs, load or delete past sessions, open the deeper analysis modal
Preference Studio /arena, /dataset Unified human-in-the-loop page with two tabs — Judge (pairwise judging to calibrate the grader and gather ground truth) and Build & Export (turn judgments, blacklist, and machine grades into training-ready JSONL). Both URLs open the same page on the matching tab

Preference Studio

A human-in-the-loop layer that calibrates the grader to your judgment and exports training-ready datasets. It is a single page — Preference Studio — with two tabs (a shared source rail spans both). See docs/preference_studio.md for the full operator + developer guide.

The loop: judge answer pairs in the Judge tab → watch alignment metrics on the Calibration panel (on Config Graders) and re-fit weights or re-grade → assemble curated pools in the Build & Export tab and export. The on-page How it works banner restates these steps.

Two training targets (pick on the Build & Export tab):

  • Production model — the model that performs the task. Formats: sft (good answers), preference (DPO/reward, chosen vs rejected), kto (good + bad).
  • Pass/Fail judge — a trainable Layer-3 grader. Formats: preference (reward model), judge_cls (binary classifier), judge_gen (generative PASS/FAIL).

Each source row in the shared rail also has a ⚠️ Report button that opens the Conflicts Report for that chat — a per-chat view of every pair where your decisive pick differs from the grader's, with the chat's pairwise accuracy and Cohen's κ. A grading-version selector lets you compare the Original grading against later re-grade runs (newest auto-selected), and your choice is saved per chat.

All Preference Studio state lives in an isolated preferences.db plus separate export/regrade directories; the live ledger is read-only here and never modified by re-grading.


Frontend Controls

Main Page — Sidebar (Model Selection)

Control Purpose
Layer 0 Model (Ideas) Selects the brainstorming model that runs before the loop
Answer Model 1 (Layer 1A) First answer model in each iteration
Answer Model 2 (Layer 1B) Second answer model in each iteration
Prompt Improver (Layer 2) Model that rewrites prompts using grader feedback
Advanced Panel Per-iteration model assignment for Layers 1A, 1B, and 2. Locks main selectors when saved
System Profile Filters model dropdowns by hardware tier (Simple / Medium / Powerful) — browser-side only, groups models by parameter size

Main Page — Controls Area

Control Purpose
Advise Models by Domain Filters model dropdowns to show only models suited to a task domain: Coding, Creative, Science, Experimental, or Balanced
Weight Preset Applies a predefined weight profile across grading categories (Balanced, Accuracy, Creativity, Conciseness)
Break Target Grade Stop the loop when this score is reached (1--100)
Iterations Maximum refinement rounds per prompt (1--5)
Degradation Break Stop if the score drops from the previous iteration
Change Prompt Enable or disable Layer 2 prompt rewriting
Give Ideas Enable or disable Layer 0 brainstorming
Last Best Answer Retention Feed the best answer from the previous iteration as context into the next
Grade vs. Current / First Prompt Choose whether graders judge the answer against the current or the first prompt in the session

Main Page — Weights and Grader Settings

Control Purpose
Weight Inputs Adjust category weights (auto-normalized). Apply and Reset buttons
Grader Setting Selector Switch between saved grading rubrics
Config Graders Link Opens the rubric editor page

Main Page — Action Buttons

Button Purpose
START ANALYSIS Runs the iterative analysis loop
Clear Chat Backs up and resets all runtime state
Upload Chat Imports a previously exported JSON backup
Download Chat Exports the session as a human-readable text log or a full restorable JSON backup
Review History Opens the Review page

Config Graders Page

Control Purpose
Load Setting Select and load an existing grading rubric
Edit / Cancel Toggle edit mode for the grading keys table
Key Name Category name (auto-lowercased, spaces converted to underscores)
Rubric Free-text description of scoring criteria
Grader Model Select which small LLM evaluates this category
Weight % How much this category counts toward the overall score
Add / Remove Keys Add a row (max 8) or remove an existing one
Weight Total Indicator Live sum — green at 100%, red otherwise
Save Setting Persist the configuration (blocked if incomplete or named default)

Review Page

Control Purpose
Chat List Browse all saved backups, newest first
Prompt Summary Scores, categories, models, and iterations for each prompt
Iteration Cards Layer 1A vs. 1B detail with winner, model, and runtime
Analyze Deeper Modal with average grade bar chart, radar overlay, per-category score breakdowns, token usage breakdown by provider, runtime comparison chart, adjustable weight sliders with live score recalculation for what-if analysis, weight reset, and the grader setting name from the original run
Load This Chat Restore a backup into the active session
Delete Chat Remove a backup file permanently
Upload Import and restore a JSON backup

Models and Providers

Calls are routed automatically based on the model name:

Provider Models Transport
Ollama All models not listed below (local inference) ollama.chat(), threaded with timeout
Mistral API mistral-small-2506, voxtral-mini-2507, open-mistral-nemo-2407 REST with retry, exponential backoff, and rate-limit handling
Google Gemini API gemini-2.5-flash, gemini-2.5-pro REST with retry, constant backoff, and rate-limit handling
GLM-4 (HuggingFace) glm-4-9b, glm-4-9b-chat Local transformers, cached, preloaded at startup

28 preconfigured models are available across layers, including gemma, granite, llama, qwen, deepseek-r1, deepseek-coder-v2, falcon3, phi4, devstral, solar, codellama, dolphin3, olmo2, starcoder2, and gpt-oss. All API calls are routed automatically based on the model name and include timeout handling; failures in any layer are caught gracefully so the pipeline continues.


Getting Started

Prerequisites

  • Python 3.10+
  • Ollama installed and running (required for local model inference unless you configure cloud-only providers)
  • A .env file with your credentials (see below)

Installation

git clone https://github.com/yuvhaim-gif/LLM_InSight.git
cd LLM_InSight
python -m venv venv
source venv/bin/activate   # Linux / macOS
venv\Scripts\activate      # Windows
pip install -r requirements.txt
cp .env.example .env       # then edit .env with your credentials

Environment Variables

Copy .env.example to .env and fill in your values.

Variable Required Purpose
APP_USER Yes Login username
APP_PASS Yes Login password
FLASK_SECRET Yes Flask session secret (any random string)
MISTRAL_API_KEY No Enables Mistral models. If omitted, those models return errors when called
GOOGLE_API_KEY No Enables Google Gemini models. If omitted, those models return errors when called
LANGCHAIN_API_KEY No Enables LangSmith tracing. If omitted, tracing is disabled
LANGCHAIN_PROJECT No LangSmith project name (defaults to llminsight)
PORT No Server port (defaults to 5000)
SSL_CERT_PATH / SSL_KEY_PATH No Paths to SSL certificate and key for HTTPS

Minimal .env (Ollama-only, no cloud APIs):

APP_USER=admin
APP_PASS=changeme
FLASK_SECRET=changeme

The app runs with just these three variables. Missing optional keys are noted at startup; models routed to a provider without a key return error responses, but the app itself continues to work normally.

Important: The default Layer 2 (prompt improver) model is open-mistral-nemo-2407, which requires MISTRAL_API_KEY. If you are running Ollama-only without a Mistral key, either disable the Change Prompt toggle in the UI or change DEFAULT_LAYER2_MODEL in config/settings.py to an Ollama model (e.g., gemma2:9b).

Pull Ollama Models

Pull the default models used by each layer (skip any you don't plan to use):

ollama pull gemma:7b-instruct-q4_K_M   # Layer 1A default
ollama pull granite4:latest              # Layer 1B default
ollama pull gemma2:9b                    # Layer 0 default
ollama pull phi3:mini                    # Layer 3 grader (accuracy)
ollama pull gemma2:2b                    # Layer 3 grader (clarity)
ollama pull qwen2.5:1.5b                # Layer 3 grader (conciseness, structure)
ollama pull llama3.2:3b                  # Layer 3 grader (creativity)

The full list of preconfigured models is in config/settings.py.

Run

Open http://localhost:5000 and sign in with the credentials from your .env file.


Disabling Providers You Don't Need

If you only want to use a subset of providers, leave the corresponding API key out of .env:

  • No Mistral: omit MISTRAL_API_KEY. Avoid selecting Mistral models in the UI and update DEFAULT_LAYER2_MODEL in config/settings.py to an Ollama or Gemini model.
  • No Google Gemini: omit GOOGLE_API_KEY. Avoid selecting Gemini models in the UI.
  • No LangSmith: omit LANGCHAIN_API_KEY. Tracing fails silently; the app works normally.
  • No GLM-4: remove glm-4-9b and glm-4-9b-chat from the model lists in config/settings.py. Optionally remove transformers and torch from requirements.txt to save disk space.
  • No Ollama: remove Ollama-only models from the model lists in config/settings.py, remove ollama from requirements.txt, and update the default model constants (DEFAULT_LAYER1A_MODEL, DEFAULT_LAYER1B_MODEL, DEFAULT_LAYER0_MODEL, LAYER3_GRADER_MODELS).

Adding Your Own Models

New Ollama model

  1. Pull it: ollama pull your-model-name
  2. Add the model name to the appropriate list(s) in config/settings.py
  3. It appears in the UI dropdowns immediately

New cloud API provider

  1. Add your API key to .env and load it in config/secrets.py
  2. Add a routing check and call function in ai/api_calls.py (follow the existing Gemini/Mistral pattern)
  3. Add the model names to the lists in config/settings.py

New grader model

Add the model name to AVAILABLE_GRADER_MODELS in config/settings.py. The model must be available via Ollama. It will appear in the grader model dropdown on the Config Graders page.

Changing defaults

Edit the DEFAULT_* constants in config/settings.py (DEFAULT_LAYER1A_MODEL, DEFAULT_LAYER1B_MODEL, DEFAULT_LAYER0_MODEL, DEFAULT_LAYER2_MODEL, LAYER3_GRADER_MODELS).


Running Tests

pip install -r requirements-dev.txt
pytest tests/ -v --tb=short

The contract tests validate backup schema, restore behavior, advanced model map compatibility, auth matrix, provider routing, and the full Preference Studio package (test_pref_*: store, extraction, active-learning queue, calibration, dataset pools/examples, export, routes, and wiring). Tests use monkeypatched temp directories and an isolated SQLite database — no production files are touched, no AI models are called, and no .env file is required.


Persistence and Backup

  • Session state: authentication, selected models, weights, toggles, prompt history, advanced model maps, and the active grader setting name are stored in the server-side session and a SQLite database.
  • Runtime files: data/ledger.jsonl (append-only event log), data/iteration_history.json, data/best_best_layer1.json, data/console_output.txt, and graderdata/ (JSONL grader settings).
  • Preference Studio (isolated): data/preferences.db (judgments, queue, blacklist, calibration runs) plus data/preferences_export/ and data/preferences_regrade/. These are never touched by the live session's clear/backup, and re-grading never writes to the ledger.
  • Browser storage: localStorage (domain filter, weight preset, system type) and sessionStorage (review-to-main handoff).
  • Lifecycle: startup, login, clear-chat, logout, exit, window close, and process signals each trigger backups of runtime files before clearing them.
  • JSON export (version 2.0): captures console output, prompt history, iteration history, best-best cache, ledger entries, and full session state. Restorable via upload or the Review page.

Observability

LangSmith/LangChain tracing is available on the orchestrating iterative loop and every individual AI layer (Layer 0, Layer 1, Layer 2, Layer 3) via @traceable decorators. Set LANGCHAIN_API_KEY in .env to enable it. If the key is missing or invalid, tracing is disabled and the app continues to function normally.


Project Structure

Path Purpose
main.py Application entry point
config/ settings.py (models, paths, default weights), secrets.py (credentials via .env)
core/ db.py (SQLite state), models.py (Pydantic schemas), state.py (hybrid state management)
data/ Runtime working files (ledger, cache, history, console output, state DB, and the isolated preferences.db + preferences_export/ / preferences_regrade/ dirs). Auto-created on first run; git-ignored except a .gitkeep placeholder
graderdata/ JSONL grader setting files
routes/ web_routes.py, api_routes.py, review_routes.py
preference/ Isolated Preference Studio package: store.py, extract.py, active_learning.py, calibrate.py, dataset.py, export.py, routes.py
ai/ iterative_loop.py, iteration_summary.py, layer0.py, layer1.py, layer2.py, layer3.py, api_calls.py
utils/ session.py, session_keys.py, file_io.py, common.py, text_processing.py, validation.py, grader_settings.py
scripts/ Developer utility scripts (check_syntax.py, check_modified.py, create_graderdata.py)
templates/ Jinja2 templates (login, main, review, config_graders, studio) with shared partials
static/ CSS, JavaScript, and assets (incl. js/studio/, js/arena/, js/dataset/, js/calibrate/)
tests/ Pytest contract tests (incl. test_pref_*.py)

Dependencies

Package Purpose
Flask Web framework, routing, sessions, template rendering
Pydantic Data validation for Layer 2 response schemas
ollama Python client for Ollama local inference
requests HTTP client for Mistral and Gemini REST APIs
python-dotenv Load .env into environment variables
transformers HuggingFace model loading for GLM-4 (optional)
torch PyTorch backend for GLM-4 inference (optional)
Chart.js + chartjs-plugin-datalabels Bar, radar, and per-category charts in the analysis modal (loaded from CDN)
langsmith Tracing and observability (optional)
pytest Test suite (dev dependency)

Further Documentation


Contributing

Contributions are welcome. If you'd like to help improve LLM InSights, please open an issue to discuss your idea before submitting a pull request. Bug reports, feature suggestions, and documentation improvements are all appreciated.


License

This project is released under the MIT License.