{
  "source_file": "0930",
  "source_platform": "Medium",
  "author": "Alexander Davis",
  "title_listed": "Evaluating Your RAG Solution",
  "keywords": "",
  "domain": "大模型算法",
  "content_type": "深度技术解析",
  "is_paid_flag": "否",
  "url": "https://towardsdatascience.com/evaluating-your-rag-solution/",
  "publish_date": "2025-09-17",
  "corpus_stage": "",
  "notes": "",
  "id": "22a81727c4d0",
  "collected_at": "2026-10-02T01:50:00",
  "title": "Evaluating Your RAG Solution | Towards Data Science",
  "body_markdown": "![Revisit consent button](../images/body-df29beacd7496220cc94.svg)\nWe value your privacy\nWe use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking \"Accept All\", you consent to our use of cookies.\nCustomise Reject All Accept All\nCustomise Consent Preferences ![](../images/body-2159bb67f3de8ad870eb.svg)\nWe use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.\nThe cookies that are categorised as \"Necessary\" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... Show more\nNecessaryAlways Active\nNecessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.\n  * Cookie\nBCTempID\n  * Duration\n10 minutes\n  * Description\nNo description available.\n\n\n  * Cookie\n__cf_bm\n  * Duration\n1 hour\n  * Description\nThis cookie, set by Cloudflare, is used to support Cloudflare Bot Management. \n\n\n  * Cookie\nAWSALBCORS\n  * Duration\n7 days\n  * Description\nAmazon Web Services set this cookie for load balancing.\n\n\n  * Cookie\n_cfuvid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to track users across sessions to optimize user experience by maintaining session consistency and providing personalized services\n\n\n  * Cookie\nli_gc\n  * Duration\n6 months\n  * Description\nLinkedin set this cookie for storing visitor's consent regarding using cookies for non-essential purposes.\n\n\n  * Cookie\n__hssrc\n  * Duration\nsession\n  * Description\nThis cookie is set by Hubspot whenever it changes the session cookie. The __hssrc cookie set to 1 indicates that the user has restarted the browser, and if the cookie does not exist, it is assumed to be a new session.\n\n\n  * Cookie\n__hssc\n  * Duration\n1 hour\n  * Description\nHubSpot sets this cookie to keep track of sessions and to determine if HubSpot should increment the session number and timestamps in the __hstc cookie.\n\n\n  * Cookie\nwpEmojiSettingsSupports\n  * Duration\nsession\n  * Description\nWordPress sets this cookie when a user interacts with emojis on a WordPress site. It helps determine if the user's browser can display emojis properly.\n\n\n  * Cookie\nBCSessionID\n  * Duration\n1 year 1 month 4 days\n  * Description\nBlueconic sets this cookie as a unique identifier for the BlueConic profile.\n\n\n  * Cookie\n_octo\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nlogged_in\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\n__Secure-YEC\n  * Duration\npast\n  * Description\nYouTube sets this cookie to stores the user's video player preferences using embedded YouTube video\n\n\n  * Cookie\n__eoi\n  * Duration\n6 months\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTGCORS\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\nlogin-status-p\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTG\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\ncsrf_token\n  * Duration\nsession\n  * Description\nNo description available.\n\n\n  * Cookie\ntoken_v2\n  * Duration\n1 day\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nD\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nPHPSESSID\n  * Duration\nsession\n  * Description\nThis cookie is native to PHP applications. The cookie stores and identifies a user's unique session ID to manage user sessions on the website. The cookie is a session cookie and will be deleted when all the browser windows are closed.\n\n\n  * Cookie\nVISITOR_PRIVACY_METADATA\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to store the user's cookie consent state for the current domain. \n\n\n  * Cookie\ncookietest\n  * Duration\nsession\n  * Description\nThe cookietest cookie is typically used to determine whether the user's browser accepts cookies, essential for website functionality and user experience.\n\n\n  * Cookie\n__Host-airtable-session\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\n__Host-airtable-session.sig\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\nm\n  * Duration\n1 year 1 month 4 days\n  * Description\nStripe sets this cookie for fraud prevention purposes. It identifies the device used to access the website, allowing the website to be formatted accordingly.\n\n\n  * Cookie\nBIGipServer*\n  * Duration\nsession\n  * Description\nMarketo sets this cookie to collect information about the user's online activity and build a profile about their interests to provide advertisements relevant to the user. \n\n\n  * Cookie\n__cfruid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to identify trusted web traffic.\n\n\n  * Cookie\n_GRECAPTCHA\n  * Duration\n6 months\n  * Description\nGoogle Recaptcha service sets this cookie to identify bots to protect the website against malicious spam attacks.\n\n\n  * Cookie\n__Secure-YNID\n  * Duration\n6 months\n  * Description\nGoogle cookie used to protect user security and prevent fraud, especially during the login process.\n\n\n  * Cookie\ncookieyes-consent\n  * Duration\n1 year\n  * Description\nCookieYes sets this cookie to remember users' consent preferences so that their preferences are respected on subsequent visits to this site. It does not collect or store any personal information about the site visitors.\n\n\nFunctional\nFunctional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.\n  * Cookie\nlidc\n  * Duration\n1 day\n  * Description\nLinkedIn sets the lidc cookie to facilitate data center selection.\n\n\n  * Cookie\nbrw\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nbrwConsent\n  * Duration\n5 minutes\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nWMF-Uniq\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nloom_anon_comment\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nloom_referral_video\n  * Duration\nsession\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nVISITOR_INFO1_LIVE\n  * Duration\n6 months\n  * Description\nA cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.\n\n\n  * Cookie\nyt-remote-connected-devices\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nytidb::LAST_RESULT_ENTRY_KEY\n  * Duration\nNever Expires\n  * Description\nThe cookie ytidb::LAST_RESULT_ENTRY_KEY is used by YouTube to store the last search result entry that was clicked by the user. This information is used to improve the user experience by providing more relevant search results in the future.\n\n\n  * Cookie\nyt-remote-device-id\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-name\n  * Duration\nsession\n  * Description\nThe yt-remote-session-name cookie is used by YouTube to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\nyt-remote-fast-check-period\n  * Duration\nsession\n  * Description\nThe yt-remote-fast-check-period cookie is used by YouTube to store the user's video player preferences for embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-app\n  * Duration\nsession\n  * Description\nThe yt-remote-session-app cookie is used by YouTube to store user preferences and information about the interface of the embedded YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-available\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-available cookie is used to store the user's preferences regarding whether casting is available on their YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-installed\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-installed cookie is used to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\ncp_session\n  * Duration\n3 months\n  * Description\nCodepen sets this cookie for Help systems found in the website.\n\n\n  * Cookie\nloid\n  * Duration\n1 year 1 month 4 days\n  * Description\nThis cookie is set by the Reddit. The cookie enables the sharing of content from the website onto the social media platform.\n\n\nAnalytics\nAnalytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.\n  * Cookie\n__hstc\n  * Duration\n6 months\n  * Description\nHubspot set this main cookie for tracking visitors. It contains the domain, initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session).\n\n\n  * Cookie\nhubspotutk\n  * Duration\n6 months\n  * Description\nHubSpot sets this cookie to keep track of the visitors to the website. This cookie is passed to HubSpot on form submission and used when deduplicating contacts.\n\n\n  * Cookie\n_ga\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors.\n\n\n  * Cookie\n_ga_*\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to store and count page views.\n\n\n  * Cookie\n__Host-psifi.analyticsTrace\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n__Host-psifi.analyticsTraceV2\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n_gh_sess\n  * Duration\nsession\n  * Description\nGitHub sets this cookie for temporary application and framework state between pages like what step the user is on in a multiple step form.\n\n\n  * Cookie\nYSC\n  * Duration\nsession\n  * Description\nYSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.\n\n\n  * Cookie\najs_anonymous_id\n  * Duration\n1 year\n  * Description\nThis cookie is set by Segment to count the number of people who visit a certain site by tracking if they have visited before.\n\n\n  * Cookie\nvuid\n  * Duration\n1 year 1 month 4 days\n  * Description\nVimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. \n\n\nPerformance\nPerformance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.\n  * Cookie\nAWSALB\n  * Duration\n7 days\n  * Description\nAWSALB is an application load balancer cookie set by Amazon Web Services to map the session to the target.\n\n\n  * Cookie\nacq\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nacq.sig\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nptc\n  * Duration\n2 years\n  * Description\nNo description available.\n\n\nAdvertisement\nAdvertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.\n  * Cookie\nmuc_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to collect user behaviour and interaction data to optimize the website.\n\n\n  * Cookie\nguest_id_marketing\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\nguest_id_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\npersonalization_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to integrate and share features for social media and also store information about how the user uses the website, for tracking and targeting.\n\n\n  * Cookie\nguest_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor. It registers if a user is signed in to the Twitter platform and collects information about ad preferences.\n\n\n  * Cookie\nbcookie\n  * Duration\n1 year\n  * Description\nLinkedIn sets this cookie from LinkedIn share buttons and ad tags to recognize browser IDs.\n\n\n  * Cookie\n__Secure-ROLLOUT_TOKEN\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to manage feature rollout and experimentation. It helps Google control which new features or interface changes are shown to users as part of testing and staged rollouts, ensuring consistent experience for a given user during an experiment.\n\n\n  * Cookie\nyt.innertube::nextId\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nyt.innertube::requests\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nsession_tracker\n  * Duration\nsession\n  * Description\nThis cookie is set by the Reddit. This cookie is used to identify trusted web traffic. It also helps in adverstising on the website.\n\n\n  * Cookie\nedgebucket\n  * Duration\nsession\n  * Description\nReddit sets this cookie to save the information about a log-on Reddit user, for the purpose of advertisement recommendations and updating the content.\n\n\n  * Cookie\ndid\n  * Duration\n1 year\n  * Description\nArbor sets this cookie to show targeted ads to site visitors.This cookie expires after 2 months or 1 year.\n\n\nUncategorised\nOther uncategorised cookies are those that are being analysed and have not been classified into a category as yet.\nNo cookies to display.\nReject All Save My Preferences Accept All\nToggle Search[](https://towardsdatascience.com/)Toggle Mobile Navigation\n[](https://towardsdatascience.com/)\nPublish AI, ML & data-science insights to a global community of data professionals.\nSign in[Submit an Article](https://write.insightmediagroup.io)\n[Latest](https://towardsdatascience.com/latest/)[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Newsletter](https://towardsdatascience.com/tag/the-variable/)[ShipAI](https://towardsdatascience.com/shipai/)\n* * *\n[Write For TDS](https://towardsdatascience.com/submissions/)\n[LinkedIn](https://www.linkedin.com/company/towards-data-science/)[X](https://x.com/TDataScience)Toggle Search\n[Large Language Models](https://towardsdatascience.com/category/artificial-intelligence/large-language-models/)\n# Evaluating Your RAG Solution\nA guide to building and evaluating RAG solutions by leveraging LLM-as-a-Judge capabilities.\n[Alex Davis](https://towardsdatascience.com/author/adavis08/)\nSeptember 17, 202513 min read\n![](../images/000.png)\nImage by Author\n## Introduction\nRetrieval-Augmented Generation (RAG) solutions are everywhere. Over the past few years, we have seen them grow rapidly as organizations use RAG or hybrid-RAG solutions in customer service, healthcare, intelligence, and more. **But how do we evaluate these solutions? And what methods can we use to determine the strengths and weaknesses of our RAG models?**\nThis article will give an introduction to RAG by building our own chatbot with open-source research data using [LangChain](https://python.langchain.com/docs/introduction/) and more. We will also leverage [DeepEval](https://deepeval.com/) to evaluate our RAG pipeline for both our retriever and generator. Lastly, we will discuss methods for human-testing RAG solutions.\n## Retrieval-Augmented Generation\nWith the emergence of LLMs, lots of criticisms were raised when these \"base\" pre-trained models would give incorrect answers, despite being trained on massive datasets. **With that came Retrieval-Augmented Generation (RAG), a combination of search and generation capabilities that reference context-specific information before generating a response.**\nLearn this step by step with the interactive [AI Engineer](https://roadmap.sh/ai-engineer) roadmap.\n![](../images/001.png)\nImage by Author\nRAG has become very popular over the last few years due to its ability to reduce hallucinations and improve factuality. They are flexible, easy to update, and much cheaper than fine-tuning LLMs. We come across RAG solutions on a daily basis now. For example, many organizations have leveraged RAG to build internal chatbots for employees to navigate their knowledge base, and external chatbots to support customer service and other business functions.\n## Building a RAG Pipeline\nFor our RAG solution, we will use abstracts from open-source research related to artificial intelligence. We can use this data to generate more \"technical\" answers when asking questions related to artificial intelligence, machine learning, etc.\n_The data used comes from the OpenAlex API (_[_https://openalex.org/_](https://openalex.org/)_). This is a dataset/catalogue of open-source research from around the world. The data is freely accessible under a No Rights Reserved license (CC0 license)._\n### Data Ingestion\nFirst, we need to load our data using the OpenAlex API. Below is code to conduct searches by publication year and key terms. We run a search for AI/ML using key terms like \"deep learning\", \"natural language processing\", \"computer vision\", etc.\npython\n\n```\nimport pandas as pd\nimport requests\n\ndef import_data(pages, start_year, end_year, search_terms):\n    \n    \"\"\"\n    This function is used to use the OpenAlex API, conduct a search on works, a return a dataframe with associated works.\n    \n    Inputs: \n        - pages: int, number of pages to loop through\n        - search_terms: str, keywords to search for (must be formatted according to OpenAlex standards)\n        - start_year and end_year: int, years to set as a range for filtering works\n    \"\"\"\n    \n    #create an empty dataframe\n    search_results = pd.DataFrame()\n    \n    for page in range(1, pages):\n        \n        #use paramters to conduct request and format to a dataframe\n        response = requests.get(f'https://api.openalex.org/works?page={page}&per-page=200&filter=publication_year:{start_year}-{end_year},type:article&search={search_terms}')\n        data = pd.DataFrame(response.json()['results'])\n        \n        #append to empty dataframe\n        search_results = pd.concat([search_results, data])\n    \n    #subset to relevant features\n    search_results = search_results[[\"id\", \"title\", \"display_name\", \"publication_year\", \"publication_date\",\n                                        \"type\", \"countries_distinct_count\",\"institutions_distinct_count\",\n                                        \"has_fulltext\", \"cited_by_count\", \"keywords\", \"referenced_works_count\", \"abstract_inverted_index\"]]\n    \n    return(search_results)\n\n#search for AI-related research\nai_search = import_data(30, 2018, 2025, \"'artificial intelligence' OR 'deep learn' OR 'neural net' OR 'natural language processing' OR 'machine learn' OR 'large language models' OR 'small language models'\")\n```\n\nWhen querying the OpenAlex database, the abstracts are returned as an inverted index. Below is a function to undo the inverted index and return the original text of the abstract.\npython\n\n```\ndef undo_inverted_index(inverted_index):\n    \n    \"\"\"\n    The purpose of the function is to 'undo' and inverted index. It inputs an inverted index and\n    returns the original string.\n    \"\"\"\n\n    #create empty lists to store uninverted index\n    word_index = []\n    words_unindexed = []\n    \n    #loop through index and return key-value pairs\n    for k,v in inverted_index.items(): \n        for index in v: word_index.append([k,index])\n\n    #sort by the index\n    word_index = sorted(word_index, key = lambda x : x[1])\n    \n    #join only the values and flatten\n    for pair in word_index:\n        words_unindexed.append(pair[0])\n    words_unindexed = ' '.join(words_unindexed)\n    \n    return(words_unindexed)\n\n#create 'original_abstract' feature\nai_search['original_abstract'] = list(map(undo_inverted_index, ai_search['abstract_inverted_index']))\n```\n\n### Create a Vector Database\nNext, we need to generate embeddings to represent the abstracts, and store them in a vector database. **It is a best practice to leverage vector databases as they are designed for low-latency queries and can scale to handle billions of data points.** They also use specialized indexing and nearest neighbor algorithms to quickly retrieve data based on contextual and/or semantic similarity, making them essential for LLM applications.\n![](../images/body-aa64f15c283c1b9da208.png)\nImage by Author\nFirst, we import the necessary libraires from LangChain and load our embedding model from HuggingFace. While we can probably get better results using larger embedding models, I decided to use a smaller model to emphasize speed in this pipeline. \n_You can find and compare embedding models based on their size, performance, intended use, etc. by using the MTEB leaderboard from Hugging Face (_[_https://huggingface.co/spaces/mteb/leaderboard_](https://huggingface.co/spaces/mteb/leaderboard) _)._   \n\npython\n\n```\nfrom langchain_community.docstore.in_memory import InMemoryDocstore\nfrom langchain_community.vectorstores import FAISS\nfrom langchain_huggingface.embeddings import HuggingFaceEmbeddings\nfrom langchain_core.documents import Document\n\n#load embedding model\nembeddings = HuggingFaceEmbeddings(model_name=\"thenlper/gte-small\")\n```\n\nNext, we create our vector database using FAISS (or LangChain's wrapper for FAISS). We start by creating the index and formatting our data and documents, while also storing their metadata (title and year). We then create a list of IDs, add the documents and IDs to the database, and save the database locally.\npython\n\n```\n#save index with faiss\nindex = faiss.IndexFlatL2(len(embeddings.embed_query(\"hello world\")))\n\n#format abstracts as documents\ndocuments = [Document(page_content=ai_search['original_abstract'][i], metadata={\"title\": ai_search['title'][i], \"year\": ai_search['publication_year'][i]}) for i in range(len(ai_search))]\n\n#create list of ids as strings\nn = len(ai_search)\nids = list(range(1, n + 1))\nids = [str(x) for x in my_list]\n\n#add documents to vector store\nvector_store.add_documents(documents=documents, ids=ids)\n\n#save the vector store\nvector_store.save_local(\"Data/faiss_index\")\n```\n\nWith LangChain's vector stores, we can query our documents directly. Let's quickly test this by searching for \"computer vision\". We can see below that the first document returned , \"Face Detection and Recognition Using OPENCV\", is highly-related to computer vision.\npython\n\n```\n#test that vector database is working\nvector_store.similarity_search(\"computer vision\", k=3)\n```\n\n> `[Document(id='783', metadata={'title': 'FACE DETECTION AND RECOGNITION USING OPENCV', 'year': 2020}, page_content='Computer Vision is one of the most fascinating and challenging tasks in the field of Artificial Intelligence.Computer Vision serves as a link between computer software and the visuals we see around us.It enables...`\n### Create RAG Pipeline\nNow let's develop our RAG pipeline. A major component of a RAG solution is the generative model leveraged to generate the responses. For this, we will use OpenAI's model from LangChain.\nSo we can compare the response before and after we implement the RAG pipeline, let's ask the \"base\" model: \"What are the most recent advancements in computer vision?\".\npython\n\n```\nfrom langchain_openai import OpenAI\nfrom langchain.chains import RetrievalQA\nfrom langchain import PromptTemplate\n\n#set API key\nOPENAI_API_KEY = os.getenv(\"OPENAI_API_KEY\",\"API KEY\") \n\n#load llm\nllm = OpenAI(openai_api_key=OPENAI_API_KEY)\n\n#test llm response\nllm.invoke(\"What are the most recent advancements in computer vision?\")\n```\n\n> '\\n\\n1. Deep Learning: Deep learning, a subset of machine learning, has shown significant progress in computer vision tasks such as object detection, recognition, and image classification. It uses neural networks with multiple hidden layers to learn and extract features from images, leading to more accurate and efficient results.\\n\\n2. Generative Adversarial Networks (GANs): GANs are a type of deep learning algorithm that generates new images by learning from a large dataset. They have been used in tasks such as image synthesis, super-resolution, and image-to-image translation, and have shown impressive results in creating realistic images.\\n\\n3. Convolutional Neural Networks (CNNs): CNNs are a type of deep learning algorithm that has revolutionized the field of computer vision. They are highly effective in extracting features from images and have been used in various tasks such as image classification, object detection, and segmentation.\\n\\n4. Transfer Learning: Transfer learning allows a pre-trained model to be used on a different task or dataset without starting from scratch. It has shown promising results in computer vision tasks, especially for tasks with limited training data.\\n\\n5. Image Segmentation: With advancements in deep learning, image segmentation has become more accurate and efficient. It involves dividing an image into different regions or segments to identify objects'\nFrom the response above, we can see a general summary of computer vision, a high-level description of how it works, and different types of models and applications. **While it is a good summary, is does not directly answer our question. A great opportunity for RAG!**\nNext, we will build the components for our RAG pipeline. First we need a **retriever** to grab the top k documents related to our query. We then build a **prompt** instructing our model how to respond to questions. Lastly, we combine them with the **base generative model** to create our pipeline. \nLet's quickly retest our query of \"What are the most recent advancements in computer vision?\".\npython\n\n```\n#test that vector database is working\nretriever = db.as_retriever(search_kwargs={\"k\": 3})\n\n#create a prompt template\ntemplate = \"\"\"<|user|>\nRelevant information:\n{context}\n\nProvide a concise answer to the following question using relevant information provided above:\n{question}\nIf the information above does not answer the question, say that you do not know. Keep answers to 3 sentences or shorter.<|end|>\n<|assistant|>\"\"\"\n\n#define prompt template\nprompt = PromptTemplate(\n    template=template,\n    input_variables=[\"context\", \"question\"])\n\n#create RAG pipeline\nrag = RetrievalQA.from_chain_type(llm=llm, chain_type=\"stuff\", retriever=retriever, return_source_documents=True,\n                                  chain_type_kwargs={\"prompt\": prompt}, verbose = True)\n\n#test rag response\nrag.invoke(\"What are the most recent advancements in computer vision?\")\n```\n\n> The most recent advancements in computer vision include the emergence of large language models equipped with vision capabilities, such as OpenAI's GPT-4V, Google's Bard AI, and Microsoft's Bing AI. These models are able to analyze images and have the ability to access real-time information, making them directly embedded in many applications. Further advancements are expected as AI continues to rapidly evolve.\nThis response does a much better job at answering our question. It directly addresses the most recent advancements by calling out specific capabilities, models, and how they contribute to advancing computer vision. This is a promising result for our technical chatbot.\n**But this is not a proper evaluation. Next, we will further test our RAG solution on a number of metrics to help us determine if its ready for production.**\n···\n## LLM-as-a-Judge\nTo begin evaluating our solution, we will use another generative model to determine how our RAG solution meets certain criteria. While LLM-as-a-Judge methods have some caveats and need to be used carefully, they offer a lot of flexibility and efficiency. They can also give detailed insights during the evaluation process, as you will see below.\nOur RAG consists of 2 main components, the retriever and generator. **We will evaluate these components separately.** Our findings could prompt us to tune hyperparameters, replace the embedding model, or use a difference generative model.\n### Retriever Evaluation\nFirst we will evaluate our retriever, the component that fetches the relevant content. We will judge on 3 metrics:\n  1. **Contextual Precision:** Represents a greater ability of the retrieval system to correctly rank relevant nodes. It first uses an LLM to determine whether each node is relevant to the input, before calculating the weighted cumulative precision.\n  2. **Contextual Recall:** Represents a greater ability of the retrieval system to capture all relevant information from the total available relevant set within your knowledge base.\n  3. **Contextual Relevancy:** Evaluates the overall relevance of the information presented for the given output.\n\n\nFirst, we import the libraries and initialize the metrics.\npython\n\n```\nfrom deepeval import evaluate\nfrom deepeval.test_case import LLMTestCase, LLMTestCaseParams\nfrom deepeval.metrics import (\n    ContextualPrecisionMetric,\n    ContextualRecallMetric,\n    ContextualRelevancyMetric)\n\n#set your OpenAI API key\nos.environ[\"OPENAI_API_KEY\"] = \"API KEY\"\n\n# Initialize metrics\ncontextual_precision = ContextualPrecisionMetric()\ncontextual_recall = ContextualRecallMetric()\ncontextual_relevancy = ContextualRelevancyMetric()\n```\n\n**Next, we need to build a test case, an expected output to a given query. These testing datasets can be difficult to build, and should have input from domain experts who understand the questions that may be asked, and what those answers should be.**\nFor this example, we will just create one test case with a mock expected output. This will not give us the true result, but will give us a result as an example.\npython\n\n```\n#define user query\ninput = 'What are the most recent advancements in computer vision?'\n\n#RAG output\nactual_output = rag.invoke(input)['result']\n\n#contexts used from the retriver\nretrieved_contexts = []\nfor el in range(0,3):\n  retrieved_contexts.append(rag.invoke(input)['source_documents'][el].page_content)\n  \n#expected output (example)\nexpected_output = 'Recent advancements in computer vision include Vision-Language Models (VLMs) that merge vision and language, Neural Radiance Fields (NeRFs) for 3D scene generation, and powerful Diffusion Models and Generative AI for creating realistic visuals. Other key areas are Edge AI for real-time processing, enhanced 3D vision techniques like NeRFs and Visual SLAM, advanced self-supervised learning methods, deepfake detection systems, and increased focus on Ethical AI and Explainable AI (XAI) to ensure fairness and transparency.'\n```\n\nWith the components above, we can now build our test case and compute our 3 metrics.\npython\n\n```\n#create test case\ntest_case = LLMTestCase(\n    input=input,\n    actual_output=actual_output,\n    retrieval_context=retrieved_contexts,\n    expected_output=expected_output)\n\n#compute contextual precision and print results\ncontextual_precision.measure(test_case)\nprint(\"Score: \", contextual_precision.score)\nprint(\"Reason: \", contextual_precision.reason)\n\n#compute contextual recall and print results\ncontextual_recall.measure(test_case)\nprint(\"Score: \", contextual_recall.score)\nprint(\"Reason: \", contextual_recall.reason)\n\n#compute relevancy precision and print results\ncontextual_relevancy.measure(test_case)\nprint(\"Score: \", contextual_relevancy.score)\nprint(\"Reason: \", contextual_relevancy.reason)\n```\n\n> Score: 1.0 Reason: The score is 1.00 because the relevant nodes are ranked at the top: the first node discusses 'recent progress on computer vision algorithms' and 'prominent achievements,' and the second node covers the 'evolution of computer vision' and foundational advancements. The irrelevant node, which only describes the OpenCV toolkit and lacks discussion of recent advancements, is correctly ranked last. This perfect ordering ensures the highest contextual precision.\n> Score: 0.0 Reason: The score is 0.00 because none of the sentences in the expected output can be traced back to any node(s) in the retrieval context; there is no overlap or relevant information present.\n> Score: 0.5555555555555556 Reason: The score is 0.56 because, while there are several statements that discuss recent progress and deep learning advancements in computer vision (e.g., 'The prominent achievements in computer vision tasks such as image classification, object detection and image segmentation brought by deep learning techniques are highlighted.'), much of the context is general background or unrelated details (e.g., 'The explanation of the term 'convolutional' as a mathematical operation is not directly relevant to the advancements in computer vision.').\nAs seen above, one of the benefits of using an LLM as a judge is that we get detailed feedback on why our scores are what they are. For example, get a 55% for contextual relevancy because the LLM deemed some of the information unnecessary (slightly going down a rabbit hole about CNNs).\nWe can also use the 'evaluate' function from DeepEval to better automate this process. This is useful when testing your RAG on several test cases.\npython\n\n```\n#run all metrics with 'evaluate' function\nevaluate(test_cases=[test_case],\n         metrics=[contextual_precision, contextual_recall, contextual_relevancy])\n```\n\n### Generation Evaluation \nNext, we evaluate our generator, which generates the responses based on the context given by the retriever. Here, we will compute 2 metrics:\n  1. **Answer Relevancy:** Similar to contextual relevancy, evaluates whether the prompt template in your generator is able to instruct your LLM to give relevant outputs based on the context.\n  2. **Faithfulness:** Evaluates whether the LLM used in your generator can output information that does not hallucinate or contradict any factual information presented in the retrieval context.\n\n\nAs before, lets initialize the metrics.\npython\n\n```\nfrom deepeval.metrics import AnswerRelevancyMetric, FaithfulnessMetric\n\nanswer_relevancy = AnswerRelevancyMetric()\nfaithfulness = FaithfulnessMetric()\n\n#compute answer relevancy and print results\nanswer_relevancy.measure(test_case)\nprint(\"Score: \", answer_relevancy.score)\nprint(\"Reason: \", answer_relevancy.reason)\n\n#compute faithfulness and print results\nfaithfulness.measure(test_case)\nprint(\"Score: \", faithfulness.score)\nprint(\"Reason: \", faithfulness.reason)\n```\n\n> Score: 1.0 Reason: The score is 1.00 because the answer was fully relevant and addressed the question directly without any irrelevant information. Great job staying focused and informative!\n> Score: 1.0 Reason: Great job! There are no contradictions, so the actual output is fully faithful to the retrieval context. \nAs seen above, our generator operates very well (with this test case). The answer remains relevant and the model does not contradict itself. Again, we can use the 'evaluate' function to evaluate several test cases.\npython\n\n```\n#run all metrics with 'evaluate' function\nevaluate(test_cases=[test_case],\n         metrics=[answer_relevancy, faithfulness])\n```\n\nA caveat of using these metrics is that they generic and only go after a few aspects of our generated output, like relevancy. **But we can also create tailored metrics to determine how well our RAG solution performs in areas important to us specifically.**\nFor example, we can pose questions like \"How does my RAG handle dark humor?\", or \"Is the output written at a kid-friendly level?\". For our example, let's determine how well our RAG provides technically written responses.\npython\n\n```\nfrom deepeval.metrics import GEval\n\n#create evaluation for technical language\ntech_eval = GEval(\n    name=\"Technical Language\",\n    criteria=\"Determine how technically written the actual output is\",\n    evaluation_params=[LLMTestCaseParams.ACTUAL_OUTPUT])\n\n#run evaluation\ntech_eval.measure(test_case)\nprint(\"Score: \", tech_eval.score)\nprint(\"Reason: \", tech_eval.reason)\n```\n\n> Score: 0.6437823499114202 Reason: The response uses appropriate technical terminology such as 'deep learning', 'image classification', 'object detection', 'image segmentation', 'GPUs', and 'FPGAs'. The explanations are clear but somewhat general, lacking specific examples or recent breakthroughs. The technical detail is moderate, mentioning both algorithmic and hardware aspects, but does not delve into particular models or methods. The writing is mostly formal and adheres to technical conventions, but the depth and specificity could be improved.\nIn the output above, we can see that our RAG produces somewhat technically written answers. It uses the appropriate technical terminology with clear explanations, but lacks examples. This is likely due to using abstracts as our data source, which are written at a somewhat high level. \n## Human Evaluation\n**While LLM-as-a-judge methods give us a lot a great information, they are generic and should be caveated as they do not fully assess real-world applicability.** Humans however, can better explore this, as no one knows the data better than the domain experts within the organization.\nHuman evaluation typically reviews for correctness, justification quality, and fluency. Evaluators must determine if the output is accurate, logically connects retrieved evidence to the conclusion, is natural, and useful. It is important to keep in mind the data, user, and purpose of your RAG solution to properly address these domain-specific requirements.\n···\n## Conclusion\nIn this article, we were able to build a RAG pipeline using open source research by leveraging FAISS, LangChain, and more. We also dove into how we can evaluate RAG solutions, evaluating both our retriever and generator. Libraries like DeepEval leverage LLM-as-a-judge metrics to build test cases and determine relevancy, faithfulness, and more. Lastly, we discussed how important human evaluation is when determining the real-world applicability or your RAG solution.\n···\n_I hope you have enjoyed my article! Please feel free to comment, ask questions, or request other topics._\n_Connect with me on LinkedIn:_[_https://www.linkedin.com/in/alexdavis2020/_](https://www.linkedin.com/in/alexdavis2020/)\n## Register Now to Continue Reading\n### Unlock Towards Data Science with a Free Account\nAll articles on Towards Data Science are available to registered users. Create a free account today to access this article and thousands more.\nRegister for freeSign in to your account\n* * *\n![](../images/body-d879ad8ec57b4f95a4cd.jpeg)\nWritten By\n## [Alex Davis](https://towardsdatascience.com/author/adavis08/)\n[See all from Alex Davis](https://towardsdatascience.com/author/adavis08/)\n[Deep Dives](https://towardsdatascience.com/tag/deep-dives/)[Llm](https://towardsdatascience.com/tag/llm/)[Llm Evaluation](https://towardsdatascience.com/tag/llm-evaluation/)[NLP](https://towardsdatascience.com/tag/nlp/)[Rag](https://towardsdatascience.com/tag/rag/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Fevaluating-your-rag-solution%2F&title=Evaluating%20Your%20RAG%20Solution)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Fevaluating-your-rag-solution%2F&title=Evaluating%20Your%20RAG%20Solution)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Fevaluating-your-rag-solution%2F&text=Evaluating%20Your%20RAG%20Solution)\n\n\nTowards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program.\n[Write for TDS](https://towardsdatascience.com/submissions/)\n## Related Articles\n  * [![](../images/002.jpeg)](https://towardsdatascience.com/will-your-vote-decide-the-next-president-0875a4927c75/)\n## [Will Your Vote Decide the Next President?](https://towardsdatascience.com/will-your-vote-decide-the-next-president-0875a4927c75/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nSimulating the probability that your singular vote swings the election in November\n[Jarom Hulet](https://towardsdatascience.com/author/jarom.hulet/)\nOctober 15, 202419 min read\n  * [![](../images/003.jpeg)](https://towardsdatascience.com/naive-bayes-classification-41d1fe802a1e/)\n## [Naive Bayes Classification](https://towardsdatascience.com/naive-bayes-classification-41d1fe802a1e/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nIn-depth explanation of the Naive Bayes family of classifiers, including a text classification example in Python\n[Dr. Roi Yehoshua](https://towardsdatascience.com/author/roiyeho/)\nJune 1, 202324 min read\n  * [![](../images/004.png)](https://towardsdatascience.com/improving-performance-and-explainability-of-zero-shot-clip-33e579d3f4bb/)\n## [Improving performance and explainability of Zero-Shot CLIP](https://towardsdatascience.com/improving-performance-and-explainability-of-zero-shot-clip-33e579d3f4bb/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nPart 2 - Visual classification via Description from LLMs\n[Alexey Kravets](https://towardsdatascience.com/author/alexml0123/)\nNovember 25, 20236 min read\n  * [![](../images/005.jpg)](https://towardsdatascience.com/using-local-llms-to-discover-high-performance-algorithms/)\n## [Using Local LLMs to Discover High-Performance Algorithms](https://towardsdatascience.com/using-local-llms-to-discover-high-performance-algorithms/)\n[Large Language Models](https://towardsdatascience.com/category/artificial-intelligence/large-language-models/)\nHow I used open-source models to explore new frontiers in efficient code generation, using my MacBook and local LLMs\n[Stefano Bosisio](https://towardsdatascience.com/author/stefanobosisio1/)\nJanuary 19, 20268 min read\n  * [![](../images/006.jpg)](https://towardsdatascience.com/loop-engineering-for-rag-generation-an-llm-cascade-from-a-cheap-local-model-up-to-a-hosted-flagship/)\n## [Loop Engineering for RAG Generation: An LLM Cascade from a Cheap Local Model Up to a Hosted Flagship](https://towardsdatascience.com/loop-engineering-for-rag-generation-an-llm-cascade-from-a-cheap-local-model-up-to-a-hosted-flagship/)\n[Large Language Models](https://towardsdatascience.com/category/artificial-intelligence/large-language-models/)\nEnterprise Document Intelligence [Vol.1 #8quater] - Two angles on the cascade, cost and a validation loop, backed by a real sweep of twenty local models against a hosted flagship\n[Kezhan Shi](https://towardsdatascience.com/author/kezhanshi/)\nJuly 24, 202611 min read\n  * [![](../images/007.jpeg)](https://towardsdatascience.com/transformers-retraining-roberta-base-using-the-roberta-mlm-procedure-7422160d5764/)\n## [🤗Transformers: Retraining roberta-base using the RoBERTa MLM Procedure](https://towardsdatascience.com/transformers-retraining-roberta-base-using-the-roberta-mlm-procedure-7422160d5764/)\n[NLP](https://towardsdatascience.com/category/artificial-intelligence/nlp/)\nIn this tutorial we will be retraining a RoBERTa LM for a more personalised downstream-oriented dataset.\n[Tanmay Garg](https://towardsdatascience.com/author/tanmay17061/)\nDecember 13, 20204 min read\n  * [![](../images/008.jpeg)](https://towardsdatascience.com/the-smarter-way-of-using-ai-in-programming-0492ac610385/)\n## [The Smarter Way of Using AI in Programming](https://towardsdatascience.com/the-smarter-way-of-using-ai-in-programming-0492ac610385/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\navoid the outdated methods of integrating AI into your coding workflow by going beyond ChatGPT\n[Hesam Sheikh](https://towardsdatascience.com/author/itshesamsheikh/)\nAugust 29, 20247 min read\n  * [![](../images/009.jpeg)](https://towardsdatascience.com/despite-their-feats-large-language-models-still-havent-contributed-to-linguistics-657bea43a8a3/)\n## [Despite Their Feats, Large Language Models Still Haven't Contributed to Linguistics](https://towardsdatascience.com/despite-their-feats-large-language-models-still-havent-contributed-to-linguistics-657bea43a8a3/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nA review of Chomsky's views on linguistics and LLMs\n[Mohamad Aboufoul](https://towardsdatascience.com/author/mohammadhia/)\nDecember 5, 202212 min read\n  * [![](../images/010.png)](https://towardsdatascience.com/from-perceptron-to-densenet-an-introduction-to-convolutional-neural-networks-ab37e3b7872e/)\n## [Convolutional Neural Networks: An Introduction](https://towardsdatascience.com/from-perceptron-to-densenet-an-introduction-to-convolutional-neural-networks-ab37e3b7872e/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nA brief journey from Perceptron to ResNet\n[Oliver Kramer](https://towardsdatascience.com/author/oliver_kramer/)\nOctober 21, 202212 min read\n\n\n  * [YouTube](https://www.youtube.com/c/TowardsDataScience)\n  * [X](https://x.com/TDataScience)\n  * [LinkedIn](https://www.linkedin.com/company/towards-data-science/)\n  * [Threads](https://www.threads.net/@towardsdatascience)\n  * [Bluesky](https://bsky.app/profile/towardsdatascience.com)\n\n\n[](https://towardsdatascience.com/)\nYour home for data science and AI. The world's leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.\nSubscribe to Our Newsletter[Write For TDS](https://towardsdatascience.com/submissions/)•[About](https://towardsdatascience.com/about-towards-data-science-d691af11cc2f/)•[Advertise](https://contact.towardsdatascience.com/advertise-with-towards-data-science)•[Privacy Policy](https://towardsdatascience.com/privacy-policy/)•[Terms of Use](https://towardsdatascience.com/website-terms-of-use/)\n© Insight Media Group, LLC 2026•[The New Stack](https://thenewstack.io)•[roadmap.sh](https://roadmap.sh)•[Creator Network](https://insightmediagroup.io/creator-network)\n####  Recommended Articles \nClose\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500) How Relevance Models Foreshadowed Transformers for NLP ](https://towardsdatascience.com/how-relevance-models-foreshadowed-transformers-for-nlp/ \"How Relevance Models Foreshadowed Transformers for NLP\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500) Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1 ](https://towardsdatascience.com/javascript-fatigue-you-dont-need-js-to-build-chatgpt/ \"Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500) The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs ](https://towardsdatascience.com/subset-sum-problem-solved-in-linear-time-for-dense-enough-inputs/ \"The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500) Does Your Company Have a Data Strategy? ](https://towardsdatascience.com/does-your-company-have-a-data-strategy-e8944dbec4ae/ \"Does Your Company Have a Data Strategy?\")\n\n\n",
  "metadata": {
    "title": "Evaluating Your RAG Solution | Towards Data Science",
    "description": "A guide to building and evaluating RAG solutions by leveraging LLM-as-a-Judge capabilities.",
    "keywords": null,
    "author": "Alex Davis",
    "og:locale": "en_US",
    "og:type": "article",
    "og:title": "Evaluating Your RAG Solution",
    "og:description": "A guide to building and evaluating RAG solutions by leveraging LLM-as-a-Judge capabilities.",
    "og:url": "https://towardsdatascience.com/evaluating-your-rag-solution/",
    "og:site_name": "Towards Data Science",
    "og:image": "https://assets.insightmediagroup.io/media/wp-content/uploads/2025/09/thumbnail-rag.png",
    "og:image:width": "1648",
    "og:image:height": "1648",
    "og:image:type": "image/png",
    "twitter:card": "summary_large_image",
    "twitter:site": "@TDataScience",
    "twitter:creator": "@TDataScience",
    "twitter:label1": "Written by",
    "twitter:data1": "Alex Davis",
    "twitter:label2": "Est. reading time",
    "twitter:data2": "13 min read",
    "article:published_time": "2025-09-17T13:04:59.000Z",
    "article:modified_time": "2025-09-17T13:04:59.000Z",
    "article:author": "https://towardsdatascience.com/author/adavis08/"
  },
  "paywall": {
    "listed_paid": false,
    "detected": false,
    "marker": "",
    "public_only": false,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 200,
    "error": ""
  },
  "code_blocks": [
    {
      "language": "txt",
      "file": "attachments/22a81727c4d0/code/block_000.txt",
      "chars": 1685
    },
    {
      "language": "txt",
      "file": "attachments/22a81727c4d0/code/block_001.txt",
      "chars": 851
    },
    {
      "language": "txt",
      "file": "attachments/22a81727c4d0/code/block_002.txt",
      "chars": 323
    },
    {
      "language": "txt",
      "file": "attachments/22a81727c4d0/code/block_003.txt",
      "chars": 580
    },
    {
      "language": "txt",
      "file": "attachments/22a81727c4d0/code/block_004.txt",
      "chars": 93
    },
    {
      "language": "txt",
      "file": "attachments/22a81727c4d0/code/block_005.txt",
      "chars": 331
    },
    {
      "language": "txt",
      "file": "attachments/22a81727c4d0/code/block_006.txt",
      "chars": 857
    },
    {
      "language": "txt",
      "file": "attachments/22a81727c4d0/code/block_007.txt",
      "chars": 449
    },
    {
      "language": "txt",
      "file": "attachments/22a81727c4d0/code/block_008.txt",
      "chars": 882
    },
    {
      "language": "txt",
      "file": "attachments/22a81727c4d0/code/block_009.txt",
      "chars": 702
    },
    {
      "language": "txt",
      "file": "attachments/22a81727c4d0/code/block_010.txt",
      "chars": 157
    },
    {
      "language": "txt",
      "file": "attachments/22a81727c4d0/code/block_011.txt",
      "chars": 465
    },
    {
      "language": "txt",
      "file": "attachments/22a81727c4d0/code/block_012.txt",
      "chars": 126
    },
    {
      "language": "txt",
      "file": "attachments/22a81727c4d0/code/block_013.txt",
      "chars": 372
    }
  ],
  "images": [
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:59:01Z"
    },
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:59:01Z"
    },
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:59:01Z"
    },
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:59:01Z"
    }
  ],
  "audio": [],
  "videos": [
    {
      "url": "https://www.youtube.com/c/TowardsDataScience",
      "kind": "channel_reference",
      "status": "reference_only"
    }
  ],
  "links": [
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/latest/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/editors-pick/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/the-variable/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/shipai/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/submissions/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/artificial-intelligence/large-language-models/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/adavis08/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/deep-dives/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/llm/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/llm-evaluation/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/nlp/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/rag/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/will-your-vote-decide-the-next-president-0875a4927c75/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/data-science/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/jarom.hulet/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/naive-bayes-classification-41d1fe802a1e/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/artificial-intelligence/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/roiyeho/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/improving-performance-and-explainability-of-zero-shot-clip-33e579d3f4bb/"
    },
    {
      "type": "external",
      "href": "https://write.insightmediagroup.io"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/company/towards-data-science/"
    },
    {
      "type": "external",
      "href": "https://x.com/TDataScience"
    },
    {
      "type": "external",
      "href": "https://python.langchain.com/docs/introduction/"
    },
    {
      "type": "external",
      "href": "https://deepeval.com/"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/ai-engineer"
    },
    {
      "type": "external",
      "href": "https://openalex.org/"
    },
    {
      "type": "external",
      "href": "https://huggingface.co/spaces/mteb/leaderboard"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/in/alexdavis2020/"
    },
    {
      "type": "external",
      "href": "https://www.facebook.com/sharer/sharer.php?title=Evaluating+Your+RAG+Solution&u=https%3A%2F%2Ftowardsdatascience.com%2Fevaluating-your-rag-solution%2F"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/shareArticle?mini=true&title=Evaluating+Your+RAG+Solution&url=https%3A%2F%2Ftowardsdatascience.com%2Fevaluating-your-rag-solution%2F"
    },
    {
      "type": "external",
      "href": "https://x.com/share?text=Evaluating+Your+RAG+Solution&url=https%3A%2F%2Ftowardsdatascience.com%2Fevaluating-your-rag-solution%2F"
    },
    {
      "type": "external",
      "href": "https://www.youtube.com/c/TowardsDataScience"
    },
    {
      "type": "external",
      "href": "https://www.threads.net/@towardsdatascience"
    },
    {
      "type": "external",
      "href": "https://bsky.app/profile/towardsdatascience.com"
    },
    {
      "type": "external",
      "href": "https://thenewstack.io"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh"
    },
    {
      "type": "external",
      "href": "https://insightmediagroup.io/creator-network"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-20T17:29:30Z",
  "source_url": "https://towardsdatascience.com/evaluating-your-rag-solution/",
  "delivery_status": "unverified",
  "discovery_status": "http_403",
  "missing_reason": "源页面未重新核验:http_403；已按保留正文补采图片",
  "repair_error": "",
  "actual_video_files": [],
  "expected_saved_body_images": 4,
  "image_discovery": "saved_markdown",
  "source_body_markdown": "![Revisit consent button](https://cdn-cookieyes.com/assets/images/revisit.svg)\nWe value your privacy\nWe use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking \"Accept All\", you consent to our use of cookies.\nCustomise Reject All Accept All\nCustomise Consent Preferences ![](https://cdn-cookieyes.com/assets/images/close.svg)\nWe use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.\nThe cookies that are categorised as \"Necessary\" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... Show more\nNecessaryAlways Active\nNecessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.\n  * Cookie\nBCTempID\n  * Duration\n10 minutes\n  * Description\nNo description available.\n\n\n  * Cookie\n__cf_bm\n  * Duration\n1 hour\n  * Description\nThis cookie, set by Cloudflare, is used to support Cloudflare Bot Management. \n\n\n  * Cookie\nAWSALBCORS\n  * Duration\n7 days\n  * Description\nAmazon Web Services set this cookie for load balancing.\n\n\n  * Cookie\n_cfuvid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to track users across sessions to optimize user experience by maintaining session consistency and providing personalized services\n\n\n  * Cookie\nli_gc\n  * Duration\n6 months\n  * Description\nLinkedin set this cookie for storing visitor's consent regarding using cookies for non-essential purposes.\n\n\n  * Cookie\n__hssrc\n  * Duration\nsession\n  * Description\nThis cookie is set by Hubspot whenever it changes the session cookie. The __hssrc cookie set to 1 indicates that the user has restarted the browser, and if the cookie does not exist, it is assumed to be a new session.\n\n\n  * Cookie\n__hssc\n  * Duration\n1 hour\n  * Description\nHubSpot sets this cookie to keep track of sessions and to determine if HubSpot should increment the session number and timestamps in the __hstc cookie.\n\n\n  * Cookie\nwpEmojiSettingsSupports\n  * Duration\nsession\n  * Description\nWordPress sets this cookie when a user interacts with emojis on a WordPress site. It helps determine if the user's browser can display emojis properly.\n\n\n  * Cookie\nBCSessionID\n  * Duration\n1 year 1 month 4 days\n  * Description\nBlueconic sets this cookie as a unique identifier for the BlueConic profile.\n\n\n  * Cookie\n_octo\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nlogged_in\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\n__Secure-YEC\n  * Duration\npast\n  * Description\nYouTube sets this cookie to stores the user's video player preferences using embedded YouTube video\n\n\n  * Cookie\n__eoi\n  * Duration\n6 months\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTGCORS\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\nlogin-status-p\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTG\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\ncsrf_token\n  * Duration\nsession\n  * Description\nNo description available.\n\n\n  * Cookie\ntoken_v2\n  * Duration\n1 day\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nD\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nPHPSESSID\n  * Duration\nsession\n  * Description\nThis cookie is native to PHP applications. The cookie stores and identifies a user's unique session ID to manage user sessions on the website. The cookie is a session cookie and will be deleted when all the browser windows are closed.\n\n\n  * Cookie\nVISITOR_PRIVACY_METADATA\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to store the user's cookie consent state for the current domain. \n\n\n  * Cookie\ncookietest\n  * Duration\nsession\n  * Description\nThe cookietest cookie is typically used to determine whether the user's browser accepts cookies, essential for website functionality and user experience.\n\n\n  * Cookie\n__Host-airtable-session\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\n__Host-airtable-session.sig\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\nm\n  * Duration\n1 year 1 month 4 days\n  * Description\nStripe sets this cookie for fraud prevention purposes. It identifies the device used to access the website, allowing the website to be formatted accordingly.\n\n\n  * Cookie\nBIGipServer*\n  * Duration\nsession\n  * Description\nMarketo sets this cookie to collect information about the user's online activity and build a profile about their interests to provide advertisements relevant to the user. \n\n\n  * Cookie\n__cfruid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to identify trusted web traffic.\n\n\n  * Cookie\n_GRECAPTCHA\n  * Duration\n6 months\n  * Description\nGoogle Recaptcha service sets this cookie to identify bots to protect the website against malicious spam attacks.\n\n\n  * Cookie\n__Secure-YNID\n  * Duration\n6 months\n  * Description\nGoogle cookie used to protect user security and prevent fraud, especially during the login process.\n\n\n  * Cookie\ncookieyes-consent\n  * Duration\n1 year\n  * Description\nCookieYes sets this cookie to remember users' consent preferences so that their preferences are respected on subsequent visits to this site. It does not collect or store any personal information about the site visitors.\n\n\nFunctional\nFunctional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.\n  * Cookie\nlidc\n  * Duration\n1 day\n  * Description\nLinkedIn sets the lidc cookie to facilitate data center selection.\n\n\n  * Cookie\nbrw\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nbrwConsent\n  * Duration\n5 minutes\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nWMF-Uniq\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nloom_anon_comment\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nloom_referral_video\n  * Duration\nsession\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nVISITOR_INFO1_LIVE\n  * Duration\n6 months\n  * Description\nA cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.\n\n\n  * Cookie\nyt-remote-connected-devices\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nytidb::LAST_RESULT_ENTRY_KEY\n  * Duration\nNever Expires\n  * Description\nThe cookie ytidb::LAST_RESULT_ENTRY_KEY is used by YouTube to store the last search result entry that was clicked by the user. This information is used to improve the user experience by providing more relevant search results in the future.\n\n\n  * Cookie\nyt-remote-device-id\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-name\n  * Duration\nsession\n  * Description\nThe yt-remote-session-name cookie is used by YouTube to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\nyt-remote-fast-check-period\n  * Duration\nsession\n  * Description\nThe yt-remote-fast-check-period cookie is used by YouTube to store the user's video player preferences for embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-app\n  * Duration\nsession\n  * Description\nThe yt-remote-session-app cookie is used by YouTube to store user preferences and information about the interface of the embedded YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-available\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-available cookie is used to store the user's preferences regarding whether casting is available on their YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-installed\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-installed cookie is used to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\ncp_session\n  * Duration\n3 months\n  * Description\nCodepen sets this cookie for Help systems found in the website.\n\n\n  * Cookie\nloid\n  * Duration\n1 year 1 month 4 days\n  * Description\nThis cookie is set by the Reddit. The cookie enables the sharing of content from the website onto the social media platform.\n\n\nAnalytics\nAnalytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.\n  * Cookie\n__hstc\n  * Duration\n6 months\n  * Description\nHubspot set this main cookie for tracking visitors. It contains the domain, initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session).\n\n\n  * Cookie\nhubspotutk\n  * Duration\n6 months\n  * Description\nHubSpot sets this cookie to keep track of the visitors to the website. This cookie is passed to HubSpot on form submission and used when deduplicating contacts.\n\n\n  * Cookie\n_ga\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors.\n\n\n  * Cookie\n_ga_*\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to store and count page views.\n\n\n  * Cookie\n__Host-psifi.analyticsTrace\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n__Host-psifi.analyticsTraceV2\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n_gh_sess\n  * Duration\nsession\n  * Description\nGitHub sets this cookie for temporary application and framework state between pages like what step the user is on in a multiple step form.\n\n\n  * Cookie\nYSC\n  * Duration\nsession\n  * Description\nYSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.\n\n\n  * Cookie\najs_anonymous_id\n  * Duration\n1 year\n  * Description\nThis cookie is set by Segment to count the number of people who visit a certain site by tracking if they have visited before.\n\n\n  * Cookie\nvuid\n  * Duration\n1 year 1 month 4 days\n  * Description\nVimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. \n\n\nPerformance\nPerformance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.\n  * Cookie\nAWSALB\n  * Duration\n7 days\n  * Description\nAWSALB is an application load balancer cookie set by Amazon Web Services to map the session to the target.\n\n\n  * Cookie\nacq\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nacq.sig\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nptc\n  * Duration\n2 years\n  * Description\nNo description available.\n\n\nAdvertisement\nAdvertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.\n  * Cookie\nmuc_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to collect user behaviour and interaction data to optimize the website.\n\n\n  * Cookie\nguest_id_marketing\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\nguest_id_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\npersonalization_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to integrate and share features for social media and also store information about how the user uses the website, for tracking and targeting.\n\n\n  * Cookie\nguest_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor. It registers if a user is signed in to the Twitter platform and collects information about ad preferences.\n\n\n  * Cookie\nbcookie\n  * Duration\n1 year\n  * Description\nLinkedIn sets this cookie from LinkedIn share buttons and ad tags to recognize browser IDs.\n\n\n  * Cookie\n__Secure-ROLLOUT_TOKEN\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to manage feature rollout and experimentation. It helps Google control which new features or interface changes are shown to users as part of testing and staged rollouts, ensuring consistent experience for a given user during an experiment.\n\n\n  * Cookie\nyt.innertube::nextId\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nyt.innertube::requests\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nsession_tracker\n  * Duration\nsession\n  * Description\nThis cookie is set by the Reddit. This cookie is used to identify trusted web traffic. It also helps in adverstising on the website.\n\n\n  * Cookie\nedgebucket\n  * Duration\nsession\n  * Description\nReddit sets this cookie to save the information about a log-on Reddit user, for the purpose of advertisement recommendations and updating the content.\n\n\n  * Cookie\ndid\n  * Duration\n1 year\n  * Description\nArbor sets this cookie to show targeted ads to site visitors.This cookie expires after 2 months or 1 year.\n\n\nUncategorised\nOther uncategorised cookies are those that are being analysed and have not been classified into a category as yet.\nNo cookies to display.\nReject All Save My Preferences Accept All\nToggle Search[](https://towardsdatascience.com/)Toggle Mobile Navigation\n[](https://towardsdatascience.com/)\nPublish AI, ML & data-science insights to a global community of data professionals.\nSign in[Submit an Article](https://write.insightmediagroup.io)\n[Latest](https://towardsdatascience.com/latest/)[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Newsletter](https://towardsdatascience.com/tag/the-variable/)[ShipAI](https://towardsdatascience.com/shipai/)\n* * *\n[Write For TDS](https://towardsdatascience.com/submissions/)\n[LinkedIn](https://www.linkedin.com/company/towards-data-science/)[X](https://x.com/TDataScience)Toggle Search\n[Large Language Models](https://towardsdatascience.com/category/artificial-intelligence/large-language-models/)\n# Evaluating Your RAG Solution\nA guide to building and evaluating RAG solutions by leveraging LLM-as-a-Judge capabilities.\n[Alex Davis](https://towardsdatascience.com/author/adavis08/)\nSeptember 17, 202513 min read\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/09/thumbnail-rag.png)\nImage by Author\n## Introduction\nRetrieval-Augmented Generation (RAG) solutions are everywhere. Over the past few years, we have seen them grow rapidly as organizations use RAG or hybrid-RAG solutions in customer service, healthcare, intelligence, and more. **But how do we evaluate these solutions? And what methods can we use to determine the strengths and weaknesses of our RAG models?**\nThis article will give an introduction to RAG by building our own chatbot with open-source research data using [LangChain](https://python.langchain.com/docs/introduction/) and more. We will also leverage [DeepEval](https://deepeval.com/) to evaluate our RAG pipeline for both our retriever and generator. Lastly, we will discuss methods for human-testing RAG solutions.\n## Retrieval-Augmented Generation\nWith the emergence of LLMs, lots of criticisms were raised when these \"base\" pre-trained models would give incorrect answers, despite being trained on massive datasets. **With that came Retrieval-Augmented Generation (RAG), a combination of search and generation capabilities that reference context-specific information before generating a response.**\nLearn this step by step with the interactive [AI Engineer](https://roadmap.sh/ai-engineer) roadmap.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/09/RAG-1024x520.png)\nImage by Author\nRAG has become very popular over the last few years due to its ability to reduce hallucinations and improve factuality. They are flexible, easy to update, and much cheaper than fine-tuning LLMs. We come across RAG solutions on a daily basis now. For example, many organizations have leveraged RAG to build internal chatbots for employees to navigate their knowledge base, and external chatbots to support customer service and other business functions.\n## Building a RAG Pipeline\nFor our RAG solution, we will use abstracts from open-source research related to artificial intelligence. We can use this data to generate more \"technical\" answers when asking questions related to artificial intelligence, machine learning, etc.\n_The data used comes from the OpenAlex API (_[_https://openalex.org/_](https://openalex.org/)_). This is a dataset/catalogue of open-source research from around the world. The data is freely accessible under a No Rights Reserved license (CC0 license)._\n### Data Ingestion\nFirst, we need to load our data using the OpenAlex API. Below is code to conduct searches by publication year and key terms. We run a search for AI/ML using key terms like \"deep learning\", \"natural language processing\", \"computer vision\", etc.\npython\n\n```\nimport pandas as pd\nimport requests\n\ndef import_data(pages, start_year, end_year, search_terms):\n    \n    \"\"\"\n    This function is used to use the OpenAlex API, conduct a search on works, a return a dataframe with associated works.\n    \n    Inputs: \n        - pages: int, number of pages to loop through\n        - search_terms: str, keywords to search for (must be formatted according to OpenAlex standards)\n        - start_year and end_year: int, years to set as a range for filtering works\n    \"\"\"\n    \n    #create an empty dataframe\n    search_results = pd.DataFrame()\n    \n    for page in range(1, pages):\n        \n        #use paramters to conduct request and format to a dataframe\n        response = requests.get(f'https://api.openalex.org/works?page={page}&per-page=200&filter=publication_year:{start_year}-{end_year},type:article&search={search_terms}')\n        data = pd.DataFrame(response.json()['results'])\n        \n        #append to empty dataframe\n        search_results = pd.concat([search_results, data])\n    \n    #subset to relevant features\n    search_results = search_results[[\"id\", \"title\", \"display_name\", \"publication_year\", \"publication_date\",\n                                        \"type\", \"countries_distinct_count\",\"institutions_distinct_count\",\n                                        \"has_fulltext\", \"cited_by_count\", \"keywords\", \"referenced_works_count\", \"abstract_inverted_index\"]]\n    \n    return(search_results)\n\n#search for AI-related research\nai_search = import_data(30, 2018, 2025, \"'artificial intelligence' OR 'deep learn' OR 'neural net' OR 'natural language processing' OR 'machine learn' OR 'large language models' OR 'small language models'\")\n```\n\nWhen querying the OpenAlex database, the abstracts are returned as an inverted index. Below is a function to undo the inverted index and return the original text of the abstract.\npython\n\n```\ndef undo_inverted_index(inverted_index):\n    \n    \"\"\"\n    The purpose of the function is to 'undo' and inverted index. It inputs an inverted index and\n    returns the original string.\n    \"\"\"\n\n    #create empty lists to store uninverted index\n    word_index = []\n    words_unindexed = []\n    \n    #loop through index and return key-value pairs\n    for k,v in inverted_index.items(): \n        for index in v: word_index.append([k,index])\n\n    #sort by the index\n    word_index = sorted(word_index, key = lambda x : x[1])\n    \n    #join only the values and flatten\n    for pair in word_index:\n        words_unindexed.append(pair[0])\n    words_unindexed = ' '.join(words_unindexed)\n    \n    return(words_unindexed)\n\n#create 'original_abstract' feature\nai_search['original_abstract'] = list(map(undo_inverted_index, ai_search['abstract_inverted_index']))\n```\n\n### Create a Vector Database\nNext, we need to generate embeddings to represent the abstracts, and store them in a vector database. **It is a best practice to leverage vector databases as they are designed for low-latency queries and can scale to handle billions of data points.** They also use specialized indexing and nearest neighbor algorithms to quickly retrieve data based on contextual and/or semantic similarity, making them essential for LLM applications.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/09/VDB-1024x919.png)\nImage by Author\nFirst, we import the necessary libraires from LangChain and load our embedding model from HuggingFace. While we can probably get better results using larger embedding models, I decided to use a smaller model to emphasize speed in this pipeline. \n_You can find and compare embedding models based on their size, performance, intended use, etc. by using the MTEB leaderboard from Hugging Face (_[_https://huggingface.co/spaces/mteb/leaderboard_](https://huggingface.co/spaces/mteb/leaderboard) _)._   \n\npython\n\n```\nfrom langchain_community.docstore.in_memory import InMemoryDocstore\nfrom langchain_community.vectorstores import FAISS\nfrom langchain_huggingface.embeddings import HuggingFaceEmbeddings\nfrom langchain_core.documents import Document\n\n#load embedding model\nembeddings = HuggingFaceEmbeddings(model_name=\"thenlper/gte-small\")\n```\n\nNext, we create our vector database using FAISS (or LangChain's wrapper for FAISS). We start by creating the index and formatting our data and documents, while also storing their metadata (title and year). We then create a list of IDs, add the documents and IDs to the database, and save the database locally.\npython\n\n```\n#save index with faiss\nindex = faiss.IndexFlatL2(len(embeddings.embed_query(\"hello world\")))\n\n#format abstracts as documents\ndocuments = [Document(page_content=ai_search['original_abstract'][i], metadata={\"title\": ai_search['title'][i], \"year\": ai_search['publication_year'][i]}) for i in range(len(ai_search))]\n\n#create list of ids as strings\nn = len(ai_search)\nids = list(range(1, n + 1))\nids = [str(x) for x in my_list]\n\n#add documents to vector store\nvector_store.add_documents(documents=documents, ids=ids)\n\n#save the vector store\nvector_store.save_local(\"Data/faiss_index\")\n```\n\nWith LangChain's vector stores, we can query our documents directly. Let's quickly test this by searching for \"computer vision\". We can see below that the first document returned , \"Face Detection and Recognition Using OPENCV\", is highly-related to computer vision.\npython\n\n```\n#test that vector database is working\nvector_store.similarity_search(\"computer vision\", k=3)\n```\n\n> `[Document(id='783', metadata={'title': 'FACE DETECTION AND RECOGNITION USING OPENCV', 'year': 2020}, page_content='Computer Vision is one of the most fascinating and challenging tasks in the field of Artificial Intelligence.Computer Vision serves as a link between computer software and the visuals we see around us.It enables...`\n### Create RAG Pipeline\nNow let's develop our RAG pipeline. A major component of a RAG solution is the generative model leveraged to generate the responses. For this, we will use OpenAI's model from LangChain.\nSo we can compare the response before and after we implement the RAG pipeline, let's ask the \"base\" model: \"What are the most recent advancements in computer vision?\".\npython\n\n```\nfrom langchain_openai import OpenAI\nfrom langchain.chains import RetrievalQA\nfrom langchain import PromptTemplate\n\n#set API key\nOPENAI_API_KEY = os.getenv(\"OPENAI_API_KEY\",\"API KEY\") \n\n#load llm\nllm = OpenAI(openai_api_key=OPENAI_API_KEY)\n\n#test llm response\nllm.invoke(\"What are the most recent advancements in computer vision?\")\n```\n\n> '\\n\\n1. Deep Learning: Deep learning, a subset of machine learning, has shown significant progress in computer vision tasks such as object detection, recognition, and image classification. It uses neural networks with multiple hidden layers to learn and extract features from images, leading to more accurate and efficient results.\\n\\n2. Generative Adversarial Networks (GANs): GANs are a type of deep learning algorithm that generates new images by learning from a large dataset. They have been used in tasks such as image synthesis, super-resolution, and image-to-image translation, and have shown impressive results in creating realistic images.\\n\\n3. Convolutional Neural Networks (CNNs): CNNs are a type of deep learning algorithm that has revolutionized the field of computer vision. They are highly effective in extracting features from images and have been used in various tasks such as image classification, object detection, and segmentation.\\n\\n4. Transfer Learning: Transfer learning allows a pre-trained model to be used on a different task or dataset without starting from scratch. It has shown promising results in computer vision tasks, especially for tasks with limited training data.\\n\\n5. Image Segmentation: With advancements in deep learning, image segmentation has become more accurate and efficient. It involves dividing an image into different regions or segments to identify objects'\nFrom the response above, we can see a general summary of computer vision, a high-level description of how it works, and different types of models and applications. **While it is a good summary, is does not directly answer our question. A great opportunity for RAG!**\nNext, we will build the components for our RAG pipeline. First we need a **retriever** to grab the top k documents related to our query. We then build a **prompt** instructing our model how to respond to questions. Lastly, we combine them with the **base generative model** to create our pipeline. \nLet's quickly retest our query of \"What are the most recent advancements in computer vision?\".\npython\n\n```\n#test that vector database is working\nretriever = db.as_retriever(search_kwargs={\"k\": 3})\n\n#create a prompt template\ntemplate = \"\"\"<|user|>\nRelevant information:\n{context}\n\nProvide a concise answer to the following question using relevant information provided above:\n{question}\nIf the information above does not answer the question, say that you do not know. Keep answers to 3 sentences or shorter.<|end|>\n<|assistant|>\"\"\"\n\n#define prompt template\nprompt = PromptTemplate(\n    template=template,\n    input_variables=[\"context\", \"question\"])\n\n#create RAG pipeline\nrag = RetrievalQA.from_chain_type(llm=llm, chain_type=\"stuff\", retriever=retriever, return_source_documents=True,\n                                  chain_type_kwargs={\"prompt\": prompt}, verbose = True)\n\n#test rag response\nrag.invoke(\"What are the most recent advancements in computer vision?\")\n```\n\n> The most recent advancements in computer vision include the emergence of large language models equipped with vision capabilities, such as OpenAI's GPT-4V, Google's Bard AI, and Microsoft's Bing AI. These models are able to analyze images and have the ability to access real-time information, making them directly embedded in many applications. Further advancements are expected as AI continues to rapidly evolve.\nThis response does a much better job at answering our question. It directly addresses the most recent advancements by calling out specific capabilities, models, and how they contribute to advancing computer vision. This is a promising result for our technical chatbot.\n**But this is not a proper evaluation. Next, we will further test our RAG solution on a number of metrics to help us determine if its ready for production.**\n···\n## LLM-as-a-Judge\nTo begin evaluating our solution, we will use another generative model to determine how our RAG solution meets certain criteria. While LLM-as-a-Judge methods have some caveats and need to be used carefully, they offer a lot of flexibility and efficiency. They can also give detailed insights during the evaluation process, as you will see below.\nOur RAG consists of 2 main components, the retriever and generator. **We will evaluate these components separately.** Our findings could prompt us to tune hyperparameters, replace the embedding model, or use a difference generative model.\n### Retriever Evaluation\nFirst we will evaluate our retriever, the component that fetches the relevant content. We will judge on 3 metrics:\n  1. **Contextual Precision:** Represents a greater ability of the retrieval system to correctly rank relevant nodes. It first uses an LLM to determine whether each node is relevant to the input, before calculating the weighted cumulative precision.\n  2. **Contextual Recall:** Represents a greater ability of the retrieval system to capture all relevant information from the total available relevant set within your knowledge base.\n  3. **Contextual Relevancy:** Evaluates the overall relevance of the information presented for the given output.\n\n\nFirst, we import the libraries and initialize the metrics.\npython\n\n```\nfrom deepeval import evaluate\nfrom deepeval.test_case import LLMTestCase, LLMTestCaseParams\nfrom deepeval.metrics import (\n    ContextualPrecisionMetric,\n    ContextualRecallMetric,\n    ContextualRelevancyMetric)\n\n#set your OpenAI API key\nos.environ[\"OPENAI_API_KEY\"] = \"API KEY\"\n\n# Initialize metrics\ncontextual_precision = ContextualPrecisionMetric()\ncontextual_recall = ContextualRecallMetric()\ncontextual_relevancy = ContextualRelevancyMetric()\n```\n\n**Next, we need to build a test case, an expected output to a given query. These testing datasets can be difficult to build, and should have input from domain experts who understand the questions that may be asked, and what those answers should be.**\nFor this example, we will just create one test case with a mock expected output. This will not give us the true result, but will give us a result as an example.\npython\n\n```\n#define user query\ninput = 'What are the most recent advancements in computer vision?'\n\n#RAG output\nactual_output = rag.invoke(input)['result']\n\n#contexts used from the retriver\nretrieved_contexts = []\nfor el in range(0,3):\n  retrieved_contexts.append(rag.invoke(input)['source_documents'][el].page_content)\n  \n#expected output (example)\nexpected_output = 'Recent advancements in computer vision include Vision-Language Models (VLMs) that merge vision and language, Neural Radiance Fields (NeRFs) for 3D scene generation, and powerful Diffusion Models and Generative AI for creating realistic visuals. Other key areas are Edge AI for real-time processing, enhanced 3D vision techniques like NeRFs and Visual SLAM, advanced self-supervised learning methods, deepfake detection systems, and increased focus on Ethical AI and Explainable AI (XAI) to ensure fairness and transparency.'\n```\n\nWith the components above, we can now build our test case and compute our 3 metrics.\npython\n\n```\n#create test case\ntest_case = LLMTestCase(\n    input=input,\n    actual_output=actual_output,\n    retrieval_context=retrieved_contexts,\n    expected_output=expected_output)\n\n#compute contextual precision and print results\ncontextual_precision.measure(test_case)\nprint(\"Score: \", contextual_precision.score)\nprint(\"Reason: \", contextual_precision.reason)\n\n#compute contextual recall and print results\ncontextual_recall.measure(test_case)\nprint(\"Score: \", contextual_recall.score)\nprint(\"Reason: \", contextual_recall.reason)\n\n#compute relevancy precision and print results\ncontextual_relevancy.measure(test_case)\nprint(\"Score: \", contextual_relevancy.score)\nprint(\"Reason: \", contextual_relevancy.reason)\n```\n\n> Score: 1.0 Reason: The score is 1.00 because the relevant nodes are ranked at the top: the first node discusses 'recent progress on computer vision algorithms' and 'prominent achievements,' and the second node covers the 'evolution of computer vision' and foundational advancements. The irrelevant node, which only describes the OpenCV toolkit and lacks discussion of recent advancements, is correctly ranked last. This perfect ordering ensures the highest contextual precision.\n> Score: 0.0 Reason: The score is 0.00 because none of the sentences in the expected output can be traced back to any node(s) in the retrieval context; there is no overlap or relevant information present.\n> Score: 0.5555555555555556 Reason: The score is 0.56 because, while there are several statements that discuss recent progress and deep learning advancements in computer vision (e.g., 'The prominent achievements in computer vision tasks such as image classification, object detection and image segmentation brought by deep learning techniques are highlighted.'), much of the context is general background or unrelated details (e.g., 'The explanation of the term 'convolutional' as a mathematical operation is not directly relevant to the advancements in computer vision.').\nAs seen above, one of the benefits of using an LLM as a judge is that we get detailed feedback on why our scores are what they are. For example, get a 55% for contextual relevancy because the LLM deemed some of the information unnecessary (slightly going down a rabbit hole about CNNs).\nWe can also use the 'evaluate' function from DeepEval to better automate this process. This is useful when testing your RAG on several test cases.\npython\n\n```\n#run all metrics with 'evaluate' function\nevaluate(test_cases=[test_case],\n         metrics=[contextual_precision, contextual_recall, contextual_relevancy])\n```\n\n### Generation Evaluation \nNext, we evaluate our generator, which generates the responses based on the context given by the retriever. Here, we will compute 2 metrics:\n  1. **Answer Relevancy:** Similar to contextual relevancy, evaluates whether the prompt template in your generator is able to instruct your LLM to give relevant outputs based on the context.\n  2. **Faithfulness:** Evaluates whether the LLM used in your generator can output information that does not hallucinate or contradict any factual information presented in the retrieval context.\n\n\nAs before, lets initialize the metrics.\npython\n\n```\nfrom deepeval.metrics import AnswerRelevancyMetric, FaithfulnessMetric\n\nanswer_relevancy = AnswerRelevancyMetric()\nfaithfulness = FaithfulnessMetric()\n\n#compute answer relevancy and print results\nanswer_relevancy.measure(test_case)\nprint(\"Score: \", answer_relevancy.score)\nprint(\"Reason: \", answer_relevancy.reason)\n\n#compute faithfulness and print results\nfaithfulness.measure(test_case)\nprint(\"Score: \", faithfulness.score)\nprint(\"Reason: \", faithfulness.reason)\n```\n\n> Score: 1.0 Reason: The score is 1.00 because the answer was fully relevant and addressed the question directly without any irrelevant information. Great job staying focused and informative!\n> Score: 1.0 Reason: Great job! There are no contradictions, so the actual output is fully faithful to the retrieval context. \nAs seen above, our generator operates very well (with this test case). The answer remains relevant and the model does not contradict itself. Again, we can use the 'evaluate' function to evaluate several test cases.\npython\n\n```\n#run all metrics with 'evaluate' function\nevaluate(test_cases=[test_case],\n         metrics=[answer_relevancy, faithfulness])\n```\n\nA caveat of using these metrics is that they generic and only go after a few aspects of our generated output, like relevancy. **But we can also create tailored metrics to determine how well our RAG solution performs in areas important to us specifically.**\nFor example, we can pose questions like \"How does my RAG handle dark humor?\", or \"Is the output written at a kid-friendly level?\". For our example, let's determine how well our RAG provides technically written responses.\npython\n\n```\nfrom deepeval.metrics import GEval\n\n#create evaluation for technical language\ntech_eval = GEval(\n    name=\"Technical Language\",\n    criteria=\"Determine how technically written the actual output is\",\n    evaluation_params=[LLMTestCaseParams.ACTUAL_OUTPUT])\n\n#run evaluation\ntech_eval.measure(test_case)\nprint(\"Score: \", tech_eval.score)\nprint(\"Reason: \", tech_eval.reason)\n```\n\n> Score: 0.6437823499114202 Reason: The response uses appropriate technical terminology such as 'deep learning', 'image classification', 'object detection', 'image segmentation', 'GPUs', and 'FPGAs'. The explanations are clear but somewhat general, lacking specific examples or recent breakthroughs. The technical detail is moderate, mentioning both algorithmic and hardware aspects, but does not delve into particular models or methods. The writing is mostly formal and adheres to technical conventions, but the depth and specificity could be improved.\nIn the output above, we can see that our RAG produces somewhat technically written answers. It uses the appropriate technical terminology with clear explanations, but lacks examples. This is likely due to using abstracts as our data source, which are written at a somewhat high level. \n## Human Evaluation\n**While LLM-as-a-judge methods give us a lot a great information, they are generic and should be caveated as they do not fully assess real-world applicability.** Humans however, can better explore this, as no one knows the data better than the domain experts within the organization.\nHuman evaluation typically reviews for correctness, justification quality, and fluency. Evaluators must determine if the output is accurate, logically connects retrieved evidence to the conclusion, is natural, and useful. It is important to keep in mind the data, user, and purpose of your RAG solution to properly address these domain-specific requirements.\n···\n## Conclusion\nIn this article, we were able to build a RAG pipeline using open source research by leveraging FAISS, LangChain, and more. We also dove into how we can evaluate RAG solutions, evaluating both our retriever and generator. Libraries like DeepEval leverage LLM-as-a-judge metrics to build test cases and determine relevancy, faithfulness, and more. Lastly, we discussed how important human evaluation is when determining the real-world applicability or your RAG solution.\n···\n_I hope you have enjoyed my article! Please feel free to comment, ask questions, or request other topics._\n_Connect with me on LinkedIn:_[_https://www.linkedin.com/in/alexdavis2020/_](https://www.linkedin.com/in/alexdavis2020/)\n## Register Now to Continue Reading\n### Unlock Towards Data Science with a Free Account\nAll articles on Towards Data Science are available to registered users. Create a free account today to access this article and thousands more.\nRegister for freeSign in to your account\n* * *\n![](https://assets.insightmediagroup.io/media/1787657658380_gf1kgl.jpeg)\nWritten By\n## [Alex Davis](https://towardsdatascience.com/author/adavis08/)\n[See all from Alex Davis](https://towardsdatascience.com/author/adavis08/)\n[Deep Dives](https://towardsdatascience.com/tag/deep-dives/)[Llm](https://towardsdatascience.com/tag/llm/)[Llm Evaluation](https://towardsdatascience.com/tag/llm-evaluation/)[NLP](https://towardsdatascience.com/tag/nlp/)[Rag](https://towardsdatascience.com/tag/rag/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Fevaluating-your-rag-solution%2F&title=Evaluating%20Your%20RAG%20Solution)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Fevaluating-your-rag-solution%2F&title=Evaluating%20Your%20RAG%20Solution)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Fevaluating-your-rag-solution%2F&text=Evaluating%20Your%20RAG%20Solution)\n\n\nTowards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program.\n[Write for TDS](https://towardsdatascience.com/submissions/)\n## Related Articles\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/10/1sfONBqMkNC3T4nLPt_n9WA-scaled.jpeg)](https://towardsdatascience.com/will-your-vote-decide-the-next-president-0875a4927c75/)\n## [Will Your Vote Decide the Next President?](https://towardsdatascience.com/will-your-vote-decide-the-next-president-0875a4927c75/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nSimulating the probability that your singular vote swings the election in November\n[Jarom Hulet](https://towardsdatascience.com/author/jarom.hulet/)\nOctober 15, 202419 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/06/1c8Gqzd-fONRwwwwQF7jiHA-scaled.jpeg)](https://towardsdatascience.com/naive-bayes-classification-41d1fe802a1e/)\n## [Naive Bayes Classification](https://towardsdatascience.com/naive-bayes-classification-41d1fe802a1e/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nIn-depth explanation of the Naive Bayes family of classifiers, including a text classification example in Python\n[Dr. Roi Yehoshua](https://towardsdatascience.com/author/roiyeho/)\nJune 1, 202324 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/11/0c9YEu2t-eY4ub7wJ.png)](https://towardsdatascience.com/improving-performance-and-explainability-of-zero-shot-clip-33e579d3f4bb/)\n## [Improving performance and explainability of Zero-Shot CLIP](https://towardsdatascience.com/improving-performance-and-explainability-of-zero-shot-clip-33e579d3f4bb/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nPart 2 - Visual classification via Description from LLMs\n[Alexey Kravets](https://towardsdatascience.com/author/alexml0123/)\nNovember 25, 20236 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2026/01/bruce-hong-asdR5r-2JxY-unsplash-scaled-1.jpg)](https://towardsdatascience.com/using-local-llms-to-discover-high-performance-algorithms/)\n## [Using Local LLMs to Discover High-Performance Algorithms](https://towardsdatascience.com/using-local-llms-to-discover-high-performance-algorithms/)\n[Large Language Models](https://towardsdatascience.com/category/artificial-intelligence/large-language-models/)\nHow I used open-source models to explore new frontiers in efficient code generation, using my MacBook and local LLMs\n[Stefano Bosisio](https://towardsdatascience.com/author/stefanobosisio1/)\nJanuary 19, 20268 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2026/07/cascade_overrocks_Y0RX9JMbA4c_card.jpg)](https://towardsdatascience.com/loop-engineering-for-rag-generation-an-llm-cascade-from-a-cheap-local-model-up-to-a-hosted-flagship/)\n## [Loop Engineering for RAG Generation: An LLM Cascade from a Cheap Local Model Up to a Hosted Flagship](https://towardsdatascience.com/loop-engineering-for-rag-generation-an-llm-cascade-from-a-cheap-local-model-up-to-a-hosted-flagship/)\n[Large Language Models](https://towardsdatascience.com/category/artificial-intelligence/large-language-models/)\nEnterprise Document Intelligence [Vol.1 #8quater] - Two angles on the cascade, cost and a validation loop, backed by a real sweep of twenty local models against a hosted flagship\n[Kezhan Shi](https://towardsdatascience.com/author/kezhanshi/)\nJuly 24, 202611 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/05/16IOv24zYgd_Zt5iqYGridg-scaled.jpeg)](https://towardsdatascience.com/transformers-retraining-roberta-base-using-the-roberta-mlm-procedure-7422160d5764/)\n## [🤗Transformers: Retraining roberta-base using the RoBERTa MLM Procedure](https://towardsdatascience.com/transformers-retraining-roberta-base-using-the-roberta-mlm-procedure-7422160d5764/)\n[NLP](https://towardsdatascience.com/category/artificial-intelligence/nlp/)\nIn this tutorial we will be retraining a RoBERTa LM for a more personalised downstream-oriented dataset.\n[Tanmay Garg](https://towardsdatascience.com/author/tanmay17061/)\nDecember 13, 20204 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/08/15bUZ6Zd8z1DiSeDvk-Aapg.jpeg)](https://towardsdatascience.com/the-smarter-way-of-using-ai-in-programming-0492ac610385/)\n## [The Smarter Way of Using AI in Programming](https://towardsdatascience.com/the-smarter-way-of-using-ai-in-programming-0492ac610385/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\navoid the outdated methods of integrating AI into your coding workflow by going beyond ChatGPT\n[Hesam Sheikh](https://towardsdatascience.com/author/itshesamsheikh/)\nAugust 29, 20247 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/10/1R4b0wdgDFVuilXvzcCGFSQ-scaled.jpeg)](https://towardsdatascience.com/despite-their-feats-large-language-models-still-havent-contributed-to-linguistics-657bea43a8a3/)\n## [Despite Their Feats, Large Language Models Still Haven't Contributed to Linguistics](https://towardsdatascience.com/despite-their-feats-large-language-models-still-havent-contributed-to-linguistics-657bea43a8a3/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nA review of Chomsky's views on linguistics and LLMs\n[Mohamad Aboufoul](https://towardsdatascience.com/author/mohammadhia/)\nDecember 5, 202212 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/10/1VoaXPBLlxY4KxP_BmnM0og.png)](https://towardsdatascience.com/from-perceptron-to-densenet-an-introduction-to-convolutional-neural-networks-ab37e3b7872e/)\n## [Convolutional Neural Networks: An Introduction](https://towardsdatascience.com/from-perceptron-to-densenet-an-introduction-to-convolutional-neural-networks-ab37e3b7872e/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nA brief journey from Perceptron to ResNet\n[Oliver Kramer](https://towardsdatascience.com/author/oliver_kramer/)\nOctober 21, 202212 min read\n\n\n  * [YouTube](https://www.youtube.com/c/TowardsDataScience)\n  * [X](https://x.com/TDataScience)\n  * [LinkedIn](https://www.linkedin.com/company/towards-data-science/)\n  * [Threads](https://www.threads.net/@towardsdatascience)\n  * [Bluesky](https://bsky.app/profile/towardsdatascience.com)\n\n\n[](https://towardsdatascience.com/)\nYour home for data science and AI. The world's leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.\nSubscribe to Our Newsletter[Write For TDS](https://towardsdatascience.com/submissions/)•[About](https://towardsdatascience.com/about-towards-data-science-d691af11cc2f/)•[Advertise](https://contact.towardsdatascience.com/advertise-with-towards-data-science)•[Privacy Policy](https://towardsdatascience.com/privacy-policy/)•[Terms of Use](https://towardsdatascience.com/website-terms-of-use/)\n© Insight Media Group, LLC 2026•[The New Stack](https://thenewstack.io)•[roadmap.sh](https://roadmap.sh)•[Creator Network](https://insightmediagroup.io/creator-network)\n####  Recommended Articles \nClose\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500) How Relevance Models Foreshadowed Transformers for NLP ](https://towardsdatascience.com/how-relevance-models-foreshadowed-transformers-for-nlp/ \"How Relevance Models Foreshadowed Transformers for NLP\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500) Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1 ](https://towardsdatascience.com/javascript-fatigue-you-dont-need-js-to-build-chatgpt/ \"Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500) The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs ](https://towardsdatascience.com/subset-sum-problem-solved-in-linear-time-for-dense-enough-inputs/ \"The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500) Does Your Company Have a Data Strategy? ](https://towardsdatascience.com/does-your-company-have-a-data-strategy-e8944dbec4ae/ \"Does Your Company Have a Data Strategy?\")\n\n\n",
  "body_base_path": "attachments/22a81727c4d0/pages/",
  "body_markdown_path": "attachments/22a81727c4d0/pages/archived-body.md",
  "local_html": "attachments/22a81727c4d0/pages/archived-body.html",
  "body_source": "prior_capture"
}