Urgent.News

What's breaking now, across thousands of outlets.

AI

Why Your LLM App Works in Demo but Fails in Production

The Demo Was Perfect I've done this more times than I'd like to admit. Build an LLM app. Test it with 10 carefully chosen questions. The answers are beautiful — accurate, well-formatted, exactly what I wanted. Record a screen capture. Post it on Twitter. "Look what I built this weekend." Then I share it with 5 real users. Within an hour, everything is on fire. The app hallucinates on questions I…

When transitioning from a demo to production, several critical factors can cause an LLM application to work well in a demo but fail in a real-world setting. The first issue is the use of cherry-picked inputs during demos. During demonstrations, testers typically use carefully chosen questions for which they already know the answers, making the results appear perfect.

However, in production, real users ask more complex, varied, and poorly phrased questions. The solution is to create an evaluation set of 100+ queries that includes "ugly" ones and test with real user phrasing, not developer phrasing.

Another issue is the lack of adversarial users in demos. In production, users may attempt to manipulate the system by exploiting vulnerabilities such as prompt injection to gain unauthorized access or perform malicious activities. The fix involves never trusting user input as part of the system prompt, implementing input sanitization, adding output filtering, testing with known attacks, and having a fallback response to handle suspicious outputs.

Latency can also pose a problem in production, as users become frustrated with delayed responses. Research shows that user satisfaction decreases after 3 seconds of wait time and most users abandon the app after 10 seconds. To address this issue, measure P95 latency, use streaming responses, cache common queries, consider smaller, faster models for simple questions, and route complex ones to larger models.

Cost is another factor that goes unnoticed during demos but becomes crucial in production. Testing with a few queries can cost as little as $0.12, but thousands of daily queries can quickly escalate costs. Implement aggressive caching, use cheaper models for simple questions, set per-user rate limits, monitor spend daily, and consider fine-tuning smaller models for 80% of queries.

Edge cases that do not exist in demos become prevalent in production. These include handling large PDFs, outdated information, language inconsistencies, contradictory documents, frequent questions, and load testing. Build resilient systems with input length limits, timeout handling, graceful degradation, logging of failures, and observability tools like LangSmith, Langfuse, or Phoenix for LLM observability.

Lastly, lack of observability in production can make it difficult to diagnose issues when users report incorrect results. To overcome this, log everything, use observability tools, build dashboards, and analyze query patterns to identify and address problems proactively.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in AI

More from Saturday 12 September →