Repository Analysis

NirDiamant/RAG_Techniques

This repository showcases various advanced techniques for Retrieval-Augmented Generation (RAG) systems. Each technique has a detailed notebook tutorial.

20.3 Moderate AI signal View on GitHub
20.3
Adjusted Score
20.3
Raw Score
100%
Time Factor
2026-05-23
Last Push
27,628
Stars
Jupyter Notebook
Language
9,983
Lines of Code
32
Files
119
Pattern Hits
2026-05-31
Scan Date

Score History

Severity Breakdown

CRITICAL 0HIGH 4MEDIUM 25LOW 90

Pattern Findings

119 matches across 9 categories. Click a row to expand file-level details.

Self-Referential Comments24 hits · 78 pts
SeverityFileLineSnippet
MEDIUMhelper_functions.py166 # Define the prompt template for chain-of-thought reasoning
MEDIUMhelper_functions.py174 # Create a PromptTemplate object with the specified template and input variables
MEDIUMhelper_functions.py180 # Create a chain by combining the prompt template and the language model
MEDIUM…unnable_scripts/HyPE_Hypothetical_Prompt_Embeddings.py46 # Create a retriever from the vector store
MEDIUM…l_rag_techniques_runnable_scripts/choose_chunk_size.py75# Define the main class for the RAG method
MEDIUM…nnable_scripts/HyDe_Hypothetical_Document_Embedding.py18# Define the HyDe retriever class - creating vector store, generating hypothetical document, and retrieving
MEDIUM…l_rag_techniques_runnable_scripts/semantic_chunking.py56 # Create a vector store and retriever from the semantic chunks
MEDIUM…iques_runnable_scripts/retrieval_with_feedback_loop.py25# Define the Response class
MEDIUM…iques_runnable_scripts/retrieval_with_feedback_loop.py104# Define the main RAG class
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py108# Define the knowledge graph class
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py109# Define the Concepts class
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py114# Define the KnowledgeGraph class
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py315# Define the Query Engine class
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py316# Define the AnswerCheck class
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py322# Define the QueryEngine class
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py47# Define the document processor class
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py48# Define the DocumentProcessor class
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py584# Import necessary libraries
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py590# Define the Visualizer class
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py731# Define the graph RAG class
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py809 # Create a graph RAG instance
MEDIUMall_rag_techniques_runnable_scripts/self_rag.py70# Define main class
MEDIUMall_rag_techniques_runnable_scripts/simple_rag.py41 # Create a retriever from the vector store
MEDIUM…_rag_techniques_runnable_scripts/adaptive_retrieval.py193# Define the main Adaptive RAG class
Unused Imports49 hits · 48 pts
SeverityFileLineSnippet
LOWtests/test_imports.py2
LOW…unnable_scripts/HyPE_Hypothetical_Prompt_Embeddings.py14
LOW…unnable_scripts/HyPE_Hypothetical_Prompt_Embeddings.py15
LOW…_techniques_runnable_scripts/contextual_compression.py9
LOW…_techniques_runnable_scripts/contextual_compression.py10
LOW…nnable_scripts/HyDe_Hypothetical_Document_Embedding.py9
LOW…nnable_scripts/HyDe_Hypothetical_Document_Embedding.py10
LOWall_rag_techniques_runnable_scripts/raptor.py22
LOWall_rag_techniques_runnable_scripts/raptor.py23
LOW…l_rag_techniques_runnable_scripts/semantic_chunking.py6
LOW…g_techniques_runnable_scripts/document_augmentation.py9
LOW…g_techniques_runnable_scripts/document_augmentation.py9
LOW…g_techniques_runnable_scripts/document_augmentation.py21
LOW…iques_runnable_scripts/retrieval_with_feedback_loop.py8
LOW…iques_runnable_scripts/retrieval_with_feedback_loop.py14
LOW…iques_runnable_scripts/retrieval_with_feedback_loop.py15
LOW…able_scripts/context_enrichment_window_around_chunk.py2
LOW…able_scripts/context_enrichment_window_around_chunk.py5
LOW…able_scripts/context_enrichment_window_around_chunk.py6
LOW…g_techniques_runnable_scripts/explainable_retrieval.py6
LOW…g_techniques_runnable_scripts/explainable_retrieval.py7
LOWall_rag_techniques_runnable_scripts/reranking.py14
LOWall_rag_techniques_runnable_scripts/reranking.py15
LOWall_rag_techniques_runnable_scripts/graph_rag.py18
LOWall_rag_techniques_runnable_scripts/graph_rag.py29
LOWall_rag_techniques_runnable_scripts/graph_rag.py33
LOWall_rag_techniques_runnable_scripts/graph_rag.py34
LOWall_rag_techniques_runnable_scripts/self_rag.py10
LOWall_rag_techniques_runnable_scripts/self_rag.py11
LOW…ag_techniques_runnable_scripts/hierarchical_indices.py8
LOW…ag_techniques_runnable_scripts/hierarchical_indices.py8
LOW…ag_techniques_runnable_scripts/hierarchical_indices.py11
LOW…ag_techniques_runnable_scripts/hierarchical_indices.py12
LOWall_rag_techniques_runnable_scripts/simple_rag.py10
LOWall_rag_techniques_runnable_scripts/simple_rag.py11
LOWall_rag_techniques_runnable_scripts/fusion_retrieval.py11
LOWall_rag_techniques_runnable_scripts/fusion_retrieval.py12
LOW…_rag_techniques_runnable_scripts/adaptive_retrieval.py9
LOW…_rag_techniques_runnable_scripts/adaptive_retrieval.py10
LOW…_rag_techniques_runnable_scripts/adaptive_retrieval.py10
LOW…_rag_techniques_runnable_scripts/adaptive_retrieval.py11
LOW…_rag_techniques_runnable_scripts/adaptive_retrieval.py17
LOW…_rag_techniques_runnable_scripts/adaptive_retrieval.py18
LOWevaluation/evalute_rag.py16
LOWevaluation/evalute_rag.py17
LOWevaluation/evalute_rag.py19
LOWevaluation/evalute_rag.py34
LOWevaluation/evalute_rag.py34
LOWevaluation/evalute_rag.py34
Verbosity Indicators11 hits · 25 pts
SeverityFileLineSnippet
LOW…_techniques_runnable_scripts/contextual_compression.py42 # Step 1: Create a vector store
LOW…_techniques_runnable_scripts/contextual_compression.py45 # Step 2: Create a retriever
LOW…_techniques_runnable_scripts/contextual_compression.py48 # Step 3: Initialize language model and create a contextual compressor
LOW…_techniques_runnable_scripts/contextual_compression.py52 # Step 4: Combine the retriever with the compressor
LOW…_techniques_runnable_scripts/contextual_compression.py58 # Step 5: Create a QA chain with the compressed retriever
LOWall_rag_techniques_runnable_scripts/self_rag.py88 # Step 1: Determine if retrieval is necessary
LOWall_rag_techniques_runnable_scripts/self_rag.py95 # Step 2: Retrieve relevant documents
LOWall_rag_techniques_runnable_scripts/self_rag.py101 # Step 3: Evaluate relevance of retrieved documents
LOWall_rag_techniques_runnable_scripts/self_rag.py119 # Step 4: Generate response using relevant contexts
LOWall_rag_techniques_runnable_scripts/self_rag.py127 # Step 5: Assess support
LOWall_rag_techniques_runnable_scripts/self_rag.py133 # Step 6: Evaluate utility
Hyper-Verbose Identifiers21 hits · 21 pts
SeverityFileLineSnippet
LOWhelper_functions.py129def retrieve_context_per_question(question, chunks_query_retriever):
LOWhelper_functions.py162def create_question_answer_from_context_chain(llm):
LOWhelper_functions.py186def answer_question_from_context(question, context, question_answer_from_context_chain):
LOWhelper_functions.py294async def retry_with_exponential_backoff(coroutine, max_retries=5):
LOWhelper_functions.py338def get_langchain_embedding_provider(provider: EmbeddingProvider, model_id: str = None):
LOWtests/test_imports.py8def execute_imports_from_notebook(notebook_path) -> None:
LOWtests/test_imports.py42def execute_imports_from_script_files(script_path) -> None:
LOW…unnable_scripts/HyPE_Hypothetical_Prompt_Embeddings.py49 def generate_hypothetical_prompt_embeddings(self, chunk_text):
LOW…l_rag_techniques_runnable_scripts/choose_chunk_size.py23def evaluate_response_time_and_accuracy(chunk_size, eval_questions, eval_documents, faithfulness_evaluator,
LOW…l_rag_techniques_runnable_scripts/choose_chunk_size.py99 def create_faithfulness_evaluator(self):
LOW…l_rag_techniques_runnable_scripts/choose_chunk_size.py110 def create_relevancy_evaluator(self):
LOW…nnable_scripts/HyDe_Hypothetical_Document_Embedding.py34 def generate_hypothetical_document(self, query):
LOW…g_techniques_runnable_scripts/document_augmentation.py52def clean_and_filter_questions(questions: List[str]) -> List[str]:
LOW…able_scripts/context_enrichment_window_around_chunk.py17def split_text_to_chunks_with_indices(text: str, chunk_size: int, chunk_overlap: int) -> List[Document]:
LOW…able_scripts/context_enrichment_window_around_chunk.py38def retrieve_with_context_overlap(vectorstore, retriever, query: str, num_neighbors: int = 1, chunk_size: int = 200,
LOWall_rag_techniques_runnable_scripts/graph_rag.py331 def _create_answer_check_chain(self):
LOWall_rag_techniques_runnable_scripts/graph_rag.py95 def compute_similarity_matrix(self, embeddings):
LOWall_rag_techniques_runnable_scripts/graph_rag.py206 def _extract_concepts_and_entities(self, content, llm):
LOWall_rag_techniques_runnable_scripts/graph_rag.py567 def _retrieve_relevant_documents(self, query: str):
LOWall_rag_techniques_runnable_scripts/fusion_retrieval.py20def encode_pdf_and_get_split_documents(path, chunk_size=1000, chunk_overlap=200):
LOWevaluation/evalute_rag.py40def create_deep_eval_test_cases(
Docstring Block Structure3 hits · 15 pts
SeverityFileLineSnippet
HIGHhelper_functions.py80 Encodes a string into a vector store using OpenAI embeddings. Args: content (str): The text content to
HIGHhelper_functions.py295 Retries a coroutine using exponential backoff upon encountering a RateLimitError. Args: coroutine:
HIGHhelper_functions.py339 Returns an embedding provider based on the specified provider and model ID. Args: provider (EmbeddingP
Redundant / Tautological Comments4 hits · 7 pts
SeverityFileLineSnippet
LOWhelper_functions.py115 # Assign metadata to each chunk
LOW…_techniques_runnable_scripts/contextual_compression.py85 # Display the result and the source documents
LOWall_rag_techniques_runnable_scripts/graph_rag.py456 # Check if we have a complete answer with the current context
LOWall_rag_techniques_runnable_scripts/graph_rag.py497 # Check if we have a complete answer after adding the neighbor's content
Excessive Try-Catch Wrapping4 hits · 6 pts
SeverityFileLineSnippet
LOWhelper_functions.py123 except Exception as e:
LOWtests/test_imports.py33 except Exception as e:
LOWtests/test_imports.py64 except Exception as e:
MEDIUMall_rag_techniques_runnable_scripts/crag.py119 print("Error parsing search results. Returning empty list.")
Synthetic Comment Markers1 hit · 2 pts
SeverityFileLineSnippet
HIGH…l_rag_techniques_runnable_scripts/choose_chunk_size.py26 Evaluate the average response time, faithfulness, and relevancy of responses generated by GPT-3.5-turbo for a given
Deep Nesting2 hits · 2 pts
SeverityFileLineSnippet
LOWtests/test_imports.py8
LOWall_rag_techniques_runnable_scripts/graph_rag.py363