Skip to content

Instantly share code, notes, and snippets.

@mattflo
Created September 11, 2023 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattflo/c95909be50d495cfff4b100df592239b to your computer and use it in GitHub Desktop.
Save mattflo/c95909be50d495cfff4b100df592239b to your computer and use it in GitHub Desktop.
Building a conversational recommender system with LangChain and OpenAI

Building a conversational recommender system with LangChain and OpenAI

Denver-Boulder AI Tinkerers Meetup - September 12th, 2023

I'll explain how we built a virtual concierge for one of the largest hotel chains in the world. We set out to create a chatbot with three main goals:

  1. Style: Use brand voice.
  2. Content: Recommend highly curated niche "finds" to explore in the area.
  3. Safety: Prevent the chatbot from talking about sensitive topics.

Tools and Techniques

  • Chaining prompts: There are ~20 different prompts and ~15 unique paths through the system.
  • Message classification: At the beginning of the chain messages are classified to route them appropriately.
  • Self evaluation: Evaluation prompts are run in the chain to evaluate if a reply is good. If it isn't, we branch to a hallucination prevention prompt.
  • Tracing and debugging: LangSmith and Chainlit offer visibility into each chain run's details, allowing us to identify problem areas and experiment with prompt improvements.
  • Example selector via embeddings: The most relevant examples (few shot) from a corpus are selected using embeddings and similarity to the incoming message.
  • Pinecone hybrid search: Pinecone hybrid search is used to find the most relevant places/activities to recommend.
  • Chat history summarization: Current and previous messages are passed through a prompt to summarize intent that may have been expressed over multiple messages.
  • Retrieval augmented generation: A markdown document full of hotel details enables the chatbot to answer specific questions about the property.

Who is this for?

This project demonstrates many techniques and tools helpful in building unique chat experiences on top of LLMs. I've learned much working on it, and I hope others will find this information interesting and valuable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment