diff --git a/ci/branch_Jenkinsfile b/ci/branch_Jenkinsfile new file mode 100644 index 0000000..ce070f8 --- /dev/null +++ b/ci/branch_Jenkinsfile @@ -0,0 +1,120 @@ +pipeline { + agent any + + options{ + skipDefaultCheckout(true) + } + environment { + PYTHONPATH = "${env.WORKSPACE}/.venv/bin" + CUDACXX = '/usr/local/cuda-12/bin/nvcc' + CMAKE_ARGS = "-DLLAMA_CUBLAS=on" + PATH="/usr/local/cuda-12.3/bin:$PATH" + LD_LIBRARY_PATH="/usr/local/cuda-12.3/lib64:$LD_LIBRARY_PATH" + GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=accept-new" + } + + + stages { + stage('Checkout') { + steps { + cleanWs() + checkout scm + } + } + + stage('Create venv'){ + steps { + sh 'python3 -m venv .venv' + } + } + + stage('Install dependencies'){ + steps { + withPythonEnv(PYTHONPATH){ + sh 'pip install -e .' + } + } + + } + + stage('Config'){ + steps{ + withPythonEnv(PYTHONPATH){ + sh 'python3 ci/modify_config.py' + sh 'rm -rf $JENKINS_HOME/ci_test_data/data/vectordb/ci_test' + sh 'cp -r $JENKINS_HOME/ci_test_data/data/backup_vectordb/ci_test $JENKINS_HOME/ci_test_data/data/vectordb' + } + } + } + + stage('Linting'){ + steps { + withPythonEnv(PYTHONPATH){ + sh 'pip install ruff' + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE'){ + sh 'ruff check . --exclude *venv* --output-format junit -o ruff-report.xml' + sh 'ruff format .' + } + } + } + post { + always{ + withChecks('Lint Checks'){ + junit 'ruff-report.xml' + } + } + } + } + + stage('Static type check'){ + steps { + withPythonEnv(PYTHONPATH){ + sh 'pip install mypy' + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE'){ + sh 'python3 -m mypy -p src.grag --junit-xml mypy-report.xml' + } + } + } + post { + always{ + withChecks('Static Type Checks'){ + junit 'mypy-report.xml' + } + } + } + } + + stage('Tests'){ + steps{ + sh 'docker pull chromadb/chroma' + sh 'docker run -d --name jenkins-chroma -p 8000:8000 chromadb/chroma' + withPythonEnv(PYTHONPATH){ + sh 'pip install pytest' + sh 'python3 ci/unlock_deeplake.py' + sh 'pytest src -vvv --junitxml=pytest-report.xml' + } + } + post { + always{ + sh 'docker stop jenkins-chroma' + sh 'docker rm jenkins-chroma' + withChecks('Integration Tests'){ + junit 'pytest-report.xml' + } + } + } + } + } + post { + cleanup{ + cleanWs( + cleanWhenNotBuilt: false, + deleteDirs: true, + disableDeferredWipeout: true, + notFailBuild: true, + patterns: [[pattern: '.gitignore', type: 'INCLUDE'], + [pattern: '.propsfile', type: 'EXCLUDE']] + ) + } + } +} diff --git a/cookbook/Basic-RAG/BasicRAG_refine.py b/cookbook/Basic-RAG/BasicRAG_refine.py index 85b640a..dffe7bd 100644 --- a/cookbook/Basic-RAG/BasicRAG_refine.py +++ b/cookbook/Basic-RAG/BasicRAG_refine.py @@ -1,6 +1,9 @@ """Refine Chain ======================= This cookbook demonstrates how to use the refine chain for BasicRAG. +.. image:: src/docs/_static/refine_chain_langchain_illustration.jpg + :width: 400 + :alt: Refine Documents Chain Process """ from grag.components.multivec_retriever import Retriever diff --git a/cookbook/Basic-RAG/BasicRAG_stuff.py b/cookbook/Basic-RAG/BasicRAG_stuff.py index fa177f5..26d1f2c 100644 --- a/cookbook/Basic-RAG/BasicRAG_stuff.py +++ b/cookbook/Basic-RAG/BasicRAG_stuff.py @@ -1,6 +1,9 @@ """Stuff Chain ======================= This cookbook demonstrates how to use the stuff chain for BasicRAG. +.. image:: src/docs/_static/stuff_chain_langchain_illustration.jpg + :width: 400 + :alt: Stuff Documents Chain Process """ from grag.components.multivec_retriever import Retriever diff --git a/cookbook/RAG-GUI/app.py b/cookbook/RAG-GUI/app.py new file mode 100644 index 0000000..6f348c5 --- /dev/null +++ b/cookbook/RAG-GUI/app.py @@ -0,0 +1,178 @@ +"""A cookbook demonstrating how to run RAG app on streamlit.""" + +import os +import sys +from pathlib import Path + +import streamlit as st +from grag.components.multivec_retriever import Retriever +from grag.components.utils import get_config +from grag.components.vectordb.deeplake_client import DeepLakeClient +from grag.rag.basic_rag import BasicRAG + +sys.path.insert(1, str(Path(os.getcwd()).parents[1])) + +st.set_page_config(page_title="GRAG", + menu_items={ + "Get Help": "https://github.com/arjbingly/Capstone_5", + "About": "This is a simple GUI for GRAG" + }) + + +def spinner(text): + """Decorator that displays a loading spinner with a custom text message during the execution of a function. + + This decorator wraps any function to show a spinner using Streamlit's st.spinner during the function call, + indicating that an operation is in progress. The spinner is displayed with a user-defined text message. + + Args: + text (str): The message to display next to the spinner. + + Returns: + function: A decorator that takes a function and wraps it in a spinner context. + """ + + def _spinner(func): + """A decorator function that takes another function and wraps it to show a spinner during its execution. + + Args: + func (function): The function to wrap. + + Returns: + function: The wrapped function with a spinner displayed during its execution. + """ + + def wrapper_func(*args, **kwargs): + """The wrapper function that actually executes the wrapped function within the spinner context. + + Args: + *args: Positional arguments passed to the wrapped function. + **kwargs: Keyword arguments passed to the wrapped function. + """ + with st.spinner(text=text): + func(*args, **kwargs) + + return wrapper_func + + return _spinner + + +@st.cache_data +def load_config(): + """Loads config.""" + return get_config() + + +conf = load_config() + + +class RAGApp: + """Application class to manage a Retrieval-Augmented Generation (RAG) model interface. + + Attributes: + app: The main application or server instance hosting the RAG model. + conf: Configuration settings or parameters for the application. + """ + + def __init__(self, app, conf): + """Initializes the RAGApp with a given application and configuration. + + Args: + app: The main application or framework instance that this class will interact with. + conf: A configuration object or dictionary containing settings for the application. + """ + self.app = app + self.conf = conf + + def render_sidebar(self): + """Renders the sidebar in the application interface with model selection and parameters.""" + with st.sidebar: + st.title('GRAG') + st.subheader('Models and parameters') + st.sidebar.selectbox('Choose a model', + ['Llama-2-13b-chat', 'Llama-2-7b-chat', + 'Mixtral-8x7B-Instruct-v0.1', 'gemma-7b-it'], + key='selected_model') + st.sidebar.slider('Temperature', + min_value=0.1, + max_value=1.0, + value=0.1, + step=0.1, + key='temperature') + st.sidebar.slider('Top-k', + min_value=1, + max_value=5, + value=3, + step=1, + key='top_k') + st.button('Load Model', on_click=self.load_rag) + st.checkbox('Show sources', key='show_sources') + + @spinner(text='Loading model...') + def load_rag(self): + """Loads the specified RAG model based on the user's selection and settings in the sidebar.""" + if 'rag' in st.session_state: + del st.session_state['rag'] + + llm_kwargs = {"temperature": st.session_state['temperature'], } + if st.session_state['selected_model'] == "Mixtral-8x7B-Instruct-v0.1": + llm_kwargs['n_gpu_layers'] = 16 + llm_kwargs['quantization'] = 'Q4_K_M' + elif st.session_state['selected_model'] == "gemma-7b-it": + llm_kwargs['n_gpu_layers'] = 18 + llm_kwargs['quantization'] = 'f16' + + retriever_kwargs = { + "client_kwargs": {"read_only": True, }, + "top_k": st.session_state['top_k'] + } + client = DeepLakeClient(collection_name="usc", read_only=True) + retriever = Retriever(vectordb=client) + + st.session_state['rag'] = BasicRAG(model_name=st.session_state['selected_model'], stream=True, + llm_kwargs=llm_kwargs, retriever=retriever, + retriever_kwargs=retriever_kwargs) + st.success( + f"""Model Loaded !!! + + Model Name: {st.session_state['selected_model']} + Temperature: {st.session_state['temperature']} + Top-k : {st.session_state['top_k']}""" + ) + + def clear_cache(self): + """Clears the cached data within the application.""" + st.cache_data.clear() + + def render_main(self): + """Renders the main chat interface for user interaction with the loaded RAG model.""" + st.title(":us: US Constitution Expert! :mortar_board:") + if 'rag' not in st.session_state: + st.warning("You have not loaded any model") + else: + user_input = st.chat_input("Ask me anything about the US Constitution.") + + if user_input: + with st.chat_message("user"): + st.write(user_input) + with st.chat_message("assistant"): + _ = st.write_stream( + st.session_state['rag'](user_input)[0] + ) + if st.session_state['show_sources']: + retrieved_docs = st.session_state['rag'].retriever.get_chunk(user_input) + for index, doc in enumerate(retrieved_docs): + with st.expander(f"Source {index + 1}"): + st.markdown(f"**{index + 1}. {doc.metadata['source']}**") + # if st.session_state['show_content']: + st.text(f"**{doc.page_content}**") + + def render(self): + """Orchestrates the rendering of both main and sidebar components of the application.""" + self.render_main() + self.render_sidebar() + + +if __name__ == "__main__": + app = RAGApp(st, conf) + app.render() diff --git a/full_report/Capstone5 Presentation v1.pptx b/full_report/Capstone5 Presentation v1.pptx deleted file mode 100644 index af8863a..0000000 Binary files a/full_report/Capstone5 Presentation v1.pptx and /dev/null differ diff --git a/full_report/~$Capstone5 Presentation v1.pptx b/full_report/~$Capstone5 Presentation v1.pptx new file mode 100644 index 0000000..2425bbd Binary files /dev/null and b/full_report/~$Capstone5 Presentation v1.pptx differ diff --git a/llm_quantize/README.md b/llm_quantize/README.md new file mode 100644 index 0000000..18660a8 --- /dev/null +++ b/llm_quantize/README.md @@ -0,0 +1,14 @@ +## Model Quantization + +This module provides an interactive way to quantize your model. +To quantize model, run: +`python -m grag.quantize.quantize` + +After running the above command, user will be prompted with the following: + +- Path where user wants to clone [llama.cpp](!https://github.com/ggerganov/llama.cpp) repo +- If user wants us to download model from [HuggingFace](!https://huggingface.co/models) or user has model downloaded + locally + - For the former, user will be prompted to provide repo path from HuggingFace + - For the latter, user will be instructed to copy the model and input the name of model directory +- Finally, user will be prompted to enter quantization (recommended Q5_K_M or Q4_K_M, etc.). For more details, check [here](!https://github.com/ggerganov/llama.cpp/blob/master/examples/quantize/quantize.cpp#L19). diff --git a/projects/Basic-RAG/BasicRAG_ingest.py b/projects/Basic-RAG/BasicRAG_ingest.py new file mode 100644 index 0000000..83d5340 --- /dev/null +++ b/projects/Basic-RAG/BasicRAG_ingest.py @@ -0,0 +1,16 @@ +"""A cookbook demonstrating how to ingest pdf files for use with BasicRAG.""" + +from pathlib import Path + +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) + +dir_path = Path(__file__).parent / "some_dir" + +retriever.ingest(dir_path) +# rag = BasicRAG(doc_chain="refine") diff --git a/src/docs/_build/doctrees/auto_examples/Basic-RAG/BasicRAG_refine.doctree b/src/docs/_build/doctrees/auto_examples/Basic-RAG/BasicRAG_refine.doctree index fb14a21..9c39ec6 100644 Binary files a/src/docs/_build/doctrees/auto_examples/Basic-RAG/BasicRAG_refine.doctree and b/src/docs/_build/doctrees/auto_examples/Basic-RAG/BasicRAG_refine.doctree differ diff --git a/src/docs/_build/doctrees/auto_examples/Basic-RAG/BasicRAG_stuff.doctree b/src/docs/_build/doctrees/auto_examples/Basic-RAG/BasicRAG_stuff.doctree index 5033902..b93672a 100644 Binary files a/src/docs/_build/doctrees/auto_examples/Basic-RAG/BasicRAG_stuff.doctree and b/src/docs/_build/doctrees/auto_examples/Basic-RAG/BasicRAG_stuff.doctree differ diff --git a/src/docs/_build/doctrees/environment.pickle b/src/docs/_build/doctrees/environment.pickle index 746b223..60057c5 100644 Binary files a/src/docs/_build/doctrees/environment.pickle and b/src/docs/_build/doctrees/environment.pickle differ diff --git a/src/docs/_build/html/.buildinfo b/src/docs/_build/html/.buildinfo index 4d1d3e2..4afd424 100644 --- a/src/docs/_build/html/.buildinfo +++ b/src/docs/_build/html/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 6b07e347145cdddb9512d0a4e5895210 +config: d4c21b77045124631c4c68a22a4bc3b5 tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/src/docs/_build/html/_downloads/08281b5b1106412fcca1eee951af6faa/BasicRAG_stuff.py b/src/docs/_build/html/_downloads/08281b5b1106412fcca1eee951af6faa/BasicRAG_stuff.py index fa177f5..26d1f2c 100644 --- a/src/docs/_build/html/_downloads/08281b5b1106412fcca1eee951af6faa/BasicRAG_stuff.py +++ b/src/docs/_build/html/_downloads/08281b5b1106412fcca1eee951af6faa/BasicRAG_stuff.py @@ -1,6 +1,9 @@ """Stuff Chain ======================= This cookbook demonstrates how to use the stuff chain for BasicRAG. +.. image:: src/docs/_static/stuff_chain_langchain_illustration.jpg + :width: 400 + :alt: Stuff Documents Chain Process """ from grag.components.multivec_retriever import Retriever diff --git a/src/docs/_build/html/_downloads/2ceb93416492b18edb9a519fe43e25d4/BasicRAG_stuff.ipynb b/src/docs/_build/html/_downloads/2ceb93416492b18edb9a519fe43e25d4/BasicRAG_stuff.ipynb index 95f75ce..63895c6 100644 --- a/src/docs/_build/html/_downloads/2ceb93416492b18edb9a519fe43e25d4/BasicRAG_stuff.ipynb +++ b/src/docs/_build/html/_downloads/2ceb93416492b18edb9a519fe43e25d4/BasicRAG_stuff.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Stuff Chain\nThis cookbook demonstrates how to use the stuff chain for BasicRAG.\n" + "# Stuff Chain\nThis cookbook demonstrates how to use the stuff chain for BasicRAG.\n\"Stuff\n" ] }, { diff --git a/src/docs/_build/html/_downloads/40ffe2716096f331549183db9c0ece72/Retriver-GUI_jupyter.zip b/src/docs/_build/html/_downloads/40ffe2716096f331549183db9c0ece72/Retriver-GUI_jupyter.zip index 76a4b2c..5fd0969 100644 Binary files a/src/docs/_build/html/_downloads/40ffe2716096f331549183db9c0ece72/Retriver-GUI_jupyter.zip and b/src/docs/_build/html/_downloads/40ffe2716096f331549183db9c0ece72/Retriver-GUI_jupyter.zip differ diff --git a/src/docs/_build/html/_downloads/7c6daaeaa6e5520da795fa975d498452/Retriver-GUI_python.zip b/src/docs/_build/html/_downloads/7c6daaeaa6e5520da795fa975d498452/Retriver-GUI_python.zip index 18f7665..22bcfd9 100644 Binary files a/src/docs/_build/html/_downloads/7c6daaeaa6e5520da795fa975d498452/Retriver-GUI_python.zip and b/src/docs/_build/html/_downloads/7c6daaeaa6e5520da795fa975d498452/Retriver-GUI_python.zip differ diff --git a/src/docs/_build/html/_downloads/bf6c4ba115907c5ef1c944698d335d59/BasicRAG_refine.ipynb b/src/docs/_build/html/_downloads/bf6c4ba115907c5ef1c944698d335d59/BasicRAG_refine.ipynb index 14b62c4..661b354 100644 --- a/src/docs/_build/html/_downloads/bf6c4ba115907c5ef1c944698d335d59/BasicRAG_refine.ipynb +++ b/src/docs/_build/html/_downloads/bf6c4ba115907c5ef1c944698d335d59/BasicRAG_refine.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Refine Chain\nThis cookbook demonstrates how to use the refine chain for BasicRAG.\n" + "# Refine Chain\nThis cookbook demonstrates how to use the refine chain for BasicRAG.\n\"Refine\n" ] }, { diff --git a/src/docs/_build/html/_downloads/d30c8b1c6e4654b2ad3d2a98fac0be74/Basic-RAG_python.zip b/src/docs/_build/html/_downloads/d30c8b1c6e4654b2ad3d2a98fac0be74/Basic-RAG_python.zip index da8c9fa..6293a17 100644 Binary files a/src/docs/_build/html/_downloads/d30c8b1c6e4654b2ad3d2a98fac0be74/Basic-RAG_python.zip and b/src/docs/_build/html/_downloads/d30c8b1c6e4654b2ad3d2a98fac0be74/Basic-RAG_python.zip differ diff --git a/src/docs/_build/html/_downloads/f9939c7be8f2cbb228881fcceb9ea19d/Basic-RAG_jupyter.zip b/src/docs/_build/html/_downloads/f9939c7be8f2cbb228881fcceb9ea19d/Basic-RAG_jupyter.zip index e251243..ba5a94e 100644 Binary files a/src/docs/_build/html/_downloads/f9939c7be8f2cbb228881fcceb9ea19d/Basic-RAG_jupyter.zip and b/src/docs/_build/html/_downloads/f9939c7be8f2cbb228881fcceb9ea19d/Basic-RAG_jupyter.zip differ diff --git a/src/docs/_build/html/_downloads/ff38cea876c84a5f22af2d8c8b56bc59/BasicRAG_refine.py b/src/docs/_build/html/_downloads/ff38cea876c84a5f22af2d8c8b56bc59/BasicRAG_refine.py index 85b640a..dffe7bd 100644 --- a/src/docs/_build/html/_downloads/ff38cea876c84a5f22af2d8c8b56bc59/BasicRAG_refine.py +++ b/src/docs/_build/html/_downloads/ff38cea876c84a5f22af2d8c8b56bc59/BasicRAG_refine.py @@ -1,6 +1,9 @@ """Refine Chain ======================= This cookbook demonstrates how to use the refine chain for BasicRAG. +.. image:: src/docs/_static/refine_chain_langchain_illustration.jpg + :width: 400 + :alt: Refine Documents Chain Process """ from grag.components.multivec_retriever import Retriever diff --git a/src/docs/_build/html/_images/basic_RAG_pipeline.png b/src/docs/_build/html/_images/basic_RAG_pipeline.png new file mode 100644 index 0000000..9a9564c Binary files /dev/null and b/src/docs/_build/html/_images/basic_RAG_pipeline.png differ diff --git a/src/docs/_build/html/_modules/grag/components/embedding.html b/src/docs/_build/html/_modules/grag/components/embedding.html new file mode 100644 index 0000000..1fccb57 --- /dev/null +++ b/src/docs/_build/html/_modules/grag/components/embedding.html @@ -0,0 +1,148 @@ + + + + + + grag.components.embedding — GRAG 0.0.1 documentation + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +

Source code for grag.components.embedding

+"""Class for embedding.
+
+This module provides:
+- Embedding
+"""
+
+from langchain_community.embeddings import HuggingFaceInstructEmbeddings
+from langchain_community.embeddings.sentence_transformer import (
+    SentenceTransformerEmbeddings,
+)
+
+
+
+[docs] +class Embedding: + """A class for vector embeddings. + + Supports: + huggingface sentence transformers -> model_type = 'sentence-transformers' + huggingface instructor embeddings -> model_type = 'instructor-embedding' + + Attributes: + embedding_type: embedding model type, refer above for supported types + embedding_model: huggingface model name + embedding_function: langchain embedding type + """ + + def __init__(self, embedding_type: str, embedding_model: str): + """Initialize the embedding with embedding_type and embedding_model.""" + self.embedding_type = embedding_type + self.embedding_model = embedding_model + match self.embedding_type: + case "sentence-transformers": + self.embedding_function = SentenceTransformerEmbeddings( + model_name=self.embedding_model + ) + case "instructor-embedding": + self.embedding_instruction = "Represent the document for retrival" + self.embedding_function = HuggingFaceInstructEmbeddings( + model_name=self.embedding_model + ) + self.embedding_function.embed_instruction = self.embedding_instruction + case _: + raise Exception("embedding_type is invalid")
+ +
+ +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/src/docs/_build/html/_modules/grag/components/llm.html b/src/docs/_build/html/_modules/grag/components/llm.html new file mode 100644 index 0000000..31b31b2 --- /dev/null +++ b/src/docs/_build/html/_modules/grag/components/llm.html @@ -0,0 +1,304 @@ + + + + + + grag.components.llm — GRAG 0.0.1 documentation + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +

Source code for grag.components.llm

+"""Class for LLM."""
+
+import os
+from pathlib import Path
+
+import torch
+from dotenv import load_dotenv
+from langchain.callbacks.manager import CallbackManager
+from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
+from langchain_community.llms import LlamaCpp
+from langchain_community.llms.huggingface_pipeline import HuggingFacePipeline
+from transformers import (
+    AutoModelForCausalLM,
+    AutoTokenizer,
+    BitsAndBytesConfig,
+    pipeline,
+)
+
+from .utils import get_config
+
+llm_conf = get_config()["llm"]
+
+print("CUDA: ", torch.cuda.is_available())
+
+
+
+[docs] +class LLM: + """A class for managing and utilizing large language models (LLMs). + + Attributes: + model_name (str): Name of the model to be loaded. + device_map (dict): Device mapping for model execution. + task (str): The task for which the model is being used. + max_new_tokens (int): Maximum new tokens to be generated. + temperature (float): Sampling temperature for generation. + n_batch (int): Number of batches for GPU CPP. + n_ctx (int): Context size for CPP. + n_gpu_layers (int): Number of GPU layers for CPP. + """ + + def __init__( + self, + model_name=llm_conf["model_name"], + device_map=llm_conf["device_map"], + task=llm_conf["task"], + max_new_tokens=llm_conf["max_new_tokens"], + temperature=llm_conf["temperature"], + n_batch=llm_conf["n_batch_gpu_cpp"], + n_ctx=llm_conf["n_ctx_cpp"], + n_gpu_layers=llm_conf["n_gpu_layers_cpp"], + std_out=llm_conf["std_out"], + base_dir=llm_conf["base_dir"], + quantization=llm_conf["quantization"], + pipeline=llm_conf["pipeline"], + ): + """Initialize the LLM class using the given parameters.""" + self.base_dir = Path(base_dir) + self._model_name = model_name + self.quantization = quantization + self.pipeline = pipeline + self.device_map = device_map + self.task = task + self.max_new_tokens = int(max_new_tokens) + self.temperature = temperature + self.n_batch = n_batch + self.n_ctx = n_ctx + self.n_gpu_layers = n_gpu_layers + if std_out: + self.callback_manager = CallbackManager([StreamingStdOutCallbackHandler()]) + else: + self.callback_manager = None + + @property + def model_name(self): + """Returns the name of the model.""" + return self._model_name + + @property + def model_path(self): + """Sets the model name.""" + return str( + self.base_dir / self.model_name / f"ggml-model-{self.quantization}.gguf" + ) + + @model_name.setter + def model_name(self, value): + """Returns the path to the model.""" + self._model_name = value + +
+[docs] + def hf_pipeline(self, is_local=False): + """Loads the model using Hugging Face transformers. + + Args: + is_local (bool): Whether to load the model from a local path. + """ + if is_local: + hf_model = Path(self.model_path).parent + else: + hf_model = self.model_name + match self.quantization: + case "Q8": + quantization_config = BitsAndBytesConfig(load_in_8bit=True) + case "Q4": + quantization_config = BitsAndBytesConfig(load_in_4bit=True) + case _: + raise ValueError( + f"{self.quantization} is not a valid quantization. Non-local hf_pipeline takes only Q4 and Q8." + ) + + try: + # Try to load the model without passing the token + tokenizer = AutoTokenizer.from_pretrained(hf_model) + model = AutoModelForCausalLM.from_pretrained( + hf_model, + quantization_config=quantization_config, + device_map=self.device_map, + torch_dtype=torch.float16, + ) + except OSError: # LocalTokenNotFoundError: + # If loading fails due to an auth token error, then load the token and retry + load_dotenv() + auth_token = os.getenv("AUTH_TOKEN") + if not auth_token: + raise ValueError("Authentication token not provided.") + tokenizer = AutoTokenizer.from_pretrained(hf_model, token=True) + model = AutoModelForCausalLM.from_pretrained( + hf_model, + quantization_config=quantization_config, + device_map=self.device_map, + torch_dtype=torch.float16, + token=True, + ) + + pipe = pipeline( + self.task, + model=model, + tokenizer=tokenizer, + torch_dtype=torch.bfloat16, + device_map=self.device_map, + max_new_tokens=self.max_new_tokens, + do_sample=True, + top_k=10, + num_return_sequences=1, + eos_token_id=tokenizer.eos_token_id, + ) + llm = HuggingFacePipeline( + pipeline=pipe, model_kwargs={"temperature": self.temperature} + ) + return llm
+ + +
+[docs] + def llama_cpp(self): + """Loads the model using a custom CPP pipeline.""" + # https://stackoverflow.com/a/77734908/13808323 + llm = LlamaCpp( + model_path=self.model_path, + max_tokens=self.max_new_tokens, + temperature=self.temperature, + n_gpu_layers=self.n_gpu_layers, + n_batch=self.n_batch, + n_ctx=self.n_ctx, + callbacks=self.callback_manager, + verbose=True, # Verbose is required to pass to the callback manager + ) + return llm
+ + +
+[docs] + def load_model( + self, model_name=None, pipeline=None, quantization=None, is_local=None + ): + """Loads the model based on the specified pipeline and model name. + + Args: + quantization (str): Quantization of the LLM model like Q5_K_M, f16, etc. Optional. + model_name (str): The name of the model to load. Optional. + pipeline (str): The pipeline to use for loading the model. Defaults to 'llama_cpp'. + is_local (bool): Whether the model is loaded from a local directory. Defaults to True. + """ + if model_name is not None: + self.model_name = model_name + if pipeline is not None: + self.pipeline = pipeline + if quantization is not None: + self.quantization = quantization + if is_local is None: + is_local = False + + match self.pipeline: + case "llama_cpp": + return self.llama_cpp() + case "hf": + return self.hf_pipeline(is_local=is_local)
+
+ +
+ +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/src/docs/_build/html/_modules/grag/components/multivec_retriever.html b/src/docs/_build/html/_modules/grag/components/multivec_retriever.html new file mode 100644 index 0000000..96f7772 --- /dev/null +++ b/src/docs/_build/html/_modules/grag/components/multivec_retriever.html @@ -0,0 +1,462 @@ + + + + + + grag.components.multivec_retriever — GRAG 0.0.1 documentation + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+
    +
  • + + +
  • +
  • +
+
+
+
+
+ +

Source code for grag.components.multivec_retriever

+"""Class for retriever.
+
+This module provides:
+- Retriever
+"""
+
+import asyncio
+import uuid
+from pathlib import Path
+from typing import Any, Dict, List, Optional, Union
+
+from grag.components.parse_pdf import ParsePDF
+from grag.components.text_splitter import TextSplitter
+from grag.components.utils import get_config
+from grag.components.vectordb.base import VectorDB
+from grag.components.vectordb.deeplake_client import DeepLakeClient
+from langchain.retrievers.multi_vector import MultiVectorRetriever
+from langchain.storage import LocalFileStore
+from langchain_core.documents import Document
+from tqdm import tqdm
+from tqdm.asyncio import tqdm as atqdm
+
+multivec_retriever_conf = get_config()["multivec_retriever"]
+
+
+
+[docs] +class Retriever: + """A class for multi vector retriever. + + It connects to a vector database and a local file store. + It is used to return most similar chunks from a vector store but has the additional functionality to return a + linked document, chunk, etc. + + Attributes: + store_path: Path to the local file store + id_key: A key prefix for identifying documents + vectordb: ChromaClient class instance from components.client + store: langchain.storage.LocalFileStore object, stores the key value pairs of document id and parent file + retriever: langchain.retrievers.multi_vector.MultiVectorRetriever class instance, + langchain's multi-vector retriever + splitter: TextSplitter class instance from components.text_splitter + namespace: Namespace for producing unique id + top_k: Number of top chunks to return from similarity search. + + """ + + def __init__( + self, + vectordb: Optional[VectorDB] = None, + store_path: str = multivec_retriever_conf["store_path"], + id_key: str = multivec_retriever_conf["id_key"], + namespace: str = multivec_retriever_conf["namespace"], + top_k=int(multivec_retriever_conf["top_k"]), + client_kwargs: Optional[Dict[str, Any]] = None, + ): + """Initialize the Retriever. + + Args: + vectordb: Vector DB client instance + store_path: Path to the local file store, defaults to argument from config file + id_key: A key prefix for identifying documents, defaults to argument from config file + namespace: A namespace for producing unique id, defaults to argument from congig file + top_k: Number of top chunks to return from similarity search, defaults to 1 + client_kwargs: kwargs to pass to the vectordb client + """ + self.store_path = store_path + self.id_key = id_key + self.namespace = uuid.UUID(namespace) + if vectordb is None: + if client_kwargs is not None: + self.vectordb = DeepLakeClient(**client_kwargs) + else: + self.vectordb = DeepLakeClient() + else: + self.vectordb = vectordb + self.store = LocalFileStore(self.store_path) + self.retriever = MultiVectorRetriever( + vectorstore=self.vectordb.langchain_client, + byte_store=self.store, + id_key=self.id_key, + ) + self.splitter = TextSplitter() + self.top_k: int = top_k + self.retriever.search_kwargs = {"k": self.top_k} + +
+[docs] + def id_gen(self, doc: Document) -> str: + """Takes a document and returns a unique id (uuid5) using the namespace and document source. + + This ensures that a single document always gets the same unique id. + + Args: + doc: langchain_core.documents.Document + + Returns: + string of hexadecimal uuid + """ + return uuid.uuid5(self.namespace, doc.metadata["source"]).hex
+ + +
+[docs] + def gen_doc_ids(self, docs: List[Document]) -> List[str]: + """Takes a list of documents and produces a list of unique id, refer id_gen method for more details. + + Args: + docs: List of langchain_core.documents.Document + + Returns: + List of hexadecimal uuid + + """ + return [self.id_gen(doc) for doc in docs]
+ + +
+[docs] + def split_docs(self, docs: List[Document]) -> List[Document]: + """Takes a list of documents and splits them into smaller chunks. + + Using TextSplitter from components.text_splitter + Also adds the unique parent document id into metadata + + Args: + docs: List of langchain_core.documents.Document + + Returns: + list of chunks after splitting + + """ + chunks = [] + for doc in docs: + _id = self.id_gen(doc) + _sub_docs = self.splitter.text_splitter.split_documents([doc]) + for _sub_doc in _sub_docs: + _sub_doc.metadata[self.id_key] = _id + chunks.extend(_sub_docs) + return chunks
+ + +
+[docs] + def add_docs(self, docs: List[Document]): + """Adds given documents into the vector database also adds the parent document into the file store. + + Args: + docs: List of langchain_core.documents.Document + + Returns: + None + + """ + chunks = self.split_docs(docs) + doc_ids = self.gen_doc_ids(docs) + self.vectordb.add_docs(chunks) + self.retriever.docstore.mset(list(zip(doc_ids, docs)))
+ + +
+[docs] + async def aadd_docs(self, docs: List[Document]): + """Adds given documents into the vector database also adds the parent document into the file store. + + Args: + docs: List of langchain_core.documents.Document + + Returns: + None + + """ + chunks = self.split_docs(docs) + doc_ids = self.gen_doc_ids(docs) + await asyncio.run(self.vectordb.aadd_docs(chunks)) + self.retriever.docstore.mset(list(zip(doc_ids)))
+ + +
+[docs] + def get_chunk(self, query: str, with_score=False, top_k=None): + """Returns the most similar chunks from the vector database. + + Args: + query: A query string + with_score: Outputs scores of returned chunks + top_k: Number of top similar chunks to return, if None defaults to self.top_k + + Returns: + list of Documents + + """ + _top_k = top_k if top_k else self.retriever.search_kwargs["k"] + return self.vectordb.get_chunk(query=query, top_k=_top_k, with_score=with_score)
+ + +
+[docs] + async def aget_chunk(self, query: str, with_score=False, top_k=None): + """Returns the most (cosine) similar chunks from the vector database, asynchronously. + + Args: + query: A query string + with_score: Outputs scores of returned chunks + top_k: Number of top similar chunks to return, if None defaults to self.top_k + + Returns: + list of Documents + + """ + _top_k = top_k if top_k else self.retriever.search_kwargs["k"] + return await self.vectordb.aget_chunk( + query=query, top_k=_top_k, with_score=with_score + )
+ + +
+[docs] + def get_doc(self, query: str): + """Returns the parent document of the most (cosine) similar chunk from the vector database. + + Args: + query: A query string + Returns: + Documents + + """ + return self.retriever.get_relevant_documents(query=query)
+ + +
+[docs] + async def aget_doc(self, query: str): + """Returns the parent documents of the most (cosine) similar chunks from the vector database. + + Args: + query: A query string + Returns: + Documents + + """ + return await self.retriever.aget_relevant_documents(query=query)
+ + +
+[docs] + def get_docs_from_chunks(self, chunks: List[Document], one_to_one=False): + """Returns the parent documents of chunks. + + Args: + chunks: chunks from vector store + one_to_one: if True, returns parent doc for each chunk + Returns: + parent documents + """ + ids = [] + for d in chunks: + if one_to_one: + if self.id_key in d.metadata: + ids.append(d.metadata[self.id_key]) + docs = self.retriever.docstore.mget(ids) + return docs + else: + if self.id_key in d.metadata and d.metadata[self.id_key] not in ids: + ids.append(d.metadata[self.id_key]) + docs = self.retriever.docstore.mget(ids) + return [d for d in docs if d is not None]
+ + +
+[docs] + def ingest( + self, + dir_path: Union[str, Path], + glob_pattern: str = "**/*.pdf", + dry_run: bool = False, + verbose: bool = True, + parser_kwargs: dict = None, + ): + """Ingests the files in directory. + + Args: + dir_path: path to the directory + glob_pattern: glob pattern to identify files + dry_run: if True, does not ingest any files + verbose: if True, shows progress + parser_kwargs: arguments to pass to the parser + + """ + _formats_to_add = ["Text", "Tables"] + filepath_gen = Path(dir_path).glob(glob_pattern) + if parser_kwargs: + parser = ParsePDF(parser_kwargs) + else: + parser = ParsePDF() + if verbose: + num_files = len(list(Path(dir_path).glob(glob_pattern))) + pbar = tqdm(filepath_gen, total=num_files, desc="Ingesting Files") + for filepath in pbar: + if not dry_run: + pbar.set_postfix_str( + f"Parsing file - {filepath.relative_to(dir_path)}" + ) + docs = parser.load_file(filepath) + pbar.set_postfix_str( + f"Adding file - {filepath.relative_to(dir_path)}" + ) + for format_key in _formats_to_add: + self.add_docs(docs[format_key]) + print(f"Completed adding - {filepath.relative_to(dir_path)}") + else: + print(f"DRY RUN: found - {filepath.relative_to(dir_path)}")
+ + +
+[docs] + async def aingest( + self, + dir_path: Union[str, Path], + glob_pattern: str = "**/*.pdf", + dry_run: bool = False, + verbose: bool = True, + parser_kwargs: dict = None, + ): + """Asynchronously ingests the files in directory. + + Args: + dir_path: path to the directory + glob_pattern: glob pattern to identify files + dry_run: if True, does not ingest any files + verbose: if True, shows progress + parser_kwargs: arguments to pass to the parser + + """ + _formats_to_add = ["Text", "Tables"] + filepath_gen = Path(dir_path).glob(glob_pattern) + if parser_kwargs: + parser = ParsePDF(parser_kwargs) + else: + parser = ParsePDF() + if verbose: + num_files = len(list(Path(dir_path).glob(glob_pattern))) + pbar = atqdm(filepath_gen, total=num_files, desc="Ingesting Files") + for filepath in pbar: + if not dry_run: + pbar.set_postfix_str( + f"Parsing file - {filepath.relative_to(dir_path)}" + ) + docs = parser.load_file(filepath) + pbar.set_postfix_str( + f"Adding file - {filepath.relative_to(dir_path)}" + ) + for format_key in _formats_to_add: + await self.aadd_docs(docs[format_key]) + print(f"Completed adding - {filepath.relative_to(dir_path)}") + else: + print(f"DRY RUN: found - {filepath.relative_to(dir_path)}")
+
+ +
+ +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/src/docs/_build/html/_modules/grag/components/parse_pdf.html b/src/docs/_build/html/_modules/grag/components/parse_pdf.html new file mode 100644 index 0000000..507a042 --- /dev/null +++ b/src/docs/_build/html/_modules/grag/components/parse_pdf.html @@ -0,0 +1,371 @@ + + + + + + grag.components.parse_pdf — GRAG 0.0.1 documentation + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +

Source code for grag.components.parse_pdf

+"""Classes for parsing files.
+
+This module provides:
+- ParsePDF
+"""
+
+from langchain_core.documents import Document
+from unstructured.partition.pdf import partition_pdf
+
+from .utils import get_config
+
+parser_conf = get_config()["parser"]
+
+
+
+[docs] +class ParsePDF: + """Parsing and partitioning PDF documents into Text, Table or Image elements. + + Attributes: + single_text_out (bool): Whether to combine all text elements into a single output document. + strategy (str): The strategy for PDF partitioning; default is "hi_res" for better accuracy. + extract_image_block_types (list): Elements to be extracted as image blocks. + infer_table_structure (bool): Whether to extract tables during partitioning. + extract_images (bool): Whether to extract images. + image_output_dir (str): Directory to save extracted images, if any. + add_captions_to_text (bool): Whether to include figure captions in text output. Default is True. + add_captions_to_blocks (bool): Whether to add captions to table and image blocks. Default is True. + add_caption_first (bool): Whether to place captions before their corresponding image or table in the output. Default is True. + """ + + def __init__( + self, + single_text_out=parser_conf["single_text_out"], + strategy=parser_conf["strategy"], + infer_table_structure=parser_conf["infer_table_structure"], + extract_images=parser_conf["extract_images"], + image_output_dir=parser_conf["image_output_dir"], + add_captions_to_text=parser_conf["add_captions_to_text"], + add_captions_to_blocks=parser_conf["add_captions_to_blocks"], + table_as_html=parser_conf["table_as_html"], + ): + """Initialize instance variables with parameters.""" + self.strategy = strategy + if extract_images: # by default always extract Table + self.extract_image_block_types = [ + "Image", + "Table", + ] # extracting Image and Table as image blocks + else: + self.extract_image_block_types = ["Table"] + self.infer_table_structure = infer_table_structure + self.add_captions_to_text = add_captions_to_text + self.add_captions_to_blocks = add_captions_to_blocks + self.image_output_dir = image_output_dir + self.single_text_out = single_text_out + self.add_caption_first = True + self.table_as_html = table_as_html + +
+[docs] + def partition(self, path: str): + """Partitions a PDF document into elements based on the instance's configuration. + + Parameters: + path (str): The file path of the PDF document to be parsed and partitioned. + + Returns: + list: A list of partitioned elements from the PDF document. + """ + self.file_path = path + partitions = partition_pdf( + filename=self.file_path, + strategy=self.strategy, + # extract_images_in_pdf=True, # Not required if specifies extract_image_block_type + extract_image_block_types=self.extract_image_block_types, + infer_table_structure=self.infer_table_structure, + extract_image_block_to_payload=False, + extract_image_block_output_dir=self.image_output_dir, + ) + return partitions
+ + +
+[docs] + def classify(self, partitions): + """Classifies the partitioned elements into Text, Tables, and Images list in a dictionary. + + Also adds captions for each element (if available). + + Parameters: + partitions (list): The list of partitioned elements from the PDF document. + + Returns: + dict: A dictionary with keys 'Text', 'Tables', and 'Images', each containing a list of corresponding elements. + """ + # Initialize lists for each type of element + classified_elements = {"Text": [], "Tables": [], "Images": []} + + for i, element in enumerate(partitions): + # enumerate, classify and add element + caption (when available) to respective list + if element.category == "Table": + if self.add_captions_to_blocks and i + 1 < len(partitions): + if ( + partitions[i + 1].category == "FigureCaption" + ): # check for caption + caption_element = partitions[i + 1] + else: + caption_element = None + classified_elements["Tables"].append((element, caption_element)) + else: + classified_elements["Tables"].append((element, None)) + elif element.category == "Image": + if self.add_captions_to_blocks and i + 1 < len(partitions): + if ( + partitions[i + 1].category == "FigureCaption" + ): # check for caption + caption_element = partitions[i + 1] + else: + caption_element = None + classified_elements["Images"].append((element, caption_element)) + else: + classified_elements["Images"].append((element, None)) + else: + if not self.add_captions_to_text: + if element.category != "FigureCaption": + classified_elements["Text"].append(element) + else: + classified_elements["Text"].append(element) + + return classified_elements
+ + +
+[docs] + def text_concat(self, elements) -> str: + """Context aware concatenates all elements into a single string.""" + full_text = "" + for current_element, next_element in zip(elements, elements[1:]): + curr_type = current_element.category + next_type = next_element.category + + # if curr_type in ["FigureCaption", "NarrativeText", "Title", "Address", 'Table', "UncategorizedText", "Formula"]: + # full_text += str(current_element) + "\n\n" + + if curr_type == "Title" and next_type == "NarrativeText": + full_text += str(current_element) + "\n" + elif curr_type == "NarrativeText" and next_type == "NarrativeText": + full_text += str(current_element) + "\n" + elif curr_type == "ListItem": + full_text += "- " + str(current_element) + "\n" + if next_element == "Title": + full_text += "\n" + elif next_element == "Title": + full_text = str(current_element) + "\n\n" + + elif curr_type in ["Header", "Footer", "PageBreak"]: + full_text += str(current_element) + "\n\n\n" + + else: + full_text += "\n" + + return full_text
+ + +
+[docs] + def process_text(self, elements): + """Processes text elements into langchain Documents. + + Parameters: + elements (list): The list of text elements to be processed. + + Returns: + docs (list): A list of Document instances containing the extracted Text content and their metadata. + """ + if self.single_text_out: + metadata = {"source": self.file_path} # Check for more metadata + text = "\n\n".join([str(el) for el in elements]) + docs = [Document(page_content=text, metadata=metadata)] + else: + docs = [] + for element in elements: + metadata = {"source": self.file_path, "category": element.category} + metadata.update(element.metadata.to_dict()) + docs.append(Document(page_content=str(element), metadata=metadata)) + return docs
+ + +
+[docs] + def process_tables(self, elements): + """Processes table elements into Documents, including handling of captions if specified. + + Parameters: + elements (list): The list of table elements (and optional captions) to be processed. + + Returns: + docs (list): A list of Document instances containing Tables, their captions and metadata. + """ + docs = [] + + for block_element, caption_element in elements: + metadata = {"source": self.file_path, "category": block_element.category} + metadata.update(block_element.metadata.to_dict()) + if self.table_as_html: + table_data = block_element.metadata.text_as_html + else: + table_data = str(block_element) + + if caption_element: + if ( + self.add_caption_first + ): # if there is a caption, add that before the element + content = "\n\n".join([str(caption_element), table_data]) + else: + content = "\n\n".join([table_data, str(caption_element)]) + else: + content = table_data + docs.append(Document(page_content=content, metadata=metadata)) + return docs
+ + +
+[docs] + def process_images(self, elements): + """Processes image elements into Documents, including handling of captions if specified. + + Parameters: + elements (list): The list of image elements (and optional captions) to be processed. + + Returns: + docs (list): A list of Document instances containing the Images, their caption and metadata. + """ + docs = [] + for block_element, caption_element in elements: + metadata = {"source": self.file_path, "category": block_element.category} + metadata.update(block_element.metadata.to_dict()) + if caption_element: # if there is a caption, add that before the element + if self.add_caption_first: + content = "\n\n".join([str(caption_element), str(block_element)]) + else: + content = "\n\n".join([str(block_element), str(caption_element)]) + else: + content = str(block_element) + docs.append(Document(page_content=content, metadata=metadata)) + return docs
+ + +
+[docs] + def load_file(self, path): + """Loads a PDF file, partitions and classifies its elements, and processes these elements into Documents. + + Parameters: + path (str): The file path of the PDF document to be loaded and processed. + + Returns: + dict: A dictionary with keys 'Text', 'Tables', and 'Images', each containing a list of processed Document instances. + """ + partitions = self.partition(str(path)) + classified_elements = self.classify(partitions) + text_docs = self.process_text(classified_elements["Text"]) + table_docs = self.process_tables(classified_elements["Tables"]) + image_docs = self.process_images(classified_elements["Images"]) + return {"Text": text_docs, "Tables": table_docs, "Images": image_docs}
+
+ +
+ +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/src/docs/_build/html/_modules/grag/components/prompt.html b/src/docs/_build/html/_modules/grag/components/prompt.html new file mode 100644 index 0000000..1587420 --- /dev/null +++ b/src/docs/_build/html/_modules/grag/components/prompt.html @@ -0,0 +1,314 @@ + + + + + + grag.components.prompt — GRAG 0.0.1 documentation + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +

Source code for grag.components.prompt

+"""Classes for prompts.
+
+This module provides:
+- Prompt - for generic prompts
+- FewShotPrompt - for few-shot prompts
+"""
+
+import json
+from pathlib import Path
+from typing import Any, Dict, List, Optional, Union
+
+from langchain.prompts.few_shot import FewShotPromptTemplate
+from langchain_core.prompts import PromptTemplate
+from pydantic import BaseModel, Field, field_validator
+
+Example = Dict[str, Any]
+
+SUPPORTED_TASKS = ["QA"]
+SUPPORTED_DOC_CHAINS = ["stuff", "refine"]
+
+
+
+[docs] +class Prompt(BaseModel): + """A class for generic prompts. + + Attributes: + name (str): The prompt name (Optional, defaults to "custom_prompt") + llm_type (str): The type of llm, llama2, etc (Optional, defaults to "None") + task (str): The task (Optional, defaults to QA) + source (str): The source of the prompt (Optional, defaults to "NoSource") + doc_chain (str): The doc chain for the prompt ("stuff", "refine") (Optional, defaults to "stuff") + language (str): The language of the prompt (Optional, defaults to "en") + filepath (str): The filepath of the prompt (Optional) + input_keys (List[str]): The input keys for the prompt + template (str): The template for the prompt + """ + + name: str = Field(default="custom_prompt") + llm_type: str = Field(default="None") + task: str = Field(default="QA") + source: str = Field(default="NoSource") + doc_chain: str = Field(default="stuff") + language: str = "en" + filepath: Optional[str] = Field(default=None, exclude=True) + input_keys: List[str] + template: str + prompt: Optional[PromptTemplate] = Field(exclude=True, repr=False, default=None) + +
+[docs] + @field_validator("input_keys") + @classmethod + def validate_input_keys(cls, v) -> List[str]: + """Validate the input_keys field.""" + if v is None or v == []: + raise ValueError("input_keys cannot be empty") + return v
+ + +
+[docs] + @field_validator("doc_chain") + @classmethod + def validate_doc_chain(cls, v: str) -> str: + """Validate the doc_chain field.""" + if v not in SUPPORTED_DOC_CHAINS: + raise ValueError( + f"The provided doc_chain, {v} is not supported, supported doc_chains are {SUPPORTED_DOC_CHAINS}" + ) + return v
+ + +
+[docs] + @field_validator("task") + @classmethod + def validate_task(cls, v: str) -> str: + """Validate the task field.""" + if v not in SUPPORTED_TASKS: + raise ValueError( + f"The provided task, {v} is not supported, supported tasks are {SUPPORTED_TASKS}" + ) + return v
+ + + # @model_validator(mode='after') + # def load_template(self): + # self.prompt = ChatPromptTemplate.from_template(self.template) + def __init__(self, **kwargs): + """Initialize the prompt.""" + super().__init__(**kwargs) + self.prompt = PromptTemplate( + input_variables=self.input_keys, template=self.template + ) + +
+[docs] + def save( + self, filepath: Union[Path, str, None], overwrite=False + ) -> Union[None, ValueError]: + """Saves the prompt class into a json file.""" + dump = self.model_dump_json(indent=2, exclude_defaults=True, exclude_none=True) + if filepath is None: + filepath = f"{self.name}.json" + if overwrite: + if self.filepath is None: + return ValueError("filepath does not exist in instance") + filepath = self.filepath + with open(filepath, "w") as f: + f.write(dump) + return None
+ + +
+[docs] + @classmethod + def load(cls, filepath: Union[Path, str]): + """Loads a json file and returns a Prompt class.""" + with open(f"{filepath}", "r") as f: + prompt_json = json.load(f) + _prompt = cls(**prompt_json) + _prompt.filepath = str(filepath) + return _prompt
+ + +
+[docs] + def format(self, **kwargs) -> str: + """Formats the prompt with provided keys and returns a string.""" + return self.prompt.format(**kwargs)
+
+ + + +
+[docs] +class FewShotPrompt(Prompt): + """A class for generic prompts. + + Attributes: + name (str): The prompt name (Optional, defaults to "custom_prompt") (Parent Class) + llm_type (str): The type of llm, llama2, etc (Optional, defaults to "None") (Parent Class) + task (str): The task (Optional, defaults to QA) (Parent Class) + source (str): The source of the prompt (Optional, defaults to "NoSource") (Parent Class) + doc_chain (str): The doc chain for the prompt ("stuff", "refine") (Optional, defaults to "stuff") (Parent Class) + language (str): The language of the prompt (Optional, defaults to "en") (Parent Class) + filepath (str): The filepath of the prompt (Optional) (Parent Class) + input_keys (List[str]): The input keys for the prompt (Parent Class) + input_keys (List[str]): The output keys for the prompt + prefix (str): The template prefix for the prompt + suffix (str): The template suffix for the prompt + example_template (str): The template for formatting the examples + examples (List[Dict[str, Any]]): The list of examples, each example is a dictionary with respective keys + """ + + output_keys: List[str] + examples: List[Dict[str, Any]] + prefix: str + suffix: str + example_template: str + prompt: Optional[FewShotPromptTemplate] = Field( + exclude=True, repr=False, default=None + ) + + def __init__(self, **kwargs): + """Initialize the prompt.""" + super().__init__(**kwargs) + eg_formatter = PromptTemplate( + input_vars=self.input_keys + self.output_keys, + template=self.example_template, + ) + self.prompt = FewShotPromptTemplate( + examples=self.examples, + example_prompt=eg_formatter, + prefix=self.prefix, + suffix=self.suffix, + input_variables=self.input_keys, + ) + +
+[docs] + @field_validator("output_keys") + @classmethod + def validate_output_keys(cls, v) -> List[str]: + """Validate the output_keys field.""" + if v is None or v == []: + raise ValueError("output_keys cannot be empty") + return v
+ + +
+[docs] + @field_validator("examples") + @classmethod + def validate_examples(cls, v) -> List[Dict[str, Any]]: + """Validate the examples field.""" + if v is None or v == []: + raise ValueError("examples cannot be empty") + for eg in v: + if not all(key in eg for key in cls.input_keys): + raise ValueError(f"input key(s) not in example {eg}") + if not all(key in eg for key in cls.output_keys): + raise ValueError(f"output key(s) not in example {eg}") + return v
+
+ + + +if __name__ == "__main__": + p = Prompt.load("../prompts/Llama-2_QA_1.json") +
+ +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/src/docs/_build/html/_modules/grag/components/text_splitter.html b/src/docs/_build/html/_modules/grag/components/text_splitter.html new file mode 100644 index 0000000..9317c72 --- /dev/null +++ b/src/docs/_build/html/_modules/grag/components/text_splitter.html @@ -0,0 +1,141 @@ + + + + + + grag.components.text_splitter — GRAG 0.0.1 documentation + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+
    +
  • + + +
  • +
  • +
+
+
+
+
+ +

Source code for grag.components.text_splitter

+"""Class for splitting/chunking text.
+
+This module provides:
+- TextSplitter
+"""
+
+from langchain.text_splitter import RecursiveCharacterTextSplitter
+
+from .utils import get_config
+
+text_splitter_conf = get_config()["text_splitter"]
+
+
+# %%
+
+[docs] +class TextSplitter: + """Class for recursively chunking text, it prioritizes '/n/n then '/n' and so on. + + Attributes: + chunk_size: maximum size of chunk + chunk_overlap: chunk overlap size + """ + + def __init__( + self, + chunk_size: int = text_splitter_conf["chunk_size"], + chunk_overlap: int = text_splitter_conf["chunk_overlap"], + ): + """Initialize TextSplitter.""" + self.text_splitter = RecursiveCharacterTextSplitter( + chunk_size=int(chunk_size), + chunk_overlap=int(chunk_overlap), + length_function=len, + is_separator_regex=False, + ) + """Initialize TextSplitter using chunk_size and chunk_overlap"""
+ +
+ +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/src/docs/_build/html/_modules/grag/components/utils.html b/src/docs/_build/html/_modules/grag/components/utils.html new file mode 100644 index 0000000..c80543c --- /dev/null +++ b/src/docs/_build/html/_modules/grag/components/utils.html @@ -0,0 +1,259 @@ + + + + + + grag.components.utils — GRAG 0.0.1 documentation + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +

Source code for grag.components.utils

+"""Utils functions.
+
+This module provides:
+- stuff_docs: concats langchain documents into string
+- load_prompt: loads json prompt to langchain prompt
+- find_config_path: finds the path of the 'config.ini' file by traversing up the directory tree from the current path.
+- get_config: retrieves and parses the configuration settings from the 'config.ini' file.
+"""
+
+import json
+import os
+import textwrap
+from configparser import ConfigParser, ExtendedInterpolation
+from pathlib import Path
+from typing import List
+
+from langchain_core.documents import Document
+from langchain_core.prompts import ChatPromptTemplate
+
+
+
+[docs] +def stuff_docs(docs: List[Document]) -> str: + r"""Concatenates langchain documents into a string using '\n\n' seperator. + + Args: + docs: List of langchain_core.documents.Document + + Returns: + string of document page content joined by '\n\n' + """ + return "\n\n".join([doc.page_content for doc in docs])
+ + + +
+[docs] +def reformat_text_with_line_breaks(input_text, max_width=110): + """Reformat the given text to ensure each line does not exceed a specific width, preserving existing line breaks. + + Args: + input_text (str): The text to be reformatted. + max_width (int): The maximum width of each line. + + Returns: + str: The reformatted text with preserved line breaks and adjusted line width. + """ + # Divide the text into separate lines + original_lines = input_text.split("\n") + + # Apply wrapping to each individual line + reformatted_lines = [ + textwrap.fill(line, width=max_width) for line in original_lines + ] + + # Combine the lines back into a single text block + reformatted_text = "\n".join(reformatted_lines) + + return reformatted_text
+ + + +
+[docs] +def display_llm_output_and_sources(response_from_llm): + """Displays the result from an LLM response and lists the sources. + + Args: + response_from_llm (dict): The response object from an LLM which includes the result and source documents. + """ + # Display the main result from the LLM response + print(response_from_llm["result"]) + + # Separator for clarity + print("\nSources:") + + # Loop through each source document and print its source + for source in response_from_llm["source_documents"]: + print(source.metadata["source"])
+ + + +
+[docs] +def load_prompt(json_file: str | os.PathLike, return_input_vars=False): + """Loads a prompt template from json file and returns a langchain ChatPromptTemplate. + + Args: + json_file: path to the prompt template json file. + return_input_vars: if true returns a list of expected input variables for the prompt. + + Returns: + langchain_core.prompts.ChatPromptTemplate (and a list of input vars if return_input_vars is True) + + """ + with open(f"{json_file}", "r") as f: + prompt_json = json.load(f) + prompt_template = ChatPromptTemplate.from_template(prompt_json["template"]) + + input_vars = prompt_json["input_variables"] + + return (prompt_template, input_vars) if return_input_vars else prompt_template
+ + + +
+[docs] +def find_config_path(current_path: Path) -> Path: + """Finds the path of the 'config.ini' file by traversing up the directory tree from the current path. + + This function starts at the current path and moves up the directory tree until it finds a file named 'config.ini'. + If 'config.ini' is not found by the time the root of the directory tree is reached, a FileNotFoundError is raised. + + Args: + current_path (Path): The starting point for the search, typically the location of the script being executed. + + Returns: + Path: The path to the found 'config.ini' file. + + Raises: + FileNotFoundError: If 'config.ini' cannot be found in any of the parent directories. + """ + config_path = Path("src/config.ini") + while not (current_path / config_path).exists(): + current_path = current_path.parent + if current_path == current_path.parent: + raise FileNotFoundError(f"config.ini not found in {config_path}.") + return current_path / config_path
+ + + +
+[docs] +def get_config() -> ConfigParser: + """Retrieves and parses the configuration settings from the 'config.ini' file. + + This function locates the 'config.ini' file by calling `find_config_path` using the script's current location. + It initializes a `ConfigParser` object to read the configuration settings from the located 'config.ini' file. + + Returns: + ConfigParser: A parser object containing the configuration settings from 'config.ini'. + """ + # Assuming this script is somewhere inside your project directory + script_location = Path(__file__).resolve() + if os.environ.get("CONFIG_PATH"): + config_path = os.environ.get("CONFIG_PATH") + else: + config_path = find_config_path(script_location) + os.environ["CONFIG_PATH"] = str(config_path) + print(f"Loaded config from {config_path}.") + # Initialize parser and read config + config = ConfigParser(interpolation=ExtendedInterpolation()) + config.read(config_path) + + return config
+ +
+ +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/src/docs/_build/html/_modules/grag/components/vectordb/base.html b/src/docs/_build/html/_modules/grag/components/vectordb/base.html new file mode 100644 index 0000000..b860ba1 --- /dev/null +++ b/src/docs/_build/html/_modules/grag/components/vectordb/base.html @@ -0,0 +1,206 @@ + + + + + + grag.components.vectordb.base — GRAG 0.0.1 documentation + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+
    +
  • + + +
  • +
  • +
+
+
+
+
+ +

Source code for grag.components.vectordb.base

+"""Abstract base class for vector database clients.
+
+This module provides:
+- VectorDB
+"""
+
+from abc import ABC, abstractmethod
+from typing import List, Tuple, Union
+
+from langchain_community.vectorstores.utils import filter_complex_metadata
+from langchain_core.documents import Document
+
+
+
+[docs] +class VectorDB(ABC): + """Abstract base class for vector database clients.""" + + @abstractmethod + def __len__(self) -> int: + """Number of chunks in the vector database.""" + ... + +
+[docs] + @abstractmethod + def delete(self) -> None: + """Delete all chunks in the vector database."""
+ + +
+[docs] + @abstractmethod + def add_docs(self, docs: List[Document], verbose: bool = True) -> None: + """Adds documents to the vector database. + + Args: + docs: List of Documents + verbose: Show progress bar + + Returns: + None + """ + ...
+ + +
+[docs] + @abstractmethod + async def aadd_docs(self, docs: List[Document], verbose: bool = True) -> None: + """Adds documents to the vector database (asynchronous). + + Args: + docs: List of Documents + verbose: Show progress bar + + Returns: + None + """ + ...
+ + +
+[docs] + @abstractmethod + def get_chunk( + self, query: str, with_score: bool = False, top_k: int = None + ) -> Union[List[Document], List[Tuple[Document, float]]]: + """Returns the most similar chunks from the vector database. + + Args: + query: A query string + with_score: Outputs scores of returned chunks + top_k: Number of top similar chunks to return, if None defaults to self.top_k + + Returns: + list of Documents + """ + ...
+ + +
+[docs] + @abstractmethod + async def aget_chunk( + self, query: str, with_score: bool = False, top_k: int = None + ) -> Union[List[Document], List[Tuple[Document, float]]]: + """Returns the most similar chunks from the vector database (asynchronous). + + Args: + query: A query string + with_score: Outputs scores of returned chunks + top_k: Number of top similar chunks to return, if None defaults to self.top_k + + Returns: + list of Documents + """ + ...
+ + + def _filter_metadata(self, docs: List[Document]) -> List[Document]: + return filter_complex_metadata(docs, allowed_types=self.allowed_metadata_types)
+ +
+ +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/src/docs/_build/html/_modules/grag/components/vectordb/chroma_client.html b/src/docs/_build/html/_modules/grag/components/vectordb/chroma_client.html new file mode 100644 index 0000000..a0cfa17 --- /dev/null +++ b/src/docs/_build/html/_modules/grag/components/vectordb/chroma_client.html @@ -0,0 +1,322 @@ + + + + + + grag.components.vectordb.chroma_client — GRAG 0.0.1 documentation + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+
    +
  • + + +
  • +
  • +
+
+
+
+
+ +

Source code for grag.components.vectordb.chroma_client

+"""Class for Chroma vector database.
+
+This module provides:
+- ChromaClient
+"""
+
+from typing import List, Tuple, Union
+
+import chromadb
+from grag.components.embedding import Embedding
+from grag.components.utils import get_config
+from grag.components.vectordb.base import VectorDB
+from langchain_community.vectorstores import Chroma
+from langchain_core.documents import Document
+from tqdm import tqdm
+from tqdm.asyncio import tqdm as atqdm
+
+chroma_conf = get_config()["chroma"]
+
+
+
+[docs] +class ChromaClient(VectorDB): + """A class for connecting to a hosted Chroma Vectorstore collection. + + Attributes: + host : str + IP Address of hosted Chroma Vectorstore + port : str + port address of hosted Chroma Vectorstore + collection_name : str + name of the collection in the Chroma Vectorstore, each ChromaClient connects to a single collection + embedding_type : str + type of embedding used, supported 'sentence-transformers' and 'instructor-embedding' + embedding_model : str + model name of embedding used, should correspond to the embedding_type + embedding_function + a function of the embedding model, derived from the embedding_type and embedding_modelname + client: chromadb.HttpClient + Chroma API for client + collection + Chroma API for the collection + langchain_client: langchain_community.vectorstores.Chroma + LangChain wrapper for Chroma collection + """ + + def __init__( + self, + host=chroma_conf["host"], + port=chroma_conf["port"], + collection_name=chroma_conf["collection_name"], + embedding_type=chroma_conf["embedding_type"], + embedding_model=chroma_conf["embedding_model"], + ): + """Initialize a ChromaClient object. + + Args: + host: IP Address of hosted Chroma Vectorstore, defaults to argument from config file + port: port address of hosted Chroma Vectorstore, defaults to argument from config file + collection_name: name of the collection in the Chroma Vectorstore, defaults to argument from config file + embedding_type: type of embedding used, supported 'sentence-transformers' and 'instructor-embedding', defaults to argument from config file + embedding_model: model name of embedding used, should correspond to the embedding_type, defaults to argument from config file + """ + self.host: str = host + self.port: str = port + self.collection_name: str = collection_name + self.embedding_type: str = embedding_type + self.embedding_model: str = embedding_model + + self.embedding_function = Embedding( + embedding_model=self.embedding_model, embedding_type=self.embedding_type + ).embedding_function + + self.client = chromadb.HttpClient(host=self.host, port=self.port) + self.collection = self.client.get_or_create_collection( + name=self.collection_name + ) + self.langchain_client = Chroma( + client=self.client, + collection_name=self.collection_name, + embedding_function=self.embedding_function, + ) + self.allowed_metadata_types = (str, int, float, bool) + + def __len__(self) -> int: + """Count the number of chunks in the database.""" + return self.collection.count() + +
+[docs] + def delete(self) -> None: + """Delete all the chunks in the database collection.""" + self.client.delete_collection(self.collection_name) + self.collection = self.client.get_or_create_collection( + name=self.collection_name + ) + self.langchain_client = Chroma( + client=self.client, + collection_name=self.collection_name, + embedding_function=self.embedding_function, + )
+ + +
+[docs] + def test_connection(self, verbose=True) -> int: + """Tests connection with Chroma Vectorstore. + + Args: + verbose: if True, prints connection status + + Returns: + A random integer if connection is alive else None + """ + response = self.client.heartbeat() + if verbose: + if response: + print(f"Connection to {self.host}/{self.port} is alive..") + else: + print(f"Connection to {self.host}/{self.port} is not alive !!") + return response
+ + +
+[docs] + def add_docs(self, docs: List[Document], verbose=True) -> None: + """Adds documents to chroma vectorstore. + + Args: + docs: List of Documents + verbose: Show progress bar + + Returns: + None + """ + docs = self._filter_metadata(docs) + for doc in ( + tqdm(docs, desc=f"Adding to {self.collection_name}:") if verbose else docs + ): + _id = self.langchain_client.add_documents([doc])
+ + +
+[docs] + async def aadd_docs(self, docs: List[Document], verbose=True) -> None: + """Asynchronously adds documents to chroma vectorstore. + + Args: + docs: List of Documents + verbose: Show progress bar + + Returns: + None + """ + docs = self._filter_metadata(docs) + if verbose: + for doc in atqdm( + docs, + desc=f"Adding documents to {self.collection_name}", + total=len(docs), + ): + await self.langchain_client.aadd_documents([doc]) + else: + for doc in docs: + await self.langchain_client.aadd_documents([doc])
+ + +
+[docs] + def get_chunk( + self, query: str, with_score: bool = False, top_k: int = None + ) -> Union[List[Document], List[Tuple[Document, float]]]: + """Returns the most similar chunks from the chroma database. + + Args: + query: A query string + with_score: Outputs scores of returned chunks + top_k: Number of top similar chunks to return, if None defaults to self.top_k + + Returns: + list of Documents + + """ + if with_score: + return self.langchain_client.similarity_search_with_relevance_scores( + query=query, k=top_k if top_k else 1 + ) + else: + return self.langchain_client.similarity_search( + query=query, k=top_k if top_k else 1 + )
+ + +
+[docs] + async def aget_chunk( + self, query: str, with_score=False, top_k=None + ) -> Union[List[Document], List[Tuple[Document, float]]]: + """Returns the most (cosine) similar chunks from the vector database, asynchronously. + + Args: + query: A query string + with_score: Outputs scores of returned chunks + top_k: Number of top similar chunks to return, if None defaults to self.top_k + + Returns: + list of Documents + + """ + if with_score: + return await self.langchain_client.asimilarity_search_with_relevance_scores( + query=query, k=top_k if top_k else 1 + ) + else: + return await self.langchain_client.asimilarity_search( + query=query, k=top_k if top_k else 1 + )
+
+ +
+ +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/src/docs/_build/html/_modules/grag/components/vectordb/deeplake_client.html b/src/docs/_build/html/_modules/grag/components/vectordb/deeplake_client.html new file mode 100644 index 0000000..8991d00 --- /dev/null +++ b/src/docs/_build/html/_modules/grag/components/vectordb/deeplake_client.html @@ -0,0 +1,280 @@ + + + + + + grag.components.vectordb.deeplake_client — GRAG 0.0.1 documentation + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+
    +
  • + + +
  • +
  • +
+
+
+
+
+ +

Source code for grag.components.vectordb.deeplake_client

+"""Class for DeepLake vector database.
+
+This module provides:
+- DeepLakeClient
+"""
+
+from pathlib import Path
+from typing import List, Tuple, Union
+
+from grag.components.embedding import Embedding
+from grag.components.utils import get_config
+from grag.components.vectordb.base import VectorDB
+from langchain_community.vectorstores import DeepLake
+from langchain_core.documents import Document
+from tqdm import tqdm
+from tqdm.asyncio import tqdm as atqdm
+
+deeplake_conf = get_config()["deeplake"]
+
+
+
+[docs] +class DeepLakeClient(VectorDB): + """A class for connecting to a DeepLake Vectorstore. + + Attributes: + store_path : str, Path + The path to store the DeepLake vectorstore. + embedding_type : str + type of embedding used, supported 'sentence-transformers' and 'instructor-embedding' + embedding_model : str + model name of embedding used, should correspond to the embedding_type + embedding_function + a function of the embedding model, derived from the embedding_type and embedding_modelname + client: deeplake.core.vectorstore.VectorStore + DeepLake API + collection + Chroma API for the collection + langchain_client: langchain_community.vectorstores.DeepLake + LangChain wrapper for DeepLake API + """ + + def __init__( + self, + collection_name: str = deeplake_conf["collection_name"], + store_path: Union[str, Path] = deeplake_conf["store_path"], + embedding_type: str = deeplake_conf["embedding_type"], + embedding_model: str = deeplake_conf["embedding_model"], + read_only: bool = False, + ): + """Initialize DeepLake client object.""" + self.store_path = Path(store_path) + self.collection_name = collection_name + self.read_only = read_only + self.embedding_type: str = embedding_type + self.embedding_model: str = embedding_model + + self.embedding_function = Embedding( + embedding_model=self.embedding_model, embedding_type=self.embedding_type + ).embedding_function + + # self.client = VectorStore(path=self.store_path / self.collection_name) + self.langchain_client = DeepLake( + dataset_path=str(self.store_path / self.collection_name), + embedding=self.embedding_function, + read_only=self.read_only, + ) + self.client = self.langchain_client.vectorstore + self.allowed_metadata_types = (str, int, float, bool) + + def __len__(self) -> int: + """Number of chunks in the vector database.""" + return self.client.__len__() + +
+[docs] + def delete(self) -> None: + """Delete all chunks in the vector database.""" + self.client.delete(delete_all=True)
+ + +
+[docs] + def add_docs(self, docs: List[Document], verbose=True) -> None: + """Adds documents to deeplake vectorstore. + + Args: + docs: List of Documents + verbose: Show progress bar + + Returns: + None + """ + docs = self._filter_metadata(docs) + for doc in ( + tqdm(docs, desc=f"Adding to {self.collection_name}:") if verbose else docs + ): + _id = self.langchain_client.add_documents([doc])
+ + +
+[docs] + async def aadd_docs(self, docs: List[Document], verbose=True) -> None: + """Asynchronously adds documents to chroma vectorstore. + + Args: + docs: List of Documents + verbose: Show progress bar + + Returns: + None + """ + docs = self._filter_metadata(docs) + if verbose: + for doc in atqdm( + docs, + desc=f"Adding documents to {self.collection_name}", + total=len(docs), + ): + await self.langchain_client.aadd_documents([doc]) + else: + for doc in docs: + await self.langchain_client.aadd_documents([doc])
+ + +
+[docs] + def get_chunk( + self, query: str, with_score: bool = False, top_k: int = None + ) -> Union[List[Document], List[Tuple[Document, float]]]: + """Returns the most similar chunks from the deeplake database. + + Args: + query: A query string + with_score: Outputs scores of returned chunks + top_k: Number of top similar chunks to return, if None defaults to self.top_k + + Returns: + list of Documents + + """ + if with_score: + return self.langchain_client.similarity_search_with_score( + query=query, k=top_k if top_k else 1 + ) + else: + return self.langchain_client.similarity_search( + query=query, k=top_k if top_k else 1 + )
+ + +
+[docs] + async def aget_chunk( + self, query: str, with_score=False, top_k=None + ) -> Union[List[Document], List[Tuple[Document, float]]]: + """Returns the most similar chunks from the deeplake database, asynchronously. + + Args: + query: A query string + with_score: Outputs scores of returned chunks + top_k: Number of top similar chunks to return, if None defaults to self.top_k + + Returns: + list of Documents + + """ + if with_score: + return await self.langchain_client.asimilarity_search_with_score( + query=query, k=top_k if top_k else 1 + ) + else: + return await self.langchain_client.asimilarity_search( + query=query, k=top_k if top_k else 1 + )
+
+ +
+ +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/src/docs/_build/html/_modules/grag/quantize/utils.html b/src/docs/_build/html/_modules/grag/quantize/utils.html new file mode 100644 index 0000000..14e9b19 --- /dev/null +++ b/src/docs/_build/html/_modules/grag/quantize/utils.html @@ -0,0 +1,250 @@ + + + + + + grag.quantize.utils — GRAG 0.0.1 documentation + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +

Source code for grag.quantize.utils

+"""Utility functions for quantization."""
+
+import os
+import subprocess
+from pathlib import Path
+from typing import Optional, Union
+
+from grag.components.utils import get_config
+from huggingface_hub import snapshot_download
+
+config = get_config()
+
+
+
+[docs] +def get_llamacpp_repo(root_path: Union[str, Path]) -> subprocess.CompletedProcess: + """Clones or pulls the llama.cpp repository into the specified root path. + + Args: + root_path: The root directory where the llama.cpp repository will be cloned or updated. + + Returns: + A subprocess.CompletedProcess instance containing the result of the git operation. + """ + if os.path.exists(f"{root_path}/llama.cpp"): + print(f"Repo exists at: {root_path}/llama.cpp") + res = subprocess.run( + ["git", "-C", f"{root_path}/llama.cpp", "pull"], + check=True, + capture_output=True, + ) + else: + res = subprocess.run( + [ + "git", + "clone", + "https://github.com/ggerganov/llama.cpp.git", + f"{root_path}/llama.cpp", + ], + check=True, + capture_output=True, + ) + + return res
+ + + +
+[docs] +def building_llamacpp(root_path: Union[str, Path]) -> None: + """Attempts to build the llama.cpp project using make or cmake. + + Args: + root_path (str): The root directory where the llama.cpp project is located. + """ + os.chdir(f"{root_path}/llama.cpp/") + try: + subprocess.run(["which", "make"], check=True, stdout=subprocess.DEVNULL) + subprocess.run(["make", "LLAMA_CUBLAS=1"], check=True) + print("Llama.cpp build successful.") + except subprocess.CalledProcessError: + try: + subprocess.run(["which", "cmake"], check=True, stdout=subprocess.DEVNULL) + subprocess.run(["mkdir", "build"], check=True) + subprocess.run( + [ + "cd", + "build", + "&&", + "cmake", + "..", + "-DLLAMA_CUBLAS=ON", + "&&", + "cmake", + "--build", + ".", + "--config", + "Release", + ], + shell=True, + check=True, + ) + print("Llama.cpp build successful.") + except subprocess.CalledProcessError: + print("Unable to build, cannot find make or cmake.") + finally: + os.chdir( + Path(__file__).parent + ) # Assuming you want to return to the root path after operation
+ + + +
+[docs] +def fetch_model_repo(repo_id: str, root_path: Union[str, Path]) -> None: + """Download model from huggingface.co/models. + + Args: + repo_id (str): Repository ID of the model to download. + root_path (str): The root path where the model should be downloaded or copied. + """ + local_dir = f"{root_path}/llama.cpp/models/{repo_id.split('/')[1]}" + os.makedirs(local_dir, exist_ok=True) + snapshot_download( + repo_id=repo_id, + local_dir=local_dir, + local_dir_use_symlinks="auto", + resume_download=True, + ) + print(f"Model downloaded in {local_dir}")
+ + + +
+[docs] +def quantize_model( + model_dir_path: Union[str, Path], + quantization: str, + root_path: Union[str, Path], + output_dir: Optional[Union[str, Path]] = None, +) -> None: + """Quantizes a specified model using a given quantization level. + + Args: + output_dir (str, Path, optional): Directory to save quantized model. Defaults to None + model_dir_path (str, Path): The directory path of the model to be quantized. + quantization (str): The quantization level to apply. + root_path (str, Path): The root directory path of the project. + """ + os.chdir(f"{root_path}/llama.cpp/") + model_dir_path = Path(model_dir_path) + if output_dir is None: + output_dir = config["llm"]["base_dir"] + + output_dir = Path(output_dir) / model_dir_path.name + os.makedirs(output_dir, exist_ok=True) + + subprocess.run(["python3", "convert.py", f"{model_dir_path}/"], check=True) + model_file = model_dir_path / "ggml-model-f32.gguf" + quantized_model_file = output_dir / f"ggml-model-{quantization}.gguf" + subprocess.run( + ["./quantize", str(model_file), str(quantized_model_file), quantization], + check=True, + ) + print(f"Quantized model present at {output_dir}") + os.chdir(Path(__file__).parent) # Return to the root path after operation
+ +
+ +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/src/docs/_build/html/_modules/grag/rag/basic_rag.html b/src/docs/_build/html/_modules/grag/rag/basic_rag.html new file mode 100644 index 0000000..14a30c5 --- /dev/null +++ b/src/docs/_build/html/_modules/grag/rag/basic_rag.html @@ -0,0 +1,336 @@ + + + + + + grag.rag.basic_rag — GRAG 0.0.1 documentation + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+ +

Source code for grag.rag.basic_rag

+"""Class for Basic RAG.
+
+This module provides:
+- BasicRAG
+"""
+
+import json
+from typing import List, Optional, Union
+
+from grag import prompts
+from grag.components.llm import LLM
+from grag.components.multivec_retriever import Retriever
+from grag.components.prompt import FewShotPrompt, Prompt
+from grag.components.utils import get_config
+from importlib_resources import files
+from langchain_core.documents import Document
+
+conf = get_config()
+
+
+
+[docs] +class BasicRAG: + """Class for Basis RAG. + + Attributes: + model_name (str): Name of the llm model + doc_chain (str): Name of the document chain, ("stuff", "refine"), defaults to "stuff" + task (str): Name of task, defaults to "QA" + llm_kwargs (dict): Keyword arguments for LLM class + retriever_kwargs (dict): Keyword arguments for Retriever class + custom_prompt (Prompt): Prompt, defaults to None + """ + + def __init__( + self, + retriever: Optional[Retriever] = None, + model_name=None, + doc_chain="stuff", + task="QA", + llm_kwargs=None, + retriever_kwargs=None, + custom_prompt: Union[Prompt, FewShotPrompt, None] = None, + ): + """Initialize BasicRAG.""" + if retriever is None: + if retriever_kwargs is None: + self.retriever = Retriever() + else: + self.retriever = Retriever(**retriever_kwargs) + else: + self.retriever = retriever + + if llm_kwargs is None: + self.llm_ = LLM() + else: + self.llm_ = LLM(**llm_kwargs) + + self.prompt_path = files(prompts) + self.custom_prompt = custom_prompt + + self._task = "QA" + self.model_name = model_name + self.doc_chain = doc_chain + self.task = task + + if self.custom_prompt is None: + self.main_prompt = Prompt.load( + self.prompt_path.joinpath(self.main_prompt_name) + ) + + if self.doc_chain == "refine": + self.refine_prompt = Prompt.load( + self.prompt_path.joinpath(self.refine_prompt_name) + ) + else: + self.main_prompt = self.custom_prompt + + @property + def model_name(self): + """Return the name of the model.""" + return self._model_name + + @model_name.setter + def model_name(self, value): + if value is None: + self.llm = self.llm_.load_model() + self._model_name = conf["llm"]["model_name"] + else: + self._model_name = value + self.llm = self.llm_.load_model(model_name=self.model_name) + + @property + def doc_chain(self): + """Returns the doc_chain.""" + return self._doc_chain + + @doc_chain.setter + def doc_chain(self, value): + _allowed_doc_chains = ["refine", "stuff"] + if value not in _allowed_doc_chains: + raise ValueError( + f"Doc chain {value} is not allowed. Available choices: {_allowed_doc_chains}" + ) + self._doc_chain = value + if value == "refine": + if self.custom_prompt is not None: + assert len(self.custom_prompt) == 2, ValueError( + f"Refine chain needs 2 custom prompts. {len(self.custom_prompt)} custom prompts were given." + ) + self.prompt_matcher() + + @property + def task(self): + """Returns the task.""" + return self._task + + @task.setter + def task(self, value): + _allowed_tasks = ["QA"] + if value not in _allowed_tasks: + raise ValueError( + f"Task {value} is not allowed. Available tasks: {_allowed_tasks}" + ) + self._task = value + self.prompt_matcher() + +
+[docs] + def prompt_matcher(self): + """Matches relvant prompt using model, task and doc_chain.""" + matcher_path = self.prompt_path.joinpath("matcher.json") + with open(f"{matcher_path}", "r") as f: + matcher_dict = json.load(f) + try: + self.model_type = matcher_dict[self.model_name] + except KeyError: + raise ValueError( + f"Prompt for {self.model_name} not found in {matcher_path}" + ) + + self.main_prompt_name = f"{self.model_type}_{self.task}_1.json" + self.refine_prompt_name = f"{self.model_type}_{self.task}-refine_1.json" + if self.custom_prompt is None: + self.main_prompt = Prompt.load( + self.prompt_path.joinpath(self.main_prompt_name) + ) + if self.doc_chain == "refine": + self.refine_prompt = Prompt.load( + self.prompt_path.joinpath(self.refine_prompt_name) + )
+ + +
+[docs] + @staticmethod + def stuff_docs(docs: List[Document]) -> str: + r"""Concatenates docs into a string seperated by '\n\n'. + + Args: + docs: List of langchain_core.documents.Document + + Returns: + string of document page content joined by '\n\n' + """ + return "\n\n".join([doc.page_content for doc in docs])
+ + +
+[docs] + @staticmethod + def output_parser(call_func): + """Decorator to format llm output.""" + + def output_parser_wrapper(*args, **kwargs): + response, sources = call_func(*args, **kwargs) + if conf["llm"]["std_out"] == "False": + # if self.llm_.callback_manager is None: + print(response) + print("Sources: ") + for index, source in enumerate(sources): + print(f"\t{index}: {source}") + return response, sources + + return output_parser_wrapper
+ + +
+[docs] + @output_parser + def stuff_call(self, query: str): + """Call function for stuff chain.""" + retrieved_docs = self.retriever.get_chunk(query) + context = self.stuff_docs(retrieved_docs) + prompt = self.main_prompt.format(context=context, question=query) + response = self.llm.invoke(prompt) + sources = [doc.metadata["source"] for doc in retrieved_docs] + return response, sources
+ + +
+[docs] + @output_parser + def refine_call(self, query: str): + """Call function for refine chain.""" + retrieved_docs = self.retriever.get_chunk(query) + sources = [doc.metadata["source"] for doc in retrieved_docs] + responses = [] + for index, doc in enumerate(retrieved_docs): + if index == 0: + prompt = self.main_prompt.format( + context=doc.page_content, question=query + ) + response = self.llm.invoke(prompt) + responses.append(response) + else: + prompt = self.refine_prompt.format( + context=doc.page_content, + question=query, + existing_answer=responses[-1], + ) + response = self.llm.invoke(prompt) + responses.append(response) + return responses, sources
+ + + def __call__(self, query: str): + """Call function for the class.""" + if self.doc_chain == "stuff": + return self.stuff_call(query) + elif self.doc_chain == "refine": + return self.refine_call(query)
+ +
+ +
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/src/docs/_build/html/_modules/index.html b/src/docs/_build/html/_modules/index.html new file mode 100644 index 0000000..d3861e6 --- /dev/null +++ b/src/docs/_build/html/_modules/index.html @@ -0,0 +1,114 @@ + + + + + + Overview: module code — GRAG 0.0.1 documentation + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+
    +
  • + +
  • +
  • +
+
+
+ + +
+
+
+
+ + + + \ No newline at end of file diff --git a/src/docs/_build/html/_sources/auto_examples/Basic-RAG/BasicRAG_refine.rst.txt b/src/docs/_build/html/_sources/auto_examples/Basic-RAG/BasicRAG_refine.rst.txt index 5c19462..3d0a0ee 100644 --- a/src/docs/_build/html/_sources/auto_examples/Basic-RAG/BasicRAG_refine.rst.txt +++ b/src/docs/_build/html/_sources/auto_examples/Basic-RAG/BasicRAG_refine.rst.txt @@ -20,8 +20,11 @@ Refine Chain ======================= This cookbook demonstrates how to use the refine chain for BasicRAG. +.. image:: src/docs/_static/refine_chain_langchain_illustration.jpg + :width: 400 + :alt: Refine Documents Chain Process -.. GENERATED FROM PYTHON SOURCE LINES 5-18 +.. GENERATED FROM PYTHON SOURCE LINES 8-21 .. code-block:: Python diff --git a/src/docs/_build/html/_sources/auto_examples/Basic-RAG/BasicRAG_stuff.rst.txt b/src/docs/_build/html/_sources/auto_examples/Basic-RAG/BasicRAG_stuff.rst.txt index 02a9d6f..cd49781 100644 --- a/src/docs/_build/html/_sources/auto_examples/Basic-RAG/BasicRAG_stuff.rst.txt +++ b/src/docs/_build/html/_sources/auto_examples/Basic-RAG/BasicRAG_stuff.rst.txt @@ -20,8 +20,11 @@ Stuff Chain ======================= This cookbook demonstrates how to use the stuff chain for BasicRAG. +.. image:: src/docs/_static/stuff_chain_langchain_illustration.jpg + :width: 400 + :alt: Stuff Documents Chain Process -.. GENERATED FROM PYTHON SOURCE LINES 5-19 +.. GENERATED FROM PYTHON SOURCE LINES 8-22 .. code-block:: Python diff --git a/src/docs/_build/html/_static/autoclasstoc.css b/src/docs/_build/html/_static/autoclasstoc.css new file mode 100644 index 0000000..8fbfd84 --- /dev/null +++ b/src/docs/_build/html/_static/autoclasstoc.css @@ -0,0 +1,12 @@ +.autoclasstoc table.docutils td>p { + margin-bottom: 0 !important; +} + +.autoclasstoc details:last-of-type { + margin-bottom: 18px; +} + +.autoclasstoc .wy-table-responsive { + margin-bottom: 12px; +} + diff --git a/src/docs/_build/html/_static/basic_RAG_pipeline.png b/src/docs/_build/html/_static/basic_RAG_pipeline.png new file mode 100644 index 0000000..9a9564c Binary files /dev/null and b/src/docs/_build/html/_static/basic_RAG_pipeline.png differ diff --git a/src/docs/_build/html/_static/refine_chain_langchain_illustration.jpg b/src/docs/_build/html/_static/refine_chain_langchain_illustration.jpg new file mode 100644 index 0000000..cdf9b84 Binary files /dev/null and b/src/docs/_build/html/_static/refine_chain_langchain_illustration.jpg differ diff --git a/src/docs/_build/html/_static/stuff_chain_langchain_illustration.jpg b/src/docs/_build/html/_static/stuff_chain_langchain_illustration.jpg new file mode 100644 index 0000000..e953dce Binary files /dev/null and b/src/docs/_build/html/_static/stuff_chain_langchain_illustration.jpg differ diff --git a/src/docs/_build/html/auto_examples/Basic-RAG/BasicRAG_refine.html b/src/docs/_build/html/auto_examples/Basic-RAG/BasicRAG_refine.html index ab5637b..15d90ea 100644 --- a/src/docs/_build/html/auto_examples/Basic-RAG/BasicRAG_refine.html +++ b/src/docs/_build/html/auto_examples/Basic-RAG/BasicRAG_refine.html @@ -99,7 +99,18 @@

Refine Chain

-

This cookbook demonstrates how to use the refine chain for BasicRAG.

+

This cookbook demonstrates how to use the refine chain for BasicRAG. +.. image:: src/docs/_static/refine_chain_langchain_illustration.jpg

+
+
+
width:
+

400

+
+
alt:
+

Refine Documents Chain Process

+
+
+
from grag.components.multivec_retriever import Retriever
 from grag.components.vectordb.deeplake_client import DeepLakeClient
 from grag.rag.basic_rag import BasicRAG
diff --git a/src/docs/_build/html/auto_examples/Basic-RAG/BasicRAG_stuff.html b/src/docs/_build/html/auto_examples/Basic-RAG/BasicRAG_stuff.html
index 5def119..db4f6cf 100644
--- a/src/docs/_build/html/auto_examples/Basic-RAG/BasicRAG_stuff.html
+++ b/src/docs/_build/html/auto_examples/Basic-RAG/BasicRAG_stuff.html
@@ -99,7 +99,18 @@
 

Stuff Chain

-

This cookbook demonstrates how to use the stuff chain for BasicRAG.

+

This cookbook demonstrates how to use the stuff chain for BasicRAG. +.. image:: src/docs/_static/stuff_chain_langchain_illustration.jpg

+
+
+
width:
+

400

+
+
alt:
+

Stuff Documents Chain Process

+
+
+
from grag.components.multivec_retriever import Retriever
 from grag.components.vectordb.deeplake_client import DeepLakeClient
 from grag.rag.basic_rag import BasicRAG
diff --git a/src/docs/_build/html/searchindex.js b/src/docs/_build/html/searchindex.js
index 9c912b6..4f22741 100644
--- a/src/docs/_build/html/searchindex.js
+++ b/src/docs/_build/html/searchindex.js
@@ -1 +1 @@
-Search.setIndex({"alltitles": {"Base": [[18, "module-grag.components.vectordb.base"]], "Basic RAG": [[21, "module-grag.rag.basic_rag"]], "Basic-RAG Cookbooks": [[5, "basic-rag-cookbooks"]], "Chroma": [[15, "chroma"]], "Chroma Client": [[18, "module-grag.components.vectordb.chroma_client"]], "Components": [[17, "components"]], "Computation times": [[6, "computation-times"], [9, "computation-times"], [24, "computation-times"]], "Contents:": [[22, null]], "Cookbooks": [[10, "cookbooks"]], "Custom Few-Shot Prompts": [[1, "custom-few-shot-prompts"]], "Custom Prompts": [[0, "custom-prompts"]], "Data Ingestion": [[15, "data-ingestion"]], "Deeplake Client": [[18, "module-grag.components.vectordb.deeplake_client"]], "Document Ingestion": [[2, "document-ingestion"]], "Embedding": [[17, "module-grag.components.embedding"]], "Embeddings": [[15, "embeddings"]], "GRAG": [[16, "grag"]], "GRAG Overview": [[13, "grag-overview"]], "Get Started": [[11, "get-started"]], "How to quantize models.": [[14, "how-to-quantize-models"]], "Indices and tables": [[22, "indices-and-tables"]], "Installation": [[12, "installation"]], "LLM": [[17, "module-grag.components.llm"]], "LLMs": [[14, "llms"]], "Module Contents": [[18, "module-grag.components.vectordb"]], "Module contents": [[16, "module-grag"], [17, "module-grag.components"], [19, "module-grag.prompts"], [20, "module-grag.quantize"], [21, "module-grag.rag"]], "Parse PDF": [[17, "module-grag.components.parse_pdf"]], "Prompt": [[17, "module-grag.components.prompt"]], "Prompts": [[19, "prompts"]], "Quantize": [[20, "quantize"], [20, "id1"]], "RAG": [[21, "rag"]], "Refine Chain": [[3, "refine-chain"]], "Retrieval-Augmented Generation": [[13, "retrieval-augmented-generation"]], "Retriever": [[17, "module-grag.components.multivec_retriever"]], "Retriever GUI": [[8, "retriever-gui"]], "Retriever-GUI Cookbooks": [[7, "retriever-gui-cookbooks"]], "Stuff Chain": [[4, "stuff-chain"]], "Submodules": [[18, "submodules"], [20, "submodules"], [21, "submodules"]], "Supported Vector Stores": [[15, "supported-vector-stores"]], "Text Splitter": [[17, "module-grag.components.text_splitter"]], "To run LLMs using HuggingFace": [[14, "to-run-llms-using-huggingface"]], "To run LLMs using LlamaCPP": [[14, "to-run-llms-using-llamacpp"]], "Utils": [[17, "module-grag.components.utils"], [20, "module-grag.quantize.utils"]], "Vector Stores": [[15, "vector-stores"]], "VectorDB": [[17, "vectordb"], [18, "vectordb"]], "Welcome to GRAG\u2019s documentation!": [[22, "welcome-to-grag-s-documentation"]], "grag": [[23, "grag"]]}, "docnames": ["auto_examples/Basic-RAG/BasicRAG_CustomPrompt", "auto_examples/Basic-RAG/BasicRAG_FewShotPrompt", "auto_examples/Basic-RAG/BasicRAG_ingest", "auto_examples/Basic-RAG/BasicRAG_refine", "auto_examples/Basic-RAG/BasicRAG_stuff", "auto_examples/Basic-RAG/index", "auto_examples/Basic-RAG/sg_execution_times", "auto_examples/Retriver-GUI/index", "auto_examples/Retriver-GUI/retriever_app", "auto_examples/Retriver-GUI/sg_execution_times", "auto_examples_index", "get_started", "get_started.installation", "get_started.introduction", "get_started.llms", "get_started.vectordb", "grag", "grag.components", "grag.components.vectordb", "grag.prompts", "grag.quantize", "grag.rag", "index", "modules", "sg_execution_times"], "envversion": {"sphinx": 61, "sphinx.domains.c": 3, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 9, "sphinx.domains.index": 1, "sphinx.domains.javascript": 3, "sphinx.domains.math": 2, "sphinx.domains.python": 4, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx.ext.todo": 2}, "filenames": ["auto_examples/Basic-RAG/BasicRAG_CustomPrompt.rst", "auto_examples/Basic-RAG/BasicRAG_FewShotPrompt.rst", "auto_examples/Basic-RAG/BasicRAG_ingest.rst", "auto_examples/Basic-RAG/BasicRAG_refine.rst", "auto_examples/Basic-RAG/BasicRAG_stuff.rst", "auto_examples/Basic-RAG/index.rst", "auto_examples/Basic-RAG/sg_execution_times.rst", "auto_examples/Retriver-GUI/index.rst", "auto_examples/Retriver-GUI/retriever_app.rst", "auto_examples/Retriver-GUI/sg_execution_times.rst", "auto_examples_index.rst", "get_started.rst", "get_started.installation.rst", "get_started.introduction.rst", "get_started.llms.rst", "get_started.vectordb.rst", "grag.rst", "grag.components.rst", "grag.components.vectordb.rst", "grag.prompts.rst", "grag.quantize.rst", "grag.rag.rst", "index.rst", "modules.rst", "sg_execution_times.rst"], "indexentries": {"aadd_docs() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.aadd_docs", false]], "aadd_docs() (grag.components.vectordb.base.vectordb method)": [[18, "grag.components.vectordb.base.VectorDB.aadd_docs", false]], "aadd_docs() (grag.components.vectordb.chroma_client.chromaclient method)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.aadd_docs", false]], "aadd_docs() (grag.components.vectordb.deeplake_client.deeplakeclient method)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.aadd_docs", false]], "add_caption_first (grag.components.parse_pdf.parsepdf attribute)": [[17, "grag.components.parse_pdf.ParsePDF.add_caption_first", false]], "add_captions_to_blocks (grag.components.parse_pdf.parsepdf attribute)": [[17, "grag.components.parse_pdf.ParsePDF.add_captions_to_blocks", false]], "add_captions_to_text (grag.components.parse_pdf.parsepdf attribute)": [[17, "grag.components.parse_pdf.ParsePDF.add_captions_to_text", false]], "add_docs() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.add_docs", false]], "add_docs() (grag.components.vectordb.base.vectordb method)": [[18, "grag.components.vectordb.base.VectorDB.add_docs", false]], "add_docs() (grag.components.vectordb.chroma_client.chromaclient method)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.add_docs", false]], "add_docs() (grag.components.vectordb.deeplake_client.deeplakeclient method)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.add_docs", false]], "aget_chunk() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.aget_chunk", false]], "aget_chunk() (grag.components.vectordb.base.vectordb method)": [[18, "grag.components.vectordb.base.VectorDB.aget_chunk", false]], "aget_chunk() (grag.components.vectordb.chroma_client.chromaclient method)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.aget_chunk", false]], "aget_chunk() (grag.components.vectordb.deeplake_client.deeplakeclient method)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.aget_chunk", false]], "aget_doc() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.aget_doc", false]], "aingest() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.aingest", false]], "basicrag (class in grag.rag.basic_rag)": [[21, "grag.rag.basic_rag.BasicRAG", false]], "building_llamacpp() (in module grag.quantize.utils)": [[20, "grag.quantize.utils.building_llamacpp", false]], "chromaclient (class in grag.components.vectordb.chroma_client)": [[18, "grag.components.vectordb.chroma_client.ChromaClient", false]], "chunk_overlap (grag.components.text_splitter.textsplitter attribute)": [[17, "grag.components.text_splitter.TextSplitter.chunk_overlap", false]], "chunk_size (grag.components.text_splitter.textsplitter attribute)": [[17, "grag.components.text_splitter.TextSplitter.chunk_size", false]], "classify() (grag.components.parse_pdf.parsepdf method)": [[17, "grag.components.parse_pdf.ParsePDF.classify", false]], "client (grag.components.vectordb.chroma_client.chromaclient attribute)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.client", false]], "client (grag.components.vectordb.deeplake_client.deeplakeclient attribute)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.client", false]], "collection (grag.components.vectordb.chroma_client.chromaclient attribute)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.collection", false]], "collection (grag.components.vectordb.deeplake_client.deeplakeclient attribute)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.collection", false]], "collection_name (grag.components.vectordb.chroma_client.chromaclient attribute)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.collection_name", false]], "custom_prompt (grag.rag.basic_rag.basicrag attribute)": [[21, "grag.rag.basic_rag.BasicRAG.custom_prompt", false]], "deeplakeclient (class in grag.components.vectordb.deeplake_client)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient", false]], "delete() (grag.components.vectordb.base.vectordb method)": [[18, "grag.components.vectordb.base.VectorDB.delete", false]], "delete() (grag.components.vectordb.chroma_client.chromaclient method)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.delete", false]], "delete() (grag.components.vectordb.deeplake_client.deeplakeclient method)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.delete", false]], "device_map (grag.components.llm.llm attribute)": [[17, "grag.components.llm.LLM.device_map", false]], "doc_chain (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.doc_chain", false]], "doc_chain (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.doc_chain", false], [17, "id6", false]], "doc_chain (grag.rag.basic_rag.basicrag attribute)": [[21, "grag.rag.basic_rag.BasicRAG.doc_chain", false]], "doc_chain (grag.rag.basic_rag.basicrag property)": [[21, "id0", false]], "embedding (class in grag.components.embedding)": [[17, "grag.components.embedding.Embedding", false]], "embedding_function (grag.components.embedding.embedding attribute)": [[17, "grag.components.embedding.Embedding.embedding_function", false]], "embedding_function (grag.components.vectordb.chroma_client.chromaclient attribute)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.embedding_function", false]], "embedding_function (grag.components.vectordb.deeplake_client.deeplakeclient attribute)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.embedding_function", false]], "embedding_model (grag.components.embedding.embedding attribute)": [[17, "grag.components.embedding.Embedding.embedding_model", false]], "embedding_model (grag.components.vectordb.chroma_client.chromaclient attribute)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.embedding_model", false]], "embedding_model (grag.components.vectordb.deeplake_client.deeplakeclient attribute)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.embedding_model", false]], "embedding_type (grag.components.embedding.embedding attribute)": [[17, "grag.components.embedding.Embedding.embedding_type", false]], "embedding_type (grag.components.vectordb.chroma_client.chromaclient attribute)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.embedding_type", false]], "embedding_type (grag.components.vectordb.deeplake_client.deeplakeclient attribute)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.embedding_type", false]], "example_template (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.example_template", false], [17, "id2", false]], "examples (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.examples", false], [17, "id3", false]], "extract_image_block_types (grag.components.parse_pdf.parsepdf attribute)": [[17, "grag.components.parse_pdf.ParsePDF.extract_image_block_types", false]], "extract_images (grag.components.parse_pdf.parsepdf attribute)": [[17, "grag.components.parse_pdf.ParsePDF.extract_images", false]], "fetch_model_repo() (in module grag.quantize.utils)": [[20, "grag.quantize.utils.fetch_model_repo", false]], "fewshotprompt (class in grag.components.prompt)": [[17, "grag.components.prompt.FewShotPrompt", false]], "filepath (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.filepath", false]], "filepath (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.filepath", false], [17, "id7", false]], "find_config_path() (in module grag.components.utils)": [[17, "grag.components.utils.find_config_path", false]], "format() (grag.components.prompt.prompt method)": [[17, "grag.components.prompt.Prompt.format", false]], "gen_doc_ids() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.gen_doc_ids", false]], "get_chunk() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.get_chunk", false]], "get_chunk() (grag.components.vectordb.base.vectordb method)": [[18, "grag.components.vectordb.base.VectorDB.get_chunk", false]], "get_chunk() (grag.components.vectordb.chroma_client.chromaclient method)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.get_chunk", false]], "get_chunk() (grag.components.vectordb.deeplake_client.deeplakeclient method)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.get_chunk", false]], "get_config() (in module grag.components.utils)": [[17, "grag.components.utils.get_config", false]], "get_doc() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.get_doc", false]], "get_docs_from_chunks() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.get_docs_from_chunks", false]], "get_llamacpp_repo() (in module grag.quantize.utils)": [[20, "grag.quantize.utils.get_llamacpp_repo", false]], "grag": [[16, "module-grag", false]], "grag.components": [[17, "module-grag.components", false]], "grag.components.embedding": [[17, "module-grag.components.embedding", false]], "grag.components.llm": [[17, "module-grag.components.llm", false]], "grag.components.multivec_retriever": [[17, "module-grag.components.multivec_retriever", false]], "grag.components.parse_pdf": [[17, "module-grag.components.parse_pdf", false]], "grag.components.prompt": [[17, "module-grag.components.prompt", false]], "grag.components.text_splitter": [[17, "module-grag.components.text_splitter", false]], "grag.components.utils": [[17, "module-grag.components.utils", false]], "grag.components.vectordb": [[18, "module-grag.components.vectordb", false]], "grag.components.vectordb.base": [[18, "module-grag.components.vectordb.base", false]], "grag.components.vectordb.chroma_client": [[18, "module-grag.components.vectordb.chroma_client", false]], "grag.components.vectordb.deeplake_client": [[18, "module-grag.components.vectordb.deeplake_client", false]], "grag.prompts": [[19, "module-grag.prompts", false]], "grag.quantize": [[20, "module-grag.quantize", false]], "grag.quantize.quantize": [[20, "module-grag.quantize.quantize", false]], "grag.quantize.utils": [[20, "module-grag.quantize.utils", false]], "grag.rag": [[21, "module-grag.rag", false]], "grag.rag.basic_rag": [[21, "module-grag.rag.basic_rag", false]], "hf_pipeline() (grag.components.llm.llm method)": [[17, "grag.components.llm.LLM.hf_pipeline", false]], "host (grag.components.vectordb.chroma_client.chromaclient attribute)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.host", false]], "id_gen() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.id_gen", false]], "id_key (grag.components.multivec_retriever.retriever attribute)": [[17, "grag.components.multivec_retriever.Retriever.id_key", false]], "image_output_dir (grag.components.parse_pdf.parsepdf attribute)": [[17, "grag.components.parse_pdf.ParsePDF.image_output_dir", false]], "infer_table_structure (grag.components.parse_pdf.parsepdf attribute)": [[17, "grag.components.parse_pdf.ParsePDF.infer_table_structure", false]], "ingest() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.ingest", false]], "input_keys (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.input_keys", false], [17, "id1", false]], "input_keys (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.input_keys", false], [17, "id8", false]], "langchain_client (grag.components.vectordb.chroma_client.chromaclient attribute)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.langchain_client", false]], "langchain_client (grag.components.vectordb.deeplake_client.deeplakeclient attribute)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.langchain_client", false]], "language (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.language", false]], "language (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.language", false], [17, "id9", false]], "llama_cpp() (grag.components.llm.llm method)": [[17, "grag.components.llm.LLM.llama_cpp", false]], "llm (class in grag.components.llm)": [[17, "grag.components.llm.LLM", false]], "llm_kwargs (grag.rag.basic_rag.basicrag attribute)": [[21, "grag.rag.basic_rag.BasicRAG.llm_kwargs", false]], "llm_type (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.llm_type", false]], "llm_type (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.llm_type", false], [17, "id10", false]], "load() (grag.components.prompt.prompt class method)": [[17, "grag.components.prompt.Prompt.load", false]], "load_file() (grag.components.parse_pdf.parsepdf method)": [[17, "grag.components.parse_pdf.ParsePDF.load_file", false]], "load_model() (grag.components.llm.llm method)": [[17, "grag.components.llm.LLM.load_model", false]], "max_new_tokens (grag.components.llm.llm attribute)": [[17, "grag.components.llm.LLM.max_new_tokens", false]], "model_computed_fields (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.model_computed_fields", false]], "model_computed_fields (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.model_computed_fields", false]], "model_config (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.model_config", false]], "model_config (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.model_config", false]], "model_fields (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.model_fields", false]], "model_fields (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.model_fields", false]], "model_name (grag.components.llm.llm attribute)": [[17, "grag.components.llm.LLM.model_name", false]], "model_name (grag.components.llm.llm property)": [[17, "id0", false]], "model_name (grag.rag.basic_rag.basicrag attribute)": [[21, "grag.rag.basic_rag.BasicRAG.model_name", false]], "model_name (grag.rag.basic_rag.basicrag property)": [[21, "id1", false]], "model_path (grag.components.llm.llm property)": [[17, "grag.components.llm.LLM.model_path", false]], "module": [[16, "module-grag", false], [17, "module-grag.components", false], [17, "module-grag.components.embedding", false], [17, "module-grag.components.llm", false], [17, "module-grag.components.multivec_retriever", false], [17, "module-grag.components.parse_pdf", false], [17, "module-grag.components.prompt", false], [17, "module-grag.components.text_splitter", false], [17, "module-grag.components.utils", false], [18, "module-grag.components.vectordb", false], [18, "module-grag.components.vectordb.base", false], [18, "module-grag.components.vectordb.chroma_client", false], [18, "module-grag.components.vectordb.deeplake_client", false], [19, "module-grag.prompts", false], [20, "module-grag.quantize", false], [20, "module-grag.quantize.quantize", false], [20, "module-grag.quantize.utils", false], [21, "module-grag.rag", false], [21, "module-grag.rag.basic_rag", false]], "n_batch (grag.components.llm.llm attribute)": [[17, "grag.components.llm.LLM.n_batch", false]], "n_ctx (grag.components.llm.llm attribute)": [[17, "grag.components.llm.LLM.n_ctx", false]], "n_gpu_layers (grag.components.llm.llm attribute)": [[17, "grag.components.llm.LLM.n_gpu_layers", false]], "name (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.name", false]], "name (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.name", false], [17, "id11", false]], "namespace (grag.components.multivec_retriever.retriever attribute)": [[17, "grag.components.multivec_retriever.Retriever.namespace", false]], "output_keys (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.output_keys", false]], "output_parser() (grag.rag.basic_rag.basicrag static method)": [[21, "grag.rag.basic_rag.BasicRAG.output_parser", false]], "parsepdf (class in grag.components.parse_pdf)": [[17, "grag.components.parse_pdf.ParsePDF", false]], "partition() (grag.components.parse_pdf.parsepdf method)": [[17, "grag.components.parse_pdf.ParsePDF.partition", false]], "port (grag.components.vectordb.chroma_client.chromaclient attribute)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.port", false]], "prefix (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.prefix", false], [17, "id4", false]], "process_images() (grag.components.parse_pdf.parsepdf method)": [[17, "grag.components.parse_pdf.ParsePDF.process_images", false]], "process_tables() (grag.components.parse_pdf.parsepdf method)": [[17, "grag.components.parse_pdf.ParsePDF.process_tables", false]], "process_text() (grag.components.parse_pdf.parsepdf method)": [[17, "grag.components.parse_pdf.ParsePDF.process_text", false]], "prompt (class in grag.components.prompt)": [[17, "grag.components.prompt.Prompt", false]], "prompt (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.prompt", false]], "prompt_matcher() (grag.rag.basic_rag.basicrag method)": [[21, "grag.rag.basic_rag.BasicRAG.prompt_matcher", false]], "quantize_model() (in module grag.quantize.utils)": [[20, "grag.quantize.utils.quantize_model", false]], "refine_call() (grag.rag.basic_rag.basicrag method)": [[21, "grag.rag.basic_rag.BasicRAG.refine_call", false]], "retriever (class in grag.components.multivec_retriever)": [[17, "grag.components.multivec_retriever.Retriever", false]], "retriever (grag.components.multivec_retriever.retriever attribute)": [[17, "grag.components.multivec_retriever.Retriever.retriever", false]], "retriever_kwargs (grag.rag.basic_rag.basicrag attribute)": [[21, "grag.rag.basic_rag.BasicRAG.retriever_kwargs", false]], "save() (grag.components.prompt.prompt method)": [[17, "grag.components.prompt.Prompt.save", false]], "single_text_out (grag.components.parse_pdf.parsepdf attribute)": [[17, "grag.components.parse_pdf.ParsePDF.single_text_out", false]], "source (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.source", false]], "source (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.source", false], [17, "id12", false]], "split_docs() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.split_docs", false]], "splitter (grag.components.multivec_retriever.retriever attribute)": [[17, "grag.components.multivec_retriever.Retriever.splitter", false]], "store (grag.components.multivec_retriever.retriever attribute)": [[17, "grag.components.multivec_retriever.Retriever.store", false]], "store_path (grag.components.multivec_retriever.retriever attribute)": [[17, "grag.components.multivec_retriever.Retriever.store_path", false]], "store_path (grag.components.vectordb.deeplake_client.deeplakeclient attribute)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.store_path", false]], "strategy (grag.components.parse_pdf.parsepdf attribute)": [[17, "grag.components.parse_pdf.ParsePDF.strategy", false]], "stuff_call() (grag.rag.basic_rag.basicrag method)": [[21, "grag.rag.basic_rag.BasicRAG.stuff_call", false]], "stuff_docs() (grag.rag.basic_rag.basicrag static method)": [[21, "grag.rag.basic_rag.BasicRAG.stuff_docs", false]], "stuff_docs() (in module grag.components.utils)": [[17, "grag.components.utils.stuff_docs", false]], "suffix (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.suffix", false], [17, "id5", false]], "task (grag.components.llm.llm attribute)": [[17, "grag.components.llm.LLM.task", false]], "task (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.task", false]], "task (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.task", false], [17, "id13", false]], "task (grag.rag.basic_rag.basicrag attribute)": [[21, "grag.rag.basic_rag.BasicRAG.task", false]], "task (grag.rag.basic_rag.basicrag property)": [[21, "id2", false]], "temperature (grag.components.llm.llm attribute)": [[17, "grag.components.llm.LLM.temperature", false]], "template (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.template", false]], "test_connection() (grag.components.vectordb.chroma_client.chromaclient method)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.test_connection", false]], "text_concat() (grag.components.parse_pdf.parsepdf method)": [[17, "grag.components.parse_pdf.ParsePDF.text_concat", false]], "text_splitter (grag.components.text_splitter.textsplitter attribute)": [[17, "grag.components.text_splitter.TextSplitter.text_splitter", false]], "textsplitter (class in grag.components.text_splitter)": [[17, "grag.components.text_splitter.TextSplitter", false]], "top_k (grag.components.multivec_retriever.retriever attribute)": [[17, "grag.components.multivec_retriever.Retriever.top_k", false]], "validate_doc_chain() (grag.components.prompt.prompt class method)": [[17, "grag.components.prompt.Prompt.validate_doc_chain", false]], "validate_examples() (grag.components.prompt.fewshotprompt class method)": [[17, "grag.components.prompt.FewShotPrompt.validate_examples", false]], "validate_input_keys() (grag.components.prompt.prompt class method)": [[17, "grag.components.prompt.Prompt.validate_input_keys", false]], "validate_output_keys() (grag.components.prompt.fewshotprompt class method)": [[17, "grag.components.prompt.FewShotPrompt.validate_output_keys", false]], "validate_task() (grag.components.prompt.prompt class method)": [[17, "grag.components.prompt.Prompt.validate_task", false]], "vectordb (class in grag.components.vectordb.base)": [[18, "grag.components.vectordb.base.VectorDB", false]], "vectordb (grag.components.multivec_retriever.retriever attribute)": [[17, "grag.components.multivec_retriever.Retriever.vectordb", false]]}, "objects": {"": [[16, 0, 0, "-", "grag"]], "grag": [[17, 0, 0, "-", "components"], [19, 0, 0, "-", "prompts"], [20, 0, 0, "-", "quantize"], [21, 0, 0, "-", "rag"]], "grag.components": [[17, 0, 0, "-", "embedding"], [17, 0, 0, "-", "llm"], [17, 0, 0, "-", "multivec_retriever"], [17, 0, 0, "-", "parse_pdf"], [17, 0, 0, "-", "prompt"], [17, 0, 0, "-", "text_splitter"], [17, 0, 0, "-", "utils"], [18, 0, 0, "-", "vectordb"]], "grag.components.embedding": [[17, 1, 1, "", "Embedding"]], "grag.components.embedding.Embedding": [[17, 2, 1, "", "embedding_function"], [17, 2, 1, "", "embedding_model"], [17, 2, 1, "", "embedding_type"]], "grag.components.llm": [[17, 1, 1, "", "LLM"]], "grag.components.llm.LLM": [[17, 2, 1, "", "device_map"], [17, 3, 1, "", "hf_pipeline"], [17, 3, 1, "", "llama_cpp"], [17, 3, 1, "", "load_model"], [17, 2, 1, "", "max_new_tokens"], [17, 4, 1, "id0", "model_name"], [17, 4, 1, "", "model_path"], [17, 2, 1, "", "n_batch"], [17, 2, 1, "", "n_ctx"], [17, 2, 1, "", "n_gpu_layers"], [17, 2, 1, "", "task"], [17, 2, 1, "", "temperature"]], "grag.components.multivec_retriever": [[17, 1, 1, "", "Retriever"]], "grag.components.multivec_retriever.Retriever": [[17, 3, 1, "", "aadd_docs"], [17, 3, 1, "", "add_docs"], [17, 3, 1, "", "aget_chunk"], [17, 3, 1, "", "aget_doc"], [17, 3, 1, "", "aingest"], [17, 3, 1, "", "gen_doc_ids"], [17, 3, 1, "", "get_chunk"], [17, 3, 1, "", "get_doc"], [17, 3, 1, "", "get_docs_from_chunks"], [17, 3, 1, "", "id_gen"], [17, 2, 1, "", "id_key"], [17, 3, 1, "", "ingest"], [17, 2, 1, "", "namespace"], [17, 2, 1, "", "retriever"], [17, 3, 1, "", "split_docs"], [17, 2, 1, "", "splitter"], [17, 2, 1, "", "store"], [17, 2, 1, "", "store_path"], [17, 2, 1, "", "top_k"], [17, 2, 1, "", "vectordb"]], "grag.components.parse_pdf": [[17, 1, 1, "", "ParsePDF"]], "grag.components.parse_pdf.ParsePDF": [[17, 2, 1, "", "add_caption_first"], [17, 2, 1, "", "add_captions_to_blocks"], [17, 2, 1, "", "add_captions_to_text"], [17, 3, 1, "", "classify"], [17, 2, 1, "", "extract_image_block_types"], [17, 2, 1, "", "extract_images"], [17, 2, 1, "", "image_output_dir"], [17, 2, 1, "", "infer_table_structure"], [17, 3, 1, "", "load_file"], [17, 3, 1, "", "partition"], [17, 3, 1, "", "process_images"], [17, 3, 1, "", "process_tables"], [17, 3, 1, "", "process_text"], [17, 2, 1, "", "single_text_out"], [17, 2, 1, "", "strategy"], [17, 3, 1, "", "text_concat"]], "grag.components.prompt": [[17, 1, 1, "", "FewShotPrompt"], [17, 1, 1, "", "Prompt"]], "grag.components.prompt.FewShotPrompt": [[17, 2, 1, "", "doc_chain"], [17, 2, 1, "id2", "example_template"], [17, 2, 1, "id3", "examples"], [17, 2, 1, "", "filepath"], [17, 2, 1, "id1", "input_keys"], [17, 2, 1, "", "language"], [17, 2, 1, "", "llm_type"], [17, 2, 1, "", "model_computed_fields"], [17, 2, 1, "", "model_config"], [17, 2, 1, "", "model_fields"], [17, 2, 1, "", "name"], [17, 2, 1, "", "output_keys"], [17, 2, 1, "id4", "prefix"], [17, 2, 1, "", "source"], [17, 2, 1, "id5", "suffix"], [17, 2, 1, "", "task"], [17, 3, 1, "", "validate_examples"], [17, 3, 1, "", "validate_output_keys"]], "grag.components.prompt.Prompt": [[17, 2, 1, "id6", "doc_chain"], [17, 2, 1, "id7", "filepath"], [17, 3, 1, "", "format"], [17, 2, 1, "id8", "input_keys"], [17, 2, 1, "id9", "language"], [17, 2, 1, "id10", "llm_type"], [17, 3, 1, "", "load"], [17, 2, 1, "", "model_computed_fields"], [17, 2, 1, "", "model_config"], [17, 2, 1, "", "model_fields"], [17, 2, 1, "id11", "name"], [17, 2, 1, "", "prompt"], [17, 3, 1, "", "save"], [17, 2, 1, "id12", "source"], [17, 2, 1, "id13", "task"], [17, 2, 1, "", "template"], [17, 3, 1, "", "validate_doc_chain"], [17, 3, 1, "", "validate_input_keys"], [17, 3, 1, "", "validate_task"]], "grag.components.text_splitter": [[17, 1, 1, "", "TextSplitter"]], "grag.components.text_splitter.TextSplitter": [[17, 2, 1, "", "chunk_overlap"], [17, 2, 1, "", "chunk_size"], [17, 2, 1, "", "text_splitter"]], "grag.components.utils": [[17, 5, 1, "", "find_config_path"], [17, 5, 1, "", "get_config"], [17, 5, 1, "", "stuff_docs"]], "grag.components.vectordb": [[18, 0, 0, "-", "base"], [18, 0, 0, "-", "chroma_client"], [18, 0, 0, "-", "deeplake_client"]], "grag.components.vectordb.base": [[18, 1, 1, "", "VectorDB"]], "grag.components.vectordb.base.VectorDB": [[18, 3, 1, "", "aadd_docs"], [18, 3, 1, "", "add_docs"], [18, 3, 1, "", "aget_chunk"], [18, 3, 1, "", "delete"], [18, 3, 1, "", "get_chunk"]], "grag.components.vectordb.chroma_client": [[18, 1, 1, "", "ChromaClient"]], "grag.components.vectordb.chroma_client.ChromaClient": [[18, 3, 1, "", "aadd_docs"], [18, 3, 1, "", "add_docs"], [18, 3, 1, "", "aget_chunk"], [18, 2, 1, "", "client"], [18, 2, 1, "", "collection"], [18, 2, 1, "", "collection_name"], [18, 3, 1, "", "delete"], [18, 2, 1, "", "embedding_function"], [18, 2, 1, "", "embedding_model"], [18, 2, 1, "", "embedding_type"], [18, 3, 1, "", "get_chunk"], [18, 2, 1, "", "host"], [18, 2, 1, "", "langchain_client"], [18, 2, 1, "", "port"], [18, 3, 1, "", "test_connection"]], "grag.components.vectordb.deeplake_client": [[18, 1, 1, "", "DeepLakeClient"]], "grag.components.vectordb.deeplake_client.DeepLakeClient": [[18, 3, 1, "", "aadd_docs"], [18, 3, 1, "", "add_docs"], [18, 3, 1, "", "aget_chunk"], [18, 2, 1, "", "client"], [18, 2, 1, "", "collection"], [18, 3, 1, "", "delete"], [18, 2, 1, "", "embedding_function"], [18, 2, 1, "", "embedding_model"], [18, 2, 1, "", "embedding_type"], [18, 3, 1, "", "get_chunk"], [18, 2, 1, "", "langchain_client"], [18, 2, 1, "", "store_path"]], "grag.quantize": [[20, 0, 0, "-", "quantize"], [20, 0, 0, "-", "utils"]], "grag.quantize.utils": [[20, 5, 1, "", "building_llamacpp"], [20, 5, 1, "", "fetch_model_repo"], [20, 5, 1, "", "get_llamacpp_repo"], [20, 5, 1, "", "quantize_model"]], "grag.rag": [[21, 0, 0, "-", "basic_rag"]], "grag.rag.basic_rag": [[21, 1, 1, "", "BasicRAG"]], "grag.rag.basic_rag.BasicRAG": [[21, 2, 1, "", "custom_prompt"], [21, 4, 1, "id0", "doc_chain"], [21, 2, 1, "", "llm_kwargs"], [21, 4, 1, "id1", "model_name"], [21, 3, 1, "", "output_parser"], [21, 3, 1, "", "prompt_matcher"], [21, 3, 1, "", "refine_call"], [21, 2, 1, "", "retriever_kwargs"], [21, 3, 1, "", "stuff_call"], [21, 3, 1, "", "stuff_docs"], [21, 4, 1, "id2", "task"]]}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "class", "Python class"], "2": ["py", "attribute", "Python attribute"], "3": ["py", "method", "Python method"], "4": ["py", "property", "Python property"], "5": ["py", "function", "Python function"]}, "objtypes": {"0": "py:module", "1": "py:class", "2": "py:attribute", "3": "py:method", "4": "py:property", "5": "py:function"}, "terms": {"": 17, "0": [6, 8, 9, 17, 24], "00": [6, 9, 24], "000": [6, 9], "001": 24, "01": 24, "03": 24, "036": 24, "06": 24, "1": [8, 9, 17], "1024": 17, "12": 24, "13b": 17, "2": [2, 15, 17], "237": 24, "275": 24, "3": [8, 14, 17], "3f": 8, "400": 17, "484": 24, "5": [6, 24], "5000": 17, "6000": 17, "8000": [15, 18], "8c9040b0b5cd4d7cbc2e737da1b24ebf": 17, "935": 24, "A": [8, 17, 18, 20], "By": 15, "For": [12, 14, 15], "If": [14, 15, 17], "It": [17, 22], "OR": 15, "The": [8, 17, 18, 20, 22], "To": [11, 15], "__fields__": 17, "__file__": [2, 15], "__init__": 8, "__main__": [3, 4, 8], "__name__": [3, 4, 8], "_queri": 8, "_top_k": 8, "aadd_doc": [16, 17, 18], "abc": 18, "about": [8, 17], "abov": [14, 17], "abstract": 18, "accuraci": 17, "activ": 8, "add": [17, 18], "add_caption_first": [16, 17], "add_captions_to_block": [16, 17], "add_captions_to_text": [16, 17], "add_doc": [16, 17, 18], "addit": 17, "address": [8, 18], "after": [14, 17], "aget_chunk": [16, 17, 18], "aget_doc": [16, 17], "aingest": [2, 16, 17], "alik": 8, "aliv": 18, "all": [5, 7, 17, 18, 19, 24], "also": [17, 22], "altern": 2, "alwai": 17, "an": [7, 13, 14, 22], "ani": [15, 17, 22], "annot": 17, "answer": [0, 1], "anyth": 8, "api": 18, "app": 8, "appli": 20, "applic": 8, "ar": [12, 14, 15], "arg": 8, "argument": [15, 17, 21], "artifici": 8, "arxiv": 18, "async": [2, 17, 18], "asynchron": [2, 17, 18], "asyncio": 2, "attempt": 20, "attribut": 8, "augment": 22, "auth": 14, "auto": 17, "auto_exampl": [6, 9], "avail": 17, "awar": 17, "backend": 8, "bar": 18, "base": [0, 1, 8, 15, 16, 17, 21], "base_dir": 17, "basemodel": 17, "basi": 21, "basic": [0, 1, 6, 10, 16, 22, 23, 24], "basic_rag": [0, 1, 3, 4, 21], "basicrag": [0, 1, 3, 4, 16, 21, 23], "basicrag_customprompt": [0, 6, 24], "basicrag_fewshotprompt": [1, 6, 24], "basicrag_ingest": [2, 6, 24], "basicrag_refin": [3, 6, 24], "basicrag_stuff": [4, 6, 24], "batch": 17, "befor": 17, "being": 17, "below": [1, 5, 7], "better": 17, "block": 17, "blog": 8, "bool": [17, 18], "both": 15, "build": 20, "building_llamacpp": [16, 20, 23], "bulb": 8, "button": 8, "call": 17, "call_func": 21, "came": 1, "can": [12, 14, 15], "cannot": 17, "capstone_5": [17, 18], "caption": 17, "chain": [5, 6, 17, 21], "chang": [14, 15], "chat": 17, "check": [8, 14], "check_connect": 8, "chroma": [2, 8, 16, 17, 22], "chroma_cli": [2, 18], "chromacli": [2, 17, 18], "chromadb": 18, "chunk": [8, 17, 18], "chunk_overlap": [16, 17], "chunk_siz": [16, 17], "ci_test": 2, "class": [8, 17, 18, 21], "classifi": [16, 17], "classmethod": 17, "classvar": 17, "client": [2, 3, 4, 8, 15, 16, 17], "client_kwarg": 17, "clientserv": 15, "clone": [12, 14, 20], "cmake": 20, "co": 20, "code": [0, 1, 2, 3, 4, 5, 7, 8], "collect": [8, 17, 18], "collection_nam": [2, 3, 4, 8, 17, 18], "combin": 17, "command": 14, "complet": 13, "completedprocess": 20, "compon": [0, 1, 2, 3, 4, 8, 15, 16, 18, 22, 23], "comput": 17, "computedfieldinfo": 17, "concat": 17, "concaten": [17, 21], "config": [12, 14, 15, 17], "configdict": 17, "configpars": 17, "configur": 17, "conform": 17, "connect": [8, 17, 18], "contain": [15, 17, 19, 20], "content": 23, "context": [0, 1, 17], "convolut": 1, "cookbook": [0, 1, 2, 3, 4, 8, 15, 22, 24], "copi": [14, 20], "core": 18, "correspond": [17, 18], "cosin": [17, 18], "could": 8, "count": 8, "cpp": [14, 17, 20], "crucial": 15, "current": [15, 17], "current_path": 17, "custom": [5, 6, 12, 17], "custom_few_shot_prompt": 1, "custom_prompt": [0, 1, 16, 17, 21], "data": [2, 11, 17, 18], "databas": [2, 15, 17, 18], "decor": 21, "deeplak": [15, 16, 17, 22], "deeplake_cli": [2, 3, 4, 18], "deeplakecli": [2, 3, 4, 15, 17, 18], "def": 8, "default": [15, 17, 18, 20, 21], "defin": 17, "delet": [17, 18], "demonstr": [0, 1, 2, 3, 4, 5, 7, 8], "deriv": 18, "detail": [8, 14, 15, 17], "develop": 12, "devic": 17, "device_map": [16, 17], "dict": [17, 21], "dictionari": 17, "differ": 19, "dimension": 15, "dir_path": [2, 15, 17], "directori": [14, 17, 20], "displai": 8, "doc": [8, 17, 18, 21], "doc_chain": [0, 1, 3, 4, 16, 17, 21], "doc_id": 17, "document": [5, 6, 17, 18, 21], "doe": [14, 17], "download": [0, 1, 2, 3, 4, 5, 7, 8, 14, 20], "dry_run": 17, "dure": 17, "e": 12, "each": [17, 18], "easi": 22, "easiest": 14, "either": [14, 15], "element": 17, "elif": 2, "els": [8, 18], "embed": [8, 11, 16, 18, 23], "embedding_funct": [16, 17, 18], "embedding_model": [8, 15, 16, 17, 18], "embedding_modelnam": 18, "embedding_typ": [8, 15, 16, 17, 18], "en": 17, "end": [0, 1, 2, 3, 4, 8, 22], "ensur": 17, "enter": [8, 14], "enumer": 8, "etc": [14, 17], "exampl": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 14, 16, 17, 24], "example_templ": [1, 16, 17], "exclud": 17, "execut": [6, 9, 17, 24], "expand": 8, "explain": [], "explicitli": 15, "extract": 17, "extract_imag": [16, 17], "extract_image_block_typ": [16, 17], "f": 8, "f16": 17, "face": 17, "fals": [8, 17, 18], "fetch_model_repo": [16, 20, 23], "few": [5, 6, 17], "fewshotprompt": [1, 16, 17, 21, 23], "field": 17, "fieldinfo": 17, "figur": 17, "file": [6, 9, 12, 14, 15, 17, 20, 24], "filenotfounderror": 17, "filepath": [16, 17], "final": 14, "find": [8, 14, 17], "find_config_path": [16, 17, 23], "flexibl": 14, "float": [17, 18], "folder": 15, "follow": [0, 1, 14], "form": [8, 14], "form_submit_button": 8, "format": [16, 17, 21], "found": 17, "from": [0, 1, 2, 3, 4, 6, 8, 9, 12, 14, 17, 18, 20, 24], "full": [0, 1, 2, 3, 4, 8], "function": [8, 17, 18, 20], "further": 12, "galleri": [0, 1, 2, 3, 4, 5, 7, 8, 24], "gate": 14, "gen_doc_id": [16, 17], "gener": [0, 1, 2, 3, 4, 5, 7, 8, 15, 17, 22], "get": [14, 17, 22], "get_chunk": [8, 16, 17, 18], "get_config": [16, 17, 23], "get_doc": [16, 17], "get_docs_from_chunk": [16, 17], "get_llamacpp_repo": [16, 20, 23], "get_search_result": 8, "getcwd": 8, "gguf": 14, "git": [12, 20], "given": [0, 1, 17, 20], "glob": 17, "glob_pattern": 17, "go": [0, 1, 2, 3, 4, 8], "gpu": 17, "grag": [0, 1, 2, 3, 4, 8, 14, 17, 18, 20, 21], "green": 8, "gui": [9, 10, 22], "gui_jupyt": 7, "gui_python": 7, "ha": [14, 17], "handl": 17, "has_result": 8, "have": 12, "hexadecim": 17, "hf_pipelin": [16, 17], "hi_r": 17, "high": 15, "hkunlp": 18, "hold": 8, "home": [8, 17, 18], "host": [8, 15, 17, 18], "how": [0, 1, 2, 3, 4], "http": 8, "httpclient": 18, "hug": 17, "huggingfac": [11, 15, 17, 20], "i": [1, 5, 7, 8, 13, 14, 15, 17, 18, 20, 22], "id": [14, 17, 20], "id_gen": [16, 17], "id_kei": [16, 17], "identifi": 17, "imag": 17, "image_output_dir": [16, 17], "implement": [13, 22], "import": [0, 1, 2, 3, 4, 8], "includ": 17, "index": 22, "infer_table_structur": [16, 17], "ingest": [5, 6, 11, 16, 17], "ini": [12, 14, 15, 17], "initi": [8, 17], "input": [3, 4, 14, 17], "input_kei": [0, 1, 16, 17], "insert": 8, "instal": [11, 22], "instanc": [8, 17, 20], "instruct": 14, "instructor": [15, 17, 18], "int": [17, 18], "integ": 18, "integrag": 22, "intellig": 8, "interact": [8, 20], "interfac": 8, "introduc": 1, "io": 8, "ip": 18, "ipynb": [0, 1, 2, 3, 4, 8], "is_loc": 17, "its": 17, "join": [17, 21], "json": 17, "jupit": 1, "jupyt": [0, 1, 2, 3, 4, 5, 7, 8], "just": 14, "k": 8, "kei": 17, "keyword": 21, "kwarg": [17, 21], "langchain": [17, 18], "langchain_cli": [17, 18], "langchain_commun": 18, "langchain_cor": [17, 21], "languag": [16, 17], "larg": 17, "largest": 1, "layer": 17, "lecun": 1, "len": 8, "level": 20, "like": [1, 8, 17, 22], "link": 17, "list": [8, 17, 18, 21], "llama": [14, 17, 20], "llama2": 17, "llama_cpp": [16, 17], "llamacpp": [11, 22], "llm": [11, 16, 19, 21, 22, 23], "llm_kwarg": [16, 21], "llm_type": [16, 17], "load": [16, 17], "load_env": 17, "load_fil": [16, 17], "load_model": [16, 17], "load_prompt": 17, "local": [14, 15, 17, 22], "localfilestor": 17, "localhost": 18, "locat": [17, 20], "look": 8, "lost": 8, "m": 14, "made": 12, "main": 8, "make": [14, 15, 20, 22], "manag": [8, 17], "map": 17, "markdown": 8, "match": 21, "max_new_token": [16, 17], "maximum": 17, "mb": [6, 9, 24], "mem": [6, 9, 24], "metadata": [8, 17], "metadata_toggl": 8, "method": 17, "min_valu": 8, "model": [8, 15, 17, 18, 20, 21], "model_computed_field": [16, 17], "model_config": [16, 17], "model_dir_path": 20, "model_field": [16, 17], "model_nam": [14, 16, 17, 21], "model_path": [16, 17], "model_typ": 17, "modul": [22, 23], "more": [14, 15, 17], "moreov": [], "most": [17, 18], "move": [15, 17], "much": 14, "multi": 17, "multi_vector": 17, "multivec_retriev": [2, 3, 4, 8, 17], "multivectorretriev": 17, "n": [8, 17], "n_batch": [16, 17], "n_ctx": [16, 17], "n_gpu_lay": [16, 17], "name": [1, 8, 14, 16, 17, 18, 21], "namespac": [16, 17], "network": 1, "neural": 1, "new": 17, "new_pap": 2, "nn": [17, 21], "non": 15, "none": [17, 18, 20, 21], "nonetyp": 17, "nosourc": 17, "note": 14, "notebook": [0, 1, 2, 3, 4, 5, 7, 8], "number": [8, 17, 18], "number_input": 8, "o": 8, "object": [17, 21], "offer": [14, 22], "one_to_on": 17, "onlin": 14, "open": 13, "oper": 20, "option": [8, 17, 20], "orchestr": 8, "otherwis": 8, "our": 15, "output": [17, 18, 21], "output_dir": 20, "output_kei": [1, 16, 17], "output_pars": [16, 21], "overlap": 17, "overwrit": 17, "packag": 22, "page": [8, 17, 21, 22], "page_cont": 8, "pagehom": 8, "pair": 17, "paramet": [8, 17, 18, 20, 21], "parent": [2, 8, 15, 17], "pars": [16, 23], "parse_pdf": 17, "parsepdf": [16, 17, 23], "parser": 17, "parser_kwarg": 17, "partit": [16, 17], "pass": 17, "path": [2, 8, 14, 15, 17, 18, 20], "pathlib": [2, 8], "pattern": 17, "pdf": [2, 15, 16, 23], "phase": 12, "pip": 12, "pipelin": 17, "place": 17, "planet": 1, "point": 17, "port": [8, 15, 17, 18], "prefix": [1, 16, 17], "print": 18, "priorit": 17, "process": [15, 17], "process_imag": [16, 17], "process_t": [16, 17], "process_text": [16, 17], "produc": 17, "progress": [17, 18], "project": 20, "prompt": [5, 6, 14, 16, 21, 22, 23], "prompt_match": [16, 21], "prompttempl": 17, "properti": [17, 21], "provid": [13, 14, 15, 17, 18, 19, 21, 22], "publish": 12, "pull": 20, "py": [0, 1, 2, 3, 4, 6, 8, 9, 24], "pydant": 17, "pypi": 12, "python": [0, 1, 2, 3, 4, 5, 7, 8, 14, 22], "q4_k_m": 14, "q5_k_m": [14, 17], "qa": [17, 21], "quantiz": [16, 17, 22, 23], "quantize_model": [16, 20, 23], "queri": [3, 4, 8, 17, 18], "question": [0, 1], "rag": [0, 1, 3, 4, 6, 10, 15, 16, 22, 23, 24], "rag_jupyt": 5, "rag_python": 5, "rais": 17, "random": 18, "reach": 17, "read": 17, "read_onli": 18, "recommend": 14, "recurs": 17, "red": 8, "refer": [15, 17], "refin": [5, 6, 17, 21], "refine_cal": [16, 21], "relvant": 21, "render": 8, "render_search_form": 8, "render_search_result": 8, "render_sidebar": 8, "render_stat": 8, "replac": 17, "repo": 14, "repo_id": 20, "repositori": [12, 14, 20], "repr": 17, "repres": 8, "requir": [14, 17], "respect": 17, "respons": 8, "result": [8, 20], "retriev": [2, 3, 4, 9, 10, 15, 16, 21, 22, 23], "retriever_app": [8, 9], "retriever_kwarg": [16, 21], "retriv": [7, 9], "return": [8, 17, 18, 20, 21], "root": [17, 20], "root_path": 20, "run": [2, 11, 15, 22], "run_chroma": 15, "same": 17, "sampl": 17, "save": [16, 17, 20], "score": [8, 17, 18], "script": [15, 17], "search": [8, 17, 22], "search_form": 8, "self": [8, 17, 18], "semant": 8, "sentenc": [17, 18], "seper": [17, 21], "server": 15, "session_st": 8, "set": [8, 14, 17], "sh": 15, "shot": [5, 6, 17], "should": [14, 17, 18, 20], "show": [8, 17, 18], "sidebar": 8, "similar": [8, 17, 18], "similiar": 8, "simpl": [7, 8, 22], "sinc": [12, 15], "singl": [17, 18], "single_text_out": [16, 17], "size": 17, "slow": 2, "smaller": 17, "so": 17, "solut": 22, "sourc": [0, 1, 2, 3, 4, 5, 7, 8, 13, 15, 16, 17, 18, 20, 21], "specifi": [17, 20], "sphinx": [0, 1, 2, 3, 4, 5, 7, 8], "sphx_glr_auto_examples_basicrag_customprompt": 24, "sphx_glr_auto_examples_basicrag_fewshotprompt": 24, "sphx_glr_auto_examples_basicrag_ingest": 24, "sphx_glr_auto_examples_basicrag_refin": 24, "sphx_glr_auto_examples_basicrag_stuff": 24, "spinner": 8, "split": 17, "split_doc": [16, 17], "splitter": [16, 23], "src": [12, 15], "st": 8, "start": [14, 17, 22], "state": 8, "static": 21, "statist": 8, "statu": 18, "std_out": 17, "step": 8, "storag": 17, "store": [11, 16, 17, 18, 22], "store_path": [16, 17, 18], "str": [8, 17, 18, 20, 21], "strategi": [16, 17], "streamlit": [7, 8], "stremlit": 8, "string": [17, 18, 21], "stuff": [0, 1, 5, 6, 17, 21], "stuff_cal": [16, 21], "stuff_doc": [16, 17, 21, 23], "submit": 8, "submodul": [16, 17, 23], "subprocess": 20, "suffix": [1, 16, 17], "support": [11, 17, 18, 22], "sure": [14, 15], "sy": 8, "sync": 2, "synchron": 2, "system": 8, "tab": 8, "tab1": 8, "tab2": 8, "tabl": 17, "table_as_html": 17, "take": 17, "task": [16, 17, 21], "temperatur": [16, 17], "templat": [0, 16, 17], "test": [2, 3, 4, 18], "test_connect": [8, 17, 18], "text": [16, 23], "text_concat": [16, 17], "text_input": 8, "text_splitt": [16, 17], "textsplitt": [16, 17, 23], "thank": 22, "them": 17, "thi": [0, 1, 2, 3, 4, 8, 14, 15, 17, 18, 21], "time": 17, "titl": 8, "toggl": 8, "token": [14, 17], "top": [8, 17, 18], "top_k": [8, 16, 17, 18], "total": [6, 9, 24], "transform": [17, 18], "travers": 17, "tree": 17, "true": [2, 3, 4, 8, 17, 18], "tupl": 18, "two": 14, "type": [8, 15, 17, 18, 21], "typic": 17, "ubuntu": [17, 18], "ui": 8, "under": 15, "union": 17, "uniqu": 17, "until": 17, "up": [1, 8, 17], "updat": 20, "us": [0, 1, 2, 3, 4, 5, 7, 8, 11, 15, 17, 18, 20, 21], "user": 14, "util": [16, 23], "uuid": 17, "uuid5": 17, "v": 17, "v1": 17, "valid": 17, "validate_doc_chain": [16, 17], "validate_exampl": [16, 17], "validate_input_kei": [16, 17], "validate_output_kei": [16, 17], "validate_task": [16, 17], "valu": [8, 17], "valueerror": 17, "variou": 22, "vector": [2, 11, 17, 18, 22], "vectordb": [2, 3, 4, 8, 15, 16, 23], "vectorstor": [15, 18], "verbos": [17, 18], "volume_2k": [17, 18], "wai": [14, 22], "want": 14, "we": 12, "web": 8, "what": [1, 8], "where": [14, 20], "whether": 17, "which": 17, "while": [3, 4], "who": 1, "with_scor": [8, 17, 18], "wrapper": 18, "write": 8, "xl": [15, 18], "yann": 1, "yet": 12, "you": 14, "your": 8, "your_collection_nam": 2, "zip": [5, 7]}, "titles": ["Custom Prompts", "Custom Few-Shot Prompts", "Document Ingestion", "Refine Chain", "Stuff Chain", "Basic-RAG Cookbooks", "Computation times", "Retriever-GUI Cookbooks", "Retriever GUI", "Computation times", "Cookbooks", "Get Started", "Installation", "GRAG Overview", "LLMs", "Vector Stores", "GRAG", "Components", "VectorDB", "Prompts", "Quantize", "RAG", "Welcome to GRAG\u2019s documentation!", "grag", "Computation times"], "titleterms": {"": 22, "To": 14, "augment": 13, "base": 18, "basic": [5, 21], "chain": [3, 4], "chroma": [15, 18], "client": 18, "compon": 17, "comput": [6, 9, 24], "content": [16, 17, 18, 19, 20, 21, 22], "cookbook": [5, 7, 10], "custom": [0, 1], "data": 15, "deeplak": 18, "document": [2, 22], "embed": [15, 17], "few": 1, "gener": 13, "get": 11, "grag": [13, 16, 22, 23], "gui": [7, 8], "how": 14, "huggingfac": 14, "indic": 22, "ingest": [2, 15], "instal": 12, "llamacpp": 14, "llm": [14, 17], "model": 14, "modul": [16, 17, 18, 19, 20, 21], "overview": 13, "pars": 17, "pdf": 17, "prompt": [0, 1, 17, 19], "quantiz": [14, 20], "rag": [5, 21], "refin": 3, "retriev": [7, 8, 13, 17], "run": 14, "shot": 1, "splitter": 17, "start": 11, "store": 15, "stuff": 4, "submodul": [18, 20, 21], "support": 15, "tabl": 22, "text": 17, "time": [6, 9, 24], "us": 14, "util": [17, 20], "vector": 15, "vectordb": [17, 18], "welcom": 22}})
\ No newline at end of file
+Search.setIndex({"alltitles": {"Base": [[18, "module-grag.components.vectordb.base"]], "Basic RAG": [[21, "module-grag.rag.basic_rag"]], "Basic-RAG Cookbooks": [[5, "basic-rag-cookbooks"]], "Chroma": [[15, "chroma"]], "Chroma Client": [[18, "module-grag.components.vectordb.chroma_client"]], "Components": [[17, "components"]], "Computation times": [[6, "computation-times"], [9, "computation-times"], [24, "computation-times"]], "Contents:": [[22, null]], "Cookbooks": [[10, "cookbooks"]], "Custom Few-Shot Prompts": [[1, "custom-few-shot-prompts"]], "Custom Prompts": [[0, "custom-prompts"]], "Data Ingestion": [[15, "data-ingestion"]], "Deeplake Client": [[18, "module-grag.components.vectordb.deeplake_client"]], "Document Ingestion": [[2, "document-ingestion"]], "Embedding": [[17, "module-grag.components.embedding"]], "Embeddings": [[15, "embeddings"]], "GRAG": [[16, "grag"]], "GRAG Overview": [[13, "grag-overview"]], "Get Started": [[11, "get-started"]], "How to quantize models.": [[14, "how-to-quantize-models"]], "Indices and tables": [[22, "indices-and-tables"]], "Installation": [[12, "installation"]], "LLM": [[17, "module-grag.components.llm"]], "LLMs": [[14, "llms"]], "Module Contents": [[18, "module-grag.components.vectordb"]], "Module contents": [[16, "module-grag"], [17, "module-grag.components"], [19, "module-grag.prompts"], [20, "module-grag.quantize"], [21, "module-grag.rag"]], "Parse PDF": [[17, "module-grag.components.parse_pdf"]], "Prompt": [[17, "module-grag.components.prompt"]], "Prompts": [[19, "prompts"]], "Quantize": [[20, "quantize"], [20, "id1"]], "RAG": [[21, "rag"]], "Refine Chain": [[3, "refine-chain"]], "Retrieval-Augmented Generation": [[13, "retrieval-augmented-generation"]], "Retriever": [[17, "module-grag.components.multivec_retriever"]], "Retriever GUI": [[8, "retriever-gui"]], "Retriever-GUI Cookbooks": [[7, "retriever-gui-cookbooks"]], "Stuff Chain": [[4, "stuff-chain"]], "Submodules": [[18, "submodules"], [20, "submodules"], [21, "submodules"]], "Supported Vector Stores": [[15, "supported-vector-stores"]], "Text Splitter": [[17, "module-grag.components.text_splitter"]], "To run LLMs using HuggingFace": [[14, "to-run-llms-using-huggingface"]], "To run LLMs using LlamaCPP": [[14, "to-run-llms-using-llamacpp"]], "Utils": [[17, "module-grag.components.utils"], [20, "module-grag.quantize.utils"]], "Vector Stores": [[15, "vector-stores"]], "VectorDB": [[17, "vectordb"], [18, "vectordb"]], "Welcome to GRAG\u2019s documentation!": [[22, "welcome-to-grag-s-documentation"]], "grag": [[23, "grag"]]}, "docnames": ["auto_examples/Basic-RAG/BasicRAG_CustomPrompt", "auto_examples/Basic-RAG/BasicRAG_FewShotPrompt", "auto_examples/Basic-RAG/BasicRAG_ingest", "auto_examples/Basic-RAG/BasicRAG_refine", "auto_examples/Basic-RAG/BasicRAG_stuff", "auto_examples/Basic-RAG/index", "auto_examples/Basic-RAG/sg_execution_times", "auto_examples/Retriver-GUI/index", "auto_examples/Retriver-GUI/retriever_app", "auto_examples/Retriver-GUI/sg_execution_times", "auto_examples_index", "get_started", "get_started.installation", "get_started.introduction", "get_started.llms", "get_started.vectordb", "grag", "grag.components", "grag.components.vectordb", "grag.prompts", "grag.quantize", "grag.rag", "index", "modules", "sg_execution_times"], "envversion": {"sphinx": 61, "sphinx.domains.c": 3, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 9, "sphinx.domains.index": 1, "sphinx.domains.javascript": 3, "sphinx.domains.math": 2, "sphinx.domains.python": 4, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx.ext.todo": 2}, "filenames": ["auto_examples/Basic-RAG/BasicRAG_CustomPrompt.rst", "auto_examples/Basic-RAG/BasicRAG_FewShotPrompt.rst", "auto_examples/Basic-RAG/BasicRAG_ingest.rst", "auto_examples/Basic-RAG/BasicRAG_refine.rst", "auto_examples/Basic-RAG/BasicRAG_stuff.rst", "auto_examples/Basic-RAG/index.rst", "auto_examples/Basic-RAG/sg_execution_times.rst", "auto_examples/Retriver-GUI/index.rst", "auto_examples/Retriver-GUI/retriever_app.rst", "auto_examples/Retriver-GUI/sg_execution_times.rst", "auto_examples_index.rst", "get_started.rst", "get_started.installation.rst", "get_started.introduction.rst", "get_started.llms.rst", "get_started.vectordb.rst", "grag.rst", "grag.components.rst", "grag.components.vectordb.rst", "grag.prompts.rst", "grag.quantize.rst", "grag.rag.rst", "index.rst", "modules.rst", "sg_execution_times.rst"], "indexentries": {"aadd_docs() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.aadd_docs", false]], "aadd_docs() (grag.components.vectordb.base.vectordb method)": [[18, "grag.components.vectordb.base.VectorDB.aadd_docs", false]], "aadd_docs() (grag.components.vectordb.chroma_client.chromaclient method)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.aadd_docs", false]], "aadd_docs() (grag.components.vectordb.deeplake_client.deeplakeclient method)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.aadd_docs", false]], "add_caption_first (grag.components.parse_pdf.parsepdf attribute)": [[17, "grag.components.parse_pdf.ParsePDF.add_caption_first", false]], "add_captions_to_blocks (grag.components.parse_pdf.parsepdf attribute)": [[17, "grag.components.parse_pdf.ParsePDF.add_captions_to_blocks", false]], "add_captions_to_text (grag.components.parse_pdf.parsepdf attribute)": [[17, "grag.components.parse_pdf.ParsePDF.add_captions_to_text", false]], "add_docs() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.add_docs", false]], "add_docs() (grag.components.vectordb.base.vectordb method)": [[18, "grag.components.vectordb.base.VectorDB.add_docs", false]], "add_docs() (grag.components.vectordb.chroma_client.chromaclient method)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.add_docs", false]], "add_docs() (grag.components.vectordb.deeplake_client.deeplakeclient method)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.add_docs", false]], "aget_chunk() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.aget_chunk", false]], "aget_chunk() (grag.components.vectordb.base.vectordb method)": [[18, "grag.components.vectordb.base.VectorDB.aget_chunk", false]], "aget_chunk() (grag.components.vectordb.chroma_client.chromaclient method)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.aget_chunk", false]], "aget_chunk() (grag.components.vectordb.deeplake_client.deeplakeclient method)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.aget_chunk", false]], "aget_doc() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.aget_doc", false]], "aingest() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.aingest", false]], "basicrag (class in grag.rag.basic_rag)": [[21, "grag.rag.basic_rag.BasicRAG", false]], "building_llamacpp() (in module grag.quantize.utils)": [[20, "grag.quantize.utils.building_llamacpp", false]], "chromaclient (class in grag.components.vectordb.chroma_client)": [[18, "grag.components.vectordb.chroma_client.ChromaClient", false]], "chunk_overlap (grag.components.text_splitter.textsplitter attribute)": [[17, "grag.components.text_splitter.TextSplitter.chunk_overlap", false]], "chunk_size (grag.components.text_splitter.textsplitter attribute)": [[17, "grag.components.text_splitter.TextSplitter.chunk_size", false]], "classify() (grag.components.parse_pdf.parsepdf method)": [[17, "grag.components.parse_pdf.ParsePDF.classify", false]], "client (grag.components.vectordb.chroma_client.chromaclient attribute)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.client", false]], "client (grag.components.vectordb.deeplake_client.deeplakeclient attribute)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.client", false]], "collection (grag.components.vectordb.chroma_client.chromaclient attribute)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.collection", false]], "collection (grag.components.vectordb.deeplake_client.deeplakeclient attribute)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.collection", false]], "collection_name (grag.components.vectordb.chroma_client.chromaclient attribute)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.collection_name", false]], "custom_prompt (grag.rag.basic_rag.basicrag attribute)": [[21, "grag.rag.basic_rag.BasicRAG.custom_prompt", false]], "deeplakeclient (class in grag.components.vectordb.deeplake_client)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient", false]], "delete() (grag.components.vectordb.base.vectordb method)": [[18, "grag.components.vectordb.base.VectorDB.delete", false]], "delete() (grag.components.vectordb.chroma_client.chromaclient method)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.delete", false]], "delete() (grag.components.vectordb.deeplake_client.deeplakeclient method)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.delete", false]], "device_map (grag.components.llm.llm attribute)": [[17, "grag.components.llm.LLM.device_map", false]], "doc_chain (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.doc_chain", false]], "doc_chain (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.doc_chain", false], [17, "id6", false]], "doc_chain (grag.rag.basic_rag.basicrag attribute)": [[21, "grag.rag.basic_rag.BasicRAG.doc_chain", false]], "doc_chain (grag.rag.basic_rag.basicrag property)": [[21, "id0", false]], "embedding (class in grag.components.embedding)": [[17, "grag.components.embedding.Embedding", false]], "embedding_function (grag.components.embedding.embedding attribute)": [[17, "grag.components.embedding.Embedding.embedding_function", false]], "embedding_function (grag.components.vectordb.chroma_client.chromaclient attribute)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.embedding_function", false]], "embedding_function (grag.components.vectordb.deeplake_client.deeplakeclient attribute)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.embedding_function", false]], "embedding_model (grag.components.embedding.embedding attribute)": [[17, "grag.components.embedding.Embedding.embedding_model", false]], "embedding_model (grag.components.vectordb.chroma_client.chromaclient attribute)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.embedding_model", false]], "embedding_model (grag.components.vectordb.deeplake_client.deeplakeclient attribute)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.embedding_model", false]], "embedding_type (grag.components.embedding.embedding attribute)": [[17, "grag.components.embedding.Embedding.embedding_type", false]], "embedding_type (grag.components.vectordb.chroma_client.chromaclient attribute)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.embedding_type", false]], "embedding_type (grag.components.vectordb.deeplake_client.deeplakeclient attribute)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.embedding_type", false]], "example_template (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.example_template", false], [17, "id2", false]], "examples (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.examples", false], [17, "id3", false]], "extract_image_block_types (grag.components.parse_pdf.parsepdf attribute)": [[17, "grag.components.parse_pdf.ParsePDF.extract_image_block_types", false]], "extract_images (grag.components.parse_pdf.parsepdf attribute)": [[17, "grag.components.parse_pdf.ParsePDF.extract_images", false]], "fetch_model_repo() (in module grag.quantize.utils)": [[20, "grag.quantize.utils.fetch_model_repo", false]], "fewshotprompt (class in grag.components.prompt)": [[17, "grag.components.prompt.FewShotPrompt", false]], "filepath (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.filepath", false]], "filepath (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.filepath", false], [17, "id7", false]], "find_config_path() (in module grag.components.utils)": [[17, "grag.components.utils.find_config_path", false]], "format() (grag.components.prompt.prompt method)": [[17, "grag.components.prompt.Prompt.format", false]], "gen_doc_ids() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.gen_doc_ids", false]], "get_chunk() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.get_chunk", false]], "get_chunk() (grag.components.vectordb.base.vectordb method)": [[18, "grag.components.vectordb.base.VectorDB.get_chunk", false]], "get_chunk() (grag.components.vectordb.chroma_client.chromaclient method)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.get_chunk", false]], "get_chunk() (grag.components.vectordb.deeplake_client.deeplakeclient method)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.get_chunk", false]], "get_config() (in module grag.components.utils)": [[17, "grag.components.utils.get_config", false]], "get_doc() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.get_doc", false]], "get_docs_from_chunks() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.get_docs_from_chunks", false]], "get_llamacpp_repo() (in module grag.quantize.utils)": [[20, "grag.quantize.utils.get_llamacpp_repo", false]], "grag": [[16, "module-grag", false]], "grag.components": [[17, "module-grag.components", false]], "grag.components.embedding": [[17, "module-grag.components.embedding", false]], "grag.components.llm": [[17, "module-grag.components.llm", false]], "grag.components.multivec_retriever": [[17, "module-grag.components.multivec_retriever", false]], "grag.components.parse_pdf": [[17, "module-grag.components.parse_pdf", false]], "grag.components.prompt": [[17, "module-grag.components.prompt", false]], "grag.components.text_splitter": [[17, "module-grag.components.text_splitter", false]], "grag.components.utils": [[17, "module-grag.components.utils", false]], "grag.components.vectordb": [[18, "module-grag.components.vectordb", false]], "grag.components.vectordb.base": [[18, "module-grag.components.vectordb.base", false]], "grag.components.vectordb.chroma_client": [[18, "module-grag.components.vectordb.chroma_client", false]], "grag.components.vectordb.deeplake_client": [[18, "module-grag.components.vectordb.deeplake_client", false]], "grag.prompts": [[19, "module-grag.prompts", false]], "grag.quantize": [[20, "module-grag.quantize", false]], "grag.quantize.quantize": [[20, "module-grag.quantize.quantize", false]], "grag.quantize.utils": [[20, "module-grag.quantize.utils", false]], "grag.rag": [[21, "module-grag.rag", false]], "grag.rag.basic_rag": [[21, "module-grag.rag.basic_rag", false]], "hf_pipeline() (grag.components.llm.llm method)": [[17, "grag.components.llm.LLM.hf_pipeline", false]], "host (grag.components.vectordb.chroma_client.chromaclient attribute)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.host", false]], "id_gen() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.id_gen", false]], "id_key (grag.components.multivec_retriever.retriever attribute)": [[17, "grag.components.multivec_retriever.Retriever.id_key", false]], "image_output_dir (grag.components.parse_pdf.parsepdf attribute)": [[17, "grag.components.parse_pdf.ParsePDF.image_output_dir", false]], "infer_table_structure (grag.components.parse_pdf.parsepdf attribute)": [[17, "grag.components.parse_pdf.ParsePDF.infer_table_structure", false]], "ingest() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.ingest", false]], "input_keys (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.input_keys", false], [17, "id1", false]], "input_keys (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.input_keys", false], [17, "id8", false]], "langchain_client (grag.components.vectordb.chroma_client.chromaclient attribute)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.langchain_client", false]], "langchain_client (grag.components.vectordb.deeplake_client.deeplakeclient attribute)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.langchain_client", false]], "language (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.language", false]], "language (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.language", false], [17, "id9", false]], "llama_cpp() (grag.components.llm.llm method)": [[17, "grag.components.llm.LLM.llama_cpp", false]], "llm (class in grag.components.llm)": [[17, "grag.components.llm.LLM", false]], "llm_kwargs (grag.rag.basic_rag.basicrag attribute)": [[21, "grag.rag.basic_rag.BasicRAG.llm_kwargs", false]], "llm_type (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.llm_type", false]], "llm_type (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.llm_type", false], [17, "id10", false]], "load() (grag.components.prompt.prompt class method)": [[17, "grag.components.prompt.Prompt.load", false]], "load_file() (grag.components.parse_pdf.parsepdf method)": [[17, "grag.components.parse_pdf.ParsePDF.load_file", false]], "load_model() (grag.components.llm.llm method)": [[17, "grag.components.llm.LLM.load_model", false]], "max_new_tokens (grag.components.llm.llm attribute)": [[17, "grag.components.llm.LLM.max_new_tokens", false]], "model_computed_fields (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.model_computed_fields", false]], "model_computed_fields (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.model_computed_fields", false]], "model_config (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.model_config", false]], "model_config (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.model_config", false]], "model_fields (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.model_fields", false]], "model_fields (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.model_fields", false]], "model_name (grag.components.llm.llm attribute)": [[17, "grag.components.llm.LLM.model_name", false]], "model_name (grag.components.llm.llm property)": [[17, "id0", false]], "model_name (grag.rag.basic_rag.basicrag attribute)": [[21, "grag.rag.basic_rag.BasicRAG.model_name", false]], "model_name (grag.rag.basic_rag.basicrag property)": [[21, "id1", false]], "model_path (grag.components.llm.llm property)": [[17, "grag.components.llm.LLM.model_path", false]], "module": [[16, "module-grag", false], [17, "module-grag.components", false], [17, "module-grag.components.embedding", false], [17, "module-grag.components.llm", false], [17, "module-grag.components.multivec_retriever", false], [17, "module-grag.components.parse_pdf", false], [17, "module-grag.components.prompt", false], [17, "module-grag.components.text_splitter", false], [17, "module-grag.components.utils", false], [18, "module-grag.components.vectordb", false], [18, "module-grag.components.vectordb.base", false], [18, "module-grag.components.vectordb.chroma_client", false], [18, "module-grag.components.vectordb.deeplake_client", false], [19, "module-grag.prompts", false], [20, "module-grag.quantize", false], [20, "module-grag.quantize.quantize", false], [20, "module-grag.quantize.utils", false], [21, "module-grag.rag", false], [21, "module-grag.rag.basic_rag", false]], "n_batch (grag.components.llm.llm attribute)": [[17, "grag.components.llm.LLM.n_batch", false]], "n_ctx (grag.components.llm.llm attribute)": [[17, "grag.components.llm.LLM.n_ctx", false]], "n_gpu_layers (grag.components.llm.llm attribute)": [[17, "grag.components.llm.LLM.n_gpu_layers", false]], "name (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.name", false]], "name (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.name", false], [17, "id11", false]], "namespace (grag.components.multivec_retriever.retriever attribute)": [[17, "grag.components.multivec_retriever.Retriever.namespace", false]], "output_keys (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.output_keys", false]], "output_parser() (grag.rag.basic_rag.basicrag static method)": [[21, "grag.rag.basic_rag.BasicRAG.output_parser", false]], "parsepdf (class in grag.components.parse_pdf)": [[17, "grag.components.parse_pdf.ParsePDF", false]], "partition() (grag.components.parse_pdf.parsepdf method)": [[17, "grag.components.parse_pdf.ParsePDF.partition", false]], "port (grag.components.vectordb.chroma_client.chromaclient attribute)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.port", false]], "prefix (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.prefix", false], [17, "id4", false]], "process_images() (grag.components.parse_pdf.parsepdf method)": [[17, "grag.components.parse_pdf.ParsePDF.process_images", false]], "process_tables() (grag.components.parse_pdf.parsepdf method)": [[17, "grag.components.parse_pdf.ParsePDF.process_tables", false]], "process_text() (grag.components.parse_pdf.parsepdf method)": [[17, "grag.components.parse_pdf.ParsePDF.process_text", false]], "prompt (class in grag.components.prompt)": [[17, "grag.components.prompt.Prompt", false]], "prompt (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.prompt", false]], "prompt_matcher() (grag.rag.basic_rag.basicrag method)": [[21, "grag.rag.basic_rag.BasicRAG.prompt_matcher", false]], "quantize_model() (in module grag.quantize.utils)": [[20, "grag.quantize.utils.quantize_model", false]], "refine_call() (grag.rag.basic_rag.basicrag method)": [[21, "grag.rag.basic_rag.BasicRAG.refine_call", false]], "retriever (class in grag.components.multivec_retriever)": [[17, "grag.components.multivec_retriever.Retriever", false]], "retriever (grag.components.multivec_retriever.retriever attribute)": [[17, "grag.components.multivec_retriever.Retriever.retriever", false]], "retriever_kwargs (grag.rag.basic_rag.basicrag attribute)": [[21, "grag.rag.basic_rag.BasicRAG.retriever_kwargs", false]], "save() (grag.components.prompt.prompt method)": [[17, "grag.components.prompt.Prompt.save", false]], "single_text_out (grag.components.parse_pdf.parsepdf attribute)": [[17, "grag.components.parse_pdf.ParsePDF.single_text_out", false]], "source (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.source", false]], "source (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.source", false], [17, "id12", false]], "split_docs() (grag.components.multivec_retriever.retriever method)": [[17, "grag.components.multivec_retriever.Retriever.split_docs", false]], "splitter (grag.components.multivec_retriever.retriever attribute)": [[17, "grag.components.multivec_retriever.Retriever.splitter", false]], "store (grag.components.multivec_retriever.retriever attribute)": [[17, "grag.components.multivec_retriever.Retriever.store", false]], "store_path (grag.components.multivec_retriever.retriever attribute)": [[17, "grag.components.multivec_retriever.Retriever.store_path", false]], "store_path (grag.components.vectordb.deeplake_client.deeplakeclient attribute)": [[18, "grag.components.vectordb.deeplake_client.DeepLakeClient.store_path", false]], "strategy (grag.components.parse_pdf.parsepdf attribute)": [[17, "grag.components.parse_pdf.ParsePDF.strategy", false]], "stuff_call() (grag.rag.basic_rag.basicrag method)": [[21, "grag.rag.basic_rag.BasicRAG.stuff_call", false]], "stuff_docs() (grag.rag.basic_rag.basicrag static method)": [[21, "grag.rag.basic_rag.BasicRAG.stuff_docs", false]], "stuff_docs() (in module grag.components.utils)": [[17, "grag.components.utils.stuff_docs", false]], "suffix (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.suffix", false], [17, "id5", false]], "task (grag.components.llm.llm attribute)": [[17, "grag.components.llm.LLM.task", false]], "task (grag.components.prompt.fewshotprompt attribute)": [[17, "grag.components.prompt.FewShotPrompt.task", false]], "task (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.task", false], [17, "id13", false]], "task (grag.rag.basic_rag.basicrag attribute)": [[21, "grag.rag.basic_rag.BasicRAG.task", false]], "task (grag.rag.basic_rag.basicrag property)": [[21, "id2", false]], "temperature (grag.components.llm.llm attribute)": [[17, "grag.components.llm.LLM.temperature", false]], "template (grag.components.prompt.prompt attribute)": [[17, "grag.components.prompt.Prompt.template", false]], "test_connection() (grag.components.vectordb.chroma_client.chromaclient method)": [[18, "grag.components.vectordb.chroma_client.ChromaClient.test_connection", false]], "text_concat() (grag.components.parse_pdf.parsepdf method)": [[17, "grag.components.parse_pdf.ParsePDF.text_concat", false]], "text_splitter (grag.components.text_splitter.textsplitter attribute)": [[17, "grag.components.text_splitter.TextSplitter.text_splitter", false]], "textsplitter (class in grag.components.text_splitter)": [[17, "grag.components.text_splitter.TextSplitter", false]], "top_k (grag.components.multivec_retriever.retriever attribute)": [[17, "grag.components.multivec_retriever.Retriever.top_k", false]], "validate_doc_chain() (grag.components.prompt.prompt class method)": [[17, "grag.components.prompt.Prompt.validate_doc_chain", false]], "validate_examples() (grag.components.prompt.fewshotprompt class method)": [[17, "grag.components.prompt.FewShotPrompt.validate_examples", false]], "validate_input_keys() (grag.components.prompt.prompt class method)": [[17, "grag.components.prompt.Prompt.validate_input_keys", false]], "validate_output_keys() (grag.components.prompt.fewshotprompt class method)": [[17, "grag.components.prompt.FewShotPrompt.validate_output_keys", false]], "validate_task() (grag.components.prompt.prompt class method)": [[17, "grag.components.prompt.Prompt.validate_task", false]], "vectordb (class in grag.components.vectordb.base)": [[18, "grag.components.vectordb.base.VectorDB", false]], "vectordb (grag.components.multivec_retriever.retriever attribute)": [[17, "grag.components.multivec_retriever.Retriever.vectordb", false]]}, "objects": {"": [[16, 0, 0, "-", "grag"]], "grag": [[17, 0, 0, "-", "components"], [19, 0, 0, "-", "prompts"], [20, 0, 0, "-", "quantize"], [21, 0, 0, "-", "rag"]], "grag.components": [[17, 0, 0, "-", "embedding"], [17, 0, 0, "-", "llm"], [17, 0, 0, "-", "multivec_retriever"], [17, 0, 0, "-", "parse_pdf"], [17, 0, 0, "-", "prompt"], [17, 0, 0, "-", "text_splitter"], [17, 0, 0, "-", "utils"], [18, 0, 0, "-", "vectordb"]], "grag.components.embedding": [[17, 1, 1, "", "Embedding"]], "grag.components.embedding.Embedding": [[17, 2, 1, "", "embedding_function"], [17, 2, 1, "", "embedding_model"], [17, 2, 1, "", "embedding_type"]], "grag.components.llm": [[17, 1, 1, "", "LLM"]], "grag.components.llm.LLM": [[17, 2, 1, "", "device_map"], [17, 3, 1, "", "hf_pipeline"], [17, 3, 1, "", "llama_cpp"], [17, 3, 1, "", "load_model"], [17, 2, 1, "", "max_new_tokens"], [17, 4, 1, "id0", "model_name"], [17, 4, 1, "", "model_path"], [17, 2, 1, "", "n_batch"], [17, 2, 1, "", "n_ctx"], [17, 2, 1, "", "n_gpu_layers"], [17, 2, 1, "", "task"], [17, 2, 1, "", "temperature"]], "grag.components.multivec_retriever": [[17, 1, 1, "", "Retriever"]], "grag.components.multivec_retriever.Retriever": [[17, 3, 1, "", "aadd_docs"], [17, 3, 1, "", "add_docs"], [17, 3, 1, "", "aget_chunk"], [17, 3, 1, "", "aget_doc"], [17, 3, 1, "", "aingest"], [17, 3, 1, "", "gen_doc_ids"], [17, 3, 1, "", "get_chunk"], [17, 3, 1, "", "get_doc"], [17, 3, 1, "", "get_docs_from_chunks"], [17, 3, 1, "", "id_gen"], [17, 2, 1, "", "id_key"], [17, 3, 1, "", "ingest"], [17, 2, 1, "", "namespace"], [17, 2, 1, "", "retriever"], [17, 3, 1, "", "split_docs"], [17, 2, 1, "", "splitter"], [17, 2, 1, "", "store"], [17, 2, 1, "", "store_path"], [17, 2, 1, "", "top_k"], [17, 2, 1, "", "vectordb"]], "grag.components.parse_pdf": [[17, 1, 1, "", "ParsePDF"]], "grag.components.parse_pdf.ParsePDF": [[17, 2, 1, "", "add_caption_first"], [17, 2, 1, "", "add_captions_to_blocks"], [17, 2, 1, "", "add_captions_to_text"], [17, 3, 1, "", "classify"], [17, 2, 1, "", "extract_image_block_types"], [17, 2, 1, "", "extract_images"], [17, 2, 1, "", "image_output_dir"], [17, 2, 1, "", "infer_table_structure"], [17, 3, 1, "", "load_file"], [17, 3, 1, "", "partition"], [17, 3, 1, "", "process_images"], [17, 3, 1, "", "process_tables"], [17, 3, 1, "", "process_text"], [17, 2, 1, "", "single_text_out"], [17, 2, 1, "", "strategy"], [17, 3, 1, "", "text_concat"]], "grag.components.prompt": [[17, 1, 1, "", "FewShotPrompt"], [17, 1, 1, "", "Prompt"]], "grag.components.prompt.FewShotPrompt": [[17, 2, 1, "", "doc_chain"], [17, 2, 1, "id2", "example_template"], [17, 2, 1, "id3", "examples"], [17, 2, 1, "", "filepath"], [17, 2, 1, "id1", "input_keys"], [17, 2, 1, "", "language"], [17, 2, 1, "", "llm_type"], [17, 2, 1, "", "model_computed_fields"], [17, 2, 1, "", "model_config"], [17, 2, 1, "", "model_fields"], [17, 2, 1, "", "name"], [17, 2, 1, "", "output_keys"], [17, 2, 1, "id4", "prefix"], [17, 2, 1, "", "source"], [17, 2, 1, "id5", "suffix"], [17, 2, 1, "", "task"], [17, 3, 1, "", "validate_examples"], [17, 3, 1, "", "validate_output_keys"]], "grag.components.prompt.Prompt": [[17, 2, 1, "id6", "doc_chain"], [17, 2, 1, "id7", "filepath"], [17, 3, 1, "", "format"], [17, 2, 1, "id8", "input_keys"], [17, 2, 1, "id9", "language"], [17, 2, 1, "id10", "llm_type"], [17, 3, 1, "", "load"], [17, 2, 1, "", "model_computed_fields"], [17, 2, 1, "", "model_config"], [17, 2, 1, "", "model_fields"], [17, 2, 1, "id11", "name"], [17, 2, 1, "", "prompt"], [17, 3, 1, "", "save"], [17, 2, 1, "id12", "source"], [17, 2, 1, "id13", "task"], [17, 2, 1, "", "template"], [17, 3, 1, "", "validate_doc_chain"], [17, 3, 1, "", "validate_input_keys"], [17, 3, 1, "", "validate_task"]], "grag.components.text_splitter": [[17, 1, 1, "", "TextSplitter"]], "grag.components.text_splitter.TextSplitter": [[17, 2, 1, "", "chunk_overlap"], [17, 2, 1, "", "chunk_size"], [17, 2, 1, "", "text_splitter"]], "grag.components.utils": [[17, 5, 1, "", "find_config_path"], [17, 5, 1, "", "get_config"], [17, 5, 1, "", "stuff_docs"]], "grag.components.vectordb": [[18, 0, 0, "-", "base"], [18, 0, 0, "-", "chroma_client"], [18, 0, 0, "-", "deeplake_client"]], "grag.components.vectordb.base": [[18, 1, 1, "", "VectorDB"]], "grag.components.vectordb.base.VectorDB": [[18, 3, 1, "", "aadd_docs"], [18, 3, 1, "", "add_docs"], [18, 3, 1, "", "aget_chunk"], [18, 3, 1, "", "delete"], [18, 3, 1, "", "get_chunk"]], "grag.components.vectordb.chroma_client": [[18, 1, 1, "", "ChromaClient"]], "grag.components.vectordb.chroma_client.ChromaClient": [[18, 3, 1, "", "aadd_docs"], [18, 3, 1, "", "add_docs"], [18, 3, 1, "", "aget_chunk"], [18, 2, 1, "", "client"], [18, 2, 1, "", "collection"], [18, 2, 1, "", "collection_name"], [18, 3, 1, "", "delete"], [18, 2, 1, "", "embedding_function"], [18, 2, 1, "", "embedding_model"], [18, 2, 1, "", "embedding_type"], [18, 3, 1, "", "get_chunk"], [18, 2, 1, "", "host"], [18, 2, 1, "", "langchain_client"], [18, 2, 1, "", "port"], [18, 3, 1, "", "test_connection"]], "grag.components.vectordb.deeplake_client": [[18, 1, 1, "", "DeepLakeClient"]], "grag.components.vectordb.deeplake_client.DeepLakeClient": [[18, 3, 1, "", "aadd_docs"], [18, 3, 1, "", "add_docs"], [18, 3, 1, "", "aget_chunk"], [18, 2, 1, "", "client"], [18, 2, 1, "", "collection"], [18, 3, 1, "", "delete"], [18, 2, 1, "", "embedding_function"], [18, 2, 1, "", "embedding_model"], [18, 2, 1, "", "embedding_type"], [18, 3, 1, "", "get_chunk"], [18, 2, 1, "", "langchain_client"], [18, 2, 1, "", "store_path"]], "grag.quantize": [[20, 0, 0, "-", "quantize"], [20, 0, 0, "-", "utils"]], "grag.quantize.utils": [[20, 5, 1, "", "building_llamacpp"], [20, 5, 1, "", "fetch_model_repo"], [20, 5, 1, "", "get_llamacpp_repo"], [20, 5, 1, "", "quantize_model"]], "grag.rag": [[21, 0, 0, "-", "basic_rag"]], "grag.rag.basic_rag": [[21, 1, 1, "", "BasicRAG"]], "grag.rag.basic_rag.BasicRAG": [[21, 2, 1, "", "custom_prompt"], [21, 4, 1, "id0", "doc_chain"], [21, 2, 1, "", "llm_kwargs"], [21, 4, 1, "id1", "model_name"], [21, 3, 1, "", "output_parser"], [21, 3, 1, "", "prompt_matcher"], [21, 3, 1, "", "refine_call"], [21, 2, 1, "", "retriever_kwargs"], [21, 3, 1, "", "stuff_call"], [21, 3, 1, "", "stuff_docs"], [21, 4, 1, "id2", "task"]]}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "class", "Python class"], "2": ["py", "attribute", "Python attribute"], "3": ["py", "method", "Python method"], "4": ["py", "property", "Python property"], "5": ["py", "function", "Python function"]}, "objtypes": {"0": "py:module", "1": "py:class", "2": "py:attribute", "3": "py:method", "4": "py:property", "5": "py:function"}, "terms": {"": 17, "0": [6, 8, 9, 17, 24], "00": [6, 9, 24], "000": [6, 9], "001": 24, "01": 24, "03": 24, "036": 24, "06": 24, "1": [8, 9, 17], "1024": 17, "12": 24, "13b": 17, "2": [2, 15, 17], "237": 24, "275": 24, "3": [8, 14, 17], "3f": 8, "400": [3, 4, 17], "484": 24, "5": [6, 24], "5000": 17, "6000": 17, "8000": [15, 18], "8c9040b0b5cd4d7cbc2e737da1b24ebf": 17, "935": 24, "A": [8, 17, 18, 20], "By": 15, "For": [12, 14, 15], "If": [14, 15, 17], "It": [17, 22], "OR": 15, "The": [8, 17, 18, 20, 22], "To": [11, 15], "__fields__": 17, "__file__": [2, 15], "__init__": 8, "__main__": [3, 4, 8], "__name__": [3, 4, 8], "_queri": 8, "_static": [3, 4], "_top_k": 8, "aadd_doc": [16, 17, 18], "abc": 18, "about": [8, 17], "abov": [14, 17], "abstract": 18, "accuraci": 17, "activ": 8, "add": [17, 18], "add_caption_first": [16, 17], "add_captions_to_block": [16, 17], "add_captions_to_text": [16, 17], "add_doc": [16, 17, 18], "addit": 17, "address": [8, 18], "after": [14, 17], "aget_chunk": [16, 17, 18], "aget_doc": [16, 17], "aingest": [2, 16, 17], "alik": 8, "aliv": 18, "all": [5, 7, 17, 18, 19, 24], "also": [17, 22], "alt": [3, 4], "altern": 2, "alwai": 17, "an": [7, 13, 14, 22], "ani": [15, 17, 22], "annot": 17, "answer": [0, 1], "anyth": 8, "api": 18, "app": 8, "appli": 20, "applic": 8, "ar": [12, 14, 15], "arg": 8, "argument": [15, 17, 21], "artifici": 8, "arxiv": 18, "async": [2, 17, 18], "asynchron": [2, 17, 18], "asyncio": 2, "attempt": 20, "attribut": 8, "augment": 22, "auth": 14, "auto": 17, "auto_exampl": [6, 9], "avail": 17, "awar": 17, "backend": 8, "bar": 18, "base": [0, 1, 8, 15, 16, 17, 21], "base_dir": 17, "basemodel": 17, "basi": 21, "basic": [0, 1, 6, 10, 16, 22, 23, 24], "basic_rag": [0, 1, 3, 4, 21], "basicrag": [0, 1, 3, 4, 16, 21, 23], "basicrag_customprompt": [0, 6, 24], "basicrag_fewshotprompt": [1, 6, 24], "basicrag_ingest": [2, 6, 24], "basicrag_refin": [3, 6, 24], "basicrag_stuff": [4, 6, 24], "batch": 17, "befor": 17, "being": 17, "below": [1, 5, 7], "better": 17, "block": 17, "blog": 8, "bool": [17, 18], "both": 15, "build": 20, "building_llamacpp": [16, 20, 23], "bulb": 8, "button": 8, "call": 17, "call_func": 21, "came": 1, "can": [12, 14, 15], "cannot": 17, "capstone_5": [17, 18], "caption": 17, "chain": [5, 6, 17, 21], "chang": [14, 15], "chat": 17, "check": [8, 14], "check_connect": 8, "chroma": [2, 8, 16, 17, 22], "chroma_cli": [2, 18], "chromacli": [2, 17, 18], "chromadb": 18, "chunk": [8, 17, 18], "chunk_overlap": [16, 17], "chunk_siz": [16, 17], "ci_test": 2, "class": [8, 17, 18, 21], "classifi": [16, 17], "classmethod": 17, "classvar": 17, "client": [2, 3, 4, 8, 15, 16, 17], "client_kwarg": 17, "clientserv": 15, "clone": [12, 14, 20], "cmake": 20, "co": 20, "code": [0, 1, 2, 3, 4, 5, 7, 8], "collect": [8, 17, 18], "collection_nam": [2, 3, 4, 8, 17, 18], "combin": 17, "command": 14, "complet": 13, "completedprocess": 20, "compon": [0, 1, 2, 3, 4, 8, 15, 16, 18, 22, 23], "comput": 17, "computedfieldinfo": 17, "concat": 17, "concaten": [17, 21], "config": [12, 14, 15, 17], "configdict": 17, "configpars": 17, "configur": 17, "conform": 17, "connect": [8, 17, 18], "contain": [15, 17, 19, 20], "content": 23, "context": [0, 1, 17], "convolut": 1, "cookbook": [0, 1, 2, 3, 4, 8, 15, 22, 24], "copi": [14, 20], "core": 18, "correspond": [17, 18], "cosin": [17, 18], "could": 8, "count": 8, "cpp": [14, 17, 20], "crucial": 15, "current": [15, 17], "current_path": 17, "custom": [5, 6, 12, 17], "custom_few_shot_prompt": 1, "custom_prompt": [0, 1, 16, 17, 21], "data": [2, 11, 17, 18], "databas": [2, 15, 17, 18], "decor": 21, "deeplak": [15, 16, 17, 22], "deeplake_cli": [2, 3, 4, 18], "deeplakecli": [2, 3, 4, 15, 17, 18], "def": 8, "default": [15, 17, 18, 20, 21], "defin": 17, "delet": [17, 18], "demonstr": [0, 1, 2, 3, 4, 5, 7, 8], "deriv": 18, "detail": [8, 14, 15, 17], "develop": 12, "devic": 17, "device_map": [16, 17], "dict": [17, 21], "dictionari": 17, "differ": 19, "dimension": 15, "dir_path": [2, 15, 17], "directori": [14, 17, 20], "displai": 8, "doc": [3, 4, 8, 17, 18, 21], "doc_chain": [0, 1, 3, 4, 16, 17, 21], "doc_id": 17, "document": [3, 4, 5, 6, 17, 18, 21], "doe": [14, 17], "download": [0, 1, 2, 3, 4, 5, 7, 8, 14, 20], "dry_run": 17, "dure": 17, "e": 12, "each": [17, 18], "easi": 22, "easiest": 14, "either": [14, 15], "element": 17, "elif": 2, "els": [8, 18], "embed": [8, 11, 16, 18, 23], "embedding_funct": [16, 17, 18], "embedding_model": [8, 15, 16, 17, 18], "embedding_modelnam": 18, "embedding_typ": [8, 15, 16, 17, 18], "en": 17, "end": [0, 1, 2, 3, 4, 8, 22], "ensur": 17, "enter": [8, 14], "enumer": 8, "etc": [14, 17], "exampl": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 14, 16, 17, 24], "example_templ": [1, 16, 17], "exclud": 17, "execut": [6, 9, 17, 24], "expand": 8, "explain": [], "explicitli": 15, "extract": 17, "extract_imag": [16, 17], "extract_image_block_typ": [16, 17], "f": 8, "f16": 17, "face": 17, "fals": [8, 17, 18], "fetch_model_repo": [16, 20, 23], "few": [5, 6, 17], "fewshotprompt": [1, 16, 17, 21, 23], "field": 17, "fieldinfo": 17, "figur": 17, "file": [6, 9, 12, 14, 15, 17, 20, 24], "filenotfounderror": 17, "filepath": [16, 17], "final": 14, "find": [8, 14, 17], "find_config_path": [16, 17, 23], "flexibl": 14, "float": [17, 18], "folder": 15, "follow": [0, 1, 14], "form": [8, 14], "form_submit_button": 8, "format": [16, 17, 21], "found": 17, "from": [0, 1, 2, 3, 4, 6, 8, 9, 12, 14, 17, 18, 20, 24], "full": [0, 1, 2, 3, 4, 8], "function": [8, 17, 18, 20], "further": 12, "galleri": [0, 1, 2, 3, 4, 5, 7, 8, 24], "gate": 14, "gen_doc_id": [16, 17], "gener": [0, 1, 2, 3, 4, 5, 7, 8, 15, 17, 22], "get": [14, 17, 22], "get_chunk": [8, 16, 17, 18], "get_config": [16, 17, 23], "get_doc": [16, 17], "get_docs_from_chunk": [16, 17], "get_llamacpp_repo": [16, 20, 23], "get_search_result": 8, "getcwd": 8, "gguf": 14, "git": [12, 20], "given": [0, 1, 17, 20], "glob": 17, "glob_pattern": 17, "go": [0, 1, 2, 3, 4, 8], "gpu": 17, "grag": [0, 1, 2, 3, 4, 8, 14, 17, 18, 20, 21], "green": 8, "gui": [9, 10, 22], "gui_jupyt": 7, "gui_python": 7, "ha": [14, 17], "handl": 17, "has_result": 8, "have": 12, "hexadecim": 17, "hf_pipelin": [16, 17], "hi_r": 17, "high": 15, "hkunlp": 18, "hold": 8, "home": [8, 17, 18], "host": [8, 15, 17, 18], "how": [0, 1, 2, 3, 4], "http": 8, "httpclient": 18, "hug": 17, "huggingfac": [11, 15, 17, 20], "i": [1, 5, 7, 8, 13, 14, 15, 17, 18, 20, 22], "id": [14, 17, 20], "id_gen": [16, 17], "id_kei": [16, 17], "identifi": 17, "imag": [3, 4, 17], "image_output_dir": [16, 17], "implement": [13, 22], "import": [0, 1, 2, 3, 4, 8], "includ": 17, "index": 22, "infer_table_structur": [16, 17], "ingest": [5, 6, 11, 16, 17], "ini": [12, 14, 15, 17], "initi": [8, 17], "input": [3, 4, 14, 17], "input_kei": [0, 1, 16, 17], "insert": 8, "instal": [11, 22], "instanc": [8, 17, 20], "instruct": 14, "instructor": [15, 17, 18], "int": [17, 18], "integ": 18, "integrag": 22, "intellig": 8, "interact": [8, 20], "interfac": 8, "introduc": 1, "io": 8, "ip": 18, "ipynb": [0, 1, 2, 3, 4, 8], "is_loc": 17, "its": 17, "join": [17, 21], "jpg": [3, 4], "json": 17, "jupit": 1, "jupyt": [0, 1, 2, 3, 4, 5, 7, 8], "just": 14, "k": 8, "kei": 17, "keyword": 21, "kwarg": [17, 21], "langchain": [17, 18], "langchain_cli": [17, 18], "langchain_commun": 18, "langchain_cor": [17, 21], "languag": [16, 17], "larg": 17, "largest": 1, "layer": 17, "lecun": 1, "len": 8, "level": 20, "like": [1, 8, 17, 22], "link": 17, "list": [8, 17, 18, 21], "llama": [14, 17, 20], "llama2": 17, "llama_cpp": [16, 17], "llamacpp": [11, 22], "llm": [11, 16, 19, 21, 22, 23], "llm_kwarg": [16, 21], "llm_type": [16, 17], "load": [16, 17], "load_env": 17, "load_fil": [16, 17], "load_model": [16, 17], "load_prompt": 17, "local": [14, 15, 17, 22], "localfilestor": 17, "localhost": 18, "locat": [17, 20], "look": 8, "lost": 8, "m": 14, "made": 12, "main": 8, "make": [14, 15, 20, 22], "manag": [8, 17], "map": 17, "markdown": 8, "match": 21, "max_new_token": [16, 17], "maximum": 17, "mb": [6, 9, 24], "mem": [6, 9, 24], "metadata": [8, 17], "metadata_toggl": 8, "method": 17, "min_valu": 8, "model": [8, 15, 17, 18, 20, 21], "model_computed_field": [16, 17], "model_config": [16, 17], "model_dir_path": 20, "model_field": [16, 17], "model_nam": [14, 16, 17, 21], "model_path": [16, 17], "model_typ": 17, "modul": [22, 23], "more": [14, 15, 17], "moreov": [], "most": [17, 18], "move": [15, 17], "much": 14, "multi": 17, "multi_vector": 17, "multivec_retriev": [2, 3, 4, 8, 17], "multivectorretriev": 17, "n": [8, 17], "n_batch": [16, 17], "n_ctx": [16, 17], "n_gpu_lay": [16, 17], "name": [1, 8, 14, 16, 17, 18, 21], "namespac": [16, 17], "network": 1, "neural": 1, "new": 17, "new_pap": 2, "nn": [17, 21], "non": 15, "none": [17, 18, 20, 21], "nonetyp": 17, "nosourc": 17, "note": 14, "notebook": [0, 1, 2, 3, 4, 5, 7, 8], "number": [8, 17, 18], "number_input": 8, "o": 8, "object": [17, 21], "offer": [14, 22], "one_to_on": 17, "onlin": 14, "open": 13, "oper": 20, "option": [8, 17, 20], "orchestr": 8, "otherwis": 8, "our": 15, "output": [17, 18, 21], "output_dir": 20, "output_kei": [1, 16, 17], "output_pars": [16, 21], "overlap": 17, "overwrit": 17, "packag": 22, "page": [8, 17, 21, 22], "page_cont": 8, "pagehom": 8, "pair": 17, "paramet": [8, 17, 18, 20, 21], "parent": [2, 8, 15, 17], "pars": [16, 23], "parse_pdf": 17, "parsepdf": [16, 17, 23], "parser": 17, "parser_kwarg": 17, "partit": [16, 17], "pass": 17, "path": [2, 8, 14, 15, 17, 18, 20], "pathlib": [2, 8], "pattern": 17, "pdf": [2, 15, 16, 23], "phase": 12, "pip": 12, "pipelin": 17, "place": 17, "planet": 1, "point": 17, "port": [8, 15, 17, 18], "prefix": [1, 16, 17], "print": 18, "priorit": 17, "process": [3, 4, 15, 17], "process_imag": [16, 17], "process_t": [16, 17], "process_text": [16, 17], "produc": 17, "progress": [17, 18], "project": 20, "prompt": [5, 6, 14, 16, 21, 22, 23], "prompt_match": [16, 21], "prompttempl": 17, "properti": [17, 21], "provid": [13, 14, 15, 17, 18, 19, 21, 22], "publish": 12, "pull": 20, "py": [0, 1, 2, 3, 4, 6, 8, 9, 24], "pydant": 17, "pypi": 12, "python": [0, 1, 2, 3, 4, 5, 7, 8, 14, 22], "q4_k_m": 14, "q5_k_m": [14, 17], "qa": [17, 21], "quantiz": [16, 17, 22, 23], "quantize_model": [16, 20, 23], "queri": [3, 4, 8, 17, 18], "question": [0, 1], "rag": [0, 1, 3, 4, 6, 10, 15, 16, 22, 23, 24], "rag_jupyt": 5, "rag_python": 5, "rais": 17, "random": 18, "reach": 17, "read": 17, "read_onli": 18, "recommend": 14, "recurs": 17, "red": 8, "refer": [15, 17], "refin": [5, 6, 17, 21], "refine_cal": [16, 21], "refine_chain_langchain_illustr": 3, "relvant": 21, "render": 8, "render_search_form": 8, "render_search_result": 8, "render_sidebar": 8, "render_stat": 8, "replac": 17, "repo": 14, "repo_id": 20, "repositori": [12, 14, 20], "repr": 17, "repres": 8, "requir": [14, 17], "respect": 17, "respons": 8, "result": [8, 20], "retriev": [2, 3, 4, 9, 10, 15, 16, 21, 22, 23], "retriever_app": [8, 9], "retriever_kwarg": [16, 21], "retriv": [7, 9], "return": [8, 17, 18, 20, 21], "root": [17, 20], "root_path": 20, "run": [2, 11, 15, 22], "run_chroma": 15, "same": 17, "sampl": 17, "save": [16, 17, 20], "score": [8, 17, 18], "script": [15, 17], "search": [8, 17, 22], "search_form": 8, "self": [8, 17, 18], "semant": 8, "sentenc": [17, 18], "seper": [17, 21], "server": 15, "session_st": 8, "set": [8, 14, 17], "sh": 15, "shot": [5, 6, 17], "should": [14, 17, 18, 20], "show": [8, 17, 18], "sidebar": 8, "similar": [8, 17, 18], "similiar": 8, "simpl": [7, 8, 22], "sinc": [12, 15], "singl": [17, 18], "single_text_out": [16, 17], "size": 17, "slow": 2, "smaller": 17, "so": 17, "solut": 22, "sourc": [0, 1, 2, 3, 4, 5, 7, 8, 13, 15, 16, 17, 18, 20, 21], "specifi": [17, 20], "sphinx": [0, 1, 2, 3, 4, 5, 7, 8], "sphx_glr_auto_examples_basicrag_customprompt": 24, "sphx_glr_auto_examples_basicrag_fewshotprompt": 24, "sphx_glr_auto_examples_basicrag_ingest": 24, "sphx_glr_auto_examples_basicrag_refin": 24, "sphx_glr_auto_examples_basicrag_stuff": 24, "spinner": 8, "split": 17, "split_doc": [16, 17], "splitter": [16, 23], "src": [3, 4, 12, 15], "st": 8, "start": [14, 17, 22], "state": 8, "static": 21, "statist": 8, "statu": 18, "std_out": 17, "step": 8, "storag": 17, "store": [11, 16, 17, 18, 22], "store_path": [16, 17, 18], "str": [8, 17, 18, 20, 21], "strategi": [16, 17], "streamlit": [7, 8], "stremlit": 8, "string": [17, 18, 21], "stuff": [0, 1, 5, 6, 17, 21], "stuff_cal": [16, 21], "stuff_chain_langchain_illustr": 4, "stuff_doc": [16, 17, 21, 23], "submit": 8, "submodul": [16, 17, 23], "subprocess": 20, "suffix": [1, 16, 17], "support": [11, 17, 18, 22], "sure": [14, 15], "sy": 8, "sync": 2, "synchron": 2, "system": 8, "tab": 8, "tab1": 8, "tab2": 8, "tabl": 17, "table_as_html": 17, "take": 17, "task": [16, 17, 21], "temperatur": [16, 17], "templat": [0, 16, 17], "test": [2, 3, 4, 18], "test_connect": [8, 17, 18], "text": [16, 23], "text_concat": [16, 17], "text_input": 8, "text_splitt": [16, 17], "textsplitt": [16, 17, 23], "thank": 22, "them": 17, "thi": [0, 1, 2, 3, 4, 8, 14, 15, 17, 18, 21], "time": 17, "titl": 8, "toggl": 8, "token": [14, 17], "top": [8, 17, 18], "top_k": [8, 16, 17, 18], "total": [6, 9, 24], "transform": [17, 18], "travers": 17, "tree": 17, "true": [2, 3, 4, 8, 17, 18], "tupl": 18, "two": 14, "type": [8, 15, 17, 18, 21], "typic": 17, "ubuntu": [17, 18], "ui": 8, "under": 15, "union": 17, "uniqu": 17, "until": 17, "up": [1, 8, 17], "updat": 20, "us": [0, 1, 2, 3, 4, 5, 7, 8, 11, 15, 17, 18, 20, 21], "user": 14, "util": [16, 23], "uuid": 17, "uuid5": 17, "v": 17, "v1": 17, "valid": 17, "validate_doc_chain": [16, 17], "validate_exampl": [16, 17], "validate_input_kei": [16, 17], "validate_output_kei": [16, 17], "validate_task": [16, 17], "valu": [8, 17], "valueerror": 17, "variou": 22, "vector": [2, 11, 17, 18, 22], "vectordb": [2, 3, 4, 8, 15, 16, 23], "vectorstor": [15, 18], "verbos": [17, 18], "volume_2k": [17, 18], "wai": [14, 22], "want": 14, "we": 12, "web": 8, "what": [1, 8], "where": [14, 20], "whether": 17, "which": 17, "while": [3, 4], "who": 1, "width": [3, 4], "with_scor": [8, 17, 18], "wrapper": 18, "write": 8, "xl": [15, 18], "yann": 1, "yet": 12, "you": 14, "your": 8, "your_collection_nam": 2, "zip": [5, 7]}, "titles": ["Custom Prompts", "Custom Few-Shot Prompts", "Document Ingestion", "Refine Chain", "Stuff Chain", "Basic-RAG Cookbooks", "Computation times", "Retriever-GUI Cookbooks", "Retriever GUI", "Computation times", "Cookbooks", "Get Started", "Installation", "GRAG Overview", "LLMs", "Vector Stores", "GRAG", "Components", "VectorDB", "Prompts", "Quantize", "RAG", "Welcome to GRAG\u2019s documentation!", "grag", "Computation times"], "titleterms": {"": 22, "To": 14, "augment": 13, "base": 18, "basic": [5, 21], "chain": [3, 4], "chroma": [15, 18], "client": 18, "compon": 17, "comput": [6, 9, 24], "content": [16, 17, 18, 19, 20, 21, 22], "cookbook": [5, 7, 10], "custom": [0, 1], "data": 15, "deeplak": 18, "document": [2, 22], "embed": [15, 17], "few": 1, "gener": 13, "get": 11, "grag": [13, 16, 22, 23], "gui": [7, 8], "how": 14, "huggingfac": 14, "indic": 22, "ingest": [2, 15], "instal": 12, "llamacpp": 14, "llm": [14, 17], "model": 14, "modul": [16, 17, 18, 19, 20, 21], "overview": 13, "pars": 17, "pdf": 17, "prompt": [0, 1, 17, 19], "quantiz": [14, 20], "rag": [5, 21], "refin": 3, "retriev": [7, 8, 13, 17], "run": 14, "shot": 1, "splitter": 17, "start": 11, "store": 15, "stuff": 4, "submodul": [18, 20, 21], "support": 15, "tabl": 22, "text": 17, "time": [6, 9, 24], "us": 14, "util": [17, 20], "vector": 15, "vectordb": [17, 18], "welcom": 22}})
\ No newline at end of file
diff --git a/src/docs/_static/refine_chain_langchain_illustration.jpg b/src/docs/_static/refine_chain_langchain_illustration.jpg
new file mode 100644
index 0000000..cdf9b84
Binary files /dev/null and b/src/docs/_static/refine_chain_langchain_illustration.jpg differ
diff --git a/src/docs/_static/stuff_chain_langchain_illustration.jpg b/src/docs/_static/stuff_chain_langchain_illustration.jpg
new file mode 100644
index 0000000..e953dce
Binary files /dev/null and b/src/docs/_static/stuff_chain_langchain_illustration.jpg differ
diff --git a/src/docs/auto_examples/Basic-RAG/Basic-RAG_jupyter.zip b/src/docs/auto_examples/Basic-RAG/Basic-RAG_jupyter.zip
index e251243..ba5a94e 100644
Binary files a/src/docs/auto_examples/Basic-RAG/Basic-RAG_jupyter.zip and b/src/docs/auto_examples/Basic-RAG/Basic-RAG_jupyter.zip differ
diff --git a/src/docs/auto_examples/Basic-RAG/Basic-RAG_python.zip b/src/docs/auto_examples/Basic-RAG/Basic-RAG_python.zip
index da8c9fa..6293a17 100644
Binary files a/src/docs/auto_examples/Basic-RAG/Basic-RAG_python.zip and b/src/docs/auto_examples/Basic-RAG/Basic-RAG_python.zip differ
diff --git a/src/docs/auto_examples/Basic-RAG/BasicRAG_FewShotPrompt_codeobj.pickle b/src/docs/auto_examples/Basic-RAG/BasicRAG_FewShotPrompt_codeobj.pickle
index 41bc3a0..28e6218 100644
Binary files a/src/docs/auto_examples/Basic-RAG/BasicRAG_FewShotPrompt_codeobj.pickle and b/src/docs/auto_examples/Basic-RAG/BasicRAG_FewShotPrompt_codeobj.pickle differ
diff --git a/src/docs/auto_examples/Basic-RAG/BasicRAG_ingest_codeobj.pickle b/src/docs/auto_examples/Basic-RAG/BasicRAG_ingest_codeobj.pickle
index 2acb6c3..d8dfee0 100644
Binary files a/src/docs/auto_examples/Basic-RAG/BasicRAG_ingest_codeobj.pickle and b/src/docs/auto_examples/Basic-RAG/BasicRAG_ingest_codeobj.pickle differ
diff --git a/src/docs/auto_examples/Basic-RAG/BasicRAG_refine.ipynb b/src/docs/auto_examples/Basic-RAG/BasicRAG_refine.ipynb
index 14b62c4..661b354 100644
--- a/src/docs/auto_examples/Basic-RAG/BasicRAG_refine.ipynb
+++ b/src/docs/auto_examples/Basic-RAG/BasicRAG_refine.ipynb
@@ -4,7 +4,7 @@
       "cell_type": "markdown",
       "metadata": {},
       "source": [
-        "# Refine Chain\nThis cookbook demonstrates how to use the refine chain for BasicRAG.\n"
+        "# Refine Chain\nThis cookbook demonstrates how to use the refine chain for BasicRAG.\n\"Refine\n"
       ]
     },
     {
diff --git a/src/docs/auto_examples/Basic-RAG/BasicRAG_refine.py b/src/docs/auto_examples/Basic-RAG/BasicRAG_refine.py
index 85b640a..dffe7bd 100644
--- a/src/docs/auto_examples/Basic-RAG/BasicRAG_refine.py
+++ b/src/docs/auto_examples/Basic-RAG/BasicRAG_refine.py
@@ -1,6 +1,9 @@
 """Refine Chain
 =======================
 This cookbook demonstrates how to use the refine chain for BasicRAG.
+.. image:: src/docs/_static/refine_chain_langchain_illustration.jpg
+  :width: 400
+  :alt: Refine Documents Chain Process
 """
 
 from grag.components.multivec_retriever import Retriever
diff --git a/src/docs/auto_examples/Basic-RAG/BasicRAG_refine.rst b/src/docs/auto_examples/Basic-RAG/BasicRAG_refine.rst
index 5c19462..3d0a0ee 100644
--- a/src/docs/auto_examples/Basic-RAG/BasicRAG_refine.rst
+++ b/src/docs/auto_examples/Basic-RAG/BasicRAG_refine.rst
@@ -20,8 +20,11 @@
 Refine Chain
 =======================
 This cookbook demonstrates how to use the refine chain for BasicRAG.
+.. image:: src/docs/_static/refine_chain_langchain_illustration.jpg
+  :width: 400
+  :alt: Refine Documents Chain Process
 
-.. GENERATED FROM PYTHON SOURCE LINES 5-18
+.. GENERATED FROM PYTHON SOURCE LINES 8-21
 
 .. code-block:: Python
 
diff --git a/src/docs/auto_examples/Basic-RAG/BasicRAG_refine_codeobj.pickle b/src/docs/auto_examples/Basic-RAG/BasicRAG_refine_codeobj.pickle
index 580cd4e..dcc3aa2 100644
Binary files a/src/docs/auto_examples/Basic-RAG/BasicRAG_refine_codeobj.pickle and b/src/docs/auto_examples/Basic-RAG/BasicRAG_refine_codeobj.pickle differ
diff --git a/src/docs/auto_examples/Basic-RAG/BasicRAG_stuff.ipynb b/src/docs/auto_examples/Basic-RAG/BasicRAG_stuff.ipynb
index 95f75ce..63895c6 100644
--- a/src/docs/auto_examples/Basic-RAG/BasicRAG_stuff.ipynb
+++ b/src/docs/auto_examples/Basic-RAG/BasicRAG_stuff.ipynb
@@ -4,7 +4,7 @@
       "cell_type": "markdown",
       "metadata": {},
       "source": [
-        "# Stuff Chain\nThis cookbook demonstrates how to use the stuff chain for BasicRAG.\n"
+        "# Stuff Chain\nThis cookbook demonstrates how to use the stuff chain for BasicRAG.\n\"Stuff\n"
       ]
     },
     {
diff --git a/src/docs/auto_examples/Basic-RAG/BasicRAG_stuff.py b/src/docs/auto_examples/Basic-RAG/BasicRAG_stuff.py
index fa177f5..26d1f2c 100644
--- a/src/docs/auto_examples/Basic-RAG/BasicRAG_stuff.py
+++ b/src/docs/auto_examples/Basic-RAG/BasicRAG_stuff.py
@@ -1,6 +1,9 @@
 """Stuff Chain
 =======================
 This cookbook demonstrates how to use the stuff chain for BasicRAG.
+.. image:: src/docs/_static/stuff_chain_langchain_illustration.jpg
+  :width: 400
+  :alt: Stuff Documents Chain Process
 """
 
 from grag.components.multivec_retriever import Retriever
diff --git a/src/docs/auto_examples/Basic-RAG/BasicRAG_stuff.rst b/src/docs/auto_examples/Basic-RAG/BasicRAG_stuff.rst
index 02a9d6f..cd49781 100644
--- a/src/docs/auto_examples/Basic-RAG/BasicRAG_stuff.rst
+++ b/src/docs/auto_examples/Basic-RAG/BasicRAG_stuff.rst
@@ -20,8 +20,11 @@
 Stuff Chain
 =======================
 This cookbook demonstrates how to use the stuff chain for BasicRAG.
+.. image:: src/docs/_static/stuff_chain_langchain_illustration.jpg
+  :width: 400
+  :alt: Stuff Documents Chain Process
 
-.. GENERATED FROM PYTHON SOURCE LINES 5-19
+.. GENERATED FROM PYTHON SOURCE LINES 8-22
 
 .. code-block:: Python
 
diff --git a/src/docs/auto_examples/Basic-RAG/BasicRAG_stuff_codeobj.pickle b/src/docs/auto_examples/Basic-RAG/BasicRAG_stuff_codeobj.pickle
index 580cd4e..dcc3aa2 100644
Binary files a/src/docs/auto_examples/Basic-RAG/BasicRAG_stuff_codeobj.pickle and b/src/docs/auto_examples/Basic-RAG/BasicRAG_stuff_codeobj.pickle differ
diff --git a/src/docs/auto_examples/Retriver-GUI/Retriver-GUI_jupyter.zip b/src/docs/auto_examples/Retriver-GUI/Retriver-GUI_jupyter.zip
index 76a4b2c..5fd0969 100644
Binary files a/src/docs/auto_examples/Retriver-GUI/Retriver-GUI_jupyter.zip and b/src/docs/auto_examples/Retriver-GUI/Retriver-GUI_jupyter.zip differ
diff --git a/src/docs/auto_examples/Retriver-GUI/Retriver-GUI_python.zip b/src/docs/auto_examples/Retriver-GUI/Retriver-GUI_python.zip
index 18f7665..22bcfd9 100644
Binary files a/src/docs/auto_examples/Retriver-GUI/Retriver-GUI_python.zip and b/src/docs/auto_examples/Retriver-GUI/Retriver-GUI_python.zip differ
diff --git a/src/docs/auto_examples/Retriver-GUI/retriever_app_codeobj.pickle b/src/docs/auto_examples/Retriver-GUI/retriever_app_codeobj.pickle
index 4221d5f..9c7f0ee 100644
Binary files a/src/docs/auto_examples/Retriver-GUI/retriever_app_codeobj.pickle and b/src/docs/auto_examples/Retriver-GUI/retriever_app_codeobj.pickle differ