How to restrict number of words to be retrieved to a limit 50 using filter attribute?

0

{ "retrievalQuery": { "text": "What is aws?" }, "retrievalConfiguration": { "vectorSearchConfiguration": { "numberOfResults": 1 } } } }

  • any answers for this is much appreciated?

Guru
已提問 2 個月前檢視次數 91 次
1 個回答
0

Hi Guru,

I apologize for responding to your post so late. I've been researching how to restrict the number of words retrieved to a maximum of 50 using the filter attribute. Unfortunately, Amazon Bedrock doesn't natively support truncating text responses based on word count using metadata attributes. Therefore, you would need to manage this requirement through:

  1. Calculate the numberOfWords for each document during pre-processing. Include this custom metadata in the document. For example, you can add "numberOfWords": 76 to indicate the total word count.
  2. Amazon Bedrock's filtering capabilities enable you to filter based on numerical comparisons in metadata values.
  3. You can query using a filter based on numberOfWords < 50 to include the documents that match this attribute.

⚠️ I haven't tested this solution, but it may work.


ℹ️ However, I believe preprocessing will be necessary to achieve this.

profile picture
專家
已回答 1 個月前
  • Thanks very much Osvaldo. I'll give it a try!

  • Let me know if this solution works

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南