Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chain-of-Verification - Prompt Engineering #29

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Ankush-lastmile
Copy link

Chain-of-Verification - Prompt Engineering

Chain-of-Verification is a prompt engineering technique to reduce hallucinations from LLMs!

Research Paper (Meta AI): https://arxiv.org/pdf/2309.11495.pdf

This recipe uses AIConfig - an open-source config-based framework for building generative AI applications.

https://github.com/lastmile-ai/aiconfig/tree/main

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@Ankush-lastmile Ankush-lastmile marked this pull request as ready for review February 16, 2024 19:26
@Ankush-lastmile
Copy link
Author

Ankush-lastmile commented Feb 16, 2024

Hi @MKhalusova! Would love a review for this recipe. Thanks!

notebooks/en/chain_of_verification.ipynb Show resolved Hide resolved
@@ -0,0 +1,470 @@
{
Copy link
Contributor

@MKhalusova MKhalusova Feb 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line #2.    import openai

As this is an open source ai cookbook, let's illustrate this technique with an open source model. From the readme, I can see that these models should be supported:


Reply via ReviewNB

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the model usage to use The Mixtral-8x7B-Instruct-v0.1, thanks for the suggestion!

@@ -0,0 +1,470 @@
{
Copy link
Contributor

@MKhalusova MKhalusova Feb 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be helpful to explain the config a little bit here. At least its essential components. Maybe add some advice on the structure/content of the prompts?


Reply via ReviewNB

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a description and links

notebooks/en/chain_of_verification.ipynb Show resolved Hide resolved
notebooks/en/chain_of_verification.ipynb Show resolved Hide resolved
notebooks/en/chain_of_verification.ipynb Show resolved Hide resolved
@@ -0,0 +1,470 @@
{
Copy link
Contributor

@MKhalusova MKhalusova Feb 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line #3.    verification_question =  "Where was this coding language developed: {{entity}}?"

How do we choose the verification question?


Reply via ReviewNB

notebooks/en/chain_of_verification.ipynb Show resolved Hide resolved
@MKhalusova
Copy link
Contributor

MKhalusova commented Feb 19, 2024

A really interesting prompting technique! Thanks for adding! I left some feedback on the notebook, mainly - let's switch to an open source model (I saw that Mistral and Llama are supported), and remove unnecessary TODOs.

In order to publish the notebook, a few more steps are needed:

  • Add the notebook to the _toctree.yml
  • Add the notebook to the list of the latest notebooks in the index.md. As this is the most recent addition, put it at the top of the list.
  • Right after the first header (notebook title), add yourself as an author, like this: _Authored by: [Your Name](https://huggingface.co/your_profile)_ Feel free to use either your Hugging Face profile, or GitHub profile, it's up to you which one to link.

@MKhalusova
Copy link
Contributor

Once you address this feedback, I'll be able to check if the notebook renders and runs correctly, and if it does, we should be able to merge.

Chain-of-Verification is a prompt engineering technique to reduce hallucinations from LLMs!

Research Paper (Meta AI): https://arxiv.org/pdf/2309.11495.pdf

This recipe uses AIConfig - an open-source config-based framework for building generative AI applications.

https://github.com/lastmile-ai/aiconfig/tree/main
@Ankush-lastmile
Copy link
Author

Ankush-lastmile commented Feb 21, 2024

  • switched model usage to Mixtral
  • rebase to main
  • removed Todos
  • added descriptions
  • updated index.md & _toctree.yml

@Ankush-lastmile
Copy link
Author

Hi @MKhalusova! Thanks for the review and the detailed comments. I've gone ahead and addressed your comments, as well as made the necessary changes you've requested. It would be great if you could take another look.

Thanks!

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@@ -0,0 +1,490 @@
{
Copy link
Contributor

@MKhalusova MKhalusova Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: GitHub (H should be capitalized)


Reply via ReviewNB

@@ -0,0 +1,490 @@
{
Copy link
Contributor

@MKhalusova MKhalusova Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph can be much shorter:

The next code cell sets up a 'CoVe prompt template' within a structure known as AIConfig. AIConfig is a data format to organize prompt templates and specific model settings. To create a config you can either:

* Generate it using the AIConfig Vscode Extension, or

* Download the config here and load it with:

config = AIConfigRuntime.load('cove_template_config.json').


Reply via ReviewNB

@@ -0,0 +1,490 @@
{
Copy link
Contributor

@MKhalusova MKhalusova Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line #7.          "baseline_prompt": "Name 20 programming languages that were developed in the United States. Include the developer name in parantheses.",

minor, typo: it should be "parentheses"


Reply via ReviewNB

@@ -0,0 +1,490 @@
{
Copy link
Contributor

@MKhalusova MKhalusova Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line #1.    # verification_question = "Where was {{entity}} born?"

I think you can remove this comment


Reply via ReviewNB

@@ -0,0 +1,490 @@
{
Copy link
Contributor

@MKhalusova MKhalusova Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line #10.        verification_completion = await config.run("verification", params, options=inference_options)

I'm getting an error on this line:

UnwrapError: Called Result.unwrap() on an Err value: "Missing API key 'OPENAI_API_KEY' in environment"

Reply via ReviewNB

@@ -0,0 +1,490 @@
{
Copy link
Contributor

@MKhalusova MKhalusova Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line #5.    # Display with Markdown

There seems to be an issue rendering this output. Let's switch to a simple print.


Reply via ReviewNB

@MKhalusova
Copy link
Contributor

MKhalusova commented Feb 21, 2024

Thank you for iterating on the cookbook notebook! I found a few typos and minor issues, but there's also an important one - the notebook throws an error:
UnwrapError: Called Result.unwrap()on anErr value: "Missing API key 'OPENAI_API_KEY' in environment"

Let's make sure it runs smoothly without errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants