クラウドインフラ構築記

現在AWSの構築支援に携わっております。今注視しているのは、GKE、BigQuery、Google Dataflowなどサービスを展開しているGoolge Cloud Platformです。

2024年6月19日
から hiruta
Bedrock Claude Night 2 はコメントを受け付けていません

Bedrock Claude Night 2

前回都合により、Anthropic の方がビデオ登壇になってしまいましたが、AWS Summit Japanのために来日の際に再度Anthropic Claude nightを開催されました。

Anthropic キーノート&デモ

@YoMaggieVo  @alexalbert__

文字起こししたもの

Hopefully, everyone can hear me from back there. I'm going to move this a little bit. Okay. Okay. Um, okay. Okay, great. Uh,
Um, this because, um,
Uh, to begin with. Um, Uh, I'm here with also Alex, Albert, who is the head of our developer relations, um, the head over to developer relations, uh, motions right now, and he will be speaking with later.
So I'm sure many of you have heard of anthropics before, so I will go directly into quad 3. I'm talking about our models. Today, we'll be talking about both vision and Tool, use mostly
To begin with. Here's an overview of the claw 3 model family. It consists of three large models. And the first one is uh Opus which is our largest most capable model. Then we also have sonnet, which is our middle, balanced model, and then we have haiku, which is our fastest and smallest model,
And you can see it in the chart on the left, that they're also spread across different cost tubes, and so, when you select a model, it's important to think about the kind of the model that can do, all the things you need it to do. Without, you know, breaking the bank and being exactly the price point that works for you.
A brief overview of the things that Claude can do. I think can be broken into three major categories, the the Category is about analysis. So all three models in the cloud 3 family are incredibly capable at high level, extremely nuanced analysis. On things like analyzing large sets of documents.
Large sets of emails, different databases of both code and text and so on.
The second major category of what plot is capable of is in the area of content generation and just general knowledge. So Claude is able to do things like help you generate marketing, copy and other types of business content, As well as be a really effective chat bot for things like product support or just helping you brainstorm your ideas or how to do something better.
Claude's a really good assistant to just help you think through things.
And the last area which uh, we think is the most exciting area going forward, is in the area of automation. So, with tool use, you're able to start automating end-to-end workflows so that Claude can do a series of tasks without you having to handle every step of the process.
We believe that this is going to be kind of more increasingly important for businesses and startups, going forward and more of a way that people use models going forward as well.
Claw 3 is able to do this with a series of improvements from previous models.
The first areas are that. It's just faster all around. So you're able to do things like chain a bunch of tools without having it hurt your latency, as much as it would if you were using older models,
And it's also much more steerable. Meaning you can do a lot more with little prompting or little prompting optimization. You can write shorter prompts to get more performance in Behavior than before.
Furthermore. Um, Claude is also much more accurate and trustworthy than previous generations meaning, for example, that Claude can Utilize more accurately information all across the context window.
We've also worked to further lower hallucination rates and to generally make you make the model both more trustworthy in terms of its performance as well, as give you tools like better citations to be able to understand and verify what the model is doing.
Then lastly excitingly all of the models in the cloud3 family have Vision capabilities, meaning that now Claude can understand images as well as text.
Going forward, I'm going to talk a little bit about our vision capabilities. Now what you can do with it as well, so there is An overview is that our vision capabilities have been specifically trained for business, type use cases. Meaning that it understands charts graphs. Technical diagrams, the kinds of things you would see a lot in business settings.
De Masco cono casanisms.
Um, let's if you can see the series on the right. There's a bunch of examples of us, kind of what this means, Claude is able to understand the conditions of items for insurance purposes or it's able to extract data from charts and graphs and then write code about analyzing that information.
It's even able to transcribe handwriting
We're very excited and grateful to have a close relationship with Amazon in Japan, especially meaning that we've been able to get feedback on our models and how well our models perform in Japanese.
That means that we do understand that our current models have some gaps. There is like claudice Claude, 3 as it curly is is not able to read um you know, extremely messy Japanese handwriting for example or um you know certain kanji that are really rare and older and so we're working on making that better for future models.
I'm going to give you a few tips right now on how to properly use Vision. Uh, these are the three main ones that I think will help you a lot.
The first one is to put your images right at the top just like you would with documents with Claude you should put your images at the top before your instructions before your query so that Claude can have that image as context to understand the rest of your instructions.
You should also label your images. So here I've labeled them just image one through four in my example but whatever label you give it this allows you to better reference it in your instructions the different images as well as gives Clauda understanding of what the order of these images or maybe even what those images are if you name them.
And then in general for images that contain information, you may want to make it a two-step process where your first step is just to ask Claude to extract the information. So the numbers from the charts or You know, certain Things that it can see in the image before asking it to do a task with that information.
So now I'm going to show you a video of an example of how Claude is able to extract. A lot of information at very fast speeds from documents that are messy. And some of the, the images are, you know, hard to understand and hard to read.
I think. Do I just play and step aside?
Okay, go ahead. I have no introduction. Just in English. Do I play it with sound or no. Uh, can you reduce the sound? Yes, but it'll be in English. Okay, let me Go back for a second.
Make it up. Please play with English. Okay. Do I pause for them to translate? Okay. In the world, to demonstrate this, we're going to read through thousands of scanned, documents in a matter of minutes. The Library of Congress Federal writers project is a collection of thousands of scanned transcripts from interviews during the Great Depression.
This is a gold, mine of incredible narratives and real life Heroes, but it's locked away in hard to access scans and transcripts. Imagine you're a documentary filmmaker or journalist, how can you dig through these thousands of messy documents to find the best source material for your research without reading them all yourself?
Since these documents are scanned images, we can't feed them into a text on the llm. And these scans are messy enough that they'd be a challenge for most dedicated OCR software. But luckily Haiku is natively Vision capable and can use surrounding text to tempt transcribe these images and really understand what's going on.
We can also go beyond simple transcription for each interview and ask Haiku to generate structured, Json output, with metadata like title date keywords, but also use some creativity and judgment to assess how compelling a documentary the story and characters would be We can process each document in parallel for performance and with Claude's high availability API, do that at massive, scale for hundreds or thousands of documents.
Let's take a look at some of that structured output. Haiku was able to not just transcribe but pull out creative things like keywords. We've transformed this collection of many, many scams into Rich. Keyword structured data. Imagine to put any organization with a knowledge base of scanned documents like a traditional publisher Healthcare provider or Law Firm can do Haiku can parse their extensive archives and bodies of work.
We'd love for you to try it out and see what we built. So, in that demo, you can see that Haiku especially can read documents extremely quickly. This video is slower than how fast Haiku is now, where now we make demos? Now we have to slow down the video just to see it properly generated.
Some other examples I want to show you. Here is an image of a whiteboard where the text is in cursive. It's hard to understand and read. And the image itself is also on a very reflective surface. Esto cochina.
I'm asking you to transcribe that content into, uh, Json, schema. And I'm not giving it this game. I'm asking it to come up with a schema that makes sense. Given the information
And you can see that as a result, Claude not only transcribes, it perfectly even the capital letters Uh, but also that Claude is able to pick a Json. Schema that makes sense with the information architecture of the Whiteboard.
The coolest part of this I think is that Claude is able to pull out the very last line of both sides of the Whiteboard. To understand that it's not part of the list above it. So in the Json schema which will give you these slides so you can see it for yourself.
Claude is also separating that from the rest of the list in its results.
I have another demo. I wanted to show you where I want to get to full use in time. So I'm going to show you just the last part of it again. I'll give you these slides so you can see them later.
So the previous slides, I asked Claude to just analyze the picture of this shoe and to come up with information within a given Json schema.
But in this example I am not giving Claude a Json schema up again I'm asking Claude to just write out everything that it can confidently infer from just looking at the image alone. I'm testing cloths, analytical capabilities.
And you can see that in the results, Claude is able to pull out the brand of the shoe, the colors, but also things like the materials and how it has a reflective kind of silver, detail in the back, for example.
Claude is even able to tell that the shoe is made for running on Trails and what kind of terrain such as gravel and dirt.
So I'm excited to see what you guys can do with vision. I think it's, you know, a state of the art in many ways and one of the most Capability. Unlocking areas of the cloth 3 family. Acadero.
So now let's talk about agents and tool use
For those of you who don't know what agents are, it looks a little bit like this.
Quad three especially has really improved agentic capabilities from previous models.
So in this example I have you can see that given a specific user request such as asking for reimbursement for blood pressure medication. Claude is able to analyze the user's goals and then complete a series of tasks that ends in either giving the reimbursement or saying something else that helps the user further along.
You can see that in the list of tasks that Claude is completing there are things like pulling the customer records and running drug interaction. Safety checks, these are all things that Claude can do with toy use. Que con company.
So you can create agent workflows with tool, use and Tool use is really simple under the hood.
It basically consists of a user prompt or a question as well as a list of tools that you've given Claude. And the tools need to just have a name, a description of what the tool is and then all the parameters that you would need to run that tool. De company.
And then you gave all that to Claude. And Claude is able to analyze the question. And then choose the right tool for the situation. So in my example, my question is, what is the final score of the yomiyori Giants game on June 16th 2024 just two days ago.
I'm asking this question because toll use is a really good way to update Clause information when you need to find out information after the training date cut off. So Claude was not trained two days ago. Meaning Claude doesn't actually know this information.
And God is able to in the on the right side of the slide, you can see that quad would pick not only the right tool but also be able to extract the various parameters of the information from the various parameters such as the name of the team as well as the date of the game.
Here's another example, that shows you what you need to do to have successful tool use
In this example, I have three different tools to look up in inventory information, to generate an invoice or to send an email.
And all of these are attached to various functions in your code. So looking up an inventory requires that you query a database or sending an email requires that you connect to an email API.
Claude doesn't have any tools of its own and it doesn't run any of these tools. So you have to write all these functions, and you also have to run them on Claude's behalf.
This allows you much finer control over the types of tools that you create instead of relying on, you know, any simple ones that we might make that aren't fulfilling your specific needs and use cases.
In my next example, I'm going to show you a detailed walkthrough of What it looks like when you call a tool and return the information to Claude,
I'm gonna begin by having a user. Ask a question, like, how many shares of General Motors can I buy with 500? This information is not available in Cloud's trading data, because stock information changes all the time. De Coco de no news.
Paul looks at that question and it knows it has a gen as get stock price tool that we've given it and so it's going to ask you to call the tool. That's what Claude is outputting.
Then when you get information, it's your job to Caught your uh query the stock market API with the information that Claude asked you for and then get that information back and then you can send to Claudid in the next part of the conversation. Um, the results of the tool call.
And then Claude is able to use that information in order to generate an answer for the user. In this case, doing some simple math, to tell the user that they can buy about 11 shares of General Motors at this time with 500.
So you might also know that there's something called agents for Amazon Bedrock, and I want to tell you a little bit about what that is and how that's different and similar to tool used directly with Claude.
So, in the middle, you can see the things that they have in common. The first being well, the series of them being that you can Define the tools. Claude is still able to request what tools to use and you still have to run those tools on your side uh and provide the information to close.
You're also able to see Claude's train of thought as to why it chose the tool and all that in both. The agents frames on Bedrock as well as tool used with anthropic directly.
Then separately outside of that. You have the ability to do Json mode. Which is when you have clogged return, every single tool call that Claude asks you for, Claude will give you the information in a Json schema. So you can use this to your advantage as a, you know, Surefire way to return Json information in Json mode.
You can also force toll use meaning that you can require a claw to definitely use a tool, either a specific tool or one that you gave it from a list of tools.
These more advanced features are capable because with using tool use with anthropic, you're able to see every single step of the process which allows you to take advantage of Json mode or Force tool use.
On top of this, there is agents frames on Bedrock. And what agents does is it builds a layer on top of tool use to abstract away The tool use syntax and structure, which allows you to get started a lot more quickly and easily. But also, you'll have a little bit less finer control over the process.
So with all this being said, I have a few demos to show you and then we can close out the keynote.
And uh, the first one is about a very simple way to use Two used with Claude for customer support.
Mero der, son lyrics.
Then the next demo, I'm going to show you. Is. Using a claw 3 to search the web and find a Find the, the fastest, uh, algorithm of a certain type using orchestration of haiku
Should I know. I don't want you to know it's scary, told you one of this. Sub agent orchestration is when you have a more capable model like, Opus, Call on and write prompts for. A smaller model like haikune in this case is going to do that a hundred times in parallel.
De gusta es me con la es.
So the last time I want to show you is, how you can do this with vision as well.
In this demo, we're given Claude some tools to browse the web. Um, as well as to run the code that it writes and the ability to call on some sub agents. So in this case, Opus will call on haiku
Res Más.
I think the coolest part of this demo is how if you give Claude the ability to run and understand the code that it can uh reason with why it made the mistake and then fix the code and make it better without you having to debug it yourself.
So I have a bunch of useful resources that I will leave you with and we will be notice that and I will give you the slides so that you can see all the different resources here as to how you can. Also, uh, Kind of do more exciting and more advanced work with Claude.
The state on a home. And, With that. Thank you. Thank you so much.

NotebookLMに作成してもらいました。

クロード3プレゼンテーションの概要と要点

本資料は、Anthropic社による「クロード3」プレゼンテーションの内容を日本語でまとめたものです。

主なテーマ:

  • クロード3モデルファミリーの概要
  • クロード3の新機能と強化点
  • 画像認識機能
  • エージェントとツール使用
  • Amazon Bedrock エージェントとの比較

重要なアイデア・事実:

クロード3モデルファミリー

  • Opus: 最大規模で最も高性能なモデル
  • Sonnet: バランスの取れた中規模モデル
  • Haiku: 最速かつ最小のモデル

各モデルは異なるコスト帯で提供され、ユースケースや予算に合わせて選択可能。

クロード3の新機能と強化点

  • 高速化: 複数ツールの連続使用時のレイテンシを改善
  • 操縦性の向上: 短いプロンプトでより高いパフォーマンスと動作を実現
  • 精度と信頼性の向上: コンテキストウィンドウ全体の情報を利用、ハルシネーション率の低下、引用機能の強化
  • 画像認識機能: チャート、グラフ、技術図などビジネスユースケースに特化した画像認識機能を搭載

画像認識機能

  • ビジネス文書に含まれるチャート、グラフ、技術図などを理解
  • アイテムの状態の理解、チャートからのデータ抽出、手書き文字の書き起こしなどが可能
  • 日本語の認識機能は発展途上であり、今後の改善に期待

画像認識機能の効果的な使い方

  1. 画像を指示やクエリの前に配置
  2. 画像にラベルを付ける
  3. 情報を含む画像の場合は、まず情報を抽出してからタスクを指示

エージェントとツール使用

  • エージェントは、ユーザーの要求を分析し、一連のタスクを実行することで目標達成を支援
  • ツール使用により、エージェントワークフローを作成可能
  • クロードはツールを使用せず、ユーザーがツールを提供し、実行する必要がある

ツール使用の成功のためのポイント

  • ツール名、説明、パラメータを定義
  • ツールの実行とクロードへの情報提供

Amazon Bedrock エージェントとの比較

  • 共通点: ツールの定義、クロードによるツールリクエスト、ユーザー側でのツール実行
  • クロード独自の機能: JSONモード、ツール使用の強制
  • Bedrock エージェント: ツール使用構文を抽象化し、容易な利用を実現

デモ

  • 顧客サポートのためのシンプルなツール使用
  • Web検索と高速アルゴリズム探索のためのオーケストレーション
  • 画像認識とコード実行を組み合わせたデモ

注目すべき引用:

  • “Claude is also much more accurate and trustworthy than previous generations meaning, for example, that Claude can Utilize more accurately information all across the context window.”
  • “We believe that this is going to be kind of more increasingly important for businesses and startups, going forward and more of a way that people use models going forward as well.”
  • “The coolest part of this I think is that Claude is able to pull out the very last line of both sides of the Whiteboard. To understand that it’s not part of the list above it.”
  • “Claude doesn’t have any tools of its own and it doesn’t run any of these tools. So you have to write all these functions, and you also have to run them on Claude’s behalf.”
  • “I think the coolest part of this demo is how if you give Claude the ability to run and understand the code that it can uh reason with why it made the mistake and then fix the code and make it better without you having to debug it yourself.”

まとめ

クロード3は、高速化、精度向上、画像認識機能、ツール使用の強化など、多くの点で進化したLLMです。ビジネスユースケースに最適化されており、今後ますます多くの企業やスタートアップで活用されることが期待されます。

画像を扱う場合のプロンプトのチップス

https://docs.anthropic.com/en/docs/build-with-claude/vision#example-one-image

LT① Claude3 on Bedrock(with Converse API + Tool use)でチャットアプリを作成してみた

@recat_125

LT② AWS構成図からCloudFormationとパラメータシートを自動生成するシステムを作ってみた

@tsukuboshi0755

LT③ LangChain Agent with RetrieverをBedrock(Claude3 Opus)で実装してみる

@meitante1conan

LT④ AWS BedrockでLLMOps / 評価をどう行うのか?

@ry0_kaga

その他

AWS Summit Day1で今日Anthropicで話されたMeggle VoがAWS SAと相談できるセッションがあるようです。

2024年6月18日
から hiruta
Bedrock開発入門書籍レビュー はコメントを受け付けていません

Bedrock開発入門書籍レビュー

最初に、献本をいただき、ありがとうございました。

第1章 生成AIの基本と動向

生成AIの機械学習のなかでの位置づけの基本から生成AIの代表的なプロダクトについての概要解説されています。

第2章 AWSの生成AIサービス Amazon Bedrock入門

アウトプットは、Qiita、DevelopersIOのほかに、Zennにもあります。

https://zenn.dev/topics/bedrock

 

Bedrockにリクエストしたデータはモデルの学習に利用しないのでビジネスユースにも使えます。

Model lifecycleが設定されていて、古いバージョンのモデルはつかえなくなることがあります。直近だと、Claude v1.3、Titan Embeddings – Text v1.1が該当します。

https://docs.aws.amazon.com/bedrock/latest/userguide/model-lifecycle.html

※限定プレビューですが、アカウントマネージャ経由でないと利用できないことがあります。

Bedrockを実際に試せるセッションでは、Playground、API boto3からBedrock APIを利用する方法が細かく記載されています。

Converse API では、invokeModelだとbase64にエンコードする必要がありましたが、bytesをそのままコンテキストに読み込ませることが可能です

テキストでは、Python 3.9をベースに記載されていますが、Python 3.12.3でも問題ありません。

第3章 生成AIアプリの開発手法

実際生成AIアプリを開発するうえでのプロンプトの基礎を学べます。

書籍では、Langchain 0.2に対応されています。(アップデートの激しい分野にもかかわらず、書籍執筆中に最新情報を取り入れられるものは取り入れられています)

トークン数をカウントできるtypescriptも公開されています。issueはあがっていますが、こちらもCluade 3には現在未対応。

https://github.com/anthropics/anthropic-tokenizer-typescript

tiktoken https://github.com/openai/tiktoken

ChatBedrockはAWS_DEFAULT_REGIONあるいは、.aws_configを参照する。ChatBedrockのregion_nameで指定することも可能。

  Error raised by bedrock service: Did not find region_name, please add an environment variable `AWS_DEFAULT_REGION` which contains it, or pass `region_name` as a named parameter. (type=value_error)

第4章 社内文書検索!RAGアプリを作ってみよう

ベクターデータベースの話から、Agent for knowledge Base、Langchain ( LCEL )での実装方法まで決め細かく解説しています

 

MongoDB Atlas は、M0 Sandboxに関してはスペックは低いですが、1サーバー無料で利用できるので、検証などに最適です。Agent for Knowledge baseで、MongoDB Atlasを使うには、M1以上のスペックになります。

第5章 便利な自律型AIエージェントを作ってみよう

2章のstreamlitとlanghcainのサンプルコードに修正してReActAgent対応させることもできそう

第6章 Bedrock のさまざまな機能を使いこなそう

カスタムモデルインポートはプライベートプレビューなので、import jobのQuotaが承認されることが前提です。

以下発表直後のインポートモデルの説明をされている動画になります。

https://www.youtube.com/watch?v=kDAheDCDDJE

Bedrock Studioは、IAM Identify Center必須なので利用するBedrockリージョンとそろえておかないといけなそうです

第7章 さまざまなAWSサービスとBedrockを連携しよう

Bedrockのリクエスト監視、ログなどBedrockの運用するうえでポイントになることが書かれています

 

第8章 生成AIアプリをローコードで開発しよう

ローコードで実際試せるハンズオン形式でなっています。

こちらのハンズオンもお薦めです。

AWSの生成AIで社内文書検索! Bedrockのナレッジベースで簡単にRAGアプリを作ってみよう

https://qiita.com/minorun365/items/24dfb0ea3afde6ed0a5

6

第9章 Bedrock以外の生成AI関連サービスの紹介

Amazon QについてもSageMaker Canvasについて

Amazon Qビジネスアプリケーション開発を実際試すことが可能です

 

第10章 活用事例

執筆者の所属会社の事例紹介がされています

最後に

Cloud9の構築方法も記載されているので、生成AI初心者に入門書としてお薦めできると思います。

 

 

 

 

索引

AWS Bedrock Documentation

https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-bedrock.html

Anthropic Developer documentation

https://docs.anthropic.com/en/docs/intro-to-claude

Cohere documetation

https://docs.cohere.com/

2024年6月17日
から hiruta
Cloud Native Days Summer 2024 に参加しました #CNDS2024 はコメントを受け付けていません

Cloud Native Days Summer 2024 に参加しました #CNDS2024

地方のCloud native daysへの参加は、Cloud native days Fukuokaに続けて、2イベント目でした。

キーノートセッションから

クラウドネイティブな省エネサービスの内製開発で、BizDevOpsを実現する
https://event.cloudnativedays.jp/cnds2024/talks/2333

Sierに発注すると画面の修正とかも高くなるので内製開発をスタート。
兼業なので人少ないなかでのスタートで苦労話も



Codespacesもそうだけど、ローカル環境だとミドルウェアのバージョンとかMac、Windowsで
変わってしまうが、CodeCatalyst Dev Environemtだと環境共通化できて開発環境構築も楽になる

リードタイム、コストを最適化しながら回復性を求めるクラウドネイティブ戦略
https://event.cloudnativedays.jp/cnds2024/talks/2334

サーバーレスを主としたアーキテクチャ

 

タイムアウト設定が、フロント(API Gateway) <バック(Lambda)の場合、API Gatewayがタイムアウトされても、バックは処理し続けるが、すでにクライアントには50xで返されると不整合がおきるケース

次世代のクラウドネイティブ基盤、Wasmの今と未来
https://event.cloudnativedays.jp/cnds2024/talks/2330

WASMはポータビリティ、Sandboxで動かせる、軽量

jit
https://github.com/wingo/wasm-jit

The AoT Compiler
https://wasmedge.org/docs/start/build-and-run/aot/

WASMはStack machine

Linear Memory
https://wasmbyexample.dev/examples/webassembly-linear-memory/webassembly-linear-memory.rust.en-us

WebAssembly System Interface (WASI)
https://wasi.dev/

wasi-nn もローカルLLMをWASMで動かすことも。

runwasi
https://github.com/containerd/runwasi

jco
https://github.com/bytecodealliance/jco

スポンサーキーノート

エンドツーエンドの可視性を実現するクエスト
https://event.cloudnativedays.jp/cnds2024/talks/2331

インフラモニタリングからRUMのモニタリングまでDatadogで提供している。

state of Cloud Cost
https://www.datadoghq.com/state-of-cloud-costs/

成長し続けるTVerサービスを支えるオブザーバビリティとカスタマーサポート
https://event.cloudnativedays.jp/cnds2024/talks/2338

デプロイ記録をnewrelicで管理
https://newrelic.com/jp/blog/how-to-relic/record-deployment-with-github-actions

デプロイ・QA・Four keys を自動化×見える化する freee の統合デリバリー基盤
https://event.cloudnativedays.jp/cnds2024/talks/2281

開発者体験を向上する
デプロイ禁止日のGoogleカレンダーとの連携で禁止日はできないようなことも
ロールバックできるできないことも

Four keys
https://cloud.google.com/blog/ja/products/gcp/using-the-four-keys-to-measure-your-devops-performance

デプロイのなかにPRが多いとコードの変更もその分含まれるので、不具合起きるケースもありそうかな

Service Weaver で始めるモジュラー モノリス、そしてマイクロサービスへ
https://event.cloudnativedays.jp/cnds2024/talks/2332

Service weaver、モジュール化されたモノリスとして記述してもマイクロサービスとしてデプロイできる

Introducing Service Weaver: A Framework for Writing Distributed Applications
https://opensource.googleblog.com/2023/03/introducing-service-weaver-framework-for-writing-distributed-applications.html

Legacy開発はモジュール間で問題おきないか慎重にならざるをえない。

マイクロサービスでも苦悩がある。

Service Weaverのコアライブラリ、モジューラーなものを別のプロセスに動かせるようにジュネレートしてくれるのか

単一バイナリだけどルーティングなり分散環境にデプロイをよしなにしてくれる
k8s deploymentやserviceの生成もしてくれる。

Service weaverのTracingはOpenTelmetryに依存している

テレメトリーシグナルの相関、してますか?第一原理からのデバッグを支える計装
https://event.cloudnativedays.jp/cnds2024/talks/2243

DB接続エラー、リクエスト量、コネクションなど他の情報があるようにしたい。
第一原理からデバッグできる

テレメトリごとの連携が重要

テレメトリーシグナルの相関は、ログのなかにトレースIDを入れるとか
ログをもとにメトリクスを作るとか、タイムスタンプと量でメトリクスにするとか

Google CloudのGKE logging、構造化ログになっているので、ログからメトリクスへの連携もしやすい

クラウドネイティブにおけるセキュアなソフトウェア・サプライ・チェーンの考え方とベストプラクティス
https://event.cloudnativedays.jp/cnds2024/talks/2336

ソース、ビルド、リポジトリのフェーズで侵害される可能性があるので、Software Supply Shainの対象になる。

クラウドネイティブにおける脅威ポイント
Source Code Theats
Build Theats
Dependency Theats
Deployment Theats

オープンソースに信頼されていないものが含んでいないか
最近だとxzの件もありましたし。

変化と挑戦:NoSQLとNewSQL、Serverless Databaseの技術革新とマルチテナンシーの秘密
https://event.cloudnativedays.jp/cnds2024/talks/2249

DynamoDBもamazonのトラフィック裁くのに作られたDynamoをベースにしている
Cloud SpannerももとはGmailとかつかわれていたSpannerをベースに誕生している

水平スケーリングに強いSQL NoSQL
リレーショナルではない。KVでテーブル設定していく

https://qiita.com/yoshii0110/items/bd71b4479ee71aa6bf53

https://zenn.dev/koiping/articles/76f12a3567da53

Discussion board

Discussion board企画でもこまっていることを議論などされていました。

次回

Cloud Native Days Winter 2024
2024/11/28,29
東京(有明セントラルタワー&カンファレンス)

8/27 KubeDay Japanと同じ会場です。
https://events.linuxfoundation.org/kubeday-japan/

ステンレスキューブを再度にもらいました。

2024年6月3日
から hiruta
THE CLOUD RUN書籍レビュー #技術書典 はコメントを受け付けていません

THE CLOUD RUN書籍レビュー #技術書典

技術書典で購入しましたCloud Run書籍レビューです。

https://techbookfest.org/product/jQP5REJPx6pwMFEyx8QHPN

第1章 Cloud Runとは

ECS Fargate、App Runner、Cloud Runを比較して、Cloud Runの構成シンプルさ、スケールで軍配があがることが書かれている

ECS Fargateのターゲット追跡、ターゲットトラッキングについて書かれていますが、ターゲット追跡以外に、ステップスケーリングの手段もあります。ステップスケーリングだと、CPU負荷等が高まったときにタスク数を複数増やせますが、リクエストをうけつけるまで2〜3分のラグはあるので、スパイクには耐えられない。

第2章 とりあえず触ってみよう

Cloud Run serviceを、Google Cloudのコンソールから作る方法について書かれています。

第3章 Cloud Runによるシステムデザイン

Cloud Run serviceを、Google Cloudのコンソールから作る方法について書かれています。

 

第3章 Cloud Runによるシステムデザイン

 

すべてのCloud Runは、HTTPのエンドポイントを持ちます。

Cloud TaskもHTTP EndpointでCloud Run エンドポイントを叩くことも可

 

一例として、Google WorkflowはHTTP エンドポイントをつなぎ合わせてワークフローを構成できる。

https://cloud.google.com/blog/ja/products/serverless/announcing-direct-vpc-egress-for-cloud-run

 

認証を利用して、特定Service Accountからの通信のみ許可することも可能。

Serverless VPC Connectorの欠点を網羅した、Direct VPC EgressでVPC内部通信も可能。

 Direct VPC Egressのmax instanceのQuotaに注意。

Cloud SQLへの通信、Auth Proxyで、TLSで暗号化できるとはいえ、データベース側がパブリックIP付与するので、データベースパブリック露呈してくなければ、Direct VPC Egressでプライベート通信がいいように思えます。

第4章 プロダクションレディな設計

サービスアカウントキーが漏洩したら、セキュリティ事故に繋がる可能性があるので、キー発行はせず、github actionからGoogle Cloudのサービスにアクセス手段は、Workload identify Federationを推奨。

Cloud Deployは、Skaffoldをベースにしたツールなので、Cloud Runだけでなく、GKEへのデプロイにも対応しています。

Cloud loggingからLog SinkでCloud Storageにも送ることガ可能

Cloud Run serviceには、Compute Engineのデフォルトサービスアカウントが付与されますが、Cloud Run serviceごとにService Acccountを分けたほうがいい。AWSだと、IAM Roleに相当します。

コンテナセキュリティについては、Cloud Runだけでなく他のGoogle Cloudのコンテナサービスにも応用できると思います。

コンテナのCPU負荷は60%前後を維持するのがよさそうか。

Cloud DeployでCPU Brustなどを定義するには、annotationsを定義します。

https://cloud.google.com/run/docs/reference/yaml/v1

Cloud Runに関することが設計思想をふくめて、もりだくさんに書かれている書籍になります。

2024年6月2日
から hiruta
Anthropic Claude 3でのTool useについて はコメントを受け付けていません

Anthropic Claude 3でのTool useについて

Anthropic Claude 3で、VertexAIやBedrockでも、Tool use (Function calling) つかえるようになりました、

https://docs.anthropic.com/en/docs/tool-use

 anthropic 0.28.0 

知りたい地区の天気をLLMに聞くと,locationを返して、Google GenCode API, openweathermap APIで現在の天気を返せるものがサクッと作れるようになりました。

from anthropic import AnthropicVertex
import requests
import json

def main():
    LOCATION = "us-central1"

    client = AnthropicVertex(region=LOCATION, project_id="xxxxxxx")
    response = client.messages.create(
        max_tokens=1024,
        tools=[
        {
            "name": "get_weather",
            "description": "Get the current weather in a given location",
            "input_schema": {
            "type": "object",
            "properties": {
                "location": {
                "type": "string",
                "description": "The city and state, e.g. San Francisco, CA"
                }
            },
            "required": ["location"]
            }
        }
        ],
        messages=[{"role": "user","content": "柏の天気を教えて?"}],
        model="claude-3-haiku@20240307",
    )
    #  print(message)
    print(response.content[-1].input)

    payload = {'address': response.content[-1].input['location'], 'key': 'xxxxxxxxxxxxxxxx'}
    r = requests.get('https://maps.googleapis.com/maps/api/geocode/json', params=payload)
    # print(r.text['results'][0].geometry.location)
    d=json.loads(r.text)
    loc = d['results'][0]['geometry']['location']
    print(loc)
    # curl "https://api.openweathermap.org/data/3.0/onecall
    payload2 = {'lat': loc['lat'], 'lon': loc['lng'], 'lang': 'ja',  'appid': 'xxxxxxxxxxxxxxxxxx'}
    r2 = requests.get('https://api.openweathermap.org/data/3.0/onecall', params=payload2)
    d2 = json.loads(r2.text)
    print(d2['current']['weather'])
if __name__ == "__main__":
    main()
 {'location': '柏, 千葉'}
{'lat': 35.8675958, 'lng': 139.9757575}
[{'id': 500, 'main': 'Rain', 'description': '小雨', 'icon': '10d'}]

 

2024年6月1日
から hiruta
Search Engineering Tech Talk 2024 Springに参加してきました。受講レポート #searchtechjp はコメントを受け付けていません

Search Engineering Tech Talk 2024 Springに参加してきました。受講レポート #searchtechjp

Search Engineering Tech Talk 2024 Spring #searchtechjp

https://search-tech.connpass.com/event/318126/

RAG改善からみたクエリ・ドキュメント理解とリランキング(FRAIM株式会社 水野多加雄 さん)

 

  • 適切なドキュメントが根拠の上位にこない
  • 同じキーワードが含まれる関係のないドキュメントがランクイン
  • ユーザのクエリ意図に合った回答ができていない
  • 用語定義を聞いているのに、関連のオペーレーション方法をかえしてしまう

の課題にたいして、どう改善するコトについての話

  • SetFit
  • Reranking
    • japanese-reranker Cross-Encoder ベースモデルを日本語データセットJSQuAD等を用いて学習したもの

自然言語処理シリーズ-2 質問応答システム
質問応答タスクの分析が詰め込まれている。RAG改善のヒントになれそう
https://www.coronasha.co.jp/np/isbn/9784339027525/

文書登録時のチャンク、メタデータでドキュメントを絞り混むことが大事になる。

MongoDB Atlas Search, Vectorsearchの紹介、デモ (MongoDB Singapore 林田千瑛 さん)

MongoDB Atlas Searchの特徴の説明がありました。

データベース、検索エンジンが分離されていると、同じデータだけどOLTPと検索を二重持ちデータ同期も複雑。パイプラインの開発も必要
レイテンシー劣化も起こる

MongoDB は、3つのシステムを1つに集約データの同期も必要ない
セキュリティも安全

MongoDBトは別にAtlas ノードがある
インデックス更新も同時にされり

20240320 MLOps勉強会 v39
https://www.youtube.com/live/x24JCS-XLGU?si=Bs7IgxIPcZiHeB-X&t=584

検索失敗率のモニタリングから改善まで (株式会社ユーザベース 崔 井源 さん)

検索しても記事や動画を開かず離脱したものを検索失敗している
ここをモニタリング

プッシュ通知の文言で検索して失敗
既存は公開日順なので古い記事はなかなかでない

検索キーワードとして登録
通知されたコンテンツをアプリでみつけるのが難しいので検索ホーム
ラインキングロジックを改善
公開してからの経過日数、人気度合いをバランス良く考慮
重みを元に

Elasticsearchでトークンのオフセットがズレるバグについて (株式会社LegalOn Technologies 神田 峻介 さん)

Lucene.Elasticserach Character Filer
ユニコード正規化するとトークンのオフセットに不正の値が入るバグ
頻繁におきるものではない

Doc Character Filter TokenizerToken Filterで登録される
ユニコード正規化、形態素解析、ストップワード除去など

start_offsert
end_offset

平成が人文字の一個のunicodeとして
空文字列として認識してしまう

CharFilter offsets correction is wonky https://issues.apache.org/jira/browse/LUCENE-6595

対象外にしても、0.12%と検索結果への影響は少なそう

char_filter
unicode_set_filter https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis-icu-normalization.html

2023年6月25日
から hiruta
Amazon CodeWhispererセットアップしてみました。Identify Center 編 はコメントを受け付けていません

Amazon CodeWhispererセットアップしてみました。Identify Center 編

AWS Dev Day 2023のGeneral Sessionでも触れられて、Reject Dayでも、Dev Day のCFPに使っているスクリプト、ほぼCodeWhisperer でコード作成しているなど、注目のプロダクトです。

Github Copilot、Duet AI for code assistance などCode Generateがでています。

Organizations 配下のAWSアカウントでは、単独ではセットアップできない。

Oraganizationsの管理アカウントから有効化する必要があります

ユーザに紐付いたら、IAM Identify Centerのポータルに下記が追加されます

ここからは、Visual Studio Code(以下VSCode)側の作業になります。

前提として、AWS Toolkit拡張がインストールされていることが前提になります。

VSCodeから、AWS IAM Identify Centerに接続

Identify Center URL

リージョン選択

IAM Identify Centerのリージョンを選択

VSCodeの通知ウィンドウに、コードが表示されます

表示されたコードをブラウザの下記に入力

AWS Toolkitからアクセスを許可

これでCodeWhispererガ利用できます。

awk も対応しているようです。

# awk filter for test file
# Usage: ./test.sh < test.txt
awk '

BEGIN {
    # Set the field separator to a comma
    FS=","

    # Set the output field separator to a comma
    OFS=","

    # Set the output record separator to a newline
    ORS="\n"

    # Set the input record separator to a newline
    RS="\n"
}

{
    # Print the first field
    print $1
}

END {
    # Exit with a success error code
    exit 0
}

2023年6月17日
から hiruta
一番安価なCloudflare RegistrarにGoogle Domainsからドメイン移管してみました。 はコメントを受け付けていません

一番安価なCloudflare RegistrarにGoogle Domainsからドメイン移管してみました。

Google DomainsがSquarespaceに事業譲渡されるアナウンスがありました。

https://support.google.com/domains/answer/13689670?sjid=4934868726297743719-AP

想定する移行先の年間料金
TLD .bizの場合

Cloudflare Registrar $13.68
Google domains $15
Route53 19.00 USD
さくらインターネット 3,340円 = $23.55 ※1$ = ¥141.84で換算

上記で一番安価なCloudflare RegistrarにGoogle DomainsでホストしているドメインをTransferしてみました。

https://www.cloudflare.com/products/registrar/

移管元で、Privacy、Transfer lockしている場合は解除しておく。

移管手続きの流れ

Cloudflare accountを作成

(https://dash.cloudflare.com/sign-up)
cloudflareのBillingでPayment info情報を登録

Websitesの作成

移行元のホストゾーンに登録している情報をCloudflareのDNS Recordsに追加してくれる

Cloudflare Nameservers情報を移行元のNSに追加

Cloudflare Namerserversが認識されたら、移行元のNS情報を削除

(反映されるまで数時間かかる。)

下記表題のStatus Activeになった旨のメールが届く

[Cloudflare]: xxxxxx is now active on a Cloudflare Free plan

Domain Registration のTransfer Domainsから移行手続きがおこなえるようになります。

移行元で取得しておいたauthorization codeをいれる

Transfer request受け付けたメールが届く

Your transfer to Cloudflare Registrar is underway

Google Domains からの移管リクエストを確認する

移行元(この場合、Google Domains)から移管リクエストを承認するメールが届くので下記表題のメール文中に記載されている移管をキャンセルまたは承認リンクで承認する

承認したあとでCloudflareから購入がクレジットカードからチャージされた旨のメールが届く。

Your Cloudflare Purchase Confirmation

Transfer完了のメールが届き、移管完了となります。

Your transfer to Cloudflare Registrar has completed!

所感

defaultでWHOIS privacyに対応している。

Proxiedというモードだと、originのIPアドレスを隠蔽するが、wp-login.phpでTOO MANY REDIRECTとリダイレクトループでエラーになってしまっているので、現状DNSに戻しています。

こちらの設定をすることで解消。

https://developers.cloudflare.com/ssl/troubleshooting/too-many-redirects/

What is the difference between “Proxied” and “DNS Only”?
https://community.cloudflare.com/t/what-is-the-difference-between-proxied-and-dns-only/173310

Cloudflare REgistrar and WHOIS privacy
https://community.cloudflare.com/t/cloudflare-registrar-and-whois-privacy/36225

Request Cloudflair Registrar To Support .Dev Domain
https://community.cloudflare.com/t/request-cloudflair-registrar-to-support-dev-domain/330897

2023年6月11日
から hiruta
Kendra HANDS-ON 参加レポート はコメントを受け付けていません

Kendra HANDS-ON 参加レポート

はじめに

6/10(土)に開催された「JAWS-UG横浜 #58 Amazon Kendra HANDS-ON」を参加しました。

Kendraの基礎的説明をAWS関谷様から説明していただき、下記ブログ記事をベースに、streamlit + OpenAI & Kendra のアプリを作成するハンズオンでした。

https://aws.amazon.com/jp/blogs/news/quickly-build-high-accuracy-generative-ai-applications-on-enterprise-data-using-amazon-kendra-langchain-and-large-language-models/

イベントページ

https://jawsug-yokohama.connpass.com/event/279141/

kendra とは

kendra 、ML coreも含まれていて、セマンティック検索も行えて、$1,008/month(Enterprice edition)はコストパフォーマンスはいいのでは。

$810のDeveloper Edtion もあり

説明の資料は公開されないので、kendraについては詳しそう

ハンズオン

streamlintを利用して、便利なオープンソースのアプリフレームワークで、簡易なChatアプリを作れます。

LLMsとして、OpenAIを利用したので、Flan-T5-XL、Flan-T5-XXLのモデルをSageMaker Studio Jump Startからデプロイすることはなかったが、これらのモデルをデプロイするのに、ml.g5.2xlarge 、ml.g5.12xlargeを使うようで、これらのインスタンスタイプは、デフォルトは、Quota 0でデプロイできないので、Quota requestが必要。

OpenAIのFree Trial Userはたたけますが、三ヶ月経過した無料アカウントではAPIたたけなくなります。

https://help.openai.com/en/articles/4936830-what-happens-after-i-use-my-free-tokens-or-the-3-months-is-up-in-the-free-trial

本家のOpenAIを利用しますが、AzureOpenAIを使うのは、下記のように変更することで対応できます

openai.api_type = "azure"
openai.api_base = "https://xxxxxx.openai.azure.com/"
openai.api_version = "2023-03-15-preview"
openai.api_key = OPENAI_KEY

def generate_response(input_text):
  llm = AzureOpenAI(
    deployment_name="text-davinci-003",
    model_name="text-davinci-003", 
    openai_api_base=openai.api_base,
    openai_api_version=openai.api_version or "",
    openai_api_key=openai.api_key or "",
)

補足

SageMaker Studio domainの削除は、下記にはManagement consoleから削除できるようになっているが、削除する項目が見つからなかった。

AWS CLIでは削除するようになります。

https://docs.aws.amazon.com/sagemaker/latest/dg/gs-studio-delete-domain.html

Kendra、Connectorで、S3、Google Driveなどのデータも検索対象にすることが可能。インデックス作成に多少時間がかかる

2023年1月2日
から hiruta
2022年の振り返りと2023年の抱負記事 はコメントを受け付けていません

2022年の振り返りと2023年の抱負記事

2020から更新されてなかった個人ブログにリセットの意味で2022年の振り返りと2023年の抱負記事を投稿します

 

2022年の仕事

技術スタックとしては、Computeとして、Fargate、キャッシュ層として、ElasitCacheAPI層として、API Gateway、サービス間通信は、サービスメッシュとして、AppMeshCloudMapを活用して、AWS CDK によるインフラ構築を主に行ってきた。

12月に上記基盤を使ったものをサービスインできた。

サービスの制約等があり、理想な構成にはなっていないところもあり(メッシュからEgress通信制御、Prometheus

 

参加オフラインイベント

Innovators Hive at Google Cloud Next’22

Google Cloud Next’22の最後の日に招待制のイベント。2022年は主にオンラインイベントでしたが、ひさしぶりのオフラインイベントでした。

KubeDay

Sidecarless Ambient MesheBPFPodSecrurityStandardkyvernoのセキュリティについて気になった

 

登壇LT)

awsCustomResourceAurora Serverless v2リソースを作成してみた

https://docs.google.com/presentation/d/1uhI_LKlp_J2twNoLxHwByClsMIJ4fW-worZhHr6BBBs/edit?usp=sharing

上記作成した当時は、AWS CDK L1 Constructsすらまだ対応しておらず、

AWS Custom Resourceを利用して作成した発表資料になります。

https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.custom_resources-readme.html

技術検証

GKE Autopilot

当ブログもGKE Autopilot + HTTPS Load Balancer + CloudSQL MySQL 5.7で作られています。

ECS Service Connect

ECS Service間でFastAPI で実装したアプリで動作確認した環境を作れます。

https://github.com/clouddev-code/ecs-service-connect-demo.git

上記で利用しているアプリは、Backgroundなタスク(スリープ60s) なものを実行するアプリで確認

https://github.com/clouddev-code/fastapi-sample.git

Django grpc framework

https://github.com/fengsp/django-grpc-framework

Django gRPCなサービスの環境をつくり、検証中

2023年に向けて

Cloud nativeな技術をつかいこなせるようにする

istioPrometheusgRPC

海外カンファレンスへの参加

https://events.linuxfoundation.org/kubecon-cloudnativecon-europe/