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

推荐订阅源

V
V2EX
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
人人都是产品经理
人人都是产品经理
博客园 - 三生石上(FineUI控件)
aimingoo的专栏
aimingoo的专栏
U
Unit 42
GbyAI
GbyAI
H
Help Net Security
A
Arctic Wolf
SecWiki News
SecWiki News
K
Kaspersky official blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Blog — PlanetScale
Blog — PlanetScale
B
Blog
Spread Privacy
Spread Privacy
L
Lohrmann on Cybersecurity
C
Check Point Blog
O
OpenAI News
Microsoft Security Blog
Microsoft Security Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
大猫的无限游戏
大猫的无限游戏
Google DeepMind News
Google DeepMind News
Webroot Blog
Webroot Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Palo Alto Networks Blog
A
About on SuperTechFans
S
SegmentFault 最新的问题
Recent Announcements
Recent Announcements
S
Schneier on Security
Martin Fowler
Martin Fowler
WordPress大学
WordPress大学
Jina AI
Jina AI
The Hacker News
The Hacker News
V2EX - 技术
V2EX - 技术
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
腾讯CDC
罗磊的独立博客
G
GRAHAM CLULEY
L
LINUX DO - 热门话题
雷峰网
雷峰网
博客园 - 【当耐特】
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
美团技术团队
M
MIT News - Artificial intelligence
Engineering at Meta
Engineering at Meta
Hacker News: Ask HN
Hacker News: Ask HN
S
Security Affairs
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Improving Determinism with LLMs: Prompting, Model Selection, Context, and Tools
Derrick Pedr · 2026-05-02 · via DEV Community

Large language models are incredibly powerful, but they are not automatically deterministic.

Ask the same question twice and you may get slightly different answers. Ask for facts without enough context and the model may fill in gaps. Ask it to perform complex matching or calculations directly in natural language and you may get an answer that sounds confident but is not reliable enough for production use.

That does not mean LLMs are unreliable by default. It means we need to design around how they work.

When building AI-powered applications, improving determinism usually comes down to four practical methods:

  1. Prompt engineering
  2. Choosing the right model
  3. Providing the right context, including RAG
  4. Using tools for deterministic work

The goal is not to make the LLM magically perfect. The goal is to reduce ambiguity, improve accuracy, and prevent the model from inventing answers when it does not have enough information.


1. Prompt Engineering

Prompt engineering is one of the simplest ways to improve LLM reliability. A vague prompt gives the model too much freedom. A specific prompt gives it boundaries.

Instead of asking:

Compare these records and tell me which ones match.

Enter fullscreen mode Exit fullscreen mode

You can improve the prompt by giving the model a clear process:

Compare the records step by step.
First, normalize company names.
Second, compare addresses.
Third, compare phone numbers.
Fourth, assign a confidence score.
If there is not enough evidence to determine a match, return `unknown`.

Enter fullscreen mode Exit fullscreen mode

Good prompt engineering often includes:

  • Step-by-step instructions
  • Specific examples
  • Example outputs
  • Clear formatting requirements
  • Constraints on what sources the model should use
  • Permission for the model to say “I don’t know”

That last point is important.

LLMs are often optimized to be helpful, which can sometimes make them answer even when they should not.

Giving the model permission to say it does not know can reduce hallucinations.

For example:

If the answer cannot be determined from the provided context, respond with:
"I don't know based on the provided information."
Do not guess.
Do not use outside knowledge.

Enter fullscreen mode Exit fullscreen mode

This kind of instruction helps the model stay inside the boundaries of the task. Prompting alone will not guarantee perfect results, but it is usually the first layer of control.


2. Choosing the Right Model

Not all LLMs are equally good at every task.

Some models are stronger at reasoning. Some are better at coding. Some are optimized for speed and cost. Some are designed for image generation, document understanding, or multimodal workflows.

For example, a model like Claude Opus 4.7 is commonly used for complex reasoning and coding-heavy tasks. A model like Nano Banana Pro is designed for high-quality image generation and editing, including use cases where accurate text rendering inside images matters.

The key point is simple:

Pick the model based on the task, not just the brand name.

If your task is code generation, evaluate models against coding benchmarks and real coding examples from your own project. If your task is medical document summarization, legal review, financial extraction, or data matching, evaluate models against examples from that subject matter. If your task is image generation, use a model designed for image generation.

Model settings matter too.

Temperature is one of the most important settings for determinism. Lower temperature generally makes responses more predictable and focused, while higher temperature increases creativity and variation.

For accuracy-focused tasks like structured extraction, classification, JSON output, or data processing, I usually prefer a low temperature (often close to 0). Conversely, for creative writing, brainstorming, or marketing copy, a higher temperature may be more appropriate.

Another useful pattern is intelligent model routing.

Instead of sending every prompt to the same model, you can route tasks based on intent:

If the user asks for code generation, use the coding model.
If the user asks for image generation, use the image model.
If the user asks for summarization, use the fast summarization model.
If the user asks for complex reasoning, use the reasoning model.

Enter fullscreen mode Exit fullscreen mode

This routing can be rule-based, or you can use an LLM to classify the task and select the best model. The more specialized the task, the more important model selection becomes.


3. Providing the Right Context (RAG)

Context is one of the biggest factors in improving LLM accuracy.

An LLM without context may answer based on general knowledge. That can be useful, but it is risky when you need answers grounded in specific documents, company policies, user data, contracts, codebases, or domain-specific content.

Context gives the model boundaries.

For example:

Answer only using the provided context.
If the context does not contain the answer, say you do not know.

Enter fullscreen mode Exit fullscreen mode

And this is where RAG becomes extremely useful.

RAG stands for Retrieval-Augmented Generation. In a RAG system, your documents are usually chunked, embedded, and stored in a vector database. When a user asks a question, the system performs a semantic search to find relevant content and passes that content to the LLM as context.

Instead of asking the model to rely only on what it already knows, you are giving it the source material it should use.

A simplified RAG flow looks like this:

User asks a question
        ↓
Search relevant documents
        ↓
Retrieve the best matching chunks
        ↓
Pass those chunks to the LLM
        ↓
Generate an answer grounded in the retrieved context

Enter fullscreen mode Exit fullscreen mode

This improves determinism because the model is no longer operating in an open-ended way. It has a defined source of truth.

RAG is especially useful for:

  • Internal documentation
  • Policy questions
  • Knowledge bases
  • Technical documentation
  • Customer support
  • Contract review
  • Medical or legal document review
  • Codebase Q&A
  • Research assistants

However, RAG does not automatically solve everything. You still need good chunking, good retrieval, good metadata, and good prompting. If the wrong context is retrieved, the model may still produce the wrong answer.

A strong RAG prompt is built on strict boundaries. While a production prompt would be much more detailed, a simplified example of the core instructions looks like this:

Use only the provided context.
Cite the source sections used.
Do not answer from general knowledge.
If the answer is not present in the context, say so.

Enter fullscreen mode Exit fullscreen mode

This helps reduce hallucinations and makes the answer easier to verify.


4. Using Tools for Deterministic Work

Tools are one of the best ways to improve reliability.

There are many tasks that an LLM should not perform directly if you need consistent, production-quality results.

For example:

  • Complex calculations
  • Fuzzy matching across large datasets
  • Sorting and filtering
  • Database queries
  • API lookups
  • File parsing
  • Data validation
  • Date calculations
  • Business rule execution

An LLM can reason about these tasks, but it should not always be the thing performing them.

If you need to compare thousands of records, do not rely on the LLM to manually inspect all of them in a prompt. Instead create a tool.

For example, a fuzzy matching tool could be written in Python and exposed to the LLM:

def fuzzy_match_records(source_records, target_records, threshold=0.85):
    """
    Deterministically compare two datasets and return likely matches.
    """
    matches = []

    for source in source_records:
        for target in target_records:
            score = calculate_similarity(source, target)

            if score >= threshold:
                matches.append({
                    "source_id": source["id"],
                    "target_id": target["id"],
                    "score": score
                })

    return matches

Enter fullscreen mode Exit fullscreen mode

The LLM can decide when to use the tool, explain the results, and help the user interpret the output. But the matching itself happens in code, which is much more reliable.

The same applies to calculations. If you need accurate math, use a calculator tool or a Python function. If you need data from a database, use a query tool. If you need to check real-time information, use an API.

The pattern is:

Use the LLM for reasoning, language, orchestration, and explanation.
Use tools for deterministic execution.

This is especially important in agentic workflows.

The more autonomy you give an AI agent, the more important tool boundaries become. Tools should be scoped, validated, logged, and restricted. A tool should do one thing clearly and safely.

Tools make LLM systems more reliable because they move critical operations out of natural language and into deterministic code.

One important clarification: a tool does not guarantee correct results just because it is a tool. It guarantees that the same code runs consistently, assuming the implementation and inputs are correct. That is still a major improvement over asking an LLM to improvise calculations or matching logic in plain text.


Bringing It All Together

Improving determinism with LLMs is not about one magic trick. It is a layered approach.

  • Prompt engineering gives the model clear instructions.
  • Model selection ensures you are using the right model for the task.
  • Context and RAG ground the model in relevant source material.
  • Tools move critical logic into deterministic code.

Together, these methods can dramatically improve the reliability of LLM-powered applications.

A practical architecture might look like this:

User Prompt
   ↓
Prompt Classification
   ↓
Model Routing
   ↓
Retrieve Context with RAG
   ↓
LLM Reasoning
   ↓
Tool Calls for Deterministic Work
   ↓
Validated Response

Enter fullscreen mode Exit fullscreen mode

This kind of design gives you the best of both worlds. You get the flexibility and reasoning ability of an LLM, but you also get the reliability of structured prompts, grounded context, model specialization, and deterministic tools.

That is where LLM applications become much more production-ready.


Final Thoughts

LLMs are powerful, but they need guardrails. If you want better accuracy, fewer hallucinations, and more repeatable results, start by asking four questions:

  1. Is my prompt specific enough?
  2. Am I using the right model for this task?
  3. Have I provided the right context?
  4. Should this task be handled by a tool instead of the LLM?

The more often you answer those questions intentionally, the more deterministic your AI system becomes. LLMs are not just chatbots anymore. They are reasoning engines, orchestrators, and interfaces to tools.

But for production systems, the best results come when we stop expecting the model to do everything by itself and instead design systems that combine LLM intelligence with deterministic software engineering.