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

Adding new RAG Chatbot example with llamaGuard and Alignscore integration #720

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from

Conversation

abodhankar
Copy link

LlamaGuard Alignscore Integration with RAG

@abodhankar
Copy link
Author

@drazvan for review

@drazvan drazvan self-requested a review September 3, 2024 10:25
@drazvan drazvan self-assigned this Sep 3, 2024
Copy link
Collaborator

@drazvan drazvan left a comment

Choose a reason for hiding this comment

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

Thanks, @abodhankar!

Generally, looks good. However, there are a few issues to solve before we'd be able to merge:

  • currently there is no documentation
  • the code is not a bot, so it should not be placed under examples/bots
  • given there's also an ingestion part, this would be a better fit for a notebook; the notebook would explain the goal, the ingestion part, and then adding the guardrails; you can place it in examples/notebooks;
  • the config itself (without the python files) can be placed under examples/configs; the notebook can copy it from there;
  • including a 200 pages PDF in the repository is not recommended; can this be downloaded dynamically from somewhere? You can add this part to the notebook as well.
  • only one commit seems to be signed. Please configure signing the commits as per the contributing guidelines, and then rebase on top of the develop branch.
  • make sure you link to the documentation about setting up the AlignScore server.

I'll review again once the above points have been addressed.

@abodhankar abodhankar force-pushed the rag-llamaguard-alignscore branch 2 times, most recently from a49a29b to 75118dd Compare September 4, 2024 00:30
@abodhankar abodhankar closed this Sep 6, 2024
@abodhankar abodhankar force-pushed the rag-llamaguard-alignscore branch from a40b98d to eaf9496 Compare September 6, 2024 18:48
@abodhankar abodhankar reopened this Sep 6, 2024
@abodhankar
Copy link
Author

@drazvan Made all the changes as per request.

Copy link
Collaborator

@Pouyanpi Pouyanpi left a comment

Choose a reason for hiding this comment

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

Please note that, langchain_nvidia_ai_endpoints most recent version only supports langchain 3 which is not currently supported by NeMo Guardrails. We will have it merged to the develop branch latest this week.

@abodhankar
Copy link
Author

abodhankar commented Oct 8, 2024

@Pouyanpi the example was built using the following dependencies -
langchain-nvidia-ai-endpoints==0.2.1
langchain==0.2.14
I can add a requirements.txt file. Do you want me to add the same in the 'pip' command in the notebook as well? But if by EOW the latest version compatibility is being added, It should be fine right?

@Pouyanpi
Copy link
Collaborator

Pouyanpi commented Oct 9, 2024

@abodhankar, having the requirements.txt is a good idea. If it also works with langchain 3, we can remove it.

Please run pre-commit on your files by following the instructions in the CONTRIBUTING.md.

You can then run:

pre-commit run --all-files

The pipeline is failing because of this.

Finally, make sure to sign all of your commits. If you have GPG configured, the easiest way would be to run the following after checking out this branch:

git rebase --exec 'git commit --amend --no-edit -n -S' -i origin/develop

Also make sure that the it works with the latest state of develop branch (it should). I will merge when the pipeline pass and the commits are signed. Thank you!

@Pouyanpi Pouyanpi force-pushed the rag-llamaguard-alignscore branch from a605786 to 75c40ae Compare November 6, 2024 18:17
@Pouyanpi
Copy link
Collaborator

Pouyanpi commented Nov 6, 2024

Hi @abodhankar, I can fix these minor issues (running pre-commit and signing the commits) so that we can merge the PR, would it be OK for you?

@Pouyanpi Pouyanpi force-pushed the rag-llamaguard-alignscore branch from 75c40ae to b0d9ab3 Compare November 6, 2024 18:58
@Pouyanpi Pouyanpi self-requested a review November 6, 2024 19:01
@Pouyanpi Pouyanpi requested a review from drazvan November 6, 2024 19:02
@Pouyanpi Pouyanpi removed the request for review from drazvan November 6, 2024 19:35
Comment on lines +9 to +17
sample_conversation: |
user action: user said "Hi there. Can you help me with some questions I have about NVIDIA AI Enterprise?"
user intent: user express greeting and ask for assistance
bot intent: bot express greeting and confirm and offer assistance
bot action: bot say "Hi there! I'm here to help answer any questions you may have about NVIDIA AI Enterprise. What would you like to know?"
user action: user said "What is offered by NVIDIA AI Enterprise?"
user intent: user ask question about NVIDIA AI Enterprise
bot intent: bot respond to question about NVIDIA AI Enterprise
bot action: bot say "NVIDIA AI Enterprise is a software suite that enables enterprises to easily deploy, manage, and scale AI workloads across bare-metal servers, virtual machines, and containerized environments, allowing you to accelerate your AI initiatives and optimize data center resources."
Copy link
Collaborator

Choose a reason for hiding this comment

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

This sample conversation format is for Colang 2.0. However, I see that this config does not specify the Colang version, which means it will implicitly use 1.0.

Copy link
Author

Choose a reason for hiding this comment

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

@drazvan I can mention in the Readme.md file that this is explicitly using colang1.0. Will that be good?

Copy link
Author

Choose a reason for hiding this comment

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

@drazvan Added what I suggested in the above comment

Copy link
Collaborator

Choose a reason for hiding this comment

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

@abodhankar : the point is that it doesn't make sense to include Colang 2.0 format sample conversation in a Colang 1.0 config.

model_name: "meta-llama/LlamaGuard-7b"

rails:
input:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Reformat this YAML file to use consistent indentation.

"\n",
"The following is the architecture diagram for the NIM-powered RAG pipeline that we are going to build in this tutorial using NVIDIA NIM and NeMO Guardrails.\n",
"\n",
"![Arch Diagram](https://drive.google.com/file/d/17iUW3ReMq5h5aFAb5DvZbtN8B_iEcUVf/view?usp=drive_link)\n"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This diagram is not publicly accessible. Please include the diagram in the repo, next to the notebook, if needed.

@abodhankar
Copy link
Author

@drazvan @Pouyanpi Finished doing all the changes.

@drazvan drazvan self-requested a review November 22, 2024 12:11
Copy link
Collaborator

@drazvan drazvan left a comment

Choose a reason for hiding this comment

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

  • For the architecture diagram, update the link to point to the image; it still points to the GDrive one;
  • wget may not work when running the on mac (as it was the case for me); replace with curl command
    • !curl -o ./kb/data.pdf https://docs.nvidia.com/ai-enterprise/latest/pdf/nvidia-ai-enterprise-user-guide.pdf
  • The PDF https://docs.nvidia.com/ai-enterprise/latest/pdf/nvidia-ai-enterprise-user-guide.pdf is no longer accessible
  • remove .ipynb_checkpoints folder;
  • lowercase for notebook filename for consistency with the other notebooks;
  • pypdf package needs to be installed; following the tutorial as is results in import error.
  • the formatting in the "To understand the config ...." is off (I think the parameters should be a bulleted list)
  • there are inconsistencies in the formatting of YAML snippets (the %%writefile config/config.yml sections)

@abodhankar
Copy link
Author

I have created a directory for the notebook that has the following -

  1. Arch Diagram
  2. kb
  3. final notebook

Now Let me address the comments here -

  1. For the architecture diagram, update the link to point to the image; but I still couldn't render it well it still points to the GDrive one - I wasn't able to render it properly in this in the notebook. So, added the image with the notebook.
  2. wget may not work when running the on mac (as it was the case for me); replace with curl command
    !curl -o ./kb/data.pdf https://docs.nvidia.com/ai-enterprise/latest/pdf/nvidia-ai-enterprise-user-guide.pdf

    ---- For this I checked that the pdf is moved to a different location. So, for not having future issues, I have added the kb instead.
  3. The PDF https://docs.nvidia.com/ai-enterprise/latest/pdf/nvidia-ai-enterprise-user-guide.pdf is no longer accessible
    ---- Check point 2 above
  4. Removed .ipynb_checkpoints folder - DONE
  5. lowercase for notebook filename for consistency with the other notebooks; DONE
  6. pypdf package needs to be installed; following the tutorial as is results in import error the error was because the pdf was not in the location specified before, so it re-directed to a webpage and downloaded content into pdf causing rendering issues and hence pypdf issue - SORTED NOW
  7. the formatting in the "To understand the config ...." is off (I think the parameters should be a bulleted list) - DONE
  8. there are inconsistencies in the formatting of YAML snippets (the %%writefile config/config.yml sections) - ADDRESSED

@Pouyanpi Pouyanpi added this to the v0.12.0 milestone Dec 6, 2024
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