Find answers from the community

Updated 4 weeks ago

Brackets

Hi, I am using the default template and default parser with an open-source LLM to generate sub-questions. Here is an example of the generated sub-questions in json format:
LLMQuestionGenerator.generate(), prediction =
Plain Text
{{
    "items": [
        {{
            "sub_question": "What is the summary of the article about Paul Graham?",
            "tool_name": "summary"
        }},
        {{
            "sub_question": "What are some specific facts about Paul Graham mentioned in the article?",
            "tool_name": "vector_search"
        }}
    ]
}}


As you can see above, "{{" and "}}" is in the json and causing the default json parser to fail. I noticed the default prompt below is instructing the LLM to replace "{" with "{{" and "}" with "}}": https://github.com/run-llama/llama_index/blob/369973f4e8c1d6928149f0904b25473faeadb116/llama-index-core/llama_index/core/question_gen/prompts.py#L68C1-L72C2

I tried removing the "replace" lines above and the sub-questions generated are in correct json format. I wonder if there were reasons to do the "replace" in the template to begin with? In other words, will there be any negative impact if I remove the "replace" in the default template?
L
J
5 comments
That's a good catch. Previously double brackets were needed to escape the python string formatter

Changes in other parts of the library made that not needed anymore, so indeed, a PR removing that replace would be the correct thing to do
I will submit a PR to do just that shortly. Thank you!!
Hi Logan, I'd appreciate it if you can review the PR: https://github.com/run-llama/llama_index/pull/16820
Appreciate it πŸ™
Add a reply
Sign up and join the conversation on Discord