Skip to content

Conversation

@pkhara31
Copy link

This toolkit enables developers to build, evaluate, and optimize Retrieval-Augmented Generation (RAG) applications with comprehensive quality metrics including accuracy, bias detection, and perplexity analysis plus a racial-bias indicator. This uses RAG pipeline optimized with Intel OpenVINO for enhanced performance on CPU, GPU, and NPU. The pipeline leverages:

Optimum-Intel’s OVModelForCausalLM with the OpenVINO backend for efficient inference.
LangChain for orchestration of document loading, chunking, embedding, retrieval, reranking, and generation.
Goal: Provide a portable notebook-driven workflow for rapid experimentation, model comparison, and validation of RAG systems on custom/private corpora.

…. The toolkit computes standard metrics (BERT, BLEU, ROUGE, perplexity score) and a racial-bias indicator, and it is implemented using Optimum-Intel’s OVModelForCausalLM with the OpenVINO backend and LangChain for orchestration.
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@sbalandi
Copy link
Collaborator

Hi @pkhara31 , the notebook https://github.com/openvinotoolkit/openvino_notebooks/blob/latest/notebooks/llm-rag-langchain/llm-rag-langchain.ipynb seems to cover the same tasks you described in comment. Could you please check ? Does this match your idea of ​​the notebook you wanted to add ?
Let's discuss this point and leave only something new in this notebook or update the existing notebook

@pkhara31
Copy link
Author

Hi @sbalandi , This NB covers the methodology to evaluate the performance of RAG pipeline by computing the BERT, BLEU, ROGUE, perplexity, racial bias scores.
This notebook also provides ability to scrap web URLs and implement RAG pipeline on the web content as well.
These are the key deltas & additions to the existing notebook on RAG.
Let me know if any more questions!

@openvino-dev-samples
Copy link
Collaborator

openvino-dev-samples commented Nov 20, 2025

Thanks for your contribution @pkhara31 Do you think if we can add this NB to RAG notebook, as a separate .ipynb, so users can directly evaluate their RAG system with selected models in your pipeline ?

@openvinotoolkit openvinotoolkit deleted a comment from pkhara31 Nov 20, 2025
@openvino-dev-samples
Copy link
Collaborator

openvino-dev-samples commented Nov 20, 2025

Another idea is to change this .ipynb to an evaludation_helper.py which can be called inside current NB, and users can evaluate the RAG pipeline without loading the model again. Whats your thought ? @pkhara31

@pkhara31
Copy link
Author

The model loading redundancy can be avoided, but I think the evaluation and the ability to apply RAG pipeline on web docs (scraping) should still remain in the helper.

@pkhara31
Copy link
Author

pkhara31 commented Dec 1, 2025

May I know the latest update on this?

@sbalandi
Copy link
Collaborator

sbalandi commented Dec 1, 2025

May I know the latest update on this?

Hi, sorry for the delay, I'm in the process of reviewing notebook, I'll write comments within a week

langchain_community
msoffcrypto-tool
docx2txt
urllib
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we need urllib , os , typing here as os/typing are build in modules
also, please, move requiremetns to notebook and use pip_install(), please, check example in https://github.com/openvinotoolkit/openvino_notebooks/blob/latest/notebooks/llm-rag-langchain/llm-rag-langchain.ipynb , Prerequisites section

@@ -0,0 +1,662 @@
{
Copy link
Collaborator

@sbalandi sbalandi Dec 5, 2025

Choose a reason for hiding this comment

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

Why these modules needed ?

Please, add openvino, "optimum[openvino,nncf,onnxruntime]"


Reply via ReviewNB

@@ -0,0 +1,662 @@
{
Copy link
Collaborator

@sbalandi sbalandi Dec 5, 2025

Choose a reason for hiding this comment

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

we can use pre-converted model here https://huggingface.co/OpenVINO/Phi-3-mini-4k-instruct-int4-ov

also, please, save model via model.save_pretrained("ov_model")


Reply via ReviewNB

@@ -0,0 +1,662 @@
{
Copy link
Collaborator

@sbalandi sbalandi Dec 5, 2025

Choose a reason for hiding this comment

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

embedding_model_name = "BAAI/bge-small-en-v1.5"

It would be also great to save the model so you don't have to download it every time

embedding = OpenVINOBgeEmbeddings(
    model_name_or_path=embedding_model_name,
    model_kwargs=embedding_model_kwargs,
    encode_kwargs=encode_kwargs,
)

Reply via ReviewNB

@@ -0,0 +1,662 @@
{
Copy link
Collaborator

@sbalandi sbalandi Dec 5, 2025

Choose a reason for hiding this comment

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

Line #11.        response = urlopen(req)

I haven't managed to load it on linux, but looks like on windows works well. Did you check it on Linux ?


Reply via ReviewNB

@pkhara31
Copy link
Author

pkhara31 commented Dec 8, 2025

@sbalandi I have made the suggested changes, can you please have a look once? I did not get to check it on Linux. Please let me know.

@openvino-dev-samples
Copy link
Collaborator

openvino-dev-samples commented Dec 12, 2025

Another idea is to change this .ipynb to an evaludation_helper.py which can be called inside current NB, and users can evaluate the RAG pipeline without loading the model again. Whats your thought ? @pkhara31

Hi @pkhara31 any feedback on this idea? Would you mind to consolidate this notebook into RAG notebook. Please let me know your concern.

@pkhara31
Copy link
Author

Another idea is to change this .ipynb to an evaludation_helper.py which can be called inside current NB, and users can evaluate the RAG pipeline without loading the model again. Whats your thought ? @pkhara31

Hi @pkhara31 any feedback on this idea? Would you mind to consolidate this notebook into RAG notebook. Please let me know your concern.

Yes, I think it should be OK.

@pkhara31
Copy link
Author

Any updates here? @sbalandi

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

This PR will be closed in a week because of 2 weeks of no activity.

@github-actions github-actions bot added the Stale label Jan 6, 2026
@pkhara31
Copy link
Author

pkhara31 commented Jan 6, 2026

Do we have any updates on this PR/next steps ? @sbalandi

@github-actions github-actions bot removed the Stale label Jan 7, 2026
@sbalandi
Copy link
Collaborator

sbalandi commented Jan 15, 2026

Hi, @pkhara31 thank you for the changes ! they look good for me, but further checks and review are transferred to @openvino-dev-samples , please, contact him for any questions

FYI @aleksandr-mokrov

@openvino-dev-samples
Copy link
Collaborator

hi @pkhara31 thanks for your update, and how about moving this notebook into [notebooks/llm-rag-langchain] instead of [notebooks/llm-rag-ov-langchain]. Then you can also merge the README into existing one.

@pkhara31
Copy link
Author

Hi @openvino-dev-samples , I am already aligned to move this notebook into llm-rag-langchain, but may I know if that is something you would help out?

Thanks.

@openvino-dev-samples
Copy link
Collaborator

Hi @openvino-dev-samples , I am already aligned to move this notebook into llm-rag-langchain, but may I know if that is something you would help out?

Thanks.

Thanks. It generally looks good to me, but I would like to test it with my local environment if you could help to move it, then I can give you detailed feedback.

Added a notebook (.ipynb) code to evaluate the effectiveness of the RAG by computing standard metrics to evaluate the RAG performance.
Update README.md with the steps to execute the RAG evaluation notebook.
@@ -0,0 +1,1597 @@
{
Copy link
Collaborator

@openvino-dev-samples openvino-dev-samples Jan 17, 2026

Choose a reason for hiding this comment

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

Please update the format of Table of contents. You can refer to other notebooks


Reply via ReviewNB

@@ -0,0 +1,1597 @@
{
Copy link
Collaborator

@openvino-dev-samples openvino-dev-samples Jan 17, 2026

Choose a reason for hiding this comment

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

Line #31.        "openvino-genai==2025.4.0.0",

I think openvino-genai will not be used in this notebook ? Please help to remove the unused dependencies.


Reply via ReviewNB

@@ -0,0 +1,1597 @@
{
Copy link
Collaborator

@openvino-dev-samples openvino-dev-samples Jan 17, 2026

Choose a reason for hiding this comment

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

Line #9.        device="GPU"  # Specify GPU for inference, can also be "CPU"

Please let user to select the device. Otherwise this notebook will be unavailable for platform without GPU. You can refer copy this part from other notebooks.


Reply via ReviewNB

@@ -0,0 +1,1597 @@
{
Copy link
Collaborator

@openvino-dev-samples openvino-dev-samples Jan 17, 2026

Choose a reason for hiding this comment

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

Line #31.            model_id = "meta-llama/Llama-2-7b-hf"

As Llama2 will require an agreement from Meta for model downloading, there would extra step for users. Would you mind to change to another model, e.g Phi4 Qwen3 ?


Reply via ReviewNB

@@ -0,0 +1,1597 @@
{
Copy link
Collaborator

@openvino-dev-samples openvino-dev-samples Jan 17, 2026

Choose a reason for hiding this comment

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

Line #303.            device="GPU",  # or "GPU" for Intel integrated graphics

Please let user to select device


Reply via ReviewNB

"\n",
"pip_install(\"--pre\", \"-U\", \"openvino==2025.4.0\", \"--extra-index-url\", \"https://storage.openvinotoolkit.org/simple/wheels/nightly\")\n",
"pip_install(\"--pre\", \"-U\", \"openvino-tokenizers==2025.4.0.0\", \"--extra-index-url\", \"https://storage.openvinotoolkit.org/simple/wheels/nightly\")\n",
"pip_install(\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"pip_install(\n",
"pip_install(\n",
" \"--q\",\n",

Copy link
Collaborator

Choose a reason for hiding this comment

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

remove the long output

"\n",
"#Usage Example:\n",
"loader = LocalDocumentLoader(directory_path=\"content\")\n",
"docs = loader.load()\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I got this error when running this line of code, could you help to check ?
image

Copy link
Author

Choose a reason for hiding this comment

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

The user needs to replace the "content" directory with their local directory name.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please set a default folder in this case, and do not let user manually create it

@pkhara31
Copy link
Author

@openvino-dev-samples Can you please take a look again, I have addressed the above feedback.

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