Urgent.News

One page, thousands of outlets. See who else covered it.

Editions

AI

The cheapest LLM call is the one you don't make: a caching layer that actually pays off

The cheapest LLM call is the one you don't make: a caching layer that actually pays off In the last post I wrote about routing across providers to cut our bill ~40%. Caching was the second lever — and honestly the more underrated one. Here's what we learned shipping it. Routing gets most of the attention because it's sexy: traffic dancing across providers, failover kicking in, dashboards lighting…

The most economical way to access language models is by not making unnecessary calls, according to the author. Caching emerged as the second critical strategy after optimizing routing across providers, which had previously cut their bill by approximately 40%. The author discovered that a significant portion of their traffic consisted of repeated requests with near-identical inputs, prompting a rethink of their approach to model calls.

Three caching strategies proved highly effective: the first being an exact cache, which stored full request hashes and served pre-stored completions when identical requests were encountered. Despite initial skepticism, this straightforward method significantly reduced costs on high-traffic endpoints. The second strategy involved a semantic cache that compared user inputs using embeddings in a vector index, reusing completions for similar prompts.

However, this approach is limited to deterministic tasks like classifications and extractions, as it risks serving outdated information for creative generation. The third cache strategy focused on deterministic preprocessing steps, transforming them into pure functions that could be cached without involving the model.

The author recommends adjusting cache expiration times based on the volatility of the data, with stable reference answers benefiting from longer TTLs and fast-moving data requiring shorter or no expiration. Additionally, token costs associated with cache lookups should be minimized, as they can still incur expenses. The author emphasizes the importance of measuring cache hit rates rather than solely focusing on savings, as the hit rate can indicate when caching measures are no longer effective due to changes in prompts or use cases.

Implementing caching alongside routing and circuit breaker techniques can lead to substantial reductions in costs while also improving response times. The author emphasizes that these caching strategies are not novel, but rather an extension of traditional caching practices applied to model calls. They invite further discussion on the subject, offering to share experiences and insights in a more casual setting.

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

Can AI Data Centers Save Local Areas? UAE Ambassador Inspects Scheduled Site in Akita A plan to build a large data center for artificial intelligence (AI) in Akita Prefecture has been attracting attention as a potential savior of the region, which is struggling with a declining population. On August 29, the UAE's ambassador to Japan, Essa Al Gergawi, inspected the site in Ogata, Akita Prefecture, where the data center is scheduled to be built. The data center, which will be built by a company called EcoPulse, is expected to start operation in 2027. The Akita Prefectural Government is pinning great hopes on the project, expecting it to have a positive impact on the local economy and help revitalize the area. The population of Akita Prefecture has been declining for 13 consecutive years, and the prefecture is considered one of the areas in Japan most affected by the declining population. The data center is expected to create about 600 jobs during the construction phase and around 100 permanent jobs after it starts operation. In addition, the prefectural government expects the data center to generate about 10 billion yen in economic impact annually. However, concerns remain about the environmental impact of the data center, including the large amount of electricity it will consume. The UAE ambassador's visit to the site was part of a broader effort to strengthen ties between Japan and the UAE. The two countries have been cooperating in various fields, including energy and technology. The UAE has been actively investing in Japan, and the ambassador's visit to Akita Prefecture is seen as a sign of the country's continued interest in the region. During his visit, Al Gergawi expressed his enthusiasm for the project, saying that it has the potential to be a game-changer for the region. He also emphasized the importance of cooperation between Japan and the UAE in the field of technology. The project is expected to be a major step forward in the development of AI technology in Japan and could have a significant impact on the country's economy. The Japanese government has been promoting the development of AI technology, and the data center in Akita Prefecture is seen as a key part of that effort. The project is also expected to contribute to the development of the region and help mitigate the effects of the declining population. The construction of the data center is expected to begin in 2025, with operation scheduled to start in 2027. The project is being closely watched by local residents, who are hopeful that it will bring new economic opportunities to the area.

More from Wednesday 19 August →