スキップしてコンテンツを表示

Knowledge BaseのベクトルストアにS3 Vectorsを使用した時のメタデータフィルタについて

1

こんにちは

ドキュメントにはメタデータフィルタにstring,numer,boolean,listが使えると書いてあるようです。

Vector indexes support string, number, boolean, and list types of metadata.

S3のデータソースに

  • a.csv
  • a.csv.metadata.json

を用意し、 a.csv.metadata.jsonに

"metadataAttributes": {
    "originalkey": ["string"],   
},

のようにリストを設定すると、Knowledge Baseのデータソース同期時に

Encountered error: Ignored 1 files due to invalid metadata attributes. Check that the attribute keys and values don't exceed the character quota, and that the attribute values are acceptable data types (strings, numbers, or Booleans).

とエラーになってしまいます。メタデータにリストは使用できませんか?

よろしくお願いします。

2回答
1
承認された回答

1年以上前のブログなのであまり参考にならないかもしれませんが、metadata.jsonで対応している型にlistは含まれていないようです。
https://aws.amazon.com/jp/blogs/news/knowledge-bases-for-amazon-bedrock-now-supports-metadata-filtering-to-improve-retrieval-accuracy/

メタデータフィルタリング機能を使用するには、ソースデータファイルと同じ名前に .metadata.json のサフィックスを付けたメタデータファイルをソースデータファイルと一緒に提供する必要があります。メタデータは文字列、数値、ブール値のいずれかです。以下は、メタデータファイルの例です。

エキスパート
回答済み 7ヶ月前
  • 情報ありがとうございます。

0

When using Amazon S3 Vectors with Amazon Bedrock Knowledge Bases, there appears to be a discrepancy between the metadata types supported by S3 Vectors generally and what's accepted when using CSV files with metadata.json for Knowledge Base ingestion.

While S3 Vectors does support string, number, boolean, and list types for metadata filtering, when using the CSV ingestion method with a metadata.json file for Knowledge Bases, the metadata values should be simple strings, numbers, or booleans - not lists.

The error you're encountering is because in your metadata.json file, you're trying to define "originalkey" as an array/list with ["string"], but this format isn't supported for CSV metadata ingestion in Knowledge Bases.

Instead, you should format your metadata attribute as a simple string value:

"metadataAttributes": {
"originalkey": "string"
}

When working with CSV files for Knowledge Base ingestion, the metadata fields are treated as string values associated with each chunk. The metadata.json file provides hints to the knowledge base on how to treat each column in the CSV, but the values themselves need to be simple data types rather than lists.

If you need to use array operations for filtering (like $in or $nin operators), those would be used during query time against properly formatted metadata, not during the definition of the metadata structure itself.
Sources
Include metadata in a data source to improve knowledge base query - Amazon Bedrock
Metadata filtering - Amazon Simple Storage Service
How to avoid generating individual metadata.json files when ingesting documents into Amazon Knowledge Base? | AWS re:Post

回答済み 7ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

関連するコンテンツ