https://retellai.com/?utm_source=discord&utm_medium=seo logo
is there a way to make sure that the LLM will alwa...
# ❓・ai-evy-support
b
@AI Evy is there a way to make sure that the LLM will always call to fetch information from the knowledge base? There are times that it skips the process and halucinates results.
a
Thanks for tagging me @Bobster2002. I'll look through relevant sources and get back to you shortly.
### Answer --- Yes, you can add specific prompt instructions to prevent the LLM from generating information not found in the knowledge base. Add the following to your agent's prompt: [(1) ]()
Copy code
Only answer using the information in ## Related Knowledge Base Contexts.
If ## Related Knowledge Base Contexts is missing or does not contain relevant information, respond:
"There is no related information in knowledge base."
This instructs the agent to only use retrieved knowledge base content and explicitly state when information isn't available rather than hallucinating. Additional tips from the community: - The model you're using can affect accuracy—certain models have higher context windows (GPT 4.1 has ~1M tokens vs GPT 4o's 128K) [(2) ]() - Consider splitting large documents into smaller, organized sections with specific names - Make your system prompt concise and to the point, and properly label possible questions & answers in your knowledge base [(3) ]() You can also configure
kb_config
parameters like
top_k
(number of results) and
filter_score
(relevance threshold) to tune retrieval behavior. [(2) ]()
​ To learn more, see the sources I considered: [[1] Knowledge Base](https://docs.retellai.com/build/knowledge-base) [[2] Discord message from @leo_poeppel_74864 on 2025-05-07](https://discord.com/channels/1186424376300679209/1186462578310910112/1369575933668888590) [[3] Knowledge base retrieval not working](https://discord.com/channels/1186424376300679209/1311001039109095484) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
b
How is knowledgebase retrieval working in retell? @AI Evy
a
### Answer Knowledge base retrieval in Retell works as follows: How it works: - During knowledge base creation, sources are chunked, embedded, and stored in a vector database. [(1) ]() - When the agent is about to respond during a call, it uses the transcript so far (prompt is not included) to find the most relevant chunks from the knowledge base. - These chunks are then fed to the LLM as context. - Retrieved knowledge base content is appended to the LLM prompt under the header
## Related Knowledge Base Contexts
. Key points: - There's no need to change your prompt for retrieval to trigger—it happens automatically for every response generation when a knowledge base is linked to an agent. - Retrieval latency is optimized for real-time use cases and should generally be under 100ms. Configurable settings: - **Chunks to retrieve**: Max number of chunks to retrieve (range 1-10, default: 3) . - **Similarity Threshold**: Controls how strict matching is—higher values give fewer but more similar matches (default: 0.6) . Best practices for better retrieval: - Prefer
.md
(Markdown) files over `.txt`—well-structured Markdown is chunked and retrieved more accurately. - Use clear, descriptive headings and keep sections focused and reasonably short. - Avoid ambiguity; include names, dates, units, and avoid ambiguous pronouns like "it" or "this" since prior chunks may not be present.
Thanks for the follow-up, @Bobster2002. I'll get back to you soon.
​ To learn more, see the sources I considered: [[1] Knowledge Base](https://docs.retellai.com/build/knowledge-base) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
b
@AI Evy why does retrival happens sometimes, and sometimes it does not?
a
Thanks for the follow-up, @Bobster2002. I'll get back to you soon.
### Answer ### Answer Knowledge base retrieval can be inconsistent for several reasons: How retrieval works: The agent uses the transcript so far to find the most relevant chunks from the knowledge base. [(1) ]() This means retrieval depends on what's been said in the conversation—if the transcript doesn't contain terms that match well with your knowledge base content, retrieval may not return relevant results. Common causes of inconsistent retrieval: 1. Similarity threshold filtering - Retrieved chunks must meet a relevance threshold (default: 0.6) . If the conversation context doesn't closely match your KB content, chunks may be filtered out. 2. How you phrase questions matters - Community members have reported that the same question asked differently can yield different retrieval results. [(2) ]() 3. URL sources vs uploaded files - Some users have reported that web page URLs are not being crawled/indexed correctly, while uploaded documents work as expected. [(3) ]() 4. Test LLM vs actual calls - Testing via "Test LLM" (text chat) may behave differently than audio calls. One user noted: "the test 'chat LLM' barely hits the knowledge base at all…test audio is better and the best is when deployed to a number." [(2) ]() 5. Document formatting - Prefer
.md
(Markdown) files with clear, descriptive headings and short, focused sections. Avoid ambiguous pronouns like "it" or "this" since prior chunks may not be present. [(1) ]() Recommendations: - Ensure your knowledge base status shows "complete" rather than "in_progress" or "error"
[(4) ]() - Keep prompts concise and properly label questions & answers in your knowledge base [(2) ]() - If using URLs, verify they're being indexed correctly—consider using uploaded files instead [(3) ]()
​ To learn more, see the sources I considered: [[1] Knowledge Base](https://docs.retellai.com/build/knowledge-base) [[2] Knowledge base retrieval not working](https://discord.com/channels/1186424376300679209/1311001039109095484) [[3] Knowledge base retrieval is not happening](https://discord.com/channels/1186424376300679209/1352014353922002975) [[4] List Knowledge Bases](https://docs.retellai.com/api-references/list-knowledge-bases) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
b
@Colin - Integrations @ Retell AI @Omar Ashraf | Community Lead why is knowledge base working with transcript only? Can I not use an prompt to fetch specific information form my knowledge base? If not that should be a feature. Because sometimes I want to be searching up information to give as suggestions, when the user hasn't explicitly mentioned any keywords that is in the database.