Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arjbingly committed Mar 26, 2024
2 parents 3560fc8 + 34e7d73 commit c18390a
Show file tree
Hide file tree
Showing 18 changed files with 882 additions and 266 deletions.
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# GRAG
<h1 align="center">GRAG</h1>

[![License: AGPL v3](https://img.shields.io/badge/License-AGPL_v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
![Static Badge](https://img.shields.io/badge/docstring%20style-google-pink?labelColor=white)
![Static Badge](https://img.shields.io/badge/linter-ruff-yellow?labelColor=white)
![Docs](https://img.shields.io/github/actions/workflow/status/arjbingly/Capstone_5/ruff_linting.yml)
![Static Badge](https://img.shields.io/badge/buildstyle-hatchling-purple?labelColor=white)
![Static Badge](https://img.shields.io/badge/codestyle-pyflake-purple?labelColor=white)
![GitHub Issues or Pull Requests](https://img.shields.io/github/issues-pr/arjbingly/Capstone_5)


## Project Overview

Expand Down
13 changes: 0 additions & 13 deletions projects/Basic-RAG/BasciRAG_CustomPrompt.py

This file was deleted.

87 changes: 0 additions & 87 deletions projects/Basic-RAG/BasicRAG-ingest_data.py

This file was deleted.

14 changes: 14 additions & 0 deletions projects/Basic-RAG/BasicRAG_CustomPrompt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""A cookbook demonstrating how to use custom prompts with Basic RAG."""

from grag.components.prompt import Prompt
from grag.rag.basic_rag import BasicRAG

custom_prompt = Prompt(
input_keys={"context", "question"},
template="""Answer the following question based on the given context.
question: {question}
context: {context}
answer:
""",
)
rag = BasicRAG(doc_chain="stuff", custom_prompt=custom_prompt)
25 changes: 13 additions & 12 deletions projects/Basic-RAG/BasicRAG_FewShotPrompt.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
"""A cookbook demonstrating how to use custom few-shot prompts with Basic RAG."""

from grag.components.prompt import FewShotPrompt
from grag.rag.basic_rag import BasicRAG
from grap.components.prompt import FewShotPrompt

custom_few_shot_prompt = FewShotPrompt(
input_keys={"context", "question"},
output_keys={"answer"},
example_template='''
example_template="""
question: {question}
answer: {answer}
''',
prefix='''Answer the following question based on the given context like examples given below:''',
suffix='''Answer the following question based on the given context
""",
prefix="""Answer the following question based on the given context like examples given below:""",
suffix="""Answer the following question based on the given context
question: {question}
context: {context}
answer:
''',
""",
examples=[
{
"question": "What is the name of largest planet?",
"answer": "Jupiter is the largest planet."
"answer": "Jupiter is the largest planet.",
},
{
"question": "Who came up with Convolutional Neural Networks?",
"answer": "Yann LeCun introduced convolutional neural networks."
}
]
"answer": "Yann LeCun introduced convolutional neural networks.",
},
],
)
rag = BasicRAG(doc_chain="stuff",
custom_prompt=custom_few_shot_prompt)
rag = BasicRAG(doc_chain="stuff", custom_prompt=custom_few_shot_prompt)
13 changes: 13 additions & 0 deletions projects/Basic-RAG/BasicRAG_ingest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""A cookbook demonstrating how to ingest pdf files for use with Basic RAG."""

from pathlib import Path

from grag.components.multivec_retriever import Retriever
from grag.components.vectordb.deeplake_client import DeepLakeClient

client = DeepLakeClient(collection_name="test")
retriever = Retriever(vectordb=client)

dir_path = Path(__file__).parents[2] / "data/client_test/test/"

retriever.ingest(dir_path)
8 changes: 7 additions & 1 deletion projects/Basic-RAG/BasicRAG_refine.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
from grag.grag.rag import BasicRAG
"""A cookbook demonstrating how to use Basic RAG with refine chain using DeepLake as client."""

from grag.components.multivec_retriever import Retriever
from grag.components.vectordb.deeplake_client import DeepLakeClient
from grag.rag.basic_rag import BasicRAG

client = DeepLakeClient(collection_name="test")
retriever = Retriever(vectordb=client)
rag = BasicRAG(doc_chain="refine")

if __name__ == "__main__":
Expand Down
2 changes: 2 additions & 0 deletions projects/Basic-RAG/BasicRAG_stuff.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""A cookbook demonstrating how to use Basic RAG with stuff chain using DeepLake as client."""

from grag.components.multivec_retriever import Retriever
from grag.components.vectordb.deeplake_client import DeepLakeClient
from grag.rag.basic_rag import BasicRAG
Expand Down
42 changes: 0 additions & 42 deletions projects/Basic-RAG/BasicRAG_v1_depricated.py

This file was deleted.

52 changes: 0 additions & 52 deletions projects/Basic-RAG/BasicRAG_v2_depricated.py

This file was deleted.

19 changes: 11 additions & 8 deletions projects/Basic-RAG/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# Basic RAG
# Basic RAG Cookbook

## BasicRAG v1
Welcome to the Basic RAG Cookbook! This repository is dedicated to showcasing how to utilize the Retrieval-Augmented
Generation (RAG) model for various applications using custom and few-shot prompts. For in depth understanding of RAG
pipelines, chains, and prompts
check [RAG-Piplines.md](https://github.com/arjbingly/Capstone_5/blob/main/projects/Basic-RAG/RAG-Piplines.md)

- Stuff document chain (Refer [RAG-Pipelines.md](./RAG-Piplines.md))
- Top-k retrival
### Contents:

## BasicRAG v2

- Refine document chain (Refer [RAG-Pipelines.md](./RAG-Piplines.md))
- Top-k retrival
- **BasicRAG_CustomPrompt.py**: Learn to integrate custom prompts into Basic RAG for tailored query responses.
- **BasicRAG_FewShotPrompt.py**: Explore the use of few-shot prompts to enhance Basic RAG's contextual understanding.
- **BasicRAG_ingest.py**: Demonstrates the process of ingesting PDF files, making them searchable via Basic RAG.
- **BasicRAG_stuff.py**: A guide on leveraging the stuff chain with Basic RAG for enriched data processing.
- **BasicRAG_refine.py**: Discover how to refine queries using the refine chain for more precise results with Basic RAG.
12 changes: 0 additions & 12 deletions projects/Basic-RAG/tests/BasicRAG_v1_test.py

This file was deleted.

12 changes: 0 additions & 12 deletions projects/Basic-RAG/tests/BasicRAG_v2_test.py

This file was deleted.

Loading

0 comments on commit c18390a

Please sign in to comment.