i-dot-ai / caddy-chatbot

Caddy is an AI powered co-pilot for customer service functions everywhere.
https://ai.gov.uk/projects/caddy/
MIT License
14 stars 4 forks source link

STORY - Improve used of structured outputs between LLM calls #173

Open AndreasThinks opened 3 weeks ago

AndreasThinks commented 3 weeks ago

We currently mostly pass raw LLM outputs, and would benefit from adding more structure to our outputs.

alexmoore-iai commented 3 weeks ago

Goal: Formalise output structures of different Caddy LLM calls so that different pieces of information can be handled programmatically, allowing for more specific prompt curation.

  1. First step would be to update Rewording of advisor message (see link) so that it returns a JSON output, with the following keys:
    • Legal Topic
    • Important keywords
    • Specific Questions asked in the query
    • Previous attempts to answer question (useful for negative reasoning)
    • Personal information (i.e. age, nationality)
  2. RAG Retrieval should then be updated to only use relevant keys in this JSON object:
    • Modify the RAG retrieval algorithm to prioritise the 'Legal Topic' and 'Specific Questions' fields
    • Create a feedback loop to refine the retrieval process based on the relevance of returned information
  3. It could be possible to replace semantic routing with this step, as legal topic could automatically be used to switch between different prompt templates Implementation details:
    • Create a mapping between 'Legal Topic' categories and corresponding prompt templates
    • Could include examples in the prompt to mimic current semantic routing logic.
  4. Other important fields could be fed into the final Caddy prompt to improve output. I.e. “previous attempt to answer question” could be explicitly ignored, preventing negative reasoning. Implementation details:
    • Integrate 'Previous attempts to answer question' into the prompt construction process, using it to guide the LLM away from repeated or ineffective approaches
    • Incorporate 'Personal information' to tailor responses to the user's specific context

Benefits: