Amazon BedrockのいくつかのモデルでSNS投稿向けにTechBlog(技術記事)の要約を試してみた

AWS

2024.1.19

Topics

はじめに

こんにちは、フクナガです。
弊社NHNテコラスでは、公式X(旧Twitter)を運用しております。
NHNテコラス公式Xでは、TechBlogの記事紹介を行うのですが、この作業は中々大変なのではないかと思っています。(いつもありがとうございます)

こちらは、私が昨年出した「Amazon Bedrockの利用トークン数をCloudWatch Logs Insightsで集計してみる」の告知文となります。素晴らしい!!!本当にありがとうございます。
https://x.com/techorus_inc/status/1741353498317332944?s=20

というわけで、Amazon Bedrockを利用したX投稿文のアイデア提案システムを作ろうと考えました!!
今回の記事では、「Amazon Bedrockのどのモデルを利用するか」という観点で検証した内容をご紹介します。

要約する記事

今回は、2023年ラストに出した「Amazon Bedrockの利用トークン数をCloudWatch Logs Insightsで集計してみる」を要約し、Xの投稿文を作ってみようと思います!

関連記事
Amazon Bedrockの利用トークン数をCloudWatch Logs Insightsで集計してみる

利用するプロンプト

モデルによっては、日本語に対応していなかったり精度が低いものがありそうなので、今回は英語でプロンプトを作成します。

入力プロンプト

You are responsible for posting summaries of technical articles on social media. I would like you to create a brief summary of a technical blog that is engaging and can increase viewership. Below is an article from a technical blog for you to summarize. Please create a brief summary within 120 characters. I would like three different versions.
[Technical blog]
記事を英訳したものをコピペします。

入力プロンプト(日本語訳)

あなたは、ソーシャルメディアで技術記事の要約を投稿する責任があります。人々を引き付け、視聴者数を増やすことができる技術ブログの簡潔な要約を作成してほしいです。以下は、あなたが要約する技術ブログからの記事です。120文字以内の簡潔な要約を作成してください。3つの異なるバージョンがほしいです。

120文字指定にしているのは、日本語に訳したとき140文字の上限を超えないように何となくです。

各モデル出力結果を比較

(1) Jurassic-2 Ultra(AI21 Labs)

  1. Use “Amazon Bedrock” without worrying about costs! Here’s how to enable log output and aggregate the number of tokens with CloudWatch Logs Insights.

  2. Use Amazon Bedrock without worrying about costs! Here’s how to enable log output and count tokens with CloudWatch Logs Insights.

  3. Worried about costs when using Amazon Bedrock? Here’s how to enable log output and count tokens with CloudWatch Logs Insights.

(2) Titan Text G1 – Express(Amazon)

プロンプトが良くないのか、7個くらい案を出してくれたので、よかったものを2つピックアップします。

  1. Amazon Bedrock is a managed service that makes foundation models from leading AI startups and Amazon’s own Titan models available through APIs. It offers a pay-as-you-go system that depends on the number of tokens inputted and outputted. To enable log output from Amazon Bedrock to CloudWatch Logs, create a CloudWatch log group and select “Settings” from the left-hand menu of the Amazon Bedrock console. Check “Model invocation logging”, enter the following, and press “Save Settings”.
  2. The number of tokens can be obtained from log information output from Amazon Bedrock to CloudWatch Logs. To aggregate the number of tokens per model, use a query to filter (inputTokenCount >= 1) and stats sum (inputTokenCount), sum (outputTokenCount) by modelId. To calculate costs, use the pricing structure for each model, which is pay-as-you-go based on the number of tokens.

(3) Claude v2.1(Anthropic)

  1. Enable Bedrock logging to CloudWatch to monitor usage and costs by tracking input and output tokens. Query logs with Insights to analyze model usage.

  2. CloudWatch Logs integration with Bedrock provides visibility into model invocation metrics like latency and token counts to monitor usage and optimize costs.

  3. Analyze Bedrock model usage by numbers of input versus output tokens with CloudWatch Logs Insights queries. Monitor usage over time to optimize costs.

(4) Command v14.7(Cohere)

AWSが提供している情報では、Supported use casesに「copywriting」や「Summarization」という文言が入っていたので、大いに期待して試してみます。

  1. Amazon Bedrock made easy! Learn how to enable log output to CloudWatch Logs and aggregate the number of tokens using CloudWatch Logs Insights. Get started with generating your AI model and track its usage with no coding required. #AI #CloudComputing

  2. Unleash the power of Amazon Bedrock with simplified token tracking! Learn how to set up log output to CloudWatch Logs and monitor your generative AI app’s performance. #AI #CloudComputing #LogAnalysis

  3. Get insights into your Amazon Bedrock usage with CloudWatch Logs! Learn how to set up logging and aggregate token data for better performance monitoring. #AI #CloudComputingTips

(5) Llama 2 Chat 70B(Meta)

  1. Learn how to enable log output from Amazon Bedrock to CloudWatch Logs and aggregate the number of tokens with CloudWatch Logs Insights. #AmazonBedrock #CloudWatch #TokenCount
  2. Understand how to monitor generative AI applications by integrating Amazon Bedrock and Amazon CloudWatch. #AI #Monitoring #AmazonBedrock
  3. Discover how to calculate costs for Amazon Bedrock models based on the number of tokens. #AmazonBedrock #Costs #Tokens

好きな回答Best3

プロンプトに対する出力が好きだったものを日本語に訳して発表していきます!

1位 Llama 2 Chat 70B(Meta)

簡潔で誠実な回答で、今回の用途に対しては理想的なモデルだったかなと感じました。

  1. Amazon Bedrock から CloudWatch Logs へのログ出力を有効にし、CloudWatch ログインサイトを使用してトークンの数を集計する方法を学びましょう。#AmazonBedrock #CloudWatch #TokenCount
  2. Amazon Bedrock と Amazon CloudWatch を統合してジェネレーティブ AI アプリケーションをモニタリングする方法を理解しましょう。#AI #Monitoring #AmazonBedrock
  3. Amazon Bedrock モデルのコストをトークンの数に基づいて計算する方法をご覧ください。#AmazonBedrock #Costs #Tokens

2位 Claude v2.1(Anthropic)

非常にわかりやすい要約になっていて、記事を読まなくてもある程度の情報を得ることが出来ます。こちらも、Xでの投稿としてとても良さそうです。

  1. CloudWatch への Bedrock ロギングを有効にすると、入出力トークンを追跡して使用状況とコストをモニタリングできます。Insights を使用してログをクエリし、モデルの使用状況を分析します。
  2. CloudWatch Logs と Bedrock の統合により、レイテンシーやトークン数などのモデル呼び出しメトリクスを可視化して、使用状況を監視してコストを最適化できます。
  3. CloudWatch Logs Insights クエリを使用して、入力トークンと出力トークンの数によって Bedrock モデルの使用状況を分析できます。経時的に使用状況をモニタリングしてコストを最適化します。

3位 Command v14.7(Cohere)

Llamaと同様誠実な回答が目立ちましたが、「Unleash the power of Amazon Bedrock with simplified token tracking! (シンプルなトークントラッキングで Amazon Bedrock の力を解き放ちましょう!)」という部分が、まさにコピーライティングっぽくてとても好きでした。
使うのに少し勇気がいるかもですが、目立った投稿をするためには役立つかもしれませんね。

  1. 「アマゾン・ベッドロックが簡単になりました!CloudWatch Logs へのログ出力を有効にし、CloudWatch ログインサイトを使用してトークンの数を集計する方法をご覧ください。コーディングなしで AI モデルの生成を開始し、その使用状況を追跡しましょう。#AI #CloudComputing」
  2. 「シンプルなトークントラッキングで Amazon Bedrock の力を解き放ちましょう!CloudWatch Logs へのログ出力を設定し、ジェネレーティブ AI アプリケーションのパフォーマンスをモニタリングする方法を学びましょう。#AI #CloudComputing #LogAnalysis」
  3. 「CloudWatch ログで Amazon Bedrock の使用状況に関するインサイトを得ましょう!パフォーマンスモニタリングを改善するために、ロギングを設定してトークンデータを集約する方法を学びましょう。#AI #CloudComputingTips」

まとめ

今回の記事では、SNS投稿用のTechBlogの要約作成をAmazon Bedrockの複数モデルで実施してみました。出力された内容をもとに文言を作成することで、大幅な時間削減につながりそうだなと感じています。
利用するモデルとプロンプトが定まったため、ゆくゆくは完全自動化を目指して頑張りたいと思います!

(番外編)翻訳はAmazon Translateを使ってみました

目指すは完全自動化!!ということで、各モデルからの回答とTechBlogの翻訳はAWSのマネージドサービスであるAmazon Translateの「リアルタイムでの翻訳」を利用しました。文言によっては誤訳もありますが、素晴らしいクオリティだと思います。

フクナガ

インフラエンジニア歴5年のフクナガです。AWS(特にBedrockとCodePipeline)が得意分野。休日はベースを弾いてます。技術力と発信力を高め、Top Engineerを目指しています。

Recommends

こちらもおすすめ

Special Topics

注目記事はこちら