Skip to main content

Tips To Improve LLM-Based Applications

Large Language Models (LLMs) are powerful AI systems that can understand and generate natural language. They have many applications in various domains, such as natural language processing, machine translation, and healthcare. However, building LLM-based applications is not a trivial task. It requires careful consideration of several factors, such as the choice of the LLM, the data quality, the evaluation metrics, and the ethical implications. 

In this blog post, I will share some tips to solve most common problems.

How to extract correct content from LLM

Problem says that, although the answer is present in the content, but model fails to extract that.  Here are the quick tips to resolve this problem:

  • Prompt compression
  • Remove irrelevant data
  • Rectify typos and grammatical errors
  • Remove duplicate data
  • Use data cleaning libraries

Problem of missing top ranked documents

Problem states that correct document was not rankled while ranking the documents. Here are the few suggestions, which can help you in solving this problem:

  • Increase the value of k
  • Experiment with chunk size
  • Use multiple retrievers
  • Use query augmentation
  • Reranking
  • Prompt optimization
  • Use model with high context length

How to get correct output format for response from LLM

Problem statement says, user is not getting the output in the format as mentioned in the question, i.e. list, table, etc. There are many ways to achieve this. Here are few you can try:

  • Write clear and concise instructions
  • Provide reference text via zero-shot, few-shot or fine-tuning
  • Test with multiple prompts
  • Split complex tasks
  • Understand LLM's output format
  • Use output parsers from LangChain, Llama-Index, etc.
  • Use text formatting libraries like pydantic


I hope, these tips will help you to build LLM-based applications that are not only powerful and versatile, but also reliable and ethical. LLM-based applications have a lot of potential to transform various domains and industries, and we are excited to see what you can create with them.