Elasticsearch で Amazon Nova モデルを使用する
ElasticsearchのAmazon Novaモデルを使用して、Elasticsearchの製品レビューからセンチメント、信頼性、要約、キーワードを自動的に抽出する方法を学びます。
この記事では、Amazon の AI モデル ファミリーである Amazon Nova について説明し、Elasticsearch と併用する方法を学びます。
Amazon Novaについて
Amazon Nova は、Amazon Bedrock で利用できる Amazon 人工知能モデルのファミリーであり、高いパフォーマンスとコスト効率を実現するように設計されています。これらのモデルは、テキスト、画像、ビデオの入力を処理し、テキスト出力を生成し、さまざまな精度、速度、コストのニーズに合わせて最適化されています。
Amazon Novaの主なモデル
Amazon Nova Micro: テキストのみに焦点を当てた、高速でコスト効率の高いモデルであり、翻訳、推論、コード補完、数学の問題の解決に最適です。1 秒あたり 200 トークンを超える生成が可能なので、即時の応答が必要なアプリケーションに最適です。
Amazon Nova Lite:画像、動画、テキストを高速処理できる低コストのマルチモーダルモデル。スピードと精度に優れており、コストが重要な要素となるインタラクティブな高容量アプリケーションに適しています。
Amazon Nova Pro: 高精度、高速、コスト効率を兼ね備えた最も高度なオプション。ビデオ要約、質疑応答、ソフトウェア開発、AI エージェントなどの複雑なタスクに最適です。専門家のレビューでは、テキストとビジュアルの理解力に優れているだけでなく、指示に従って自動化されたワークフローを実行する能力も証明されています。
Amazon Nova モデルは、コンテンツ作成やデータ分析からソフトウェア開発や AI を活用したプロセス自動化まで、さまざまなアプリケーションに適しています。
以下では、Amazon Nova モデルを Elasticsearch と組み合わせて使用し、製品レビューを自動化する方法を説明します。
私たちが行うこと:
推論 API 経由でエンドポイントを作成し、Amazon Bedrock と Elasticsearch を統合します。
推論プロセッサを使用してパイプラインを作成し、推論 API エンドポイントを呼び出します。
製品レビューをインデックス化し、パイプラインを使用してレビューの分析を自動的に生成します。
統合の結果を分析します。
Amazon Nova Liteを使用して推論APIにエンドポイントを作成
まず、Amazon Bedrock と Elasticsearch を統合するために Inference API を設定します。Amazon Nova Lite(ID amazon.nova-lite-v1:0 )を定義します。速度、精度、コストのバランスが取れているため、使用すべきモデルです。
注意: Amazon Bedrock を使用するには有効な認証情報が必要です。アクセス キーを取得するためのドキュメントは、こちらで参照できます。
PUT _inference/completion/bedrock_completion_amazon_nova-lite
{
"service": "amazonbedrock",
"service_settings": {
"access_key": "#access_key#",
"secret_key": "#secret_key#",
"region": "us-east-1",
"provider": "amazontitan",
"model": "amazon.nova-lite-v1:0"
}
}レビュー分析パイプラインの作成
ここで、推論プロセッサを使用してレビュー分析プロンプトを実行する処理パイプラインを作成します。このプロンプトにより、レビュー データが Amazon Nova Lite に送信され、次の処理が実行されます。
感情の分類(肯定的、否定的、または中立的)。
レビューの要約。
キーワードの生成。
信頼性の測定 (本物 | 疑わしい | 一般的な)。
PUT /_ingest/pipeline/review_analyzer_ai
{
"processors": [
{
"script":
{
"source": """ctx.prompt = "Analyze the following product review and return a structured JSON. Task: - Summarize the review concisely. - Detect and classify the sentiment as positive, neutral, or negative.- Generate relevant tags (keywords) based on the review content and detected sentiment. - Evaluate the authenticity of the review (authentic, suspicious, or generic). Review: " + ctx.review + " Respond in JSON format with the following fields: \"review_analyze\": {\"sentiment\": \"<positive | neutral | negative>\", \"authenticity\": \"<authentic | suspicious | generic>\",\"summary\": \"<short review summary>\", \"keywords\": [\"<keyword 1>\", \"<keyword 2>\", \"...\"]}}}"
"""
}
},
{
"inference": {
"model_id": "bedrock_completion_amazon_nova-lite",
"input_output": {
"input_field": "prompt",
"output_field": "result"
}
}
},
{
"gsub": {
"field": "result",
"pattern": "```json",
"replacement": ""
}
},
{
"json" : {
"field" : "result",
"strict_json_parsing": false,
"add_to_root" : true
}
},
{
"remove": {
"field": "result"
}
},
{
"remove": {
"field": "prompt"
}
}
]
}レビューのインデックス作成
ここで、Bulk API を使用して製品レビューのインデックスを作成します。先ほど作成したパイプラインが自動的に適用され、Nova モデルによって生成された分析がインデックス付けされたドキュメントに追加されます。
POST bulk/
{ "index": { "_index" : "products", "_id": 1, "pipeline":"review_analyzer_ai" } }
{ "product": "Pampers Pants Premium Care Fralda", "review": "Best diaper ever! Great material, lots of cotton, without all that plastic. Doesn't leak! My baby is a boy and every diaper leaked around the waist, this model solved the problem. Even on a small baby it's worth the effort of putting on the short diaper. I put it on my baby at 9 pm and only take it off in the morning, without any leaks." }
{ "index": { "_index" : "products", "_id": 2, "pipeline":"review_analyzer_ai" } }
{ "product": "Portable Electric Body Massager", "review": "It broke in three months for no apparent reason, thank goodness I didn't review it before. I don't recommend buying it because it has a short lifespan." }
{ "index": { "_index" : "products", "_id": 3, "pipeline":"review_analyzer_ai" } }
{ "product": "Havit Fuxi-H3 Black Quad-Mode Wired and Wireless Gaming Headset", "review": "The sound is good for the price, but the connectivity is horrible. You always need to be playing audio, otherwise it loses connection (I work from home, and this is very annoying). Sometimes it loses connection and you have to turn it off and on again to get it back on. The microphone is very sensitive, so it loses connection frequently and you have to turn the headset off and on for the microphone to work again. The flexibility of the stem is useless, because if you move it, the microphone can turn off. Sometimes I need to use Linux and the headset simply doesn't work. It's light and comfortable, the sound is adequate, but the connectivity is terrible." }
{ "index": { "_index" : "products", "_id": 4, "pipeline":"review_analyzer_ai" } }
{ "product": "Air Fryer 4L Oil Free Fryer Mondial", "review": "For those looking for value for money, it's a good option, but the tray (which is underneath the perforated basket) is already peeling a lot. My mother has one just like it and said that hers is even rusting, in other words, the material is MUCH inferior. There's also something that bothers me, because it looks like a microwave, it doesn't fry evenly, it's weaker in the middle and stronger on the sides. Buy at your own risk." }結果のクエリと分析
最後に、Amazon Nova Lite モデルがレビューをどのように分析および分類するかを確認するためにクエリを実行します。GET products/_search を実行すると、レビュー コンテンツから生成されたフィールドがすでに強化されたドキュメントが取得されます。
モデルは、主な感情(肯定的、中立的、否定的)を識別し、簡潔な要約を生成し、関連するキーワードを抽出し、各レビューの信憑性を推定します。これらのフィールドは、全文を読まなくても顧客の意見を理解するのに役立ちます。
結果を解釈するには、次の点を考慮します。
感情。これは、消費者の製品に対する全体的な認識を示します。
言及された主なポイントを強調した要約。
キーワード。類似のレビューをグループ化したり、フィードバック パターンを識別したりするために使用できます。
信憑性。レビューが信頼できるかどうかを示します。これはキュレーションやモデレーションに役立ちます。
"hits": [
{
"_index": "products",
"_id": "1",
"_score": 1,
"_ignored": [
"review.keyword"
],
"_source": {
"product": "Pampers Pants Premium Care Fralda",
"model_id": "bedrock_completion_amazon_nova-lite",
"review_analyze": {
"summary": "The reviewer praises the diaper for its great material, high cotton content, and leak-proof design, especially highlighting its effectiveness for their baby.",
"sentiment": "positive",
"keywords": [
"best diaper",
"great material",
"cotton",
"no plastic",
"leak-proof",
"baby",
"effective"
],
"authenticity": "authentic"
},
"review": "Best diaper ever! Great material, lots of cotton, without all that plastic. Doesn't leak! My baby is a boy and every diaper leaked around the waist, this model solved the problem. Even on a small baby it's worth the effort of putting on the short diaper. I put it on my baby at 9 pm and only take it off in the morning, without any leaks."
}
},
{
"_index": "products",
"_id": "2",
"_score": 1,
"_source": {
"product": "Portable Electric Body Massager",
"model_id": "bedrock_completion_amazon_nova-lite",
"review_analyze": {
"summary": "The product broke in three months for no apparent reason and the reviewer does not recommend it due to its short lifespan.",
"sentiment": "negative",
"keywords": [
"broke",
"short lifespan",
"not recommend"
],
"authenticity": "authentic"
},
"review": "It broke in three months for no apparent reason, thank goodness I didn't review it before. I don't recommend buying it because it has a short lifespan."
}
},
{
"_index": "products",
"_id": "3",
"_score": 1,
"_ignored": [
"review.keyword"
],
"_source": {
"product": "Havit Fuxi-H3 Black Quad-Mode Wired and Wireless Gaming Headset",
"model_id": "bedrock_completion_amazon_nova-lite",
"review_analyze": {
"summary": "The headset has good sound quality for the price but suffers from poor connectivity, especially when using the microphone or moving the headset. It also has compatibility issues with Linux.",
"sentiment": "negative",
"keywords": [
"sound",
"connectivity",
"microphone",
"compatibility",
"annoying",
"turn off and on",
"Linux",
"flexible stem",
"work from home"
],
"authenticity": "authentic"
},
"review": "The sound is good for the price, but the connectivity is horrible. You always need to be playing audio, otherwise it loses connection (I work from home, and this is very annoying). Sometimes it loses connection and you have to turn it off and on again to get it back on. The microphone is very sensitive, so it loses connection frequently and you have to turn the headset off and on for the microphone to work again. The flexibility of the stem is useless, because if you move it, the microphone can turn off. Sometimes I need to use Linux and the headset simply doesn't work. It's light and comfortable, the sound is adequate, but the connectivity is terrible."
}
},
{
"_index": "products",
"_id": "4",
"_score": 1,
"_ignored": [
"review.keyword"
],
"_source": {
"product": "Air Fryer 4L Oil Free Fryer Mondial",
"model_id": "bedrock_completion_amazon_nova-lite",
"review_analyze": {
"summary": "The product offers value for money but has issues with peeling, rusting, and uneven frying.",
"sentiment": "negative",
"keywords": [
"value for money",
"peeling",
"rusting",
"uneven frying",
"weaker in the middle"
],
"authenticity": "authentic"
},
"review": "For those looking for value for money, it's a good option, but the tray (which is underneath the perforated basket) is already peeling a lot. My mother has one just like it and said that hers is even rusting, in other words, the material is MUCH inferior. There's also something that bothers me, because it looks like a microwave, it doesn't fry evenly, it's weaker in the middle and stronger on the sides. Buy at your own risk."
}
}
]結びに
Amazon Nova Lite と Elasticsearch の統合により、言語モデルが生のレビューを構造化された価値ある情報に変換する方法が実証されました。パイプラインを通じてレビューを処理することで、感情、信憑性、要約、キーワードを自動的かつ一貫して抽出できるようになりました。
結果は、モデルがレビューのコンテキストを理解し、ユーザーの意見を分類し、各体験の最も関連性の高いポイントを強調できることを示しています。これにより、検索機能の向上に活用できる、より豊富なデータセットが作成されます。




