[Feature Request]: Leverage prompt caching by swapping instructions & content #1699
Replies: 1 comment
-
|
We implemented this — PR #1873. All 4 extraction prompts in If you want to try it before it's merged: pip install git+https://github.com/hafezparast/crawl4ai.git@fix/prompt-caching-order-1699To verify caching is working, check your provider's dashboard for cached token counts after running a batch extraction across multiple pages with the same Would be great to hear if you see the expected cost reduction in practice — especially the actual cache hit rate across a real crawl session. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
What needs to be done?
We should first give the instructions in the prompt, then give the URL & Content : https://github.com/unclecode/crawl4ai/blob/main/crawl4ai/prompts.py
What problem does this solve?
We could leverage prompt caching. Depending on the provider, the cached tokens for input can ben up to 90% cheaper than normal input tokens. In my use-case, I'm crawling a lot of different pages with the same instructions set.
If we change the prompt to be :
We could also leverage on prompt caching for the HTML content which is quite the same (for example common body structure).
Target users/beneficiaries
Everyone using LLM Extraction. It would be cheaper at the end. For example with OpenAI : https://platform.openai.com/docs/pricing
Current alternatives/workarounds
No response
Proposed approach
No response
Beta Was this translation helpful? Give feedback.
All reactions