[ワークショップ] #MFG301 Connect machines and map industrial data at scale using generative AI に参加して、産業 IoT での生成 AI の活用について学びました #AWSreInvent

2023.11.29

こんにちは、CX 事業本部 Delivery 部の若槻です。

今回は、AWS re:Invent でワークショップ「MFG301-R | Connect machines and map industrial data at scale using generative AI」に参加して、産業 IoT での生成 AI の活用について学んできたのでレポートします。

Factories are often full of machines, and it can be cumbersome to connect and map these disparate datasets to a standard machine informational model for future analysis. In this builders’ session, learn how to use a generative AI model trained with custom machine definitions to automatically connect factory machines at scale and map the data. Explore how you can use the data and data models with various AWS services, from AWS IoT Greengrass to your data lake, including AWS IoT TwinMaker. You must bring your laptop to participate.

(日本語訳) 工場には機械がたくさんあることが多く、将来の分析のためにこれらの異種データセットを標準的な機械情報モデルに接続してマッピングするのは面倒な場合があります。 このビルダー セッションでは、カスタム マシン定義でトレーニングされた生成 AI モデルを使用して、工場のマシンを大規模に自動的に接続し、データをマッピングする方法を学びます。 AWS IoT Greengrass から AWS IoT TwinMaker などのデータレイクまで、さまざまな AWS のサービスでデータとデータモデルを使用する方法を検討します。 参加するにはラップトップを持参する必要があります。

なお、本セッションのタイプは「Builders' Session」なのですが、本記事では便宜的に「Workshop」と表現しています。

セッション情報

  • セッションタイプ
    • Builders' Session
  • トピック
    • AI/ML
    • Internet of Things
  • 日時
    • Nov. 27 2023
    • Monday
    • 3:00 PM - 4:00 PM (PST)
  • 会場
    • Caesars Forum
    • 1F
    • Academy 416
  • レベル
    • 300 - Advanced
  • 関心のある分野
    • Edge Computing
  • 業界
    • Manufacturing & Industrial
  • 役割
    • Data Scientist
    • Developer/Engineer
    • Solution/Systems Architect
  • サービス
    • Amazon SageMaker
    • AWS IoT Greengras

入場

予約していたので順番待ち無しで入場できました。外には Walk-up に 20 人ほど並んでおり、人気のセッションであるようでした。

会場には 6 つの机があり、それぞれに約 5 人ずつ計 30 名くらいの参加者がいました。

席について PC および自前のモバイルティスプレイをセットアップします。

モバイルティスプレイについては昨年にいくつかのワークショップに参加した際にマルチディスプレイの必要性を痛感し、今年は日本から持参しました。

産業プロトコルの乱立を生成 AI で解決する

冒頭で SA のスタッフの方からワークショップの目的について説明がありました。

下記は、競合する標準(スタンダード)が 14 個もあるため、それらのすべてをカバーする標準を作ったところ、15 個目の標準になってしまっただけというネットミームの画像です。

それと同じことが産業プロトコルでも起きています。様々なマシンの異なるプロトコルのデータを IT システムに接続して使用可能にする「マッピング」を行うのは大変です。

そこで、生成 AI を使って、そのマッピング用のコードを自動生成するというのがこのワークショップの目的です。

下記では Amazon Bedrock を使って生成したコンポーネントを AWS IoT Greengrass にデプロイし、PLC から取得したデータをマッピングして IoT Core に送信するというものです。

ワークショップ実施

いつもの Workshop Studio でハンズオンを進めていきます。

Amazon Bedrock のプレイグラウンドでプロンプトを入力し、実行します。使用するモデルは Anthropic の Claude v2 です。

この時使用したのは以下のプロンプトです。PLCOpen ファイルを取得して PLC が提供するインターフェイスと変数に関する必要な情報を抽出できるように XML で定義しています。

Human: As a developer, I want to access the variables on a Beckhoff PLC with the following PLCOpen specification:

<variable name="Pressure">
    <type>
      <REAL />
    </type>
    <addData>
      <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation">
        <Attributes>
          <Attribute Name="OPC.UA.DA" Value="1" />
          <Attribute Name="OPC.UA.DA.Access" Value="1" />
        </Attributes>
      </data>
    </addData>
  </variable>
  <variable name="SpindleSpeed">
    <type>
      <INT />
    </type>
    <addData>
      <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation">
        <Attributes>
          <Attribute Name="OPC.UA.DA" Value="1" />
          <Attribute Name="OPC.UA.DA.Access" Value="1" />
        </Attributes>
      </data>
    </addData>
  </variable>

Write the Python code to read the global variables found in the PLCOpen file via OPC UA.
The OPC UA server has the ip address 10.0.100.100 and runs on port 4840.
The variables are using the default OPC UA node hirarchy and namespace from Beckhoff.
Use the library python opcua to read out all variables one time and print them out.

またパラメーターを次のように指定して、モデルの「創造性」を最小限に抑え、実行可能なコードが取得できる可能性を上げるようにします。

  • Temperature: 0
  • Top P: 0.999
  • Top K:1

プロンプトを実行すると次のコードが生成されました。

Assistant:
 Here is the Python code to read the global variables from the Beckhoff PLC via OPC UA:

import opcua
from opcua import Client

url = "opc.tcp://10.0.100.100:4840"
client = Client(url)
client.connect()

# Namespace and node ids from Beckhoff
ns = client.get_namespace_index('http://beckhoff.com/OPC/UA/GlobalVars')
pressure_node = client.get_node(ns, 'Pressure')
speed_node = client.get_node(ns, 'SpindleSpeed')

pressure = pressure_node.get_value()
speed = speed_node.get_value()

print(f"Pressure: {pressure}")
print(f"Spindle Speed: {speed}")

client.disconnect()

This creates an OPC UA client, connects to the Beckhoff PLC, gets the namespace index and node ids for the variables, reads the value attributes, and prints them out. The namespace and node ids match the default Beckhoff conventions for exposing global variables via OPC UA.

しかしこのコードを実行すると、下記のようにエラーが発生しました。

と言うのも、ワークショップの解説によるとコードが適切に実行されないケースは 15%ほどあるとのことです。

In the previous chapter, we have generated code and in most cases this "one-shot prompt" approach delivers executable code. But there are typically 15% of the cases where the results do not properly execute. For instance, the code below is a possible result that Claude v2 generates with the one-shot prompt discussed in the previous chapter.

というわけで正答例のコードを実行すると、変数を取得することができました。実際には正しいコードが生成されるまで、何度もプロンプトを入力してコードを生成する必要があります。

おわりに

ワークショップ #MFG301 Connect machines and map industrial data at scale using generative AI に参加して、産業 IoT での生成 AI の活用について学びました。

製造産業を工場からスマート化するスマートファクトリーという概念が叫ばれて久しいですが、実際には現場では多くの種類の PLC による産業プロトコルが乱立しており、統一的なフォーマットを得るためにデータのマッピングに多くの時間を費やさなければならないという泥臭い現状があるようです。

しかし産業プロトルに精通している人材は限られているため、生成 AI を使うことにより、そのマッピング作業を効率的に行うことができるようになるというものでした。

ワークショップを通じて、産業 IoT での現状のペインと、それを解決するための一手段として生成 AI が役立ちうるということを学ぶことができました。

以上