[DEV-390/BE] fix: LLM 응답이 일부만 오는 문제에 대응#637
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Summary of ChangesHello @kckc0608, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 LLM(Large Language Model) 응답이 불완전하게 오는 문제를 해결하기 위해 백엔드 로직을 개선합니다. 특히, 프롬프트 생성 시 질문의 수를 제한하고, LLM 응답 처리 과정에서 누락된 카테고리 정보에 대한 견고성을 높여 시스템의 안정성과 데이터 처리의 정확성을 향상시킵니다. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
이 PR은 LLM 응답이 부분적으로 오는 문제에 대응하기 위한 두 가지 수정을 포함합니다. 첫째, 클러스터의 질문 수가 30개를 초과할 경우 30개로 제한하여 프롬프트를 생성하도록 변경했습니다. 둘째, LLM 응답에서 누락된 ID가 있을 경우 이를 무시하고 계속 진행하도록 예외 처리를 추가했습니다.
QuestionCategoryBatchService의 변경 사항은 견고성을 높이는 좋은 수정입니다. PromptGenerateUtil의 변경 사항은 기능적으로는 맞지만, 스트림 내에서 반복적으로 리스트를 생성하고 List.contains를 사용하여 성능이 저하될 수 있습니다. 이를 개선하기 위해 Set을 사용하고 리스트 생성을 스트림 외부로 옮기는 것을 제안합니다.
I am having trouble creating individual review comments. Click here to see my feedback.
backend/src/main/java/com/shyashyashya/refit/global/util/PromptGenerateUtil.java (81-90)
현재 구현에서는 questionVectors 스트림의 filter 내부에서 각 questionVector에 대해 subList를 반복적으로 생성하고 있습니다. 이는 비효율적입니다. 또한 List.contains는 O(n) 시간 복잡도를 가지므로 성능 저하를 유발할 수 있습니다.
filter를 적용하기 전에 subList를 한 번만 생성하고, 빠른 조회를 위해 HashSet을 사용하는 것이 좋습니다. 이렇게 하면 contains 연산의 시간 복잡도를 평균 O(1)로 줄일 수 있습니다.
List<Long> questionIds = category.getQuestionDocumentIds();
List<Long> idsForPrompt = questionIds.size() > 30 ? questionIds.subList(0, 30) : questionIds;
java.util.Set<Long> idSet = new java.util.HashSet<>(idsForPrompt);
List<String> questions = questionVectors.stream()
.filter(questionVector -> idSet.contains(questionVector.getId()))
.map(QuestionVectorDocument::getQuestion)
.toList();
관련 이슈
close #636
작업한 내용
PR 리뷰시 참고할 사항
참고 자료 (링크, 사진, 예시 코드 등)