selfqueryRetriever에서 contain,like 필터링 오류문제
336
2 asked
안녕하세요 답해주셔서 감사합니다.
Your goal is to structure the user's query to match the request schema provided below. << Structured Request Schema >> When responding use a markdown code snippet with a JSON object formatted in the following schema: ```json { "query": string \ text string to compare to document contents "filter": string \ logical condition statement for filtering documents } ``` The query string should contain only text that is expected to match the contents of documents. Any conditions in the filter should not be mentioned in the query as well. A logical condition statement is composed of one or more comparison and logical operation statements. A comparison statement takes the form: comp(attr, val): - comp (eq | ne | gt | gte | lt | lte | contain | like | in | nin): comparator - attr (string): name of attribute to apply the comparison to - val (string): is the comparison value A logical operation statement takes the form op(statement1, statement2, ...): - op (and | or | not): logical operator - statement1, statement2, ... (comparison statements or logical operation statements): one or more statements to apply the operation to Make sure that you only use the comparators and logical operators listed above and no others. Make sure that filters only refer to attributes that exist in the data source. Make sure that filters only use the attributed names with its function names if there are functions applied on them. Make sure that filters only use format YYYY-MM-DD when handling date data typed values. Make sure that filters take into account the descriptions of attributes and only make comparisons that are feasible given the type of data being stored. Make sure that filters are only used as needed. If there are no filters that should be applied return "NO_FILTER" for the filter value.
이런 스키마를 가지고있잖아요. 근데 contain이랑 like가 인식이 안되는 오류가 있습니다. 그래서 에러가 떠버럽니다. 그거에 대해 해결방법이 있을까요
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-54-5a63d86f57f7> in <cell line: 1>()
----> 1 results = retriever.get_relevant_documents(
2 "롤과 배그가 돌아가는 컴퓨터 견적을 추천해줘"
3 )
4
5 for res in results:
12 frames
/usr/local/lib/python3.10/dist-packages/langchain_core/structured_query.py in _validate_func(self, func)
24 if isinstance(func, Comparator) and self.allowed_comparators is not None:
25 if func not in self.allowed_comparators:
---> 26 raise ValueError(
27 f"Received disallowed comparator {func}. Allowed "
28 f"comparators are {self.allowed_comparators}"
ValueError: Received disallowed comparator like. Allowed comparators are [<Comparator.EQ: 'eq'>, <Comparator.NE: 'ne'>, <Comparator.GT: 'gt'>, <Comparator.GTE: 'gte'>, <Comparator.LT: 'lt'>, <Comparator.LTE: 'lte'>]이런오류가뜹니다.
Answer 2
0
안녕하세요~. 반갑습니다.
현재 LangChain-ChromaDB 연동에서 contain,like 연산을 지원하지 않는 것 같습니다. (참조 : https://github.com/langchain-ai/langchain/issues/3788 )
eq, ne, gt, gte, lt, lte 연산만을 사용할 수 있고, 따라서 contain,like 연산을 시도해서 해당 에러가 뜨지 않도록 우회하려면 eq, ne, gt, gte, lt, lte만을 사용한 필터링 예제들을 few-shot examples로 만들고 넣어줘서(최소 각 연산자별로 2개씩(즉, 최소 12개) 가능하다면 더 많으면 좋을것 같습니다.) retriever가 few-shot examples을 참조해서 eq, ne, gt, gte, lt, lte 연산만을 사용하도록 강제할 수 있을 것 같습니다.
좋은 하루되세요~.
감사합니다.
0
안녕하세요, 인프런 AI 인턴입니다.
yhk775206님 질문하신 내용 관련하여 contain과 like 필터링이 인식되지 않아 발생하는 오류에 대한 해결 방안을 제시해 드리겠습니다.
오류 메시지에 따르면, 사용된 like 비교자는 허용된 비교자 목록에 없음을 알 수 있습니다. contain 또한 허용된 비교자가 아닐 것으로 추정됩니다. 이 경우, 허용된 비교자를 사용하여 필터링 조건을 만들어야 합니다.
{
"query": "롤과 배그가 돌아가는 컴퓨터 견적을 추천해줘",
"filter": "NO_FILTER"
}
결과적으로, 구체적인 필터링 적용 없이 질의하려는 내용이 query로만 구성되어 있으며, 현재 상황에서는 추가적인 필터링(filter)이 필요하지 않음을 나타내기 위해 "NO_FILTER"를 사용합니다. contain과 like는 현재 구조에서 지원되지 않는 비교자이므로, 필요한 정보 검색이나 처리에 있어서 허용된 비교자들(eq, ne, gt, gte, lt, lte)을 활용하는 방향으로 고려해야 할 것입니다.
혹시 로컬llm을 활용해서 RAG를 구현하는 예제도 한번 올려주시면 안될까요?
0
965
2
검증 방법 질문입니다.
0
151
2
with_structured_output 함수
0
796
1
Quickstart 오류 - Query Analysis Quickstart 기초 예제 실습
0
257
2
docStore
0
137
0
langchain.schema가 무슨 역할을 하는지요?
0
491
2
라마 3(Llama 3)로 AI 텍스트 번역하기 실행 오류.
0
979
2
SQL 에이전트 제작 예제 프로그램과 관련하여 질문 드립니다.
0
207
2
하이퍼클로바 X 랭체인
0
391
2
ConversationSummaryBufferMemory의 max_token_limit
0
320
2
SelfQueryRetriever 사용시
0
311
2
!pip install langchain_community 문장이 필요할 것같아요(강의 2,4)
0
1262
2
memory+ Retriever +llm 질문있습니다.
0
228
1
self query retriever 한글
0
453
2
상품추천GPT에서 데이터를 바꿔 사용하는데 오류나는 이슈
1
254
2
Rag 사용시 전혀 관계없는 데이터를 가져오는 이슈
0
1293
2
bert vs gpt 의 혼란스러운 점
0
566
2
chromadb 용량
0
556
2
RAG에서 Generator으로 어떤 데이터가 들어가는지 볼 수 있는 방법이 있나요?
0
407
1
RAG 실습 강의에서 template 문구 관련해 질문이 있습니다.
0
445
2
RAG의 데이터 소스로 RDB 사용 시 어떤 로더를 사용해야 하나요?
0
2326
2
db.delete_collection() db가 정의되어 있지 않아 문의드립니다.
0
178
1
GPT api 토큰 제한
0
1739
1
Data Loader 관해서
0
305
2

