Giter Club home page Giter Club logo

chain-of-verification's Introduction

β›“ chain-of-verification πŸ’‘

How Chain-of-Verification (CoVe) works and how to implement it using Python 🐍 + Langchain πŸ”— + OpenAI 🦾 + Search ToolΒ πŸ”

πŸ“„ Article: I highly recommend reading this article before diving into the code.

Architecture

CoVe_Architecture

πŸš€ Getting Started

  1. Clone the Repository
  2. Install Dependencies:
    python3 -m pip install -r requirements.txt
  3. Set Up OpenAI API Key:
    export OPENAI_API_KEY='sk-...'
  4. Run the Program:
    cd src/
    python3 main.py --question "Who are some politicians born in Boston?"

πŸ›  Other Arguments

python3 main.py --question "Who are some politicians born in Boston?" --llm-name "gpt-3.5-turbo-0613" --temperature 0.1 --max-tokens 500 --show-intermediate-steps
  • --question: This is the original query/question asked by the user
  • --llm-name: The OpenAI model name the user wants to use
  • --temperature: You know it πŸ˜‰
  • --max-tokens: Tou know it as well πŸ˜‰
  • --show-intermediate-steps: Activating this will alow printing of the intermediate results such as baseline response, verification questions and answers.

Few ways to improve

This implementation provides a comprehensive guide for you to modify according to your need and use case. Although below are some of the ideas you can employ to make it more robust and effective.

  1. Prompt Engineering: One of the major ways to improve performances of any LLM powered applications is through prompt engineering and prompt optimizations. You can check all the prompts used in the prompts.py file. Try your own prompt engineering and experiment in your use case.
  2. External Tools: As the final output highly depends on the answers of the verification questions, based on different use cases you can try out different tools. For factual questions & answering you can use advanced search tools like google search or serp API etc. For custom use cases you can always use RAG methods or other retrieval techniques for answering the verification questions.
  3. More Chains: I have implemented three chains according to the three question types (Wiki Data, Mutli-Span QA & Long-Form QA) the authors have used for their research. Depending on your use case you can create other chains which can handle other types of QA methods to increase the variabilty.
  4. Human In Loop (HIL): HIL is one of the important steps in many LLM powered applications. In your specific applications, the whole pipeline can be designed to incorporate HIL either for generating proper verification questions or answering verification questions to further improve the overall CoVe pipeline.

❀️ If this repository helps, please star ⭐, and share βœ”οΈ!
If you also found the article informative and think it could be beneficial to others, I'd be grateful if you could like πŸ‘, follow πŸ‘‰, and shareβœ”οΈ the piece with others.
Happy coding!

chain-of-verification's People

Contributors

ritun16 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.