Hybrid Rag
llmsathina-rag-cookbooksadvanced_rag_techniquesopenaiAItutorialsChromaDBcookbooksfaissqdrantLLMPythonpineconeraglangchainweaviate
Export
Hybrid RAG
Hybrid RAG refers to an advanced retrieval technique that combines vector similarity search with traditional search methods, such as full-text search or BM25. This approach enables more comprehensive and flexible information retrieval by leveraging the strengths of both methods, vector similarity for semantic understanding and traditional techniques for precise keyword or text-based matching.
Initial Setup
[ ]
[ ]
Indexing
[ ]
[ ]
[ ]
[ ]
Retrievers
[ ]
Keyword Retriever
[ ]
[ ]
/usr/local/lib/python3.10/dist-packages/langchain_core/_api/deprecation.py:119: LangChainDeprecationWarning: The method `BaseRetriever.get_relevant_documents` was deprecated in langchain-core 0.1.46 and will be removed in 0.3.0. Use invoke instead. warn_deprecated(
[Document(page_content='predominantly made from the lactose sugar in the agar.\\n\\n\\n== Variant ==\\nA variant, sorbitol-MacConkey agar, (with the addition of additional selective agents) can assist in the isolation and differentiation of enterohemorrhagic E. coli serotype E. coli O157:H7, by the presence of colorless circular colonies that are non-sorbitol fermenting.\\n\\n\\n== See also ==\\nR2a agar\\nMRS agar (culture medium designed to grow Gram-positive bacteria and differentiate them for lactose fermentation).\\n\\n\\n==', metadata={'source': './context.csv', 'row': 6}),
, Document(page_content='zoonotic disease since around 1910, but in the 1930s knowledge was gained that the bacteria lost their virulent power when repeatedly spread on agar media. This explained the difficulties to reproduce results from different studies as the pre-inoculating handlings of the bacteria were not standardized among scientists.Today it is established that at least some primate species are highly susceptible to B. pertussis and develop clinical whooping cough in high incidence when exposed to low', metadata={'source': './context.csv', 'row': 37}),
, Document(page_content="context: ['MacConkey agar is a selective and differential culture medium for bacteria. It is designed to selectively isolate Gram-negative and enteric (normally found in the intestinal tract) bacteria and differentiate them based on lactose fermentation. Lactose fermenters turn red or pink on MacConkey agar, and nonfermenters do not change color. The media inhibits growth of Gram-positive organisms with crystal violet and bile salts, allowing for the selection and isolation of gram-negative", metadata={'source': './context.csv', 'row': 6})] Ensemble Retriever
[ ]
[ ]
[Document(page_content="context: ['MacConkey agar is a selective and differential culture medium for bacteria. It is designed to selectively isolate Gram-negative and enteric (normally found in the intestinal tract) bacteria and differentiate them based on lactose fermentation. Lactose fermenters turn red or pink on MacConkey agar, and nonfermenters do not change color. The media inhibits growth of Gram-positive organisms with crystal violet and bile salts, allowing for the selection and isolation of gram-negative", metadata={'row': 6, 'source': './context.csv'}),
, Document(page_content='predominantly made from the lactose sugar in the agar.\\n\\n\\n== Variant ==\\nA variant, sorbitol-MacConkey agar, (with the addition of additional selective agents) can assist in the isolation and differentiation of enterohemorrhagic E. coli serotype E. coli O157:H7, by the presence of colorless circular colonies that are non-sorbitol fermenting.\\n\\n\\n== See also ==\\nR2a agar\\nMRS agar (culture medium designed to grow Gram-positive bacteria and differentiate them for lactose fermentation).\\n\\n\\n==', metadata={'row': 6, 'source': './context.csv'}),
, Document(page_content='0.001 g\\nAgar – 13.5 g\\nWater – add to make 1 litre; adjust pH to 7.1 +/− 0.2\\nSodium taurocholateThere are many variations of MacConkey agar depending on the need. If the spreading or swarming of Proteus species is not required, sodium chloride is omitted. Crystal violet at a concentration of 0.0001% (0.001 g per litre) is included when needing to check if Gram-positive bacteria are inhibited. MacConkey with sorbitol is used to isolate E. coli O157, an enteric pathogen.\\n\\n\\n== History ==\\nThe', metadata={'row': 6, 'source': './context.csv'}),
, Document(page_content='zoonotic disease since around 1910, but in the 1930s knowledge was gained that the bacteria lost their virulent power when repeatedly spread on agar media. This explained the difficulties to reproduce results from different studies as the pre-inoculating handlings of the bacteria were not standardized among scientists.Today it is established that at least some primate species are highly susceptible to B. pertussis and develop clinical whooping cough in high incidence when exposed to low', metadata={'source': './context.csv', 'row': 37}),
, Document(page_content='medium was developed by Alfred Theodore MacConkey while working as a bacteriologist for the Royal Commission on Sewage Disposal.\\n\\n\\n== Uses ==\\nUsing neutral red pH indicator, the agar distinguishes those Gram-negative bacteria that can ferment the sugar lactose (Lac+) from those that cannot (Lac-).\\nThis medium is also known as an "indicator medium" and a "low selective medium". Presence of bile salts inhibits swarming by Proteus species.\\n\\n\\n=== Lac positive ===\\nBy utilizing the lactose', metadata={'row': 6, 'source': './context.csv'})] RAG Chain
[ ]
[ ]
[ ]
'Gram-negative and enteric bacteria grow on MacConkey agar.'
Preparing Data for Evaluation
[ ]
[ ]
[ ]
[ ]
[ ]
Evaluation in Athina AI
We will use Context Relevancy eval here. It Measures the relevancy of the retrieved context, calculated based on both the query and contexts. Please refer to our documentation for further details
[ ]
[ ]
[ ]
evaluating with [context_relevancy] evaluating with [context_relevancy]
0%| | 0/1 [00:00<?, ?it/s] 0%| | 0/1 [00:00<?, ?it/s] 100%|██████████| 1/1 [00:00<00:00, 1.74it/s] 100%|██████████| 1/1 [00:01<00:00, 1.13s/it]
You can view your dataset at: https://app.athina.ai/develop/171e53cf-55e1-4d30-a4cf-71648edb7650