AI·News
뒤로

평가 주도 개발을 통한 LLM 신뢰성의 반복적 향상

Iterating Towards LLM Reliability with Evaluation Driven Development

편집자 주: 다음은 Dosu의 CEO인 Devin Stein의 게스트 블로그 포스트입니다. Dosu는 소프트웨어를 개발, 유지 및 지원하도록 도와주는 엔지니어링 팀원입니다.

이 시점에서 프로덕션급 LLM 제품을 구축하는 것이 어렵다는 것은 잘 알려져 있습니다. 신뢰성은 모든 제품이 성공하기 위해 중요하지만, 제품이 일련의 확률 함수에 의해 지지되고 있을 때 신뢰성을 보장하는 것은 결코 간단하지 않습니다.

Dosu에서는 지속적으로 제품을 개선하고 있습니다. 우리가 하는 모든 변경에 대해 최종 사용자에 미치는 영향을 이해해야 합니다. 평가 기반 개발(EDD)은 우리가 자신감을 가지고 출시할 수 있게 합니다. 지난 몇 개월 동안 LangSmith는 Dosu의 활동을 쉽게 모니터링하고 검색할 수 있도록 함으로써 EDD를 확장할 수 있게 해주었습니다.

Dosu란 무엇인가?

LangChain GitHub 저장소에서 시간을 보낸 적이 있다면 이미 소프트웨어 프로젝트를 개발, 유지 및 지원하도록 도와주는 AI 팀원인 Dosu를 만났을 수도 있습니다.

Dosu는 오픈 소스 소프트웨어 유지보수자로서의 제 경험에서 태어났습니다. 보람 있지만 악명 높게 시간이 많이 걸리는 역할입니다. OSS 프로젝트가 인기가 높아지면서 새로운 기능을 개발하는 대신 지원 역할에 훨씬 더 많은 시간을 쓰고 있음을 깨달았습니다.

유지보수자들의 경우 이 책임이 종종 번아웃을 야기하며 일부는 모든 열린 이슈와 PR을 단순히 종료하는 과정인 이슈 파산선언하도록 몰아갔습니다. OSS 커뮤니티도 이 상황으로 고통받고 있습니다. 사람들은 종종 유지보수자의 이슈 응답을 받기 위해 며칠, 몇 주, 심지어 몇 개월을 기다립니다.

이 현상은 오픈 소스에만 국한되지 않습니다. 산업 내에서 개발자 시간의 최대 85%는 임시 질문에 답하기, 이슈 분류, 오버헤드 처리 등 코딩이 아닌 작업에 소비됩니다.

Dosu는 이러한 작업을 개발자들의 업무에서 제거하여 개발자들이 좋아하는 일을 할 수 있도록 합니다: 흐름을 유지하고, 코드를 작성하고, 훌륭한 기능을 출시합니다. 동시에 Dosu는 OSS 커뮤니티의 리소스로서 커뮤니티 멤버들이 예상치 못한 이슈에 직면하거나 오직 코드로만 답할 수 있는 새로운 질문이 있을 때마다 즉각적인 피드백을 제공합니다.

초기 시절

Dosu는 2023년 6월 말에 출시되었습니다. 그 당시 우리의 트래픽은 모든 단일 응답을 검사할 수 있을 정도로 낮았습니다. 매일 grepprint 문만으로 무장하여 개선 영역을 식별하기 위해 로그를 꼼꼼히 검토했습니다.

이 작업은 힘들었지만 Dosu의 아키텍처를 설계하고 개발하는 데 중요했습니다. 사람들이 Dosu를 어떻게 사용하려고 했는지, 어떤 유형의 요청에서 우수했는지, 부족했던 부분이 무엇인지 우리 팀이 깊이 있게 이해하도록 도와주었습니다.

개선해야 할 것을 알게 되자 어떻게 개선할 것인지가 문제였습니다. 기존의 코드 업데이트와 달리 LLM 로직을 변경하는 것은 간단하지 않습니다. 작은 변경이 전체 성능에 어떤 영향을 미칠 수 있는지 알기 어렵습니다. 많은 경우 프롬프트에 대한 약간의 수정이 한 도메인에서는 더 나은 결과를 보였지만 다른 도메인에서는 퇴행을 야기했습니다.

변경의 영향을 측정할 방법이 필요했습니다. 모든 변경에 대해 우리는 다음을 확인하고 싶었습니다:

  1. 우리가 잘하고 있는 영역의 성능 유지
  2. 우리가 어려움을 겪고 있는 영역의 성능 개선

진행 상황을 벤치마크하기 위해 평가 기반 개발로 전환한 것은 이러한 초기 시절이었습니다.

평가 기반 개발

테스트 주도 개발처럼 평가 기반 개발(EDD)은 우리에게 개발 목표를 제공합니다. 평가 — 또는 "evals" — 는 업데이트와 새로운 기능을 이해하기 위한 우리의 기준선입니다. EDD는 우리가 Dosu의 핵심 로직, 모델 또는 프롬프트에 하는 모든 변경의 영향을 이해하도록 도와줍니다.

EDD를 통해 우리는 Dosu를 개선하기 위한 잘 정의된 프로세스를 가지고 있습니다:

  1. 초기 evals를 가지고 새로운 동작 생성
  2. 사용자에게 새로운 동작 출시
  3. 프로덕션에서 결과 모니터링 및 실패 모드 식별
  4. 각 실패 모드에 대한 예제를 오프라인 evals에 추가
  5. 성능을 개선하기 위해 업데이트된 evals에서 반복
  6. 재출시 및 반복

이 개발 워크플로우는 Dosu가 시작될 때 우리에게 잘 작동했지만 사용량이 증가하면서 Dosu의 활동을 따라가기가 어려워졌습니다.

규모에 따른 품질 기준 유지

오늘날 Dosu는 수천 개의 저장소에 설치되어 있으며 하루 종일 응답을 생성합니다. 우리는 다양한 유형의 시나리오를 지능적으로 처리하기 위해 수십 개의 서브모듈을 구축했으며 모델과 분야의 연구가 발전함에 따라 문제 해결 접근 방식을 지속적으로 개선하고 있습니다.

Dosu의 성장은 흥미로웠지만 과제가 따랐습니다. Dosu의 증가된 활동은 응답을 모니터링하고 프로덕션에서 실패 모드를 식별하는 것을 거의 불가능하게 만들었으며, 이는 우리 EDD 워크플로우에 중요합니다.

우리는 LLM 모니터링 스택을 업그레이드할 시간이라고 결정했습니다. 우리는 Dosu의 활동을 모니터링하는 데 도움이 될 뿐만 아니라 기존 워크플로우에 맞을 수 있을 정도로 유연한 도구를 찾고 있었습니다. 우리의 기준 중 일부는 다음과 같습니다:

  • 프롬프트는 Git에 있어야 합니다 — EDD의 정신에서 우리는 프롬프트를 코드로 취급합니다. 프롬프트에 대한 모든 변경은 코드 변경과 동일한 기준으로 취급해야 합니다.
  • 코드 레벨 추적 — Dosu는 일련의 LLM 요청 이상입니다. 우리는 단일 추적 내에서 LLM 요청 간의 메타데이터를 추적하고 싶었습니다.
  • 쉬운 데이터 내보내기 — 우리는 기존의 평가 데이터셋과 도구를 유지하고 싶었습니다.
  • 사용자 정의 및 확장 가능 - LLM 공간은 빠르게 진화하고 있습니다. LLM 앱을 구축하는 표준적인 방법이 없습니다. 우리는 어떤 메타데이터가 추적되는지에 대한 제어를 원했고 도구를 우리 요구사항에 맞게 조정할 수 있는 능력을 원했습니다.

우리는 LLM 모니터링 및 평가 환경을 탐색하여 우리의 요구사항을 충족하는 제품을 찾으려고 했습니다. 우리의 초기 파트너 중 하나인 LangChain 팀과의 통화 후 LangSmith가 모든 항목을 충족하는 것 같다는 것을 들어서 기뻤습니다.

SDK를 통한 LangSmith 구현

LangSmith에 가장 흥분한 것은 세련된 UI나 광범위한 기능 세트가 아니라 실제로 SDK였습니다. LangSmith SDK는 우리가 찾고 있던 세밀한 제어와 사용자 정의 가능성을 제공했습니다.

LangSmith를 시도하기 위해 우리는 LLM 관련 함수 중 몇 개에 @traceable 데코레이터를 추가하기만 하면 되었습니다. 계측하는 데 몇 분만 걸렸고, 이 변경 사항을 프로덕션에 푸시한 직후 즉시 LangSmith UI로 추적이 흐르는 것을 보았습니다.

@traceable 데코레이터의 예상치 못한 멋진 기능은 함수와 LLM 호출 추적을 LangSmith로 보낼 수 있다는 것입니다. 이를 통해 원본 함수 입력, 렌더링된 프롬프트 템플릿 및 LLM 출력을 모두 LangSmith UI의 단일 추적에서 볼 수 있습니다.

즉시 사용 가능한 LangSmith는 Dosu의 모든 활동에 대한 가시성을 제공했습니다. 다음 단계는 LangSmith를 활용하여 실패 모드를 식별하고 EDD 워크플로우에 통합하는 것이었습니다.

실패 찾기

Dosu는 사용자로부터 무수한 요청을 받습니다. 코드베이스에 대한 간단한 질문부터 새 라이브러리 버전으로 업그레이드할 때 오류 추적, 기능 상태에 대한 질문까지 모든 것입니다. Dosu에 더 많은 입력 가능성이 있다는 것은 더 많은 가능한 실패 모드가 있다는 의미입니다.

실패 모드 또는 Dosu가 잘 처리하지 못하는 요청을 식별하려고 할 때, 우리는 다양한 신호를 찾을 수 있습니다:

  • 명시적 피드백: ChatGPT에 의해 대중화된 클래식 엄지손가락 위/아래 피드백.
  • 사용자 감정: 사용자가 GitHub 이슈에서 Dosu와 상호작용할 때 그들의 응답은 보통 Dosu가 도움이 되었는지 여부를 보여줍니다
  • 내부 오류: LLM은 여러 가지 이유로 실패할 수 있습니다. 입력 또는 출력이 너무 컸습니까? 생성된 응답이 원하는 스키마와 일치하지 않았습니까?
  • 응답 시간: Dosu에서 우리는 속도보다 품질을 우선시합니다. 그러나 응답이 느린 이유를 이해하는 것이 중요합니다. 일부 요청은 빠른 응답이 필요하고 다른 요청은 더 느리지만 더 정확한 응답이 필요합니다.

LangSmith의 고급 검색 기능은 비정상적인 동작을 식별하기 쉽게 합니다. 우리는 명시적 사용자 피드백, 최근 오류 사건, 응답 시간 지연 또는 부정적인 감정을 포함한 다양한 기준을 사용하여 검색을 수행할 수 있습니다. LangSmith는 또한 각 추적에 추가 메타데이터를 첨부하여 검색 기능을 더 확장할 수 있도록 합니다.

이미 우리는 여러 가지 예상치 못한 실패 모드를 식별했습니다. 예를 들어, 사용자가 수천 줄의 로그나 OpenAI 임베딩의 원본 부동 소수점 값을 공유할 때 극도로 느린 응답의 패턴을 발견했습니다.

우리 팀의 가장 좋아하는 실패 중 하나는 Dosu에게 풀 요청에 라벨을 붙이도록 요청받았을 때 발생했습니다. 풀 요청에 라벨을 붙이는 대신 Dosu는 사용자에게 그 밤에 가고 싶어하는 콘서트에 대해 말하기로 결정했습니다. Dosu가 Swiftie인지 여부는 아직 결정되지 않았습니다.

실패 모드를 발견하면 EDD 워크플로우는 이전과 동일합니다.

  1. 추가 예제에 대해 LangSmith 검색
  2. eval 데이터셋에 추가
  3. evals에 대해 반복
  4. Dosu의 새 버전을 푸시하고 반복합니다.

평가 데이터셋 수집 자동화

Dosu에서 평가 기반 개발의 미래는 밝습니다. 우리 팀은 LangSmith를 더 사용자 정의하여 프로덕션 트래픽에서 자동으로 평가 데이터셋을 구축할 수 있도록 허용하고 있습니다. 우리는 Dosu의 엔지니어들이 대화 주제, 사용자 세그먼트, 요청 범주 등을 기반으로 데이터셋을 큐레이션하는 것을 가능한 한 간단하게 하고 싶습니다.

Dosu와 LangChain의 협력에는 재미있는 플라이휠 효과가 있습니다. LangSmith는 우리가 Dosu의 성능을 개선하기 위해 더 빨리 반복하도록 도와줍니다. Dosu의 개선은 LangChain 팀의 유지 보수 및 지원 부담을 줄이는 것으로 직접 변환되며, 이를 통해 LangSmith의 기능을 출시하는 데 더 많은 시간을 할애할 수 있습니다. 이는 차례로 Dosu의 개발을 가속화합니다. 그리고 프로세스는 계속됩니다!

PS: Dosu는 채용 중입니다! jobs@dosu.dev로 연락하세요

Editor's Note: the following is a guest blog post from the Devin Stein, CEO of Dosu. Dosu is an engineering teammate that helps you develop, maintain, and support software.

It’s well known at this point that building production-grade LLM products is hard. Reliability is critical for any product to succeed, but when your product is underpinned by a series of probabilistic functions, ensuring reliability is far from straightforward.

At Dosu, we are continuously iterating on our product. For every change we make, we need to understand it’s impact on end users. Evaluation driven development (EDD) allow us to ship with confidence. Over the last few months, LangSmith has allowed us to scale EDD by enabling us to easily monitor and search Dosu’s activity.

What is Dosu?

If you’ve spent any time on the LangChain GitHub repository, you may have already met Dosu, an AI teammate that helps develop, maintain, and support software projects.

Dosu was born out of my time as an open source software maintainer, a rewarding, but notoriously time-consuming role. As my OSS project grew in popularity, I found myself spending far more time playing support instead of developing new features.

For maintainers, this responsibility frequently causes burnout and has driven some to declare issue bankruptcy, a process that involves simply closing all open issues and PRs. The OSS community also suffers from this situation, as people often wait days, weeks, or even months for a maintainer to respond to their issues.

This phenomenon isn’t exclusive to open source. Within the industry, up to 85% of developers’ time is spent on non-coding tasks, like answering ad-hoc questions, triaging issues, and processing overhead.

Dosu takes these tasks off developers’ plates, so they can do what they love: stay in flow, code, and ship great features. At the same time, Dosu is a resource to the OSS community, giving community members immediate feedback whenever they run into an unforeseen issue or have novel questions that only code can answer.

Early Days

Dosu launched in late June, 2023. Back then, our volume was low enough for us to inspect every single response. Each day, armed with just grep and print statements, we meticulously combed through logs to identify areas for improvement.

The work was painstaking, but it was important for designing and developing Dosu's architecture. It helped our team deeply understand how people were trying to use Dosu, which types of requests it excelled at, and ones where it fell short.

Once we knew what we needed to improve, the question was how to improve it. Unlike traditional code updates, changing LLM logic is not straightforward. It’s difficult to know how a small change might affect performance as a whole. Many times we saw that a slight tweak to a prompt led to better results in one domain but caused regression in another.

We needed a way to measure the impact of our changes. For every change, we wanted to make sure that we were:

  1. Maintaining performance in areas where we were doing well
  2. Improving performance in areas where we were struggling

It was during these early days that we turned to evaluation driven development to benchmark our progress.

Evaluation Driven Development

Evaluation driven development (EDD), like test driven development, gives us end goal to develop against. The evaluations — or “evals” — are our baseline for understanding updates and new functionality. EDD helps us understand the impact of any change we make to Dosu’s core logic, models, or prompts.

With EDD, we have a well-defined process for improving Dosu:

  1. Create a new behavior with a handful of initial evals
  2. Launch the new behavior to users
  3. Monitor results in production and identify failure modes
  4. Add examples for each failure mode to our offline evals
  5. Iterate on the updated evals to improve performance
  6. Relaunch & repeat

This development workflow worked well for us when Dosu started, but as our usage grew, it became difficult to keep up with Dosu’s activity.

Keeping the Quality Bar High at Scale

Today, Dosu is installed on thousands of repositories and generates responses at all hours of the day. We’ve built dozens of submodules to intelligently handle different types of scenarios, and we’re constantly iterating on our approach to problem solving as models and the research in the field evolve.

While the growth of Dosu was exciting, it came with challenges. Dosu’s increased activity made it nearly impossible to monitor responses and identify failure modes in production, which is critical to our EDD workflow.

We decided it was time to upgrade our LLM monitoring stack. We looked for a tool that could not only help us monitor Dosu’s activity, but that was flexible enough to fit into our existing workflow. Some of our criteria included:

  • Prompts must live in Git — In the ethos of EDD, we treat prompts as code. Any changes to a prompt must be treated with the same standards as code changes.
  • Code-level tracing — There is more to Dosu than a series of LLM requests. We wanted to track metadata between LLM requests within a single trace.
  • Easy to export data — We had existing evaluation datasets and tooling that we wanted keep.
  • Customizable and extensible - The LLM space is rapidly evolving. There is no standard way of building LLM apps. We wanted to have control over what metadata is tracked and the ability tailor the tool to meet our needs.

We explored the LLM monitoring and evaluation landscape, trying to find a product that satisfied our requirements. After a call with the LangChain team, one of our early partners, we were pleased to hear that LangSmith seemed to check all the boxes.

Implementing LangSmith via the SDK

What got us most excited about LangSmith wasn’t its sleek UI or extensive feature set, but actually its SDK. The LangSmith SDK gave us the fine-grain controls and customizability we were looking for.

To try out LangSmith, we just had to add a @traceable decorator to a few of our LLM-related functions. It only took us minutes to instrument, and immediately upon pushing these changes to production we saw traces flooding into the LangSmith UI.

An unexpectedly awesome feature of the @traceable decorator is it can send the function and LLM call traces to LangSmith. This allows us to see the raw function inputs, rendered prompt templates, and LLM output all in a single trace in the LangSmith UI.

Out-of-the-box, LangSmith gave us visibility into all of Dosu’s activity. The next step was to leverage LangSmith to identify failure modes and integrate it into our EDD workflow.

Finding Failures

Dosu receives a myriad of requests from users—everything from simple questions about a codebase, to error traces from upgrading to a new library version, to asking about the status of a feature. More possible inputs to Dosu means more possible failure modes.

When trying to identify failure modes, or requests that Dosu doesn’t handle well, we have a variety of signals to look for like:

  • Explicit Feedback: The classic thumbs up/down feedback popularized by ChatGPT.
  • User Sentiment: When users interact with Dosu on GitHub issues, their responses usually show whether or not Dosu was helpful
  • Internal Errors: LLMs can fail for a number of reasons. Was the input or output too large? Did the generated response not match the desired schema?
  • Response Time: At Dosu, we prioritize quality over speed; however, understanding why a response is slow matters. Some requests require a fast response, while others require a slower, but more precise response.

LangSmith's advanced search functionality makes it easy to identify anomalous behaviors. We can perform searches using a range of criteria, including: explicit user feedback, recent error incidents, response time delays, or negative sentiment. LangSmith also allows us to attach additional metadata to each trace to further extend its search capabilities.

Already, we’ve identified a number of unforeseen failure modes. For example, we found a pattern of extremely slow responses when users would share thousands of lines of logs or the raw float values of an OpenAI embedding.

One of our team’s favorite failures happened when Dosu was asked to label a pull request. Rather than labeling the pull request, Dosu decided it should tell the user about the concert it was excited to go to the concert that night. Jury is still out on whether Dosu is a Swiftie.

Once we find a failure mode, the EDD workflow is the same as before.

  1. We search LangSmith for additional examples
  2. Add them to our eval datasets
  3. Iterate against the evals
  4. Push a new version of Dosu, and repeat.

Automating Evaluation Dataset Collection

The future of evaluation driven development at Dosu is bright. Our team is customizing LangSmith even further to allow us to automatically build evaluation datasets from production traffic. We want it to be as simples as possible for engineers at Dosu to curate datasets based on conversation topics, user segments, request categories, and more.

There is a fun flywheel effect in Dosu’s collaboration with LangChain. LangSmith helps us iterate faster to improve Dosu’s performance. Improvements to Dosu directly translates to reducing the maintenance and support burden on the LangChain team, allowing them to spend more time shipping features for LangSmith, which in turn speeds up the development of Dosu. And so the process continues!

PS: Dosu’s hiring! Reach out at jobs*@dosu.dev*

원문 보기 https://www.langchain.com/blog/iterating-towards-llm-reliability-with-evaluation-driven-development