Skip to content

fix: improve grouped dormitory facility search#36

Merged
1024andrew merged 1 commit into
devfrom
fix/grouped-dormitory-facility-search
May 5, 2026
Merged

fix: improve grouped dormitory facility search#36
1024andrew merged 1 commit into
devfrom
fix/grouped-dormitory-facility-search

Conversation

@1024andrew

@1024andrew 1024andrew commented May 5, 2026

Copy link
Copy Markdown
Contributor

유형

  • Feat
  • Fix
  • Design
  • Docs
  • Chore
  • Hotfix

변경 사항

  • dormitory = null 상태에서 생활관별 시설 질문을 처리할 때, 전체 검색 top_k 안에 특정 생활관 정보가 누락되는 문제를 개선했습니다.
  • 휴게실/다리미/수용인원처럼 생활관별로 정보가 달라질 수 있는 질문은 각 생활관별 검색 결과를 합쳐 답변 생성에 사용하도록 보완했습니다.

수정 배경

휴게실에 뭐 있어?처럼 생활관을 특정하지 않은 질문에서 제1, 제3학생생활관 정보는 검색되었지만 제2학생생활관 정보가 top_k 밖으로 밀려 답변에서 누락되는 문제가 있었습니다.

테스트

  • 휴게실에 뭐 있어? + dormitory = null
  • 다리미 있어? + dormitory = null
  • 기숙사 수용 인원 어느 정도야? + dormitory = null

기대 효과

  • 생활관 미지정 상태에서 생활관별 시설/현황 정보를 더 빠짐없이 안내
  • 단순히 top_k를 늘리지 않고 필요한 경우에만 생활관별 검색을 수행

@1024andrew 1024andrew merged commit dd5b008 into dev May 5, 2026
1 check passed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a conditional search mechanism for dormitory-related queries, implementing a per-dormitory search strategy when specific keywords are detected in the user's question. The feedback focuses on cleaning up the implementation by removing debug print statements, externalizing hardcoded trigger keywords to constants or settings for better maintainability, and removing redundant hardcoded parameters that match default values in the search function.

Comment on lines +439 to +451
print("===== GROUPED SEARCH DEBUG =====")
print("question:", question)
print("chunks_count:", len(chunks))
for index, chunk in enumerate(chunks, start=1):
print(
index,
chunk.get("document_id"),
chunk.get("dormitory"),
chunk.get("similarity"),
chunk.get("source"),
(chunk.get("content") or "")[:300],
)
print("================================")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

디버깅을 위해 추가된 print 문들이 코드에 남아 있습니다. 운영 환경의 로그를 오염시킬 수 있으므로, 이를 제거하거나 logging 모듈을 사용하여 적절한 로그 레벨(예: DEBUG)로 기록하는 것을 권장합니다.

Comment on lines +896 to +909
dormitory_specific_triggers = [
"휴게실",
"다리미",
"편의점",
"전자레인지",
"전자렌지",
"정수기",
"세탁실",
"탕비실",
"수용인원",
"몇명",
"몇명수용",
"호실수",
]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

dormitory_specific_triggers 리스트가 함수 내부에 하드코딩되어 있습니다. 이러한 키워드 목록은 정책 변화에 따라 자주 수정될 수 있으므로, 유지보수 편의를 위해 모듈 수준의 상수로 분리하거나 Settings 클래스에서 관리하는 것이 좋습니다.

Comment on lines +925 to +933
dormitory_chunks = search_hybrid_chunks(
db=db,
query_text=question,
query_embedding=query_embedding,
dormitory=dormitory,
top_k=top_k_per_dormitory,
candidate_k=20,
keyword_weight=0.3,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

candidate_kkeyword_weight 값이 하드코딩되어 있습니다. 이 값들은 search_hybrid_chunks 함수의 기본값과 동일하므로 생략 가능하며, 만약 명시적으로 관리하고 싶다면 Settings나 공통 상수를 사용하여 중복을 피하는 것이 좋습니다.

        dormitory_chunks = search_hybrid_chunks(
            db=db,
            query_text=question,
            query_embedding=query_embedding,
            dormitory=dormitory,
            top_k=top_k_per_dormitory,
        )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant