Not getting relavant results for AWS KENDRARetriver #26143
Replies: 13 comments 21 replies
-
I found a similar unsolved discussion that might be relevant to your issue:
Additionally, here are some potential reasons and troubleshooting steps for why the code might not be fetching relevant results from AWS Kendra, even though the same text search in the Kendra console returns a perfect match:
Here is the relevant code snippet for the def _kendra_query(self, query: str) -> Sequence[ResultItem]:
kendra_kwargs = {
"IndexId": self.index_id,
"QueryText": query.strip()[0:999],
"PageSize": self.top_k,
}
if self.attribute_filter is not None:
kendra_kwargs["AttributeFilter"] = self.attribute_filter
if self.document_relevance_override_configurations is not None:
kendra_kwargs["DocumentRelevanceOverrideConfigurations"] = (
self.document_relevance_override_configurations
)
if self.user_context is not None:
kendra_kwargs["UserContext"] = self.user_context
response = self.client.retrieve(**kendra_kwargs)
r_result = RetrieveResult.parse_obj(response)
if r_result.ResultItems:
return r_result.ResultItems
response = self.client.query(**kendra_kwargs)
q_result = QueryResult.parse_obj(response)
return q_result.ResultItems Ensure that the If all these factors are correct and the issue persists, further investigation into the specific implementation of the |
Beta Was this translation helpful? Give feedback.
-
i am getting results but it is not the same when compared with console |
Beta Was this translation helpful? Give feedback.
-
even i have passed specific data source id to fetch the info from very specific document @dosu. |
Beta Was this translation helpful? Give feedback.
-
if you can help me with the complete code |
Beta Was this translation helpful? Give feedback.
-
how can i Integrate above code with below code def build_chain(): #llm = OpenAI(batch_size=5, temperature=0, max_tokens=300) The base URL for your Azure OpenAI resource. e.g. "https://.openai.azure.com"#gpt 4 config API version e.g. "2023-07-01-preview"#openai_api_version="2024-03-01-preview" The name of your Azure OpenAI deployment chat model. e.g. "gpt-35-turbo-0613"#deployment_name="gpt-35-turbo" The API key for your Azure OpenAI resource.openai_api_key = os.environ["openai_api_key"] This is set to
|
Beta Was this translation helpful? Give feedback.
-
but this code does not have Kendraretriver custom class |
Beta Was this translation helpful? Give feedback.
-
this sma ecode i am using but not getting the desired result |
Beta Was this translation helpful? Give feedback.
-
How can i check whether retrive query is returning zero results |
Beta Was this translation helpful? Give feedback.
-
When I am explicitly calling query api with filters getting the right result
Can you please guide me if i can use the above code response in ConversationalRetrievalChain |
Beta Was this translation helpful? Give feedback.
-
[ERROR] AttributeError: 'dict' object has no attribute 'to_doc' |
Beta Was this translation helpful? Give feedback.
-
again getting to_doc error |
Beta Was this translation helpful? Give feedback.
-
getting same erors again and again.. this code will get dict error. Doing same thing again and again |
Beta Was this translation helpful? Give feedback.
-
Thanks this solved the issue . now its fetching the expected results |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
I am using above code to implement the que ans based chatbot. but i am facing few issues in search. when I am searching for any specific text through above code I am not getting relevant result . but if i search the same text in Kendra console getting the perfect match for the resonse.
So my question is even there is perfect match is available in Kendra and from console i am able to get the answer .why the above code is not fetching the same result
System Info
NA
Beta Was this translation helpful? Give feedback.
All reactions