11. Groundedness (Halucination) Assessment

Groundedness Evaluator

Evaluator that evaluates whether an answer is correct based on a given context.

This Evaluator can be used to evaluate Hallucination for RAG's answer.

In this tutorial, we will look at how to evaluate Groundedness by utilizing the Upstage Groundness Checker and the Groundness Checker created by the job custom.

# installation
# !pip install -qU langsmith langchain-teddynote
# Configuration file for managing API KEY as environment variable
from dotenv import load_dotenv

# Load API KEY information
load_dotenv()
 True 
# Set up LangSmith tracking. https://smith.langchain.com
# !pip install -qU langchain-teddynote
from langchain_teddynote import logging

# Enter a project name.
logging.langsmith("CH16-Evaluations")
 Start tracking LangSmith. 
[Project name] 
CH16-Evaluations 

Define functions for RAG performance testing

We will create a RAG system to use for testing.

UpstageGroundednessCheck

In order to take advantage of Upstage's Groundedness Check feature, you must be issued an API key from the link below.

Defines UpstageGroundednessCheck Evaluator. Later, it is utilized by the Evaluate function.

langchain_teddynote Groundness Checker

Utilize OpenAI's model to create a custom Groundness Checker.

Use the OpenAI model to check Groundedness.

Run Groundedness assessment.

Comprehensive evaluation of datasets using Summary Evaluators

This is useful when running Groundedness ratings for the entire dataset. (The previous step was to evaluate the individual data.)

Last updated