Live data from Hacker News

Prompt Caching

docs.anthropic.com

11–20 of 75 posts

Re: Prompt Caching

#11

Why does prompt caching reduce costs? I'm assuming that the primary cost driver is GPU/TPU FLOPS, as opposed to any network / storage / etc costs. My understanding is that an LLM will take in the stream of text, tokenize it (can be faster with caching, sure, but it's a minor drop in the bucket), then run a transformer on the entire sequence. You can't just cache the output of a transformer on a prefix to reduce workl…

The transformer only looks backwards, so if the first part of the sequence (the prompt) doesn't change, you don't need to rerun it again on that part, just on the part after it that changed. For use cases with large prompts relative to the output size (e.g. lots of examples in the prompt), this can significantly speed up the workload.

Re: Prompt Caching

#12

Why does prompt caching reduce costs? I'm assuming that the primary cost driver is GPU/TPU FLOPS, as opposed to any network / storage / etc costs. My understanding is that an LLM will take in the stream of text, tokenize it (can be faster with caching, sure, but it's a minor drop in the bucket), then run a transformer on the entire sequence. You can't just cache the output of a transformer on a prefix to reduce workl…

Autoregressive models can't just resume so they have to re-parse the entire prompt again for each execution.

By caching them they resume from where it left off from before thereby completely bypassing all that computation.

For large contexts this could save a ton of compute!

I think this feature and structured outputs are some of the biggest inventions in LLMs this year.

Re: Prompt Caching

#13
post #2

Sounds kinda useless, TBH. This sounds as if it assumes the exact same context window across requests. If so, given the 5 minute window, unless for example your entire team is operating in the same codebase at the same time, you won't really see any savings beyond simple prompts. Are contexts included in the prompt cache? Are they identified as the same or not? What happens if we approach the 10k token range? 128k? 1…

I have a system prompt of around 100k which includes a couple of internal schema definitions. Having this cached could be super useful to us.

Re: Prompt Caching

#14

Why does prompt caching reduce costs? I'm assuming that the primary cost driver is GPU/TPU FLOPS, as opposed to any network / storage / etc costs. My understanding is that an LLM will take in the stream of text, tokenize it (can be faster with caching, sure, but it's a minor drop in the bucket), then run a transformer on the entire sequence. You can't just cache the output of a transformer on a prefix to reduce workl…

Autoregressive models can't just resume so they have to re-parse the entire prompt again for each execution. By caching them they resume from where it left off from before thereby completely bypassing all that computation. For large contexts this could save a ton of compute! I think this feature and structured outputs are some of the biggest inventions in LLMs this year.

Prompt caching has been a thing for LLMs since GPT-2 (e.g. transformers's `use_past=True`), it's more of a surprise that it took this long for the main LLM providers to provide a good implementation.

Re: Prompt Caching

#15
post #2

Sounds kinda useless, TBH. This sounds as if it assumes the exact same context window across requests. If so, given the 5 minute window, unless for example your entire team is operating in the same codebase at the same time, you won't really see any savings beyond simple prompts. Are contexts included in the prompt cache? Are they identified as the same or not? What happens if we approach the 10k token range? 128k? 1…

[deleted]

Re: Prompt Caching

#16

Earlier quoted context omitted.

Autoregressive models can't just resume so they have to re-parse the entire prompt again for each execution. By caching them they resume from where it left off from before thereby completely bypassing all that computation. For large contexts this could save a ton of compute! I think this feature and structured outputs are some of the biggest inventions in LLMs this year.

Prompt caching has been a thing for LLMs since GPT-2 (e.g. transformers's `use_past=True`), it's more of a surprise that it took this long for the main LLM providers to provide a good implementation.

I’m building an app with OpenAI, using structured outputs. Does OpenAI also support prompt caching?

Re: Prompt Caching

#17
post #16

Earlier quoted context omitted.

Prompt caching has been a thing for LLMs since GPT-2 (e.g. transformers's `use_past=True`), it's more of a surprise that it took this long for the main LLM providers to provide a good implementation.

I’m building an app with OpenAI, using structured outputs. Does OpenAI also support prompt caching?

Not currently.

Re: Prompt Caching

#18
post #2

Sounds kinda useless, TBH. This sounds as if it assumes the exact same context window across requests. If so, given the 5 minute window, unless for example your entire team is operating in the same codebase at the same time, you won't really see any savings beyond simple prompts. Are contexts included in the prompt cache? Are they identified as the same or not? What happens if we approach the 10k token range? 128k? 1…

I have a system prompt of around 100k which includes a couple of internal schema definitions. Having this cached could be super useful to us.

100k … I hear and use all of these high token context LLMs, but often they fail to include all information that should be in their context.

Does your approach work for you?

Re: Prompt Caching

#19
post #16

Earlier quoted context omitted.

Prompt caching has been a thing for LLMs since GPT-2 (e.g. transformers's `use_past=True`), it's more of a surprise that it took this long for the main LLM providers to provide a good implementation.

I’m building an app with OpenAI, using structured outputs. Does OpenAI also support prompt caching?

I'm sure internally they use it for the system prompt at least, probably since launch. And maybe for common initial user queries that exactly match.

Re: Prompt Caching

#20

Why does prompt caching reduce costs? I'm assuming that the primary cost driver is GPU/TPU FLOPS, as opposed to any network / storage / etc costs. My understanding is that an LLM will take in the stream of text, tokenize it (can be faster with caching, sure, but it's a minor drop in the bucket), then run a transformer on the entire sequence. You can't just cache the output of a transformer on a prefix to reduce workl…

The transformer only looks backwards, so if the first part of the sequence (the prompt) doesn't change, you don't need to rerun it again on that part, just on the part after it that changed. For use cases with large prompts relative to the output size (e.g. lots of examples in the prompt), this can significantly speed up the workload.

I think most architectures do a layer of normalization on the whole text embeddings before calculating attention which makes this infeasible

Shouldn’t be a huge deal to adjust imo

One of the bigger problems is that closed model providers don’t want to expose the embedding space and let’s users see what they have

Post reply on HN