Find answers from the community

Updated 3 months ago

Context

Hi everybody,
First congrats, this is a fantastic project.

How can I customize the context_str variable?

My docs have a metadata with filename and page, when I send a query, the prompt
injects the context_str as

filename: contract2.txt\npage_number: 2\n\n< text >\n
filename: contract3.txt\npage_number: 3\n\n< text >\n

The problem is that the LLM sometimes get confused and don't answer correct, if I send the context as a string formatted as JSON it always works

{ context: [
{ content: "<text>", filename:"contract2.txt", page_number: 1 },
{ content: "<text>", filename:"contract3.txt", page_number: 3 }
]
}

Thanks for any help
L
B
3 comments
You can customize what each document/node looks like when it converts to text. You can even customize which metatdata is used for emebeddings and the llm

Check out the full guide here, it may help!

https://gpt-index.readthedocs.io/en/latest/core_modules/data_modules/documents_and_nodes/usage_documents.html
I also have a video on this here
https://youtu.be/nGNoacku0YY
Thanks @Logan M thats exactly what I need
Add a reply
Sign up and join the conversation on Discord