23.06.15
DEVOTEE를 활성화 시키면
지금 작성한 커뮤니티 글에 대해 1개의 댓글을 달아줍니다.
버튼을 누르면 글 수정 시 ChatGPT가 작성한 댓글이 수정됩니다.
| 컨텐츠 유형 | 제목 | 저장일 | 삭제 |
|---|
본인인증 로그인에 실패하였습니다.
회원이 아니시거나 본인인증 등록이
완료되지 않은 사용자입니다.
파이썬 가상환경에서 pipenv 도구를 통해 파이썬 패키지를 설치합니다.
pipenv install!cat ../Pipfile이 튜토리얼에서는 RAG 파이프라인을 평가하기 위한 합성 평가 데이터 세트를 만드는 방법을 안내합니다.
이를 위해 OpenAI 모델을 활용합니다. 사용자 환경 내에서 OpenAI API 키를 환경변수로 입력합니다.
아래 코드의 경우 .env 파일에 OPENAI_API_KEY= 설정하고, load_dotenv 함수를 이용하여 환경변수를 한번에 로딩했습니다.
from dotenv import load_dotenv
import os
load_dotenv(verbose=True)
# Create your own .env file in root path and add OPENAI_API_KEY
os.environ['OPENAI_API_KEY'] = os.getenv("OPENAI_API_KEY")처음 합성 데이터셋에 Question/Contexts/Ground_Truth 샘플을 생성하기 위해서는 망뭉치가 필요합니다.
이를 위해 LangChain WebBaseLoader 를 사용해서 https://blog.langchain.dev/langchain-v0-1-0/ 웹문서를 로드합니다.
이후 웹문서 말뭉치를 청크 단위로 자르고, 이 청크를 워드 임베딩 모델 (text-embedding-ada-002) 이용하여 벡터화하여 Faiss 벡터 데이터베이스에 인덱싱 합니다.
FAISS.from_documents() 함수를 통해 워드 임베딩하고, 메모리에 저장된 벡터 값들을 파일로 저장하여 이후 다시 메모리에 리로딩하여 재사용할 수 있도록 합니다.
from langchain_community.document_loaders import WebBaseLoader
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_openai import OpenAIEmbeddings
from langchain_community.vectorstores import FAISS
import os
embeddings = OpenAIEmbeddings(model="text-embedding-ada-002")
loader = WebBaseLoader(
"https://blog.langchain.dev/langchain-v0-1-0/"
)
documents = loader.load()
for document in documents:
document.metadata['filename'] = document.metadata['source']
# save & load data
vdb_path = "db/faiss/langchain_docs"
if(os.path.exists(vdb_path)):
print(f'load faiss {vdb_path}')
vector_store = FAISS.load_local(vdb_path, embeddings, allow_dangerous_deserialization=True)
else:
text_splitter = RecursiveCharacterTextSplitter(
chunk_size = 1250,
chunk_overlap = 100,
length_function = len,
is_separator_regex = False
)
split_docs = text_splitter.split_documents(documents)
vector_store = FAISS.from_documents(split_docs, embeddings)
vector_store.save_local(vdb_path)
load faiss db/faiss/langchain_docsRagas 이용하여 합성 데이터셋 (Question/Contexts/Ground_Truth)을 자동으로 생성합니다.
합성 데이터셋을 이용하여 RAG 파이프라인을 평가하려면 Question/Contexts 데이터셋을 RAG Chain 으로 실행하여
Answer 값을 생성한후 Ragas Evalation 도구를 이용하여 Ground Truth 값과 비교하여 주요 평가지표 (Metric)로 수치화 합니다.
이를 위한 RAG Chain 기능을 아래와 같이 구현하여 Ragas Evaluation 에 활용합니다.
아래 코드는 RAG Chain 을 이용하여 Faiss에 이미 워드 임베딩한 langchain docs 문서를 기반으로
"What are the major changes in v 0.1.0?" 질문에 대한 Answer 를 생성하는 과정을 테스트하여 검증하는 예제코드입니다.
from operator import itemgetter
from langchain import hub
from langchain_core.runnables import RunnablePassthrough
from langchain_core.output_parsers import StrOutputParser
from langchain_community.chat_models import ChatOpenAI
retriever = vector_store.as_retriever()
prompt = hub.pull("rlm/rag-prompt")
llm = ChatOpenAI(model_name="gpt-3.5-turbo", temperature=0)
def format_docs(args):
docs = args["source_docs"]
return "\n\n".join(doc.page_content for doc in docs)
rag_chain = (
RunnablePassthrough.assign(
question=itemgetter("question")
)
| {
"source_docs" : itemgetter("question") | retriever,
"question": itemgetter("question"),
}
| {
"source_docs": itemgetter("source_docs"),
"answer": {
"context": format_docs,
"question": itemgetter("question"),
} | prompt | llm | StrOutputParser()
}
)
rag_chain.invoke({"question" : "What are the major changes in v 0.1.0?"})/Users/1111999/.local/share/virtualenvs/llmops-ESENPtay/lib/python3.11/site-packages/langchain_core/_api/deprecation.py:119: LangChainDeprecationWarning: The class `ChatOpenAI` was deprecated in LangChain 0.0.10 and will be removed in 0.3.0. An updated version of the class exists in the langchain-openai package and should be used instead. To use it run `pip install -U langchain-openai` and import as `from langchain_openai import ChatOpenAI`.
warn_deprecated(
{'source_docs': [Document(page_content='versioning policy for a little over a month now.langchain itself, however, still remained on 0.0.x versions. Having all releases on minor version 0 created a few challenges:Users couldn’t be confident that updating would not have breaking changeslangchain became bloated and unstable as we took a “maintain everything” approach to reduce breaking changes and deprecation notificationsHowever, starting today with the release of langchain 0.1.0, all future releases will follow a new versioning standard. Specifically:Any breaking changes to the public API will result in a minor version bump (the second digit)Any bug fixes or new features will result in a patch version bump (the third digit)We hope that this, combined with the previous architectural changes, will:Communicate clearly if breaking changes are made, allowing developers to update with confidenceGive us an avenue for officially deprecating and deleting old code, reducing bloatMore responsibly deal with integrations (whose SDKs are often changing as rapidly as LangChain)Even after we release a 0.2 version, we will commit to maintaining a branch of 0.1, but will only patch critical bug fixes. See more towards the end of this post on our plans for that.While re-architecting the', metadata={'source': 'https://blog.langchain.dev/langchain-v0-1-0/', 'title': 'LangChain v0.1.0', 'language': 'en', 'filename': 'https://blog.langchain.dev/langchain-v0-1-0/'}, _lc_kwargs={'page_content': 'versioning policy for a little over a month now.langchain itself, however, still remained on 0.0.x versions. Having all releases on minor version 0 created a few challenges:Users couldn’t be confident that updating would not have breaking changeslangchain became bloated and unstable as we took a “maintain everything” approach to reduce breaking changes and deprecation notificationsHowever, starting today with the release of langchain 0.1.0, all future releases will follow a new versioning standard. Specifically:Any breaking changes to the public API will result in a minor version bump (the second digit)Any bug fixes or new features will result in a patch version bump (the third digit)We hope that this, combined with the previous architectural changes, will:Communicate clearly if breaking changes are made, allowing developers to update with confidenceGive us an avenue for officially deprecating and deleting old code, reducing bloatMore responsibly deal with integrations (whose SDKs are often changing as rapidly as LangChain)Even after we release a 0.2 version, we will commit to maintaining a branch of 0.1, but will only patch critical bug fixes. See more towards the end of this post on our plans for that.While re-architecting the', 'metadata': {'source': 'https://blog.langchain.dev/langchain-v0-1-0/', 'title': 'LangChain v0.1.0', 'language': 'en', 'filename': 'https://blog.langchain.dev/langchain-v0-1-0/'}}),
Document(page_content='Today we’re excited to announce the release of langchain 0.1.0, our first stable version. It is fully backwards compatible, comes in both Python and JavaScript, and comes with improved focus through both functionality and documentation. A stable version of LangChain helps us earn developer trust and gives us the ability to evolve the library systematically and safely.Python GitHub DiscussionPython v0.1.0 GuidesJS v0.1.0 GuidesYouTube WalkthroughIntroductionLangChain has been around for a little over a year and has changed a lot as it’s grown to become the default framework for building LLM applications. As we previewed a month ago, we recently decided to make significant changes to the\xa0 LangChain package architecture in order to better organize the project and strengthen the foundation.\xa0Specifically we made two large architectural changes: separating out langchain-core and separating out partner packages (either into langchain-community or standalone partner packages) from langchain.\xa0As a reminder, langchain-core contains the main abstractions, interfaces, and core functionality. This code is stable and has been following a stricter versioning policy for a little over a month now.langchain itself, however, still remained on 0.0.x', metadata={'source': 'https://blog.langchain.dev/langchain-v0-1-0/', 'title': 'LangChain v0.1.0', 'language': 'en', 'filename': 'https://blog.langchain.dev/langchain-v0-1-0/'}, _lc_kwargs={'page_content': 'Today we’re excited to announce the release of langchain 0.1.0, our first stable version. It is fully backwards compatible, comes in both Python and JavaScript, and comes with improved focus through both functionality and documentation. A stable version of LangChain helps us earn developer trust and gives us the ability to evolve the library systematically and safely.Python GitHub DiscussionPython v0.1.0 GuidesJS v0.1.0 GuidesYouTube WalkthroughIntroductionLangChain has been around for a little over a year and has changed a lot as it’s grown to become the default framework for building LLM applications. As we previewed a month ago, we recently decided to make significant changes to the\xa0 LangChain package architecture in order to better organize the project and strengthen the foundation.\xa0Specifically we made two large architectural changes: separating out langchain-core and separating out partner packages (either into langchain-community or standalone partner packages) from langchain.\xa0As a reminder, langchain-core contains the main abstractions, interfaces, and core functionality. This code is stable and has been following a stricter versioning policy for a little over a month now.langchain itself, however, still remained on 0.0.x', 'metadata': {'source': 'https://blog.langchain.dev/langchain-v0-1-0/', 'title': 'LangChain v0.1.0', 'language': 'en', 'filename': 'https://blog.langchain.dev/langchain-v0-1-0/'}}),
Document(page_content="new types of agentsImproving our production ingestion capabilitiesRemoving old and unused functionalityImportantly, even though we are excited about removing some of the old and legacy code to make langchain slimmer and more focused, we also want to maintain support for people who are still using the old version. That is why we will maintain 0.1 as a stable branch (patching in critical bug fixes) for at least 3 months after 0.2 release. We plan to do this for every stable release from here on out.And if you've been wanting to get started contributing, there's never been a better time. We recently added a good getting started issue on GitHub if you're looking for a place to start.One More ThingA large part of LangChain v0.1.0 is stability and focus on the core areas outlined above. Now that we've identified the areas people love about LangChain, we can work on adding more advanced and complete tooling there.One of the main things people love about LangChain is it's support for agents. Most agents are largely defined as running an LLM in some sort of a loop. So far, the only way we've had to do that is with AgentExecutor. We've added a lot of parameters and functionality to AgentExecutor, but its still just one way of running a", metadata={'source': 'https://blog.langchain.dev/langchain-v0-1-0/', 'title': 'LangChain v0.1.0', 'language': 'en', 'filename': 'https://blog.langchain.dev/langchain-v0-1-0/'}, _lc_kwargs={'page_content': "new types of agentsImproving our production ingestion capabilitiesRemoving old and unused functionalityImportantly, even though we are excited about removing some of the old and legacy code to make langchain slimmer and more focused, we also want to maintain support for people who are still using the old version. That is why we will maintain 0.1 as a stable branch (patching in critical bug fixes) for at least 3 months after 0.2 release. We plan to do this for every stable release from here on out.And if you've been wanting to get started contributing, there's never been a better time. We recently added a good getting started issue on GitHub if you're looking for a place to start.One More ThingA large part of LangChain v0.1.0 is stability and focus on the core areas outlined above. Now that we've identified the areas people love about LangChain, we can work on adding more advanced and complete tooling there.One of the main things people love about LangChain is it's support for agents. Most agents are largely defined as running an LLM in some sort of a loop. So far, the only way we've had to do that is with AgentExecutor. We've added a lot of parameters and functionality to AgentExecutor, but its still just one way of running a", 'metadata': {'source': 'https://blog.langchain.dev/langchain-v0-1-0/', 'title': 'LangChain v0.1.0', 'language': 'en', 'filename': 'https://blog.langchain.dev/langchain-v0-1-0/'}}),
Document(page_content='bug fixes. See more towards the end of this post on our plans for that.While re-architecting the package towards a path to a stable 0.1 release, we took the opportunity to talk to hundreds of developers about why they use LangChain and what they love about it. This input guided our direction and focus. We also used it as an opportunity to bring parity to the Python and JavaScript versions in the core areas outlined below. 💡While certain integrations and more tangential chains may be language specific, core abstractions and key functionality are implemented equally in both the Python and JavaScript packages.We want to share what we’ve heard and our plan to continually improve LangChain. We hope that sharing these learnings will increase transparency into our thinking and decisions, allowing others to better use, understand, and contribute to LangChain. After all, a huge part of LangChain is our community – both the user base and the 2000+ contributors – and we want everyone to come along for the journey.\xa0Third Party IntegrationsOne of the things that people most love about LangChain is how easy we make it to get started building on any stack. We have almost 700 integrations, ranging from LLMs to vector stores to tools for agents', metadata={'source': 'https://blog.langchain.dev/langchain-v0-1-0/', 'title': 'LangChain v0.1.0', 'language': 'en', 'filename': 'https://blog.langchain.dev/langchain-v0-1-0/'}, _lc_kwargs={'page_content': 'bug fixes. See more towards the end of this post on our plans for that.While re-architecting the package towards a path to a stable 0.1 release, we took the opportunity to talk to hundreds of developers about why they use LangChain and what they love about it. This input guided our direction and focus. We also used it as an opportunity to bring parity to the Python and JavaScript versions in the core areas outlined below. 💡While certain integrations and more tangential chains may be language specific, core abstractions and key functionality are implemented equally in both the Python and JavaScript packages.We want to share what we’ve heard and our plan to continually improve LangChain. We hope that sharing these learnings will increase transparency into our thinking and decisions, allowing others to better use, understand, and contribute to LangChain. After all, a huge part of LangChain is our community – both the user base and the 2000+ contributors – and we want everyone to come along for the journey.\xa0Third Party IntegrationsOne of the things that people most love about LangChain is how easy we make it to get started building on any stack. We have almost 700 integrations, ranging from LLMs to vector stores to tools for agents', 'metadata': {'source': 'https://blog.langchain.dev/langchain-v0-1-0/', 'title': 'LangChain v0.1.0', 'language': 'en', 'filename': 'https://blog.langchain.dev/langchain-v0-1-0/'}})],
'answer': 'The major changes in version 0.1.0 include a new versioning standard where breaking changes result in a minor version bump and bug fixes or new features result in a patch version bump. This release aims to communicate clearly about breaking changes, reduce bloat, and responsibly deal with integrations. The release also brings stability, improved focus, and compatibility in both Python and JavaScript versions.'}이제 로딩된 말뭉치를 이용하여 합성 데이터셋을 빠르게 생성하기 위해 Ragas의 TestsetGenerator 실행합니다.
TestsetGenerator 실행을 위해 아래와 같은 모듈이 필요합니다.
generator_llm: generator_llm은 질문을 생성하고 관련성을 높이기 위해 질문을 발전시키는 컴포넌트입니다.
critic_llm: critic_llm은 질문과 노드 관련성에 따라 질문과 노드를 필터링하는 구성 요소입니다.
embeddings: 노드 간에 유사도를 측정하기 위한 용도로 활용

위 3가지 모듈을 이용하여 사전에 로딩한 말뭉치를 이용하여 합성 데이터셋을 생성합니다.
이때 In-Depth Evlution 기능을 통해 대규모 언어 모델(LLM)을 이용하여 간단한 질문을 보다 복잡한 질문으로 효과적으로 변환합니다.
제공된 문서에서 중간에서 어려운 샘플을 생성하기 위해 다음과 같은 방법을 사용합니다:
Reasoning(추론): 질문에 효과적으로 답하기 위해 추론의 필요성을 강화하는 방식으로 질문을 다시 작성합니다.
Conditioning(복잡한 조건): 문제에 복잡성을 더하는 조건 요소를 도입하도록 문제를 수정합니다.
Multi-Context(다중 맥락): 답변을 구성하기 위해 여러 관련 섹션 또는 단락의 정보를 필요로 하는 방식으로 질문을 다시 작성합니다.
위 3가지 Evlution 타입을 비율 (0.5:0.25:0.25) 샘플링하여 합성 데이터셋을 생성합니다.
from ragas.testset.generator import TestsetGenerator
from ragas.testset.evolutions import simple, reasoning, multi_context
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
# generator with openai models
generator_llm = ChatOpenAI(model="gpt-3.5-turbo-16k")
critic_llm = ChatOpenAI(model="gpt-4")
embeddings = OpenAIEmbeddings()
generator = TestsetGenerator.from_langchain(
generator_llm,
critic_llm,
embeddings
)
# generate testset
testset = generator.generate_with_langchain_docs(documents, test_size=10, distributions={simple: 0.5, reasoning: 0.25, multi_context: 0.25})Generating: 100%|██████████| 10/10 [05:02<00:00, 30.28s/it] test_df = testset.to_pandas()
test_questions = test_df["question"].values.tolist()
test_groundtruths = test_df["ground_truth"].values.tolist()
testset.to_pandas().dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}question | contexts | ground_truth | evolution_type | metadata | episode_done | |
|---|---|---|---|---|---|---|
0 | What is the purpose of the Langgraph library i... | [ the old and legacy code to make langchain sl... | The purpose of the Langgraph library in LangCh... | simple | [{'source': 'https://blog.langchain.dev/langch... | True |
1 | How has LangChain implemented composability wi... | [ own package, we can more strictly version th... | LangChain has implemented composability with t... | simple | [{'source': 'https://blog.langchain.dev/langch... | True |
2 | What is the main focus of the LangChain v0.1.0... | [ the old and legacy code to make langchain sl... | The main focus of the LangChain v0.1.0 release... | simple | [{'source': 'https://blog.langchain.dev/langch... | True |
3 | What are some advanced methods for data retrie... | [ own package, we can more strictly version th... | nan | simple | [{'source': 'https://blog.langchain.dev/langch... | True |
4 | What changes have been made to improve the rob... | [\n\n\nLangChain v0.1.0\n\n\n\n\n\n\n\n\n\n\n\... | The third party integrations in LangChain have... | simple | [{'source': 'https://blog.langchain.dev/langch... | True |
5 | What is the main focus of the LangChain v0.1.0... | [ the old and legacy code to make langchain sl... | The main focus of the LangChain v0.1.0 release... | reasoning | [{'source': 'https://blog.langchain.dev/langch... | True |
6 | What challenges did the old LangChain versioni... | [\n\n\nLangChain v0.1.0\n\n\n\n\n\n\n\n\n\n\n\... | The old LangChain versioning policy, which had... | reasoning | [{'source': 'https://blog.langchain.dev/langch... | True |
7 | What changes were made in the LangChain v0.1.0... | [\n\n\nLangChain v0.1.0\n\n\n\n\n\n\n\n\n\n\n\... | The LangChain v0.1.0 release made two large ar... | multi_context | [{'source': 'https://blog.langchain.dev/langch... | True |
8 | How does LangSmith contribute to LLM observabi... | [ own package, we can more strictly version th... | One of the main value props that LangSmith pro... | multi_context | [{'source': 'https://blog.langchain.dev/langch... | True |
9 | What are the core areas of focus in LangChain ... | [\n\n\nLangChain v0.1.0\n\n\n\n\n\n\n\n\n\n\n\... | The core areas of focus in LangChain v0.1.0 ar... | multi_context | [{'source': 'https://blog.langchain.dev/langch... | True |
Ragas를 통해 자동 생성한 합성 데이터셋의 Question 에 대한 Answer 값을 RAG Chain을 통해 생성하여 최종적으로 응답 데이터셋(response_dataset) 생성합니다.
따라서 Base Line(Naive) RAG 파이프라인으로 생성된 응답 값이 ground_truth 와 비교 검증하여 Ragas 평가를 진행합니다.
response_dataset
question
answer
contexts
ground_truth
from datasets import Dataset
answers = []
contexts = []
for question in test_questions:
response = rag_chain.invoke({"question": question})
answers.append(response['answer'])
contexts.append([context.page_content for context in response['source_docs']])
response_dataset = Dataset.from_dict({
"question" : test_questions,
"answer" : answers,
"contexts" : contexts,
"ground_truth" : test_groundtruths
})
response_dataset.to_pandas().dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}question | answer | contexts | ground_truth | |
|---|---|---|---|---|
0 | What is the purpose of the Langgraph library i... | The purpose of the Langgraph library in LangCh... | [some from other industry solutions (like Mult... | The purpose of the Langgraph library in LangCh... |
1 | How has LangChain implemented composability wi... | LangChain has implemented composability with t... | [a lot in scalability so that we can release a... | LangChain has implemented composability with t... |
2 | What is the main focus of the LangChain v0.1.0... | The main focus of the LangChain v0.1.0 release... | [Today we’re excited to announce the release o... | The main focus of the LangChain v0.1.0 release... |
3 | What are some advanced methods for data retrie... | Some advanced methods for data retrieval in La... | [some from other industry solutions (like Mult... | nan |
4 | What changes have been made to improve the rob... | To improve the robustness, stability, scalabil... | [any stack. We have almost 700 integrations, r... | The third party integrations in LangChain have... |
5 | What is the main focus of the LangChain v0.1.0... | The main focus of the LangChain v0.1.0 release... | [Today we’re excited to announce the release o... | The main focus of the LangChain v0.1.0 release... |
6 | What challenges did the old LangChain versioni... | The challenges of the old LangChain versioning... | [versioning policy for a little over a month n... | The old LangChain versioning policy, which had... |
7 | What changes were made in the LangChain v0.1.0... | In the LangChain v0.1.0 release, significant c... | [Today we’re excited to announce the release o... | The LangChain v0.1.0 release made two large ar... |
8 | How does LangSmith contribute to LLM observabi... | LangSmith contributes to LLM observability in ... | [changes. These can now be reflected on an ind... | One of the main value props that LangSmith pro... |
9 | What are the core areas of focus in LangChain ... | The core areas of focus in LangChain v0.1.0 ar... | [Today we’re excited to announce the release o... | The core areas of focus in LangChain v0.1.0 ar... |
평가 실행은 선택한 메트릭을 사용하여 데이터 세트에서 평가하기를 호출하는 것만큼 간단합니다.
우리가 사용하는 평가 메트릭은 다음과 같습니다.
Metric
faithfulness: 이는 주어진 context(문맥)에 대해 생성된 답변의 사실적 일관성을 측정합니다.
답변과 검색된 문맥에서 계산됩니다. 답변은 (0,1) 범위로 스케일링됩니다. 높을수록 좋습니다.
answer_relevancy: 평가 지표인 답변 관련성은 생성된 답변이 주어진 프롬프트와 얼마나 관련성이 있는지를 평가 하는 데 중점을 둡니다.
불완전하거나 중복된 정보를 포함하는 답변에는 낮은 점수가 부여되며, 점수가 높을수록 관련성이 높음을 나타냅니다.
이 메트릭은 question, context, answer을 사용하여 계산됩니다.
context_recall: context_recall은 retrievedc context가 RAG Chain을 통해 생성된 Answer(ground truth 취급)와 일치하는 정도를 측정합니다.
이 값은 ground truth, retrieved context 기반으로 계산되며, 값은 0과 1 사이의 범위로, 값이 클수록 더 나은 성능을 나타냅니다.
context_precision: context_precision는 컨텍스트에 존재하는 모든 근거 기반 관련 항목의 순위가 높은지 여부를 평가하는 측정지표입니다.
이상적으로는 모든 관련 청크가 상위 순위에 표시되어야 합니다.
이 메트릭은 question, ground_truth 및 context를 사용하여 0에서 1 사이의 값으로 계산되며, 점수가 높을수록 정확도가 높다는 것을 나타냅니다.
answer_correctness: answer_correctness 평가에는 생성된 answer 값이 ground truth와 비교했을 때 얼마나 정확한지 측정하는 작업이 포함됩니다.
이 평가는 ground truth, answer에 따라 0~1점 범위의 점수로 이루어집니다.
점수가 높을수록 생성된 답안과 기준 진실이 더 가깝게 일치하는 것으로, 정답률이 높다는 것을 의미합니다.
from ragas import evaluate
from ragas.metrics import (
faithfulness,
answer_relevancy,
answer_correctness,
context_recall,
context_precision,
)
metrics = [
faithfulness,
answer_relevancy,
context_recall,
context_precision,
answer_correctness,
]
results = evaluate(response_dataset, metrics, raise_exceptions=False)
results
평가 결과값이 confidence value 값으로 확인 가능합니다.
Evaluating: 100%|██████████| 50/50 [00:20<00:00, 2.50it/s]
{'faithfulness': 1.0000, 'answer_relevancy': 0.9790, 'context_recall': 1.0000, 'context_precision': 0.8444, 'answer_correctness': 0.6330}
DEVOTEE를 활성화 시키면
지금 작성한 댓글에 AI가 댓글을 달아줍니다.