LangSmith Evaluator로 Ollama 모델 설정
강의 전반을 개인 데스크탑에 도커를 설치하여 Ollama에 한국어로 파인튜닝된 llama3.2 모델을 사용하였었습니다.
streamlit으로 만든 프로젝트도 문제없이 돌아갔었는데,
Langsmith에서 Evaluator로 해당 모델을 설정하니 아래와 같은 에러가 나옵니다.
langsmith에서는 ollama 모델로 평가를 할 수 없는건가요?
ollama._types.ResponseError: llama3.2-ko does not support tools
Error running evaluator <DynamicRunEvaluator answer_hallucination_evaluator> on run 38c51823-def2-4eb1-8347-c019874622eb: KeyError('contexts')
Traceback (most recent call last):
File "E:\PythonProject\rag_streamlit\.venv\Lib\site-packages\langsmith\evaluation\_runner.py", line 1573, in _run_evaluators
evaluator_response = evaluator.evaluate_run(
^^^^^^^^^^^^^^^^^^^^^^^
File "E:\PythonProject\rag_streamlit\.venv\Lib\site-packages\langsmith\evaluation\evaluator.py", line 331, in evaluate_run
result = self.func(
^^^^^^^^^^
File "E:\PythonProject\rag_streamlit\.venv\Lib\site-packages\langsmith\run_helpers.py", line 617, in wrapper
raise e
File "E:\PythonProject\rag_streamlit\.venv\Lib\site-packages\langsmith\run_helpers.py", line 614, in wrapper
function_result = run_container["context"].run(func, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Temp\ipykernel_10064\4107259675.py", line 12, in answer_hallucination_evaluator
contexts = run.outputs["contexts"]
~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'contexts'
Error running evaluator <DynamicRunEvaluator answer_evaluator> on run 4a5e6612-1a97-4efc-9da4-ee0b4f113b70: ResponseError('llama3.2-ko does not support tools')
# Prompt
# hallucination 판단을 위한 프롬프트
grade_prompt_hallucinations = prompt = hub.pull("langchain-ai/rag-answer-hallucination")
def answer_hallucination_evaluator(run, example) -> dict:
"""
hallucination 판단을 위한 Evaluator
"""
# 데이터셋에 있는 질문과, LLM이 답변을 생성할 때 사용한 context를 활용
input_question = example.inputs["input_question"]
contexts = run.outputs["contexts"]
# LLM의 답변
prediction = run.outputs["answer"]
# LLM Judge로 사용될 LLM
llm = ChatOllama(
model="llama3.2-ko",
base_url=os.getenv("LLM_BASE_URL"),
temperature=0
)
# LLM 응답을 위한 LCEL 활용
# 3.6 `dictionary_chain`의 `prompt | llm | StrOutputParser()`` 의 구조와 유사함
answer_grader = grade_prompt_hallucinations | llm
# Evaluator 실행
score = answer_grader.invoke({"documents": contexts,
"student_answer": prediction})
score = score["Score"]
return {"key": "answer_hallucination", "score": score}
코드는 llm 부분만 ChatOllama를 사용하고 나머지 부분은 모두 동일합니다
답변 1
0
안녕하세요!
llama3.2-ko라는 모델을 사용해 본적이 없어서 정확히는 모르겠지만 아래 에러메시지로 봤을 때는 해당 모델과 관련된 에러일 수 있을 것 같고,
ollama._types.ResponseError: llama3.2-ko does not support tools
그리고 KeyError: 'contexts' 라는 에러로 봤을 때는 run.outpus 를 한번 확인하시고 디버깅 해보시면 원인 파악이 가능할 것 같습니다
소득세법 docx 파일 공유 요청건
0
64
1
EXAONE 모델 불러오기 안되는 문제
0
87
2
[5.1 강의] LLM Evaluator에 Upstage를 사용하는 방법 + 변경된 Langsmith Docs를 참고하여 구현하는 방법 공유
0
102
2
강의 9에 QA관련된 import가 되지 않네요
0
110
2
🚨 python3.14 를 쓰고 계시면 chroma 에서 ConfigError 가 발생합니다.
1
199
1
강의와 책 관련 질문
0
86
1
문서 전처리 고민
0
109
1
RAG 배포 질문드립니다
0
94
1
강의 내용과는 별개로 궁금한 점이 있습니다
0
87
2
폐쇄망 챗봇 모델
0
93
1
AI agent 쿠폰
0
94
2
저는 왜 그대로 했는데 답변이 틀리게 나오는지 모르겠네요
0
101
2
langchain howto/sequence는 지금 doc 공식 사이트 어디서 확인할 수 있나요?
1
94
1
new_question에 대한 답 출력
0
72
2
랭체인 라이브러리
0
147
2
[LangGraph를 활용한 AI Agent 개발] 쿠폰 유효기간
0
105
1
postgresql의 pgvector 벡터는 어떤가요?
0
343
2
doc관련
0
127
2
load_dotenv() 실행 False
0
94
1
RAG 답변 개선을 위한 정답지 활용 구조 검토 요청
0
118
2
3.2 from langchain.chains ~ 에서 모듈을 찾지 못할 때.
1
404
2
강의 완료 오류
0
87
1
hub.pull 이슈
0
129
2
[3.3 강의] Upstage를 사용한 RAG 구현 성공기 공유
1
148
1





