Repository Analysis

NirDiamant/RAG_Techniques

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

28.4 Moderate AI signal View on GitHub

Analysis Overview

This report presents the forensic synthetic code analysis of NirDiamant/RAG_Techniques, a Jupyter Notebook project with 28,535 GitHub stars. SynthScan v2.0 examined 9,959 lines of code across 32 source files, recording 149 pattern matches distributed across 12 syntactic categories. The overall adjusted score of 28.4 places this repository in the Moderate AI signal band.

The scanner applied 160+ deterministic lexical heuristics, multi-line block detectors, abstract syntax tree depth profilers, and a cross-file Jaccard similarity matrix to construct a statistically normalised synthetic code estimate. All matches are individually weighted by severity coefficient and contextual multiplier before summation, and the resulting headline score is temporally discounted to account for the repository's development history relative to the commercial emergence of large language model coding tooling (November 2022 onward).

28.4
Adjusted Score
28.4
Raw Score
100%
Time Factor
2026-07-12
Last Push
28.5K
Stars
Jupyter Notebook
Language
10.0K
Lines of Code
32
Files
149
Pattern Hits
2026-07-14
Scan Date
0.12
HC Hit Rate

What These Metrics Mean

Adjusted Score
Primary synthetic code indicator. Raw score normalised per 1,000 lines of code and multiplied by the temporal discount factor. This is the definitive comparative metric — use it to rank repositories by AI authorship density.
Raw Score
The unmodified sum of all severity-weighted, context-multiplied pattern match scores before temporal discounting. Reflects the absolute signal strength independent of when the repository was last active.
Time Factor
The temporal discount multiplier (0–100%) applied to the raw score. Repositories last updated before ChatGPT's launch (Nov 2022) receive a 5% factor. Full signal is only assigned to repositories active in the post-adoption era (Jan 2024+).
Pattern Hits
Total count of individual pattern matches across all files and categories. A high hit count with a low score may indicate a very large codebase with isolated AI snippets; a low count with a high score indicates dense, concentrated AI signatures.
HC Hit Rate
High+Critical pattern hits per file, averaged across the repository. This orthogonal signal catches repositories where a few files are densely packed with high-severity AI tells — a strong indicator even when the normalised score appears moderate due to codebase size.
Lines of Code / Files
Total lines and files analysed. The scanner examines 94 file extensions. These denominators are used to normalise the score, enabling fair comparison between repositories of vastly different sizes.

Score History

This chart maps the temporal evolution of the adjusted synthetic code score across successive scan runs. An upward trajectory indicates ongoing incorporation of AI-generated code or expanding LLM-assisted scaffolding; a stable or declining trajectory may reflect active human refactoring, code removal, or the adoption of stricter authorship policies. The dashed secondary line (right axis) independently tracks total raw pattern hit count, which can diverge from the normalised score when codebase size changes significantly between scans.

Severity Breakdown

Classifies detected patterns by their diagnostic confidence and structural impact. CRITICAL patterns (coefficient 10) represent definitive synthetic signatures — hallucinated imports, explicit LLM attribution metadata — virtually never produced by human authors. HIGH (5) indicates strong structural tells such as cross-file repetition or cross-linguistic idioms. MEDIUM (2) covers recognisable conversational padding and AI-specific vocabulary. LOW (1) captures subtle indicators like tautological comments and generic boilerplate that require density to carry independent signal.

CRITICAL 0HIGH 4MEDIUM 43LOW 102

Directory Score Breakdown

This horizontal bar chart decomposes the repository's raw synthetic code score by top-level directory, allowing you to pinpoint precisely which modules or components carry the highest AI authorship density. Directories with disproportionately high scores relative to their size warrant targeted manual review: concentrated AI signatures often trace back to mass-generated configuration layers, auto-ported test suites, LLM-scaffolded boilerplate classes, or entire subsystems authored under heavy copilot assistance. Use this view to prioritise your human code-review effort.

Pattern Findings

The scanner identified 149 distinct pattern matches across 12 syntactic categories. Each entry below represents a discrete location in the source code where the engine recorded a statistically significant AI authorship indicator. Expand any category row to inspect the individual file paths, line numbers, code snippets, and the lexical context (CODE, COMMENT, or STRING) in which each match was detected.

Reading the findings table: The Severity column indicates the diagnostic confidence level (CRITICAL / HIGH / MEDIUM / LOW). The Context column identifies whether the match occurred inside executable code, an inline comment, or a string literal — comment-context matches receive a ×1.5 weight because LLMs systematically over-annotate. The ⚡ bolt icon marks clustered matches: three or more patterns within a 10-line window, each receiving an additional ×1.5 density multiplier as dense clusters constitute far stronger evidence of synthetic authorship than isolated hits.

Self-Referential Comments24 hits · 79 pts
SeverityFileLineSnippetContext
MEDIUMhelper_functions.py166 # Define the prompt template for chain-of-thought reasoningCOMMENT
MEDIUMhelper_functions.py174 # Create a PromptTemplate object with the specified template and input variablesSTRING
MEDIUMhelper_functions.py180 # Create a chain by combining the prompt template and the language modelSTRING
MEDIUM…unnable_scripts/HyPE_Hypothetical_Prompt_Embeddings.py46 # Create a retriever from the vector storeCOMMENT
MEDIUM…l_rag_techniques_runnable_scripts/choose_chunk_size.py75# Define the main class for the RAG methodCOMMENT
MEDIUM…nnable_scripts/HyDe_Hypothetical_Document_Embedding.py18# Define the HyDe retriever class - creating vector store, generating hypothetical document, and retrievingCOMMENT
MEDIUM…l_rag_techniques_runnable_scripts/semantic_chunking.py56 # Create a vector store and retriever from the semantic chunksCOMMENT
MEDIUM…iques_runnable_scripts/retrieval_with_feedback_loop.py25# Define the Response classCOMMENT
MEDIUM…iques_runnable_scripts/retrieval_with_feedback_loop.py104# Define the main RAG classSTRING
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py108# Define the knowledge graph classCOMMENT
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py109# Define the Concepts classCOMMENT
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py114# Define the KnowledgeGraph classCOMMENT
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py315# Define the Query Engine classCOMMENT
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py316# Define the AnswerCheck classCOMMENT
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py322# Define the QueryEngine classCOMMENT
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py809 # Create a graph RAG instanceCOMMENT
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py47# Define the document processor classCOMMENT
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py48# Define the DocumentProcessor classCOMMENT
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py584# Import necessary librariesCOMMENT
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py590# Define the Visualizer classCOMMENT
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py731# Define the graph RAG classCOMMENT
MEDIUMall_rag_techniques_runnable_scripts/self_rag.py70# Define main classCOMMENT
MEDIUMall_rag_techniques_runnable_scripts/simple_rag.py41 # Create a retriever from the vector storeCOMMENT
MEDIUM…_rag_techniques_runnable_scripts/adaptive_retrieval.py193# Define the main Adaptive RAG classCOMMENT
Modern AI Meta-Vocabulary18 hits · 54 pts
SeverityFileLineSnippetContext
MEDIUMhelper_functions.py166 # Define the prompt template for chain-of-thought reasoningCOMMENT
MEDIUMREADME.md3# Advanced RAG Techniques 🚀COMMENT
MEDIUMREADME.md163### 🌱 Foundational RAG TechniquesCOMMENT
MEDIUMCONTRIBUTING.md1# Contributing to RAG TechniquesCOMMENT
MEDIUMCONTRIBUTING.md41## Adding a New RAG MethodCOMMENT
MEDIUMCONTRIBUTING.md80### 1. [Simple RAG 🌱](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/siCOMMENT
MEDIUM…unnable_scripts/HyPE_Hypothetical_Prompt_Embeddings.py185 # Initialize the HyPE-based RAG RetrieverCOMMENT
MEDIUM…l_rag_techniques_runnable_scripts/choose_chunk_size.py75# Define the main class for the RAG methodCOMMENT
MEDIUM…_techniques_runnable_scripts/contextual_compression.py109# Main function to run the RAG pipelineCOMMENT
MEDIUM…nnable_scripts/HyDe_Hypothetical_Document_Embedding.py76 # Create and run the RAG method instanceCOMMENT
MEDIUM…iques_runnable_scripts/retrieval_with_feedback_loop.py104# Define the main RAG classSTRING
MEDIUM…able_scripts/context_enrichment_window_around_chunk.py74# Main class that encapsulates the RAG methodCOMMENT
MEDIUM…able_scripts/context_enrichment_window_around_chunk.py139 # Initialize and run the RAG methodSTRING
MEDIUM…g_techniques_runnable_scripts/query_transformations.py62# Main class for the RAG methodCOMMENT
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py809 # Create a graph RAG instanceCOMMENT
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py815 # Input a query and get the retrieved information from the graph RAGCOMMENT
MEDIUMall_rag_techniques_runnable_scripts/graph_rag.py731# Define the graph RAG classCOMMENT
MEDIUM…_rag_techniques_runnable_scripts/adaptive_retrieval.py193# Define the main Adaptive RAG classCOMMENT
Unused Imports49 hits · 47 pts
SeverityFileLineSnippetContext
LOWtests/test_imports.py2CODE
LOW…unnable_scripts/HyPE_Hypothetical_Prompt_Embeddings.py14CODE
LOW…unnable_scripts/HyPE_Hypothetical_Prompt_Embeddings.py15CODE
LOW…_techniques_runnable_scripts/contextual_compression.py9CODE
LOW…_techniques_runnable_scripts/contextual_compression.py10CODE
LOW…nnable_scripts/HyDe_Hypothetical_Document_Embedding.py9CODE
LOW…nnable_scripts/HyDe_Hypothetical_Document_Embedding.py10CODE
LOWall_rag_techniques_runnable_scripts/raptor.py22CODE
LOWall_rag_techniques_runnable_scripts/raptor.py23CODE
LOW…l_rag_techniques_runnable_scripts/semantic_chunking.py6CODE
LOW…g_techniques_runnable_scripts/document_augmentation.py9CODE
LOW…g_techniques_runnable_scripts/document_augmentation.py9CODE
LOW…g_techniques_runnable_scripts/document_augmentation.py21CODE
LOW…iques_runnable_scripts/retrieval_with_feedback_loop.py8CODE
LOW…iques_runnable_scripts/retrieval_with_feedback_loop.py14CODE
LOW…iques_runnable_scripts/retrieval_with_feedback_loop.py15CODE
LOW…able_scripts/context_enrichment_window_around_chunk.py2CODE
LOW…able_scripts/context_enrichment_window_around_chunk.py5CODE
LOW…able_scripts/context_enrichment_window_around_chunk.py6CODE
LOW…g_techniques_runnable_scripts/explainable_retrieval.py6CODE
LOW…g_techniques_runnable_scripts/explainable_retrieval.py7CODE
LOWall_rag_techniques_runnable_scripts/reranking.py14CODE
LOWall_rag_techniques_runnable_scripts/reranking.py15CODE
LOWall_rag_techniques_runnable_scripts/graph_rag.py18CODE
LOWall_rag_techniques_runnable_scripts/graph_rag.py29CODE
LOWall_rag_techniques_runnable_scripts/graph_rag.py33CODE
LOWall_rag_techniques_runnable_scripts/graph_rag.py34CODE
LOWall_rag_techniques_runnable_scripts/self_rag.py10CODE
LOWall_rag_techniques_runnable_scripts/self_rag.py11CODE
LOW…ag_techniques_runnable_scripts/hierarchical_indices.py8CODE
LOW…ag_techniques_runnable_scripts/hierarchical_indices.py8CODE
LOW…ag_techniques_runnable_scripts/hierarchical_indices.py11CODE
LOW…ag_techniques_runnable_scripts/hierarchical_indices.py12CODE
LOWall_rag_techniques_runnable_scripts/simple_rag.py10CODE
LOWall_rag_techniques_runnable_scripts/simple_rag.py11CODE
LOWall_rag_techniques_runnable_scripts/fusion_retrieval.py11CODE
LOWall_rag_techniques_runnable_scripts/fusion_retrieval.py12CODE
LOW…_rag_techniques_runnable_scripts/adaptive_retrieval.py9CODE
LOW…_rag_techniques_runnable_scripts/adaptive_retrieval.py10CODE
LOW…_rag_techniques_runnable_scripts/adaptive_retrieval.py10CODE
LOW…_rag_techniques_runnable_scripts/adaptive_retrieval.py11CODE
LOW…_rag_techniques_runnable_scripts/adaptive_retrieval.py17CODE
LOW…_rag_techniques_runnable_scripts/adaptive_retrieval.py18CODE
LOWevaluation/evalute_rag.py16CODE
LOWevaluation/evalute_rag.py17CODE
LOWevaluation/evalute_rag.py19CODE
LOWevaluation/evalute_rag.py34CODE
LOWevaluation/evalute_rag.py34CODE
LOWevaluation/evalute_rag.py34CODE
Verbosity Indicators11 hits · 25 pts
SeverityFileLineSnippetContext
LOW…_techniques_runnable_scripts/contextual_compression.py42 # Step 1: Create a vector storeCOMMENT
LOW…_techniques_runnable_scripts/contextual_compression.py45 # Step 2: Create a retrieverCOMMENT
LOW…_techniques_runnable_scripts/contextual_compression.py48 # Step 3: Initialize language model and create a contextual compressorCOMMENT
LOW…_techniques_runnable_scripts/contextual_compression.py52 # Step 4: Combine the retriever with the compressorCOMMENT
LOW…_techniques_runnable_scripts/contextual_compression.py58 # Step 5: Create a QA chain with the compressed retrieverCOMMENT
LOWall_rag_techniques_runnable_scripts/self_rag.py88 # Step 1: Determine if retrieval is necessaryCOMMENT
LOWall_rag_techniques_runnable_scripts/self_rag.py95 # Step 2: Retrieve relevant documentsCOMMENT
LOWall_rag_techniques_runnable_scripts/self_rag.py101 # Step 3: Evaluate relevance of retrieved documentsCOMMENT
LOWall_rag_techniques_runnable_scripts/self_rag.py119 # Step 4: Generate response using relevant contextsCOMMENT
LOWall_rag_techniques_runnable_scripts/self_rag.py127 # Step 5: Assess supportCOMMENT
LOWall_rag_techniques_runnable_scripts/self_rag.py133 # Step 6: Evaluate utilityCOMMENT
Structural Annotation Overuse11 hits · 25 pts
SeverityFileLineSnippetContext
LOW…_techniques_runnable_scripts/contextual_compression.py42 # Step 1: Create a vector storeCOMMENT
LOW…_techniques_runnable_scripts/contextual_compression.py45 # Step 2: Create a retrieverCOMMENT
LOW…_techniques_runnable_scripts/contextual_compression.py48 # Step 3: Initialize language model and create a contextual compressorCOMMENT
LOW…_techniques_runnable_scripts/contextual_compression.py52 # Step 4: Combine the retriever with the compressorCOMMENT
LOW…_techniques_runnable_scripts/contextual_compression.py58 # Step 5: Create a QA chain with the compressed retrieverCOMMENT
LOWall_rag_techniques_runnable_scripts/self_rag.py88 # Step 1: Determine if retrieval is necessaryCOMMENT
LOWall_rag_techniques_runnable_scripts/self_rag.py95 # Step 2: Retrieve relevant documentsCOMMENT
LOWall_rag_techniques_runnable_scripts/self_rag.py101 # Step 3: Evaluate relevance of retrieved documentsCOMMENT
LOWall_rag_techniques_runnable_scripts/self_rag.py119 # Step 4: Generate response using relevant contextsCOMMENT
LOWall_rag_techniques_runnable_scripts/self_rag.py127 # Step 5: Assess supportCOMMENT
LOWall_rag_techniques_runnable_scripts/self_rag.py133 # Step 6: Evaluate utilityCOMMENT
Hyper-Verbose Identifiers21 hits · 20 pts
SeverityFileLineSnippetContext
LOWhelper_functions.py129def retrieve_context_per_question(question, chunks_query_retriever):CODE
LOWhelper_functions.py162def create_question_answer_from_context_chain(llm):CODE
LOWhelper_functions.py186def answer_question_from_context(question, context, question_answer_from_context_chain):STRING
LOWhelper_functions.py294async def retry_with_exponential_backoff(coroutine, max_retries=5):STRING
LOWhelper_functions.py338def get_langchain_embedding_provider(provider: EmbeddingProvider, model_id: str = None):STRING
LOWtests/test_imports.py8def execute_imports_from_notebook(notebook_path) -> None:CODE
LOWtests/test_imports.py42def execute_imports_from_script_files(script_path) -> None:CODE
LOW…unnable_scripts/HyPE_Hypothetical_Prompt_Embeddings.py49 def generate_hypothetical_prompt_embeddings(self, chunk_text):CODE
LOW…l_rag_techniques_runnable_scripts/choose_chunk_size.py23def evaluate_response_time_and_accuracy(chunk_size, eval_questions, eval_documents, faithfulness_evaluator,CODE
LOW…l_rag_techniques_runnable_scripts/choose_chunk_size.py99 def create_faithfulness_evaluator(self):CODE
LOW…l_rag_techniques_runnable_scripts/choose_chunk_size.py110 def create_relevancy_evaluator(self):STRING
LOW…nnable_scripts/HyDe_Hypothetical_Document_Embedding.py34 def generate_hypothetical_document(self, query):CODE
LOW…g_techniques_runnable_scripts/document_augmentation.py52def clean_and_filter_questions(questions: List[str]) -> List[str]:CODE
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]:CODE
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,CODE
LOWall_rag_techniques_runnable_scripts/graph_rag.py331 def _create_answer_check_chain(self):CODE
LOWall_rag_techniques_runnable_scripts/graph_rag.py95 def compute_similarity_matrix(self, embeddings):CODE
LOWall_rag_techniques_runnable_scripts/graph_rag.py206 def _extract_concepts_and_entities(self, content, llm):CODE
LOWall_rag_techniques_runnable_scripts/graph_rag.py567 def _retrieve_relevant_documents(self, query: str):CODE
LOWall_rag_techniques_runnable_scripts/fusion_retrieval.py20def encode_pdf_and_get_split_documents(path, chunk_size=1000, chunk_overlap=200):CODE
LOWevaluation/evalute_rag.py40def create_deep_eval_test_cases(CODE
Docstring Block Structure3 hits · 15 pts
SeverityFileLineSnippetContext
HIGHhelper_functions.py80 Encodes a string into a vector store using OpenAI embeddings. Args: content (str): The text content toSTRING
HIGHhelper_functions.py295 Retries a coroutine using exponential backoff upon encountering a RateLimitError. Args: coroutine:STRING
HIGHhelper_functions.py339 Returns an embedding provider based on the specified provider and model ID. Args: provider (EmbeddingPSTRING
Redundant / Tautological Comments4 hits · 7 pts
SeverityFileLineSnippetContext
LOWhelper_functions.py115 # Assign metadata to each chunkCOMMENT
LOW…_techniques_runnable_scripts/contextual_compression.py85 # Display the result and the source documentsCOMMENT
LOWall_rag_techniques_runnable_scripts/graph_rag.py456 # Check if we have a complete answer with the current contextCOMMENT
LOWall_rag_techniques_runnable_scripts/graph_rag.py497 # Check if we have a complete answer after adding the neighbor's contentCOMMENT
Excessive Try-Catch Wrapping4 hits · 6 pts
SeverityFileLineSnippetContext
LOWhelper_functions.py123 except Exception as e:CODE
LOWtests/test_imports.py33 except Exception as e:CODE
LOWtests/test_imports.py64 except Exception as e:CODE
MEDIUMall_rag_techniques_runnable_scripts/crag.py119 print("Error parsing search results. Returning empty list.")CODE
Synthetic Comment Markers1 hit · 2 pts
SeverityFileLineSnippetContext
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 STRING
Deep Nesting2 hits · 2 pts
SeverityFileLineSnippetContext
LOWtests/test_imports.py8CODE
LOWall_rag_techniques_runnable_scripts/graph_rag.py363CODE
AI Structural Patterns1 hit · 1 pts
SeverityFileLineSnippetContext
LOWall_rag_techniques_runnable_scripts/crag.py91CODE