Find answers from the community

Updated 2 months ago

Persist the Index

Hey friends!

I am using LlamaIndex to summarize a list index with a bunch of different final prompts. The text I pass in might be 60,000 tokens long and the only thing I'm changing is the prompt. "Generate three titles from the summary." "Generate a blog post from the summary of the text".

Is there any way to save money instead of having to parse all of the documents over and over again for the different types of summaries, or, maybe store embeddings instead?
W
b
L
16 comments
Hey! Are you not persisting the Indexes? If not then you should!
This helps you to not create embedding everytime you run the code.

Check this out: https://gpt-index.readthedocs.io/en/latest/getting_started/starter_example.html#saving-and-loading
Persist the Index
I don't know if it creates any embeddings
for the List Index
or uses them rather
Hey!

Yea was thinking about this a bit this morning.

I think one idea might be to use a single prompt to generate a generic summary. Then from there, use your custom prompts and generate your different outputs from a common generic summary πŸ‘€

This way,. you only read all 60,000 tokens once, then from there you re-use the generic summary to build different outputs

This would work really well actually with tree_summarize for the generic summary, and then a pydantic program for getting structured outputs out of the summary
This assumes that a generic summary will cover all uses cases though
@Logan M hello friend!
Don't you think it'd lose a lot of context? also, I'm correct in saying we don't use embeddings in this scenario?
Yea I'm struggling to see a way to use embeddings.

Its losing some context (it's condensing everything into a summary), but it's not losing anymore context than you already are I think πŸ€”
What would your prompt look like. Would it just be a base summary and then every prompt after that would be using that with the same prompt?
Yea like it would just be "Summarize the text. Be sure to include key details."

Once you have that summary, you could pass it through other simple API calls or pydantic programs, to re-structure and re-write the summary however you need
@Logan M I would probably take that output and pass it back through the documents etc and just do the same way I do it now?
hello new docs 😍
yessss new docs! Hope you like them, worked like 16 hour days over the weekend to crunch them out after we got roasted on hackernews πŸ˜†
pretty much? But if you need structured outputs, the generic summary should be short enough to just shove into a pydantic program
Add a reply
Sign up and join the conversation on Discord