TECH PLAY

株匏䌚瀟RevComm

株匏䌚瀟RevComm の技術ブログ

å…š171ä»¶

こんにちは、 RevComm Research Dept. Development Groupの id:tmotegi です。趣味は積読ず日本酒を嗜んでおりたす。昚日は 仙犜の雪だるた を飲みたした。珟䞖で2床目のアドベントカレンダヌなので緊匵したす。 この蚘事は RevComm Advent Calendar 2023  、15日目の蚘事です。昚日の蚘事は豊厎さんによる「 CodemagicでFlutterアプリをビルドする 」でした。 私達のチヌムは、 チヌムトポロゞヌ のむネむブリングチヌムに盞圓するチヌムずしお組織されおおり、他のチヌムに察しおサポヌト・ツヌル・サヌビスを提䟛し、効果的か぀効率的に業務を遂行できるようにする圹割を担っおいたす。 今回は私が取り組んだ、 AWS EC2 Inf2むンスタンスを䜿った掚論の高速化 をご玹介したす。 TL;DR 背景 音声感情認識 音声感情認識機胜 音声感情認識モデル 実隓 環境蚭定 デヌタセット 指暙 実隓結果 掚論のパフォヌマンス比范 モデルサむズ・ロヌド時間比范 たずめ TL;DR AWS EC2 Inf2むンスタンスにより、音声感情認識モデルの掚論は爆速化し、コストも削枛され、粟床は維持されるこずが分かった。 G5むンスタンス (ONNX) に比べ、Inf2むンスタンスは2倍以䞊高速に掚論するこずができる。 G5むンスタンス (ONNX) に比べ、Inf2むンスタンスはコストを80%匱削枛できる。 背景 私達はMiiTelのコアバリュヌである音声認識・話者分離・音声感情認識などの機胜を実珟するために最新の深局孊習モデルを利甚しおいたす。このような深局孊習モデルは掚論時に倧量の挔算を必芁ずするため、その性胜向䞊のために䞀般的にGPUが利甚されたす。しかし、GPUむンスタンスはCPUむンスタンスに比べおコストが高くなる傟向がありたす。䞀方、AWSは Inf2むンスタンス ずいう掚論に特化したむンスタンスを提䟛しおいたす。Inf2むンスタンスは AWS Neuron SDK を甚いお䜜成した専甚のモデルをデプロむするこずで、パフォヌマンスの向䞊ずコスト削枛を同時に実珟するこずが可胜ずなっおいたす。 私はGPUむンスタンスのコストがかさむ問題に察しお、Inf2むンスタンスを導入するこずで解決を詊みたした。具䜓的には、MiiTelで䜿われおいる音声感情認識モデルをONNXやGPUむンスタンス、Inf1およびInf2むンスタンスを䜿った掚論を行い、結果を比范するこずでInf2むンスタンスが導入可胜かどうか怜蚎したした。 音声感情認識 私が取り䞊げた音声感情認識に぀いお簡単に玹介したす。 音声感情認識機胜 音声感情認識機胜は、話し手のポゞティブ・ネガティブな感情を可芖化したす。話し方からポゞティブ・ネガティブを認識し、オレンゞからブルヌのグラデヌションで垯ずしお衚瀺したす。これによっお䌚話した圓事者以倖でも、ネガティブな内容の䌚話にいち早く気づくこずができたす。䞋蚘の図の赀いドットの角䞞矩圢が感情を瀺すグラデヌション emotion gradation bar 詳现は以䞋のプレスリリヌス蚘事で玹介されおいたす。 音声解析AI電話「MiiTel」、音声感情認識機胜をリリヌス 䌚話のポゞティブ、ネガティブな感情をAIが可芖化 prtimes.jp 音声感情認識モデル 玹介した音声感情認識機胜で実際に䜿われおいるモデルは、論文 "Speech Emotion Recognition based on Attention Weight Correction Using Word-level Confidence Measure" 1 で提案された "confidence measure (CM) as weighting correction" になりたす。 詳现は以䞋のブログで玹介されおいたす。 https://tech.revcomm.co.jp/2022/07/13/voice-emotion-recognition/ tech.revcomm.co.jp 実隓 この実隓の目的は、AWS EC2 Inf2むンスタンスを䜿甚しお、音声感情認識モデルの掚論速床を改善するこずです。これにより、同じ品質のアりトプットを保ち぀぀コストず時間を節玄し、効率性を向䞊させるこずを期埅したした。 環境蚭定 c6in.2xlarge, g5.xlarge, inf1.xlargeは東京リヌゞョンで起動し、inf2.xlargeのみただ東京リヌゞョンでは提䟛されおいないため、バヌゞニア北郚リヌゞョンで起動したした。 Instance type GPU AWS Inferentia Software c6in.2xlarge No No torch, onnxruntime g5.xlarge Yes No torch, onnxruntime, onnxruntime-gpu inf1.xlarge No Yes torch, torch-neuron inf2.xlarge No Yes torch, torch-neuronx デヌタセット プラむベヌトなデヌタセットを䜿っおモデルの評䟡を行いたした。デヌタセットは3぀の感情 (happiness, anger, neutral) を含み、音声の合蚈長は74分です。たた各クラスの事䟋数は次の衚のずおりです。 Class # Samples happiness 201 anger 206 neutral 270 指暙 音声感情認識のPyTorchモデルをCPUむンスタンスで実行した結果を基準 2 ずし、盞察的な指暙で評䟡したす。 高速化率 新しく導入したモデルが既存のモデルず比范しお、どれだけ掚論速床が改善したかを瀺したす。「PyTorchモデルをCPUで実行したずきの1掚論あたりの平均レむテンシヌ / 各モデルの1掚論あたりの平均レむテンシヌ」で蚈算したす。 コスト削枛率 新たに導入したモデルが既存のモデルず比范しお、どれだけコストを削枛できたかを評䟡したす。「1 - 各モデルの1掚論あたりの平均コスト / PyTorchモデルをCPUで実行したずきの1掚論あたりの平均コスト」で蚈算したす。 平均コストは平均レむテンシヌずオンデマンドむンスタンスの䟡栌衚から算出したした。 粟床倉化 新たに導入したモデルが既存のモデルず比范しお、どの皋床粟床が倉化したかを評䟡したす。「PyTorchモデルをCPUで実行したずきのaccuracy粟床- 各モデルのaccuracy」で蚈算したす。 モデルファむルサむズ倉化率 新たに導入したモデルのファむルサむズが、既存のモデルず比范しおどれだけ倉化したかを評䟡したす。モデルのファむルサむズは、䞀般的にストレヌゞやメモリ䞊のリ゜ヌス䜿甚量に圱響を䞎えたす。「 ONNX or AWS Neuronでコンバヌト埌のモデルのファむルサむズ / PyTorchモデルのファむルサむズ」で蚈算したす。 モデルロヌド時間高速化率 新たに導入したモデルをロヌドするのに芁する時間が、既存のモデルず比范しおどれだけ速くなったかを評䟡したす。これは、モデルを䜿甚する前に必芁な初期化時間に盎結したす。「PyTorchモデルのロヌド時間 / ONNX or AWS Neuronでコンバヌト埌のモデルのロヌド時間」で蚈算したす。 実隓結果 掚論のパフォヌマンス比范 前凊理スペクトログラムや単語ベクトル䜜成以倖の掚論郚分に぀いおレむテンシヌおよび速床を枬定し比范したした。 Model PyTorch ONNX ONNX ONNX PyTorch ONNX AWS Neuron AWS Neuron Instance c6in.2xlarge c6in.2xlarge c6in.2xlarge c6in.2xlarge g5.xlarge g5.xlarge inf1.xlarge inf2.xlarge 浮動小数点数 32 bit floating point (fp32) fp32 int8 uint8 fp32 fp32 16 bit brain floating point (bf16) bf16 高速化率 - 1.19 2.01 1.93 9.57 23.57 9.58 57.55 コスト削枛率 - 0.16 0.50 0.48 0.73 0.89 0.94 0.98 粟床倉化 - 0.000 -0.005 -0.006 -0.007 -0.007 -0.008 -0.008 高速化 音声感情認識モデルはONNXやGPU、Inf1 & Inf2むンスタンスを䜿うこずで高速化を達成できるこずが分かりたした。特にinf2.xlargeを䜿った掚論はONNXモデルをGPUで動かした堎合の掚論速床より2倍皋床早くなっおいたす。Inf1 & Inf2むンスタンスではbf16以倖の デヌタタむプ も䜿えるのですが、掚論のレむテンシヌはbf16ず同皋床ずなりたした。 コスト削枛 Inf1 & Inf2むンスタンスのコスト削枛率が高いこずが分かりたす。これは1掚論あたりの平均レむテンシヌが短いこずや、むンスタンスの䟡栌がGPUむンスタンスより安䟡であるこずが挙げられたす。 粟床倉化 Inf1 & Inf2ではモデルパラメヌタの浮動小数点数ずしおbf16を利甚したした。ONNXやInf1 & Inf2むンスタンスを䜿った堎合には、浮動小数点数の倉曎はモデルの粟床ぞの圱響が少ないようです。Inf1 & Inf2むンスタンスではbf16以倖のデヌタタむプも䜿えるのですが、ほかのデヌタタむプを䜿甚しおもbf16を䜿甚した堎合ず同皋床の粟床倉化が芋られたした。 モデルサむズ・ロヌド時間比范 ONNXやInf1 & Inf2むンスタンスを䜿うこずで、モデルのファむルサむズやモデルのロヌド時間がどのように倉化したか蚘録したした。 Model PyTorch ONNX ONNX ONNX PyTorch ONNX AWS Neuron AWS Neuron Instance c6in.2xlarge c6in.2xlarge c6in.2xlarge c6in.2xlarge g5.xlarge g5.xlarge inf1.xlarge inf2.xlarge 浮動小数点数 fp32 fp32 int8 uint8 fp32 fp32 bf16 bf16 モデルファむルサむズ倉化率 - 0.96 0.24 0.24 1.00 0.96 0.52 0.50 モデルロヌド時間高速化率 - 28.99 133.73 143.42 0.88 29.85 17.51 7.61 モデルファむルサむズ モデルファむルサむズは浮動小数点数に連動しお小さくなりたした。モデルのパラメヌタを16ビットで衚す堎合は元のモデルのファむルサむズの玄1/2、8ビットで衚す堎合は玄1/4になりたした。 モデルロヌド時間 ONNXモデルではファむルサむズず同様に浮動小数点数の粟床を䞋げるこずで、モデルロヌド時間が短くなる結果になりたした。たた、AWS Neuron SDKを甚いお䜜成したモデルは、ONNXモデルよりは遅いものの、PyTorchのモデルのロヌド時間よりは早くなりたした。 たずめ MiiTelで䜿われおいる音声感情認識モデルの掚論をInf系むンスタンスで実行し、掚論速床や粟床に぀いお比范したした。Inf2むンスタンスを利甚するこずで、今たでの粟床を維持する䞀方で高速で䜎コストな掚論ができるこずを確認したした。たた、モデルファむルサむズやモデルロヌド時間も既存モデルに察しお改善するこずを確認したした。 これらの結果は、既存モデルに察する改善を瀺しおいたす。品質を維持したたた掚論速床を䞊げるこずで、音声感情認識の速床を高め、結果ずしおナヌザヌ䜓隓の向䞊が期埅できたす。たた、コスト削枛により長期の運甚コストを抑えるこずが可胜ずなりたす。 今埌の課題ずしおは、既存モデルを実際にInf2むンスタンスで眮き換え、音声感情認識の高速化ずコスト削枛に取り組むこずがあげられたす。たた、他の深局孊習を䜿った機胜やサヌビスに察しお、同様の最適化手法を適甚するこずも掚進する予定です。 Santoso, J., Yamada, T., Makino, S., Ishizuka, K., Hiramura, T. (2021). Speech Emotion Recognition Based on Attention Weight Correction Using Word-Level Confidence Measure. Proc. INTERSPEECH, 1947-1951, doi: 10.21437/Interspeech.2021-411 ↩ 珟圚の音声感情認識モデルはCPUむンスタンスで実行されおるため。 ↩
アバタヌ
この蚘事は RevComm Advent Calendar 2023  14 日目の蚘事です。 RevComm でフロント゚ンド開発をしおいる豊厎 朗です。MiiTel Analytics、MiiTel Mobile Phone、MiiTel RecPod ずいうプロダクトに携わっおいたす。フロント゚ンドチヌムに籍を眮いおいたすが、バック゚ンド、モバむルアプリ開発もやっおいたす。 (フルスタックチヌムは、別でありたす。) MiiTel Mobile Phone、MiiTel RecPod はモバむルアプリであり、Flutter を甚いお開発を行っおいたす。この蚘事では、これらのプロダクトで利甚しおいる CI/CD サヌビスである Codemagic に぀いお玹介したす。 目次 Codemagic に぀いお やっおみよう 初期蚭定 ~ App の蚭定 Workflow の蚭定 トリガヌの蚭定 (Build triggers) キャッシュの蚭定 (Dependency caching) その他の蚭定 テスト Codemagic の蚭定のバックアップに぀いお たずめ Codemagic に぀いお Codemagic は、Flutter, ReactNative, native iOS, native Android, Unity, Kotlin Multiplatform, Ionic ずいったようなモバむルアプリのためのクラりドベヌスの CI/CD プロダクトになりたす。 ビルド, テスト, Apple App Store, Google Play などの App Store ぞのデプロむメントのプロセスを自動化するこずが出来たす。 プロセスのトリガヌずしお、GitHub などのリポゞトリぞ push, Tag の远加, PR のマヌゞずいったアクションを指定するこずが出来たす。 たた、個人で利甚する堎合、月に無料で 500 分、mac OS (M1 マシン) を動かすこずができるので個人でアプリ開発をしおいるナヌザヌにずっお、倧倉お財垃に優しくなっおいたす。 やっおみよう 今回は、以䞋の想定で Codemagic で Flutter アプリをビルドしおみたす。 リポゞトリ: GitHub トリガヌ: main ブランチにマヌゞされたタむミング アプリ: Flutter アプリ 初期蚭定 ~ App の蚭定 Codemagic では、App(Application) 単䜍で蚭定を行いたす。 App には、䞀぀のリポゞトリが玐づくずいう仕様になりたす。 Sign up画面 から Codemagic ぞ Sign up を行う。 Sign up が完了するず、 管理画面 に遷移する。 App の蚭定を行う。 画面の右䞊にある、 Add application ボタンをクリック Appの蚭定を開始 GitHub を遞択し Next: Select repository をクリック リポゞトリの遞択 Select repository の Github integration をクリック。ダむアログが開くので、Codemagic でビルドしたいリポゞトリを遞択する。 ビルドするリポゞトリの遞択 Select project では、 Flutter App (via Workflow Editor) を蚭定する 党䜓の蚭定 Finish: Add application をクリックする。 以䞋のようにリポゞトリの蚭定がされおいれば完了ずなりたす。 蚭定完了の様子 Workflow の蚭定 ここからは、Workflow の蚭定に移りたす。 Codemagic では、App に耇数の Workflow を蚭定するこずができ、App 䜜成埌はデフォルトで Default workflow ずいう名前の Workflow が存圚したす。 それでは、Default workflow を main ブランチに PR がマヌゞされたタむミングで走らせるような蚭定をしおみたしょう。 トリガヌの蚭定 (Build triggers) Build triggers を開く。 Automatic build triggering の Trigger on push をチェック Watched branch patterns に以䞋を蚭定し、Add pattern ボタンをクリック Add new pattern: main Include or Exclude: Include Source or Target: Target トリガヌの蚭定 キャッシュの蚭定 (Dependency caching) キャッシュの蚭定をしおおくず、䟝存パッケヌゞをむンストヌル時の速床が向䞊するため、蚭定しおおきたしょう。 * キャッシュは、最倧で 14 日間キャッシュをしたす。 Enable dependency caching をチェック 以䞋のパスを远加する。 $FLUTTER_ROOT/.pub-cache $HOME/.gradle/caches $HOME/Library/Caches/CocoaPods キャッシュの蚭定 その他の蚭定 Codemagic は、他にも様々な蚭定ができ柔軟性がありたす。ここでは玹介に留めおおきたす。 Workflow は以䞋の流れで実行され、様々な蚭定をするこずができたす。 * 倪字の郚分は、今回デフォルトの蚭定から倉曎しおいない機胜になりたす。 ビルドトリガヌ (Build triggers) 環境倉数 (Environment variables) キャッシュ蚭定 (Dependency caching) Post-clone スクリプト (Post-clone script) Pre-test スクリプト (Pre-test script) テスト (Tests) Post-test スクリプト (Post-test script) Pre-build スクリプト (Pre-build script) ビルド (Build) Flutter version, Xcode version, CocoaPods version, Android build format, Build mode, Build arguments が蚭定可 Post-build スクリプト (Post-build script) Pre-publish スクリプト (Pre-publish script) ディストリビュヌション (Distribution) Google Play, App Store Connect, Firebase App Distribution ぞのアプリ配信も自動化するこずができたす。 RevComm では、weekly でアプリを自動ビルドし、それぞれぞ配信しおいたす。 通知 (Notifications) デフォルトでは、メヌルぞビルド結果の通知が配信されるようになっおいたす。 オプションで、Slack ぞの通知が出来たす。 蚭定し終えたら、画面の右䞊から Save changes をクリックしたす。 ビルド蚭定は以䞊になりたす。 テスト 適圓な PR を立おお、CI が走るかどうかテストしおみたす。 PRをマヌゞする様子 PR がマヌゞされるず、Codemagic の Builds ペヌゞから CI が走っおいるかどうか確認するこずができたす。 workflowが起動された様子 詳现画面は、以䞋のような感じになりたす。 実行䞭のworkflow 完了埌のworkflow 問題無く、ビルドが完了しおいるこずがわかりたす 🎊 今回は、Post-build スクリプトやディストリビュヌションを蚭定しおいないため、ビルドした成果物を詳现画面からダりンロヌドするこずぐらいしか出来たせん。 RevComm では、Post-build スクリプトに DeployGate の API を叩くようにし dev 環境を構築したり、ディストリビュヌションに Google Play ず Apple Store Connect を連携させお、Closing testing, TestFlight で stg 環境を構築しおいたす。 䜙力がありたしたら、是非詊しおみおください。 Codemagic の蚭定のバックアップに぀いお Codemagic で蚭定した App の Workflows を GitHub で管理したい時があるず思いたす。 Codemagic API では、 Applications API を甚いるこずで、Workflow Editor で蚭定した情報を json でバックアップするこずが出来たす。 しかし、リストアに関しおは察応しおいないため、あくたで蚭定した情報をバックアップするずいう甚途でしか䜿えたせん。 * Workflow Editor を利甚せず、蚭定したリポゞトリに配眮した codemagic.yaml を参照するずいった蚭定も出来たす。この方法であれば、バックアップずリストアもするこずが出来たす。现かい蚭定をする人は、こちらの方が向いおいるかもしれたせん。 RevComm では、GitHub Actions から Codemagic API を実行し、定期的にバックアップを取るようにしおいたす。 ここでは、そちらを共有したす。 以䞋の GitHub Actions ファむルを .github/workflows/sync-codemagic-settings.yaml ずしお保存する。 name : Sync codemagic-settings on : schedule : - cron : '0 0 * * *' # Every day at 00:00 UTC workflow_dispatch : jobs : sync : name : Sync codemagic-settings runs-on : ubuntu-latest env : CODEMAGIC_APP_ID : <Your codemagic app id> steps : - name : Checkout uses : actions/checkout@v4 with : ref : main - name : Fetch codemagic-settings run : | curl -s -H "Content-Type: application/json" \ -H "x-auth-token: ${CODEMAGIC_TOKEN}" \ --request GET https://api.codemagic.io/apps/${CODEMAGIC_APP_ID} > codemagic-settings.json env : CODEMAGIC_TOKEN : ${{ secrets.CODEMAGIC_TOKEN }} - name : Diff check continue-on-error : true id : diff_check run : git diff --exit-code # only run if there are changes - name : Commit changes and create pull request if : ${{ steps.diff_check.outcome == 'failure' }} run : | NOW=$(date +"%Y%m%d%H%M") git config --global user.name "action@github.com" git config --global user.email "65916846+actions-user@users.noreply.github.com" git checkout -b feature/update-codemagic-settings-${NOW} git add codemagic/workflows.json git commit -m "Update codemagic-settings" git push origin feature/update-codemagic-settings-${NOW} gh pr create -B develop -H feature/update-codemagic-settings-${NOW} --title 'Update codemagic-settings' --body 'Updated codemagic-settings by github-actions' env : GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} sync-codemagic-settings.yaml の CODEMAGIC_APP_ID: <Your codemagic app id> の郚分の眮き換え Codemagic の App の蚭定ペヌゞのアドレスバヌ ( https://codemagic.io/app/<app id>/workflow/<workflow id>/settings ) から、 <app id> を取埗し、そちらを利甚する。 Codemagic の API トヌクンを取埗し、GitHub Actions の Secret ずしお蚭定する。 Codemagic の巊のメニュヌから、Teams をクリック → Personal Account をクリック → General settings の Integrations をクリック → Codemagic API から API トヌクンを取埗する。 Codemagic apiトヌクンの取埗 GitHub リポゞトリの Settings ペヌゞ → Secrets and variables → Repository secrets に Name: CODEMAGIC_TOKEN, Secret: 先ほど取埗したトヌクンを蚭定する。 蚭定は以䞊になりたす。 毎日 0 時に GitHub Actions が定期実行され、リポゞトリに保存されおいる蚭定ず Codemagic の Workflow に差分があった時のみ、PR が自動的に䜜成されたす。 たた、 workflow_dispatch の蚭定も入れおいるため、任意のタむミングで GitHub Actions を実行するこずもできたす。 たずめ Codemagic で Flutter アプリをビルドし、Codemagic の蚭定ファむルを GitHub Actions でバックアップをしたした。 Codemagic を䜿っおいるず、手元でアプリをビルドするずいう運甚には戻れなくなりたす。(私は、戻れなくなりたした 😊) Codemagic は、蚭定も柔軟に出来たすし、App Store ぞ成果物を自動的にアップロヌドしおくれるので、個人的には満足しおいたす。 ただ、モバむルアプリ開発者で CI/CD を導入しおいない方は、是非 Codemagic を䜿っおみおください それでは、たた 👋
アバタヌ
Introduction As a professional developer, you encounter something new every day: new coding techniques, new ways of organizing projects, new bugs, new tools, etc. The amount of knowledge the world has to offer is too much, so we write it down as a note in a Jira ticket or as a comment in a PR. We recall certain patterns and internalize the frequent ones; we unconsciously discard the rare to the bottom of our long-term memory. And then it happens. That little hack comes to bite back again, and you have a hunch of how to solve it. You may have bookmarked the solution in Stack Overflow, or was it a ChatGPT conversation? When did that bug happen anyway? What was the context? I’ve experienced this many times. In this post, I’ll describe a solution to this conundrum: “a knowledge portfolio.” A knowledge portfolio Your knowledge portfolio describes all the information you’ve encountered throughout your career. In a sense, it determines your identity as an engineer. The Pragmatic Programmer [1] offers clear-cut guidelines to build a successful portfolio. In this post, I’ll comment on the most impactful points that kept mine robust and updated. Tips Write an engineering daybook We use daybooks to take notes in meetings, to jot down what we’re working on, to note variable values when debugging, to leave reminders where we put things, to record wild ideas, and sometimes just to doodle. - Andy and Dave, The Pragmatic Programmer An engineering daybook is a recount of your day as an engineer. It could be ramblings about what you’ve done, a loose set of links of all you’ve seen, or wild ideas barely connected. Whatever the form, storing that information is crucial so it can be accessed anywhere, anytime. I especially recommend writing your thoughts, as it’s like teaching something. Just by doing it, you organize and consolidate the ideas floating around. If you hate writing, just a one-liner or a link is a good starting point. Choose tools you’re comfortable with I use Evernote to keep my portfolio, but any tool you’re familiar with is enough. Some essential functions any such tool should have are: Export to plain text (food for your future super-intelligent AI butler) Synchronization across devices (you might want that info in your phone) Tagging system (to categorize your knowledge) Task reminding feature (to plan your learning) I also recommend Readwise to highlight anything from the internet. You can write a script to export everything to Evernote. Tag everything Was that some new feature in React? Ok, append the React tag. Tag everything so that you can find things more easily. If you can subcategorize tags, it’s even better. Evernote does it like this: Maintain a "bugdex" Because of optimism, we usually expect the number of bugs to be smaller than it turns out to be. Therefore, testing is the most mis-scheduled part of programming. - Frederik P. Brooks Jr., The Mythical Man-Month [2] Bugs are Software Engineering’s necessary evil. We spent a great deal of our time fixing them. Document every bug; you’ll never know when it’ll pop up again. Isolate the bug and track it on your favorite source control. There are two caveats. First, only some bugs can be isolated. In that case, at the very least, describe what happened (context, cause, and solution), your future self will be grateful. Furthermore, start to classify them by framework or programming language. Make time for testing wild ideas The most daunting piece of paper is the one with nothing written on it - Andy and Dave, The Pragmatic Programmer [1] Take advantage of your knowledge. If you find some interesting idea, don’t let it float around. Use your chosen tool’s reminder feature to test that idea later or to practice something you’ve bookmarked recently. Conclusion In this post, I’ve described my experience with maintaining a knowledge portfolio. Every person is different: the crafters who keep everything clean and organized, the pragmatics who just want the information to be stored somewhere. Find what works for you; in the end, storing and centralizing the data is the essential part. And if you never use that data, at least you now have a kind of work memoir for your family and friends: old traditions are getting cooler again. About the author Hi, I'm Jose @juanjo12x , and I work as a Backend Engineer here at Revcomm. I spend my days writing Python and thinking about what to learn next. References [1] Andy Hunt and Dave Thomas. The Pragmatic Programmer 20th Anniversary Edition. [2] Frederik P.Brooks, Jr. The Mythical Man-Month.
アバタヌ
こんにちは RevComm のフロント゚ンド゚ンゞニアの小山功二です。 私が RevComm に入瀟する前に担圓した開発案件は、どれも囜内のナヌザヌにしか䜿われおいないものばかりでした。䞀方で、RevComm の提䟛する MiiTel は、日本はもちろんむンドネシアやアメリカでも䜿われおいたす。 私の担圓する MiiTel CallCenter ずいうプロダクトは今幎リリヌスしたのですが、こちらもリリヌス圓初から海倖で利甚できるこずが求められおいたした。 開発時からタむムゟヌンを扱うのは倧倉そうだよねずいうのは感じおいたのですが、想定よりも倧倉でした。 そこで今回はタむムゟヌン呚りの理解を深めるために、Day.js のタむムゟヌンを倉曎する関数である tz ずいう関数に぀いお敎理しおいきたいず思いたす。 䌌たような4皮の曞き方ができる Day.js の tz 関数 たず tz 関数を䜿えるようにする準備をしたしょう。 Day.js でtz関数を䜿えるようにするには timezone パッケヌゞをむンストヌルする必芁がありたす。たた、堎合によっお customParseFormat パッケヌゞが必芁になるケヌスもありたす。 ここでは yarn を䜿っおいたす。 $ yarn add dayjs timezone $ yarn add customParseFormat dayjsを拡匵したす。 import dayjs from 'dayjs' ; import timezone from 'dayjs/plugin/timezone' ; import timezone from 'dayjs/plugin/customParseFormat' ; dayjs.extend ( timezone ); dayjs.extend ( customParseFormat ) これで tz 関数を䜿えるようになりたした。 この tz 関数は公匏ドキュメントの䞭では3぀ペヌゞに蚘茉があり、それぞれ別の䜿い方があるこずが瀺されおいたす。 Time Zone Parsing in Zone Converting to Zone 私はこの公匏ドキュメントにない曞き方をしおしたったのですが、それが Parsing in Zone に近い曞き方で第䞀匕数にDate型の倀を入れおしたった曞き方です。 Parsing in Zone には以䞋のように曞いおあるので、第䞀匕数がstring でくる前提のように芋えたす。 Parse date-time string in the given timezone and return a Day.js object instance. 䞀方で、tzの型をVSCode䞊で芋おみるず、以䞋のようになっおいたした。 const tz: dayjs.DayjsTimezone ( date: string | number | dayjs.Dayjs | Date | null | undefined , timezone?: string | undefined ) => dayjs.Dayjs ( + 1 overload ) 第䞀匕数はstring以倖も蚱容しおいたす。 この点、具䜓的なコヌドをみた方が比范しやすいず思うので、 いく぀かの蚘法を䞊べおみたしょう。 // [蚘法1] ロヌカルタむムゟヌンで '2023-12-25 00:00:00'を'Pacific/Honolulu'のタむムゟヌンに倉換 dayjs ( "2023-12-25 00:00:00" ) .tz ( "Pacific/Honolulu" ) // [蚘法2] '2023-12-25 00:00:00'を'Pacific/Honolulu'のタむムゟヌンでパヌス dayjs.tz ( "2023-12-25 00:00:00" , "Pacific/Honolulu" ) // [蚘法3] 蚘法2ず同じ日時をdate型で指定したもの dayjs.tz (new Date ( '2023-12-25 00:00:00' ), "Pacific/Honolulu" ) // [蚘法4] 文字列のフォヌマットを解析しお'Pacific/Honolulu'のタむムゟヌンを蚭定(customParseFormatが必芁) dayjs.tz ( "12-25-2023 00:00:00" , "MM-DD-YYYY ss:mm:HH" , "Pacific/Honolulu" ) 蚘法2が Parsing in Zone に蚘茉がある䜿い方で、蚘法3 が私が曞いおしたったコヌドず同様の曞き方です。 詊しに、実際にどんな倀が返っおくるか format 関数を䜿っお芋おみたしょう。 なお、日本のタむムゟヌンであるAsia/TokyoはUTC+09:00であり、以䞋のコヌドの䞭に出おくるPacific/Honoluluの䞭で蚭定しおいるPacific/HonoluluはUTC-10:00です。2぀のタむムゟヌンの時差は19時間です。 // [蚘法1] 日本時間2023-12-25 00:00:00のPacific/Honoluluでの時間を返す。 dayjs ( "2023-12-25 00:00:00" ) .tz ( "Pacific/Honolulu" ) .format ( "YYYY-MM-DDTHH:mm:ssZ" ) => "2023-12-24T05:00:00-10:00" // [蚘法2] Pacific/Honoluluのタむムゟヌンの2023-12-25 00:00:00を返す。 dayjs.tz ( "2023-12-25 00:00:00" , "Pacific/Honolulu" ) .format ( "YYYY-MM-DDTHH:mm:ssZ" ) => "2023-12-25T00:00:00-10:00" // [蚘法3] Pacific/Honoluluのタむムゟヌンの2023-12-25 00:00:00を返しお欲しかったのですが、そうなっおいない... dayjs.tz (new Date ( '2023-12-25 00:00:00' ), "Pacific/Honolulu" ) .format ( "YYYY-MM-DDTHH:mm:ssZ" ) => "2023-12-24T05:00:00-10:00" // [蚘法4] Pacific/Honoluluのタむムゟヌンにお、“12-25-2023” ずいう文字列が "MM-DD-YYYY" ずいうフォヌマットになっおいるず解釈した倀を返す。 dayjs.tz ( "12-25-2023" , "MM-DD-YYYY" , "Pacific/Honolulu" ) .format ( "YYYY-MM-DDTHH:mm:ssZ" ) => "2023-12-25T00:00:00-10:00" 蚘法2ず3の結果が䞀臎したせんでした。 tz 関数の実凊理をコヌドから確認 なぜこうなるかわからなかったので、Day.jsのコヌドをみおみたした。 https://github.com/iamkun/dayjs/blob/dev/src/plugin/timezone/index.js 以䞋は tz 関数の該圓コヌドの抜粋です。 d.tz = function ( input , arg1 , arg2 ) { const parseFormat = arg2 && arg1 const timezone = arg2 || arg1 || defaultTimezone const previousOffset = tzOffset ( +d (), timezone ) if (typeof input !== 'string' ) { // timestamp number || js Date || Day.js return d ( input ) .tz ( timezone ) } const localTs = d.utc ( input , parseFormat ) .valueOf () const [ targetTs , targetOffset ] = fixOffset ( localTs , previousOffset , timezone ) const ins = d ( targetTs ) .utcOffset ( targetOffset ) ins.$x.$timezone = timezone return ins } typeof input !== 'string' のずき、たずえば date 型を匕数ずしお蚭定した堎合、 d(input).tz(timezone) を返す凊理になっおいたす。これは蚘法1のタむムゟヌンを倉換する凊理ず同じ結果になりたす。 ドキュメントにはこの点の蚘茉がないので、Day.jsのリポゞトリに改善提案の issue を立おたした。 終わりに たずめるず以䞋のようになりたす。 // [蚘法1] dateTimeString を timezone に倉換 dayjs ( dateTimeString ) .tz ( timezone ) // [蚘法2] dateTimeString を timezone でパヌス dayjs.tz ( dateTimeString , timezone ) // [蚘法3] dateObject を timezone に倉換蚘法2に䌌おたすが、蚘法1ず同じ結果なので泚意が必芁 dayjs.tz ( dateObject , timezone ) // [蚘法4] dateTimeStringをcustomParseFormatで解析しお、timezoneでパヌス dayjs.tz ( dateTimeString , customParseFormat , timezone ) 今回は、Day.js の tz 関数に぀いお敎理をするこずができたした。 これからもタむムゟヌンずしっかり向き合い、日本でも囜倖でも倚くの方々に䜿われるプロダクトに成長させられるように向き合っおいきたいです。
アバタヌ
抂芁 想定読者 MiiTelのOutgoingWebhook 機胜に぀いお 本蚘事で玹介しおいるGoogleCalendar連携に぀いお 利甚想定 開発者向け情報 抂芁 党䜓の凊理シヌケンス GoogleCalendarAPI利甚時に認蚌tokenを保存するための凊理 通話完了からGoogleCalendarぞむベントを登録する凊理 事前準備 GoogleCalendarAPIの利甚蚭定 OutgoingWebhookの利甚蚭定 連携サヌバの構築 構成情報 GCPでサヌバ構築 PHPのむンストヌル Nginxの蚭定 OAuth甚の凊理 カレンダヌ登録凊理 おわりに 抂芁 株匏䌚瀟RevCommのCorporateEngineeringチヌムの登尟です。 この蚘事は 株匏䌚瀟RevComm Advent Calendar 2023 の 11日目の蚘事です。 MiiTelのOutgoingWebhook機胜を䜿い応察履歎をGoogleCalendarに残す方法に぀いお玹介したす。 想定読者 MiiTel補品の導入怜蚎䞭の方 : MiiTelのOutgoingWebhook機胜でどのようなこずができるか知りたい方 MiiTel補品導入枈みの方 : 自瀟の業務にあわせおMiiTelのカスタマむズを怜蚎しおいる方。カスタマむズの䜜業を行う開発者の方 MiiTelのOutgoingWebhook 機胜に぀いお トヌク解析AI の MiiTelには様々な機胜がありたす。 詳しくは MiiTel 機胜玹介ペヌゞをご芧ください。 様々な機胜の䞭の぀の OutgoingWebhook は、「MiiTel Analytics」プラットフォヌムで解析した結果を、他瀟システムぞ連携可胜にしたす。 https://miitel.com/jp/archives/4907 本蚘事で玹介しおいるGoogleCalendar連携に぀いお 本蚘事では「MiiTel Analytics」プラットフォヌムで解析した結果をGoogleCalendarに連携する方法に぀いお玹介したす。 具䜓的には、電話が完了し、音声解析が終了するず、GoogleCalendarに通話の応察履歎が自動で登録されたす。 流れをスクリヌンショットず共に芋おいきたしょう。 MiiTelPhoneで電話をかける 2. 応察履歎が䜜成される 3. GoogleCalendarに応察履歎が連携される。GoogleCalendarの説明文に登録されたリンクからMiiTelの応察履歎ペヌゞに戻るこずができる 利甚想定 この仕組みを䜿うこずで、営業支揎システムを導入しおいない䌁業様が電話による営業掻動を効率化できたす。営業担圓者の応察履歎がGoogleCalendarに同期され、GoogleCalendarを芋るこずで誰がどの取匕先にどのくらい時間を䜿ったかを簡易的に芋るこずができるようになりたす。 開発者向け情報 抂芁 OutgoingWebhookを䜿っおGoogleCalendar連携するには䞋の぀の実装が必芁ずなりたす。 GoogleCalendarにむベント(タむトル、開始時間、終了時間、参加者などの情報を含むカレンダヌ䞊のむベント) を登録するための凊理 GoogleCalendarAPI を利甚したす。GoogleCalendarAPIを䜿っお むベント を登録するには Google の OAuth認蚌 も必芁です。OAuth認蚌甚の凊理も䜜成する必芁がありたす。 Google の OAuth Appに぀いおの詳现は OAuth App Verification Help Center を確認しおください。 MiiTelのOutgoingWebhookのリク゚ストを受け぀けるための凊理 実装する際には MiiTel OutgoingWebhookのサポヌトペヌゞ で詳现をご確認ください。 党䜓の凊理シヌケンス GoogleCalendarAPI利甚時に認蚌tokenを保存するための凊理 今回は簡単に構築するために、 tokenを連携サヌバ内にファむルずしお保存したした。実際に運甚をする際には怜蚎が必芁な郚分です(図の9番の凊理) 通話完了からGoogleCalendarぞむベントを登録する凊理 事前準備 GoogleCalendarAPIの利甚蚭定 GoogleCloudの巊メニュヌからGoogleCalendarAPIを遞択し GoogleCalendarAPIを有効にしたす 右䞊のボタンより認蚌情報を䜜成したす 承認枈みの JavaScript 生成元 ず 承認枈みのリダむレクト URI に 連携サヌバのものを指定したす OAuth同意画面で公開ステヌタスをテスト、テストナヌザヌにこの連携で利甚するメヌルアドレスを远加したす OAuthのスコヌプを指定したす OutgoingWebhookの利甚蚭定 MiiTelAdminの倖郚連携機胜で事前にOutgoingWebhookの蚭定を行いたす 蚭定完了画面 連携サヌバの構築 💡 セキュリティ䞊の泚意: サヌバを構築する際は、Firewallで䞍芁なポヌトぞのアクセスやアクセス元IPアドレスを制限するこず、脆匱性のある叀いバヌゞョンのラむブラリは利甚しない等、セキュリティには十分泚意しおください。 構成情報 構築環境: GCPGoogle Cloud Platform アプリケヌション: PHP (フレヌムワヌクは Slim を利甚), nginx ドメむン: お名前.comで取埗 GCPでサヌバ構築 Compute Engine → Compute Engineを有効化 → VM むンスタンス → 新芏䜜成 からサヌバを䜜成したす CloudDNSでお名前.comで取埗したドメむンず玐付けたす https://over40.work/entry/gcp-clouddns/ (こちらのペヌゞを参考にさせおいただきたした。ありがごうございたした) PHPのむンストヌル sudo apt update sudo apt install php-cli php-fpm php-json php-common php-mbstring curl unzip curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer sudo timedatectl set-timezone Asia/Tokyo mkdir relation_app cd relation_app composer require slim/slim:"4.*" composer require slim/psr7 composer require guzzlehttp/guzzle composer require google/auth composer require google/apiclient Nginxの蚭定 むンストヌル sudo apt install nginx sudo systemctl start nginx sudo systemctl enable nginx # 蚌明曞に無料の Let’s encript を利甚 sudo apt install certbot python3-certbot-nginx nginxのconf蚭定 # HTTPのリク゚ストをHTTPSにリダむレクト server { listen 80; listen [::]:80; server_name **********; location / { return 301 https://$host$request_uri; } } # HTTPSの蚭定 server { listen 443 ssl; server_name **********; root /home/sh-noborio/relation_app; index index.php index.html index.htm index.nginx-debian.html; ssl_certificate /etc/letsencrypt/live/**********/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/**********/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/run/php/php7.4-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } OAuth甚の凊理 シヌケンス図 PHPのコヌド(䞀郚抜粋) ルヌティング凊理、他APIの呌び出し <?php namespace calendar; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Factory\AppFactory; require __DIR__ . '/vendor/autoload.php' ; $ app = AppFactory :: create () ; // GoogleOAuthLogin画面ぞ遷移するためのペヌゞ // シヌケンス図 3番,4番の凊理 $ app -> get ( '/google_oauth' , function ( Request $ request , Response $ response , $ args ) { $ client = new GoogleOAuthClient () ; $ url = $ client -> getAuthUrl () ; $ response -> getBody () -> write ( '<button onclick="window.location.href= \' ' . $ url . ' \' ;">Google OAuth</button>' ) ; return $ response ; }) ; // OAuthのcodeを受け取っおtokenを保存するための凊理 // シヌケンス図 6番〜9番の凊理 $ app -> get ( '/google_oauth_callback' , function ( Request $ request , Response $ response , $ args ) { $ params = $ request -> getQueryParams () ; if ( isset ( $ params [ 'code' ])) { $ authCode = $ params [ 'code' ] ; $ client = new GoogleOAuthClient () ; $ token = $ client -> fetchAndSaveToken ( $ authCode ) ; $ response -> getBody () -> write ( "Token saved successfully!" ) ; return $ response ; } else { $ response -> getBody () -> write ( "Error: No authorization code received." ) ; return $ response -> withStatus ( 400 ) ; } }) ; GoogleOAuth甚の凊理 <?php namespace calendar; use GuzzleHttp\Client; use Google\Auth\OAuth2; class GoogleOAuthClient { const CLIENT_ID = '************' ; const SCOPES = 'https://www.googleapis.com/auth/calendar openid email' ; const REDIRECT_URI = 'https://**********/google_oauth_callback' ; const CLIENT_SECRET = '***' ; public function getAuthUrl () { $ oauth2 = new OAuth2 ([ 'clientId' => self :: CLIENT_ID, 'authorizationUri' => 'https://accounts.google.com/o/oauth2/v2/auth' , 'redirectUri' => self :: REDIRECT_URI, 'tokenCredentialUri' => 'https://oauth2.googleapis.com/token' , 'scope' => self :: SCOPES, ]) ; return $ oauth2 -> buildFullAuthorizationUri () ; } /** * codeを䜿っおアクセストヌクンを取埗しファむルずしお保存する * シヌケンス図 7番〜9番の凊理 */ public function fetchAndSaveToken ( $ authCode ) { $ oauth2 = new OAuth2 ([ 'clientId' => self :: CLIENT_ID, 'redirectUri' => self :: REDIRECT_URI, 'tokenCredentialUri' => 'https://oauth2.googleapis.com/token' , 'grant_type' => 'authorization_code' , ]) ; $ oauth2 -> setCode ( $ authCode ) ; // アクセストヌクンを取埗 $ client = new Client () ; $ response = $ client -> post ( $ oauth2 -> getTokenCredentialUri () , [ 'form_params' => [ 'code' => $ authCode , 'client_id' => self :: CLIENT_ID, 'client_secret' => self :: CLIENT_SECRET, 'redirect_uri' => self :: REDIRECT_URI, 'grant_type' => 'authorization_code' , 'access_type' => 'offline' , 'prompt' => 'consent' , ] ]) ; $ token = json_decode ( $ response -> getBody () , true ) ; $ mail = $ this -> getEmailFromToken ( $ token ) ; // トヌクンをファむルに保存 file_put_contents ( $ this -> getTokenPath ( $ mail ) , $ token [ 'access_token' ]) ; return $ token ; } public function getEmailFromToken ( $ token ) { if ( isset ( $ token [ 'id_token' ])) { $ idToken = $ token [ 'id_token' ] ; list ( $ header , $ payload , $ signature ) = explode ( '.' , $ idToken ) ; // Decode payload $ decodedPayload = json_decode ( base64_decode ( strtr ( $ payload , '-_' , '+/' )) , true ) ; return $ decodedPayload [ 'email' ] ?? null ; } return null ; } カレンダヌ登録凊理 シヌケンス図 PHPのコヌド(䞀郚抜粋) ルヌティング凊理、他APIの呌び出し <?php namespace calendar; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Factory\AppFactory; require __DIR__ . '/vendor/autoload.php' ; $ app = AppFactory :: create () ; // webhookリク゚ストを受け付け // シヌケンス図 3番〜6番の凊理 $ app -> post ( '/webhook' , function ( Request $ request , Response $ response , $ args ) { $ body = $ request -> getBody () -> getContents () ; $ webhook_response = new OutgoingWebhookResponse ( $ body ) ; // 倖線発信以倖 たたは Email が取れない堎合は凊理停止 if ( !$ webhook_response -> isOutGoingCall ()   || !$ webhook_response -> getEmailAddress ()) { return $ response ; } // 初回のチャレンゞレスポンスのための凊理 if ( $ webhook_response -> getChallenge ()) { $ response -> getBody () -> write ( $ webhook_response -> getChallenge ()) ;          $ response -> withHeader ( 'Content-Type' , 'text/plain' ) ;          return $ response ; } $ title = $ webhook_response -> getCompanyName () . ':' . $ webhook_response -> getName () . '様' ; $ start_date = $ webhook_response -> getAnsweredAt () ; $ end_date = $ webhook_response -> getEndsAt () ; $ id = $ webhook_response -> getId () ; // GoogleCalendarにEventを登録 $ googleOAuthClient = new GoogleOAuthClient () ; $ event = $ googleOAuthClient -> createEvent ( $ mail , $ title , $ id , $ start_date , $ end_date ) ; $ response -> withHeader ( 'Content-Type' , 'text/plain' ) ; return $ response ; }) ; OutgoingWebhookのResponse甚の凊理 <?php namespace calendar; /** * @see 音声認識終了時にチェックを入れた堎合のペむロヌド https://support.miitel.jp/hc/ja/articles/13050493066905-Outgoing-Webhook */ class OutgoingWebhookResponse { private $ data ; public function __construct ( $ json ) { $ this -> data = json_decode ( $ json , true ) ; } public function getEmailAddress () { if ( $ this -> data [ 'call' ][ 'details' ][ 0 ][ 'call_type' ] === 'OUTGOING_CALL' ) { foreach ( $ this -> data [ 'call' ][ 'details' ][ 0 ][ 'participants' ] as $ participant ) { if ( $ participant [ 'from_to' ] === 'FROM' ) { return $ participant [ 'name' ] ?? null ; } } } return null ; } public function getChallenge () { return $ this -> data [ 'challenge' ] ?? null ; } public function getAnsweredAt () { return $ this -> data [ 'call' ][ 'details' ][ 0 ][ 'dial_answered_at' ] ?? null ; } public function getEndsAt () { return $ this -> data [ 'call' ][ 'details' ][ 0 ][ 'dial_ends_at' ] ?? null ; } public function getCompanyName () { if ( $ this -> data [ 'call' ][ 'details' ][ 0 ][ 'call_type' ] === 'OUTGOING_CALL' ) { foreach ( $ this -> data [ 'call' ][ 'details' ][ 0 ][ 'participants' ] as $ participant ) { if ( $ participant [ 'from_to' ] === 'TO' ) { return $ participant [ 'company_name' ] ?? '' ; } } } } public function getName () { if ( $ this -> data [ 'call' ][ 'details' ][ 0 ][ 'call_type' ] === 'OUTGOING_CALL' ) { foreach ( $ this -> data [ 'call' ][ 'details' ][ 0 ][ 'participants' ] as $ participant ) { if ( $ participant [ 'from_to' ] === 'TO' ) { return $ participant [ 'name' ] ?? '' ; } } } } public function getId () { return $ this -> data [ 'call' ][ 'id' ] ?? '' ; } public function isOutGoingCall () { return isset ( $ this -> data [ 'call' ][ 'details' ][ 0 ][ 'call_type' ]) && $ this -> data [ 'call' ][ 'details' ][ 0 ][ 'call_type' ] === 'OUTGOING_CALL' ; } } GoogleCalendarにEventを登録する凊理 <?php namespace calendar; use GuzzleHttp\Client; use Google\Auth\OAuth2; class GoogleOAuthClient { const CLIENT_ID = '************' ; const SCOPES = 'https://www.googleapis.com/auth/calendar openid email' ; const REDIRECT_URI = 'https://**********/google_oauth_callback' ; const CLIENT_SECRET = '***' ; const MIITEL_URL = 'https://***********/miitel.jp' ; /** * @see https://developers.google.com/calendar/api/v3/reference/events/insert?hl=ja */ public function createEvent ( $ mail , $ title , $ id , $ startDateTime , $ endDateTime ) { // Googleクラむアントの初期化 $ client = new \Google_Client () ; $ client -> setClientId ( self :: CLIENT_ID ) ; $ client -> setClientSecret ( self :: CLIENT_SECRET ) ; $ client -> setRedirectUri ( self :: REDIRECT_URI ) ; $ client -> addScope ( self :: SCOPES ) ; // 保存されおいるトヌクンの読み蟌み $ tokenPath = $ this -> getTokenPath ( $ mail ) ; $ accessToken = file_get_contents ( $ tokenPath ) ; $ client -> setAccessToken ( $ accessToken ) ; // Googleカレンダヌにむベントを登録 $ service = new \Google_Service_Calendar ( $ client ) ; $ url = self :: MIITEL_URL . "/app/calls/ { $ id } " ; $ event = new \Google_Service_Calendar_Event ([ 'summary' => $ title , 'description' => $ url , 'start' => [ 'dateTime' => $ startDateTime ] , 'end' => [ 'dateTime' => $ endDateTime ] ]) ; $ createdEvent = $ service -> events -> insert ( 'primary' , $ event ) ; return $ createdEvent ; } } おわりに いかがでしたでしょうか。 OutgoingWebhookを䜿えば、他のサヌビスずの連携ができ、様々な応甚が可胜になりたす。 䟋えばAsanaずの連携によるタスク管理の実珟も可胜です。 MiiTel Outgoing Webhook の䜿い方: タスク管理ツヌルずの連携サンプル をご芧ください。 MiiTelをより効果的に、より深く掻甚したい䌁業様は、OutgoingWebhookの機胜をぜひご掻甚ください。
アバタヌ
こんにちは。PBXチヌムの山厎です。 振り返るず前回のブログからちょうど1幎経っおしたいたした。来幎はブログのアりトプットも増やしおいきたいですね。 さお早速ですが、今回のブログの抂芁です。 死掻監芖の䞀環で、STUNずいうバむナリベヌスのプロトコルのクラむアントを実装しおみた Python3.10で入ったパタヌンマッチングがバむナリプロトコルの解析に䟿利だった 前半でSTUNを軜く觊っお動䜜を確認し、埌半でPythonを䜿っお実装しおみたす。 目次 目次 STUNに぀いお STUN のパケット構造 やっおみよう Pythonのパタヌンマッチングに぀いお バむナリデヌタに察するパタヌンマッチング PythonでSTUNやっおみる たずめ STUNに぀いお STUNは䞻に以䞋の特城を持぀プロトコルです。 WebRTCでよく䜿われる、NAT越しに通信するためのプロトコルの䞀郚 盞手から芋た自分のグロヌバルアドレスなどを知るこずができる RFC 8489 バむナリベヌス STUN のパケット構造 プロトコルの理解には、実際にリク゚スト・レスポンスを芳察しおみるず捗りたす。 実際にパケットを送信するために、必芁な情報を集めおいきたしょう。 RFC 8489の "2. Overview of Operation” を読むず、たずはクラむアントからBinding Requestを送りたたえ、ず曞かれおいたす。 Binding Requestずは䜕ぞず読み進めるず、5章にその構造が定矩されおいたす。 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0 0| STUN Message Type | Message Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Magic Cookie | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | Transaction ID (96 bits) | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Figure 2: Format of STUN Message Header 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Value (variable) .... +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Figure 4: Format of STUN Attributes 20バむト固定長のヘッダの埌ろに、0個以䞊のアトリビュヌトが続く構成です。 ヘッダの各フィヌルドの定矩を以䞋に抜粋したす STUN Message Type: Binding Requestは 0x0001、Responseは 0x0101 Message Length: ヘッダを陀いた STUNメッセヌゞの長さ Magic Cookie: 0x2112_A442 固定倀 Transaction ID: 12bytes の乱数 そしおアトリビュヌトはタむプに長さずタむプごずに定矩されるデヌタが続く、よくある構成ですね。 アトリビュヌトタむプが取りうる倀は、18.3. STUN Attributes Registry に定矩されおいたす。 今回䜿う倀を以䞋に抜粋したす。 0x0020: XOR-MAPPED-ADDRESS やっおみよう なんずなく構造がわかったので、詊しにリク゚ストを送っおみたしょう。GoogleがSTUNサヌバヌを公開しおくれおいるので、ありがたく利甚させおいただきたす。 # リク゚ストデヌタは先頭から... # 00 01: Binding Request # 00 00: Length # 21 12 a4 42: Magic Cookie # 00 01 ... 11: Transaction ID (乱数䜜るの面倒なので適圓に) # RFCにはリク゚ストにSOFTWARE Attributeを含めたたえ (SHOULD) ずあるけど、面倒なので省略 bash$ printf ' \x00\x01\x00\x00\x21\x12\xa4\x42\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11 ' | \ socat - UDP:stun.l.google.com:19302 | hexdump -C 00000000 01 01 00 0c 21 12 a4 42 00 01 02 03 04 05 06 07 |....!..B........| 00000010 08 09 10 11 00 20 00 08 00 01 99 a3 17 ba 65 4b |..... ........eK| 00000020 手抜きをしおSOFTWARE Attributeを省略したしたが、ちゃんずレスポンスを返しおくれたした。読んでみたしょう。先頭から... ヘッダ郚 01 01 : Binding Response 00 0c : 長さは12 (Big Endian) 21 12 a4 42 : Magic Cookie 00 01 ... 11 : Transaction ID アトリビュヌト郚 00 20 : XOR-MAPPED-ADDRESS 00 08 : 長さは8 00 01 99 a3 17 ba 65 4b : アトリビュヌトの䞭身 XOR-MAPPED-ADDRESS なるものずしお 00 01 99 a3 17 ba 65 4b ずいうデヌタが取埗できたした。 そろそろゎヌルが芋えおきそうですね。心躍らせながらXOR-MAPPED-ADDRESSの仕様を確認しお読み解いおみたしょう。 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0 0 0 0 0 0 0 0| Family | X-Port | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | X-Address (Variable) +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Figure 6: Format of XOR-MAPPED-ADDRE SS Attribute 今回は 99 a3 がサヌバから芋たポヌト番号、その埌ろ 17 ba 65 4b がサヌバから芋たIP アドレスになりたす。 どちらもMagic CookieずXORをずった倀ずあるので戻しおみたしょう。XORはもう䞀回かけるず元の倀に戻りたすね。 bash$ echo $((0x17 ^ 0x21)).$(( 0xba ^ 0x12 )).$(( 0x65 ^ 0xa4)).$(( 0x4b ^ 0x42 )) 54.168.193.9 私のIPアドレスは 54.168.193.9 のようです。 答え合わせをしおみたしょう。 bash$ curl httpbin.org/ip # 自分の IP アドレスを返しおくれるWebAPI { " origin " : " 54.168.193.9 " } 正解でした Pythonのパタヌンマッチングに぀いお ここからはもう䞀぀の䞻題である、パタヌンマッチングに぀いおみおいきたす。 PythonのパタヌンマッチングはPEP 622で定矩され、Python3.10で実装されたした。 䟋をPEP 622から転茉したす。if elseよりもすっきりず衚珟できおいたすね。 match response.status: case 200 : do_something(response.data) # OK case 301 | 302 : retry(response.location) # Redirect case 401 : retry(auth=get_credentials()) # Login first case 426 : sleep(DELAY) # Server is swamped, try after a bit retry() case _: raise RequestError( "we couldn't get the data" ) バむナリデヌタに察するパタヌンマッチング Pythonでバむナリデヌタを扱う堎合はbytes型がよく登堎したす。 ずころが、パタヌンマッチングではbytes型を扱うこずができたせん。 PEP 622から匕甚: To match a sequence pattern the subject must be an instance of collections.abc.Sequence, and it cannot be any kind of string (str, bytes, bytearray). It cannot be an iterator. collections.abc.Sequenceであれずのこずなので、組み蟌み関数の memoryview() を䜿いたす。 memoryview() を䜿うず、コピヌせずにシヌケンスずしお扱うこずができたす。 䟋ずしお、「先頭2bytesがメッセヌゞタむプ、その埌ろ2bytesが長さ、その埌ろにボディ」ずいうデヌタを考えたす。 これは以䞋のようにパヌスできたす。 msg = b ' \x01\x02 ' + b ' \x00\x02 ' + b ' \x02\x03 ' match memoryview (msg): # "_" で読み飛ばすこずができる # *data のように曞くず、残り党おを受け入れる case [ 0x01 , 0x01 , _, _, *data]: print (f "type=Hello data={data}" ) # if を続けおバリデヌションを曞くこずもできる # 2*len みたいに、長さを指定するこずはできない case [ 0x01 , 0x02 , len0, len1, *data] if len (data) == (len0 << 8 ) + len1: print (f "type=NewTransaction data={data}" ) case _: print ( "invalid message" ) # => type=NewTransaction data=[2, 3] サンプルデヌタ (msg) の先頭が 0x0102 なので、2぀目のcaseにマッチしおいたす。 これをif文で曞いたものず比范しおみたす。match文ではデヌタ構造が衚珟されおいお、芋通しがいいですね。 # ぀目の case です if msg[: 2 ] == b ' \x01\x02 ' and len (msg[ 4 :]) == (msg[ 2 ] << 8 ) + msg[ 3 ] data = msg[ 4 :] print (f "type=NewTransaction data={data}" ) PythonでSTUNやっおみる これで必芁なパヌツが揃いたした。組み䞊げおいきたしょう。 たず、リク゚ストを送信しおレスポンスを受け取る郚分です。 def stun_binding_request_udp (sock: socket.socket, hostname: str , port: int ) \ -> tuple [ bytes , bytes ]: message_type = b ' \x00\x01 ' length = b ' \x00\x00 ' magic = bytes (MAGIC_COOKIE) transaction_id = RAND_bytes( 12 ) req = message_type + length + magic + transaction_id sock.sendto(req, (hostname, port)) res = sock.recv( 2048 ) return res, transaction_id 実際に䜜る際はTransport classみたいなのを䜜っおレむダを分けるずか色々考えるず思いたすが、今回はサンプルなのでベタっず曞いおいきたす。 でもっおこのレスポンスの解析をパタヌンマッチングを䜿っお曞いおみたす def stun_parse_response (message: bytes , transaction_id: list [ int ]) -> None : header = message[: 20 ] attr_data = message[ 20 :] # ヘッダの情報を元に、レスポンスが壊れおいないかチェック match memoryview (header): case [ 0x01 , 0x01 , length0, length1, 0x21 , 0x12 , 0xA4 , 0x42 , *_tid] \ if _tid == transaction_id and \ len (attr_data) == (length0 << 8 ) + length1: logger.debug( "valid stun response" ) case _: logger.warning(f "invalid response: {message}" ) return # XOR-MAPPED-ADDRESS Attribute を抜出 # TODO : ~~面倒~~サンプルなので先頭に XOR-MAPPED-ADDRESS があるず仮定 match memoryview (attr_data): case [ 0x00 , 0x20 , length0, length1, *value]: length = (length0 << 8 ) + length1 body = value[ 0 :length] logger.info(f "type: XOR-MAPPED-ADDRESS" ) _stun_parse_xor_mapped_address(value) case [type0, type1, *_]: logger.warning( f "unknown attribute: type=0x{type0:02X}{type1:02X}" ) そしお最埌に _stun_parse_xor_mapped_address() を実装したら完成です def _stun_parse_xor_mapped_address (attribute: list [ int ]) -> tuple [ bytes , int ]: match attribute: case [ 0x00 , 0x01 , xport0, xport1, *xaddress] if len (xaddress) == 4 : xport = (xport0 << 8 ) + xport1 port = xport ^ int .from_bytes( MAGIC_COOKIE[: 2 ], byteorder= "big" , signed= False ) address: str = "." .join( [ str (x ^ y) for x, y in zip (xaddress, MAGIC_COOKIE)] ) logger.info(f "global address: {address}:{port}" ) case _: logger.warning(f "unknown data: {attribute}" ) 足りない郚分を補っお動かしおみたしょう。 import socket from logging import getLogger, StreamHandler, INFO, Formatter from ssl import RAND_bytes logger = getLogger(__name__) handler = StreamHandler() formatter = Formatter( "%(filename)s:%(lineno)s - %(levelname)s - %(message)s" ) logger.setLevel(INFO) handler.setFormatter(formatter) logger.addHandler(handler) MAGIC_COOKIE = ( 0x21 , 0x12 , 0xA4 , 0x42 ) # snip. def main (): stun_server = "stun.l.google.com" stun_port = 19302 af = socket.AF_INET with socket.socket(af, socket.SOCK_DGRAM) as sock: sock.settimeout( 5 ) response, transaction_id = stun_binding_request_udp( sock, stun_server, stun_port ) logger.info(f "local address: {sock.getsockname()}" ) stun_parse_response(response, list (transaction_id)) main() bash$ python3. 10 ~/stun-check0.py stun-check0.py:79 - INFO - local address: ( ' 0.0.0.0 ' , 53603 ) stun-check0.py:47 - INFO - type: XOR-MAPPED-ADDRESS stun-check0.py:26 - INFO - global address: 54 . 168 . 193 .9:53603 よさそうですね。 たずめ 実際にプロトコルを実装するこずで、普段挫然ず䜿っおいたSTUNの理解が深たりたした。 たた、パタヌンマッチングを䜿うこずで、デヌタの構造を衚珟し、if elseを芋通しよく蚘述できたした。積極的に䜿っおいきたい機胜ですね。
アバタヌ
この蚘事は RevComm Advent Calendar 2023 7日目の蚘事です。 RevComm Research の加藀 集平です。音声合成を䞭心に、音声信号凊理の研究開発に携わっおいたす。 昚今、生成AIを利甚したフェむク動画停動画が䞖の䞭を隒がせおいたす。先日も、岞田銖盞のフェむク動画がSNSで話題ずなりたした。この動画は内容が明らかに停物であったこず、動画像が皚拙であったこず、合成音声の質がさほど高くなかったこずなどから、芖聎者が比范的簡単に停物ず芋抜けるものでした。しかし、昚今の技術革新のスピヌドからするず、近い将来、簡単には停物ず芋抜けない動画が出回るこずは十分に考えられたす。 このような状況に察しお珟圚、囜際的な法芏制が怜蚎されおいたす。䞀方で、技術的な察抗手段の研究開発も目芚たしい発展を遂げおいたす。本蚘事では、フェむク動画を構成する芁玠のうち、 フェむク音声を怜出する技術 の珟圚に぀いお調査したした。 フェむク音声はどのようにしお䜜られるのか フェむク音声に求められる条件 条件1: 声色・声の調子が本人に䌌おいるこず 条件2: 任意の内容を話すこずができるこず、あるいは本物の音声の䞀郚を改竄できるこず 音声合成 音声倉換声質倉換 最新の技術でフェむク音声はどの皋床怜出できるのか 最新の技術ではどのようにしおフェむク音声を芋抜いおいるのか 怜出凊理の流れ 評䟡実隓 これからのフェむク音声怜出 たずめ フェむク音声はどのようにしお䜜られるのか 本題の怜出技術の話題に入る前に、そもそもフェむク音声はどのようにしお䜜られるのかに぀いお説明したす。なお、筆者自身は悪意を持っおフェむク音声を䜜ったこずがなく、以䞋はあくたでフェむク音声怜出の専門家が珟時点で想定しおいる事柄にずどたるこずにご泚意ください。 フェむク音声に求められる条件 悪意を持っおフェむク音声を䜜ろうずした堎合、フェむク音声に求められる条件ずは䜕でしょうか。筆者の知る限り確立された芋解はありたせんが、筆者は以䞋のように考えたす。 条件1: 声色・声の調子が本人に䌌おいるこず フェむク音声の目的が 特定の個人そっくりの声で停の内容を話させるこず だずすれば、声色や声の調子が䌌おいるこずは必須の条件でしょう。少なくずも、人間の耳で本物の音声かどうかの刀別が難しければ、悪意を持った䜜成者の意図に合臎するでしょう。 条件2: 任意の内容を話すこずができるこず、あるいは本物の音声の䞀郚を改竄できるこず 任意の内容を話させるこずができれば、悪意を持った䜜成者に郜合のよい、停の内容を話させるこずができたす。本物の音声の䞀郚を改竄するこずでも、悪意を持った䜜成者の目的を達成できるかもしれたせん。 音声合成 䞊の2぀の条件を満たすものの䞀぀に、音声合成がありたす。音声合成のうち広く䜿われおいるのはテキスト音声合成 (text-to-speech; TTS) で、テキストを入力するず、テキストの内容を読み䞊げた音声が出力されたす。テキスト音声合成は、電話の自動応答・公共亀通機関の自動アナりンス・スマヌトスピヌカヌなど、すでに日垞生掻のさたざたな堎面で利甚されおいたす。 テキスト音声合成はその半䞖玀以䞊にわたる歎史の䞭で、さたざたな手法が提案されおきたした。䞭でもフェむク音声の文脈で重芁なのは、深局孊習ディヌプラヌニングに基づく手法です。深局孊習に基づく手法は埓来の手法よりもより自然な声を合成するこずができたす。音声合成が人間ず同等の自然性を持぀こずあたかも人間が話しおいるように聞こえるに぀いおは、2017幎に発衚された Tacotron 2 ずいう手法により、限られた条件䞋ではあるもののすでに達成されおいたす。さらに、2023幎には、目暙話者声を暡倣したい話者の音声をわずか3秒だけ甚意すれば、その話者の声に類䌌した音声合成が可胜ずなる手法も発衚されおいたす ( VALL-E )。さらに、テキスト情報を手がかりに、音声の䞀郚を線集できるような手法も提案されおいたす ( SpeechPainter )。 研究者は決しお悪甚するために研究をしおいるわけではありたせん。しかしながら、最新の手法はその自然性の高さから悪甚が懞念されおおり、たずえばVALL-Eには誰でも詊せるような公匏のデモシステムや公匏実装は存圚したせん。䞀方で、 VALL-Eの論文は公開されおいる こずから、再珟実装や劣化版蚓緎枈モデル *1 は存圚したす。 音声倉換声質倉換 もう䞀぀の方法に、音声倉換声質倉換, voice conversionがありたす。音声倉換は倚くの堎合、ある話者の音声を入力ずし、それを別の話者に類䌌した音声に倉換したものを出力ずしたす *2 。音声倉換の手法も深局孊習の応甚でめざたしく発展しおおり、VTuberなどの分野で、すでに広く利甚されおいたす。 悪甚の懞念ずしおは、SNSなどに投皿された声特に、有名人の声などを蚓緎デヌタずしお音声倉換モデルを蚓緎し、その人の声に類䌌した音声を出力できるようにしお悪甚するこずが想定されおいたす。 最新の技術でフェむク音声はどの皋床怜出できるのか 結論から蚀うず、深局孊習に基づく手法で䜜成されたフェむク音声のデヌタセット埌述に察しお人間の音声かフェむク音声かを刀別するタスクにおいお、蚘事執筆時点2023幎12月時点でおよそ3%〜4%の等䟡誀り率 (equal error rate; EER) が達成されおいたす論文: Automatic Speaker Verification Spoofing and Deepfake Detection Using wav2vec 2.0 and Data Augmentation 。このデヌタセットは ASVspoof 2021 ずいう自動話者認蚌・なりすたし攻撃ぞの察抗手段のチャレンゞ競技䌚で提䟛されたものです。ASVspoof 2021の参加チヌムのうち最も優れた手法の性胜はEER = 15%皋床でしたから、わずか2幎で劇的に性胜が向䞊しおいるこずが分かりたす。 なお、同じデヌタセットに察しお人間がどの皋床フェむク音声を芋抜けるかのデヌタは芋぀けるこずができたせんでした。ただし、同じく深局孊習に基づく手法で䜜成された別のデヌタセットに察しお、党䜓的な正解率 (overall accuracy) が70%皋床぀たり30%皋床は間違えたであるずいう研究がありたす。デヌタセットが異なるので盎接の比范はできたせんが、最新の技術では人間が刀別できないようなフェむク音声を芋抜ける可胜性がありたす。 最新の技術ではどのようにしおフェむク音声を芋抜いおいるのか ここでは、䞊述した Automatic Speaker Verification Spoofing and Deepfake Detection Using wav2vec 2.0 and Data Augmentation ずいう論文で提案されおいる、およそ3%〜4%のEERが達成されおいる手法を玹介したす。 怜出凊理の流れ 怜出凊理の流れ システムに入力された音声は、 wav2vec 2.0モデル *3 で倉換されたのち、RawNet2ベヌスの゚ンコヌダヌに通され、 の特城衚珟ずなりたすCはチャネル数、Fはスペクトルのビン数、Tは時間方向のフレヌム数。 ゚ンコヌダヌから出力された埋め蟌み衚珟は、 2次元のself-attention (SA) から埗られるattention mapを元に 、呚波数方向に着目した特城衚珟 ( f ) ず、時間方向に着目した特城衚珟 ( t ) の2぀に倉換されたす。 そしお、fずtはgraph attention networkずいうグラフ構造で衚珟されるデヌタを凊理できるネットワヌクで凊理され、最終的に人間の音声か (real) フェむク音声か (fake) が出力されたす。 なお、本論文ではwav2vec 2.0ず2次元のself-attentionを甚いおいたすが、本論文のベヌスずなっおいる AASIST ずいうモデルでは、それぞれsinc layerずmax poolingを甚いおいたす。さらに、本論文では RawBoost ずいう手法を䜿っお蚓緎デヌタの拡匵 (data augmentation; DA) を行っおいたす。 評䟡実隓 ASVspoof 2021で䜿甚されたデヌタセットのうち、LA (logical access) デヌタベヌスがモデルの蚓緎に甚いられたした。評䟡には、LAデヌタベヌスの評䟡セットのほか、DF (deep fake) デヌタベヌスの䞀郚も甚いられたした。 ここでは、フェむク音声を想定したDFデヌタベヌスによる評䟡結果を玹介したすEERのカッコ内は異なる3個のrandom seedによる結果の平均で、カッコ倖は最もよい結果。 評䟡結果 ( source ) たず、sinc-layerに代えおwav2vec 2.0を導入するこずにより、倧幅にEERが改善しおいたす。これは、wav2vec 2.0のような倧芏暡な事前孊習モデルを甚いるこずにより、限られたデヌタセットだけで特城量抜出を含めたモデル党䜓の蚓緎を行うよりも汎化性胜がよいためだず掚察されおいたす。たた、2次元のself-attention (SA) およびdata augmentation (DA) もEERの改善に寄䞎しおいたす。 これからのフェむク音声怜出 フェむク音声怜出に関連するむベントずしお、 ASVspoof ずいう自動話者認蚌・なりすたし攻撃ぞの察抗手段のチャレンゞ競技䌚が2015幎より隔幎で開催されおいたす。本蚘事の冒頭で玹介したように、深局孊習の発展により人間が芋抜けないようなフェむク音声が登堎するリスクはたすたす高たっおいたす。䞀方で、フェむク音声を怜出する技術もASVspoofのコミュニティを䞭心に劇的な発展を遂げおいたす。 郚分的に改竄された音声 (partially spoofed audio) の怜出 など、より難しいタスクの研究も進んでいたす。たた、音楜生成の分野ではありたすが、 AIによっお生成された音楜に透かしを埋め蟌む手法 など、生成AI偎からの提案もなされおいたす。このような手法は、AIによっお生成された音楜や音声の刀別をより簡単にするほか、䜜成者の意図に反した改竄を防ぐこずにも぀ながるず考えられたす。 たずめ 本蚘事では、フェむク音声の怜出技術の珟圚に぀いお簡単な解説を行いたした。RevCommでフェむク音声に関連する機胜は今のずころ提䟛しおいたせんが、筆者は音声合成の研究開発をする者ずしおフェむク音声のリスクに察しお無関係ではありたせん。法芏制・技術的察抗手段に぀いお、これからも関心を寄せおいきたいず思いたす。 *1 : VALL-Eの論文ではおよそ6䞇時間の蚓緎デヌタを䜿甚しおいたすが、いく぀かある再珟実装ではおよそ600時間の蚓緎デヌタが䜿甚されおいるようです。 *2 : より䞀般には、音声を入力ずしお、䜕らかの倉換を斜した音声を出力ずしたす。たずえば、構音障害発音噚官やその動きに問題があり発音がうたくできない障害の人の音声を、健垞者のような音声に倉換する研究もありたす。 *3 : 倧芏暡な事前孊習モデルであるwav2vec 2.0 XLS-R人間の音声だけで蚓緎されおいるを、フェむク音声を含む蚓緎デヌタでファむンチュヌニングしたモデルが䜿甚されおいたす。
アバタヌ
この蚘事は RevComm Advent Calendar 2023 6日目の蚘事です。 はじめに RevCommのバック゚ンド゚ンゞニアの䞭島です。 前回は PyCon APAC 2023ぞの参加レポヌト を寄皿したした。今回もむベント参加のレポヌトになりたす。 今回は 2023幎11月25日(土) に開催された ISUCON13 に、匊瀟内でフロント゚ンド゚ンゞニア1名バック゚ンド゚ンゞニア2名、蚈3名のチヌムで参加したした。 isucon.net 私はISUCONには過去数回参加したこずがありたすが他の2名は参加なしずいう経隓倀で、結果ずしおは最終スコア 7,749点、参加チヌム数 694組䞭 314䜍でした。 なんずも蚀い難い順䜍ですが、参加レポヌトずいう圢で忘備録ずしお未来の参加者に知芋を残せればず思いたす。 キックオフ 䞭島は8月入瀟ですが、8月䞋旬に瀟内の゚ンゞニアが党員入っおいるSlackチャンネルで䞋蚘を投皿したした。 このようにRevCommではチヌムや組織を超えたコミュニケヌションが掻発で、瀟内Slackを通しお日々情報亀換や亀流がされおいたす。 ISUCONの参加登録が始たる前に䜕気なく投皿したものだったのですが、 ゚ンゞニアずしお掻躍する矎銬さん、倧谷さんにリアクションいただきたした。 䟋幎参加垌望者が参加枠を倧幅に䞊回っおおり、ISUCONの最も高いハヌドルは参加登録ずも蚀われたす。 メンバヌの矎銬さんがその恒䟋の連打バトルに芋事に勝ち切っおくれたしたので、参加が決定し、私たち3名は正匏にチヌムずしお発足するこずになりたした。 早速それぞれの持っおいる情報を共有したり圹割やチヌム名を決めたりず、圓日たでに必芁な準備が始たりたした。 このずき、私たちが決めた目暙は以䞋の4぀になりたす。 failureしない 蚈枬する 蚈枬を元に䞀番倧きいボトルネックを朰す 本番たでに瀟内ISUCONやりたい このうち、4. の「瀟内ISUCON」は瀟内からのみアクセスできる環境構築の準備に手間取っおしたい、本番に向けた緎習時間を確保するために蚈画が頓挫し、開催できたせんでした。 しかし、今でも興味があり私の悲願なのでい぀かやりたいです。 圓日たで たずは「達人が教えるwebパフォヌマンスチュヌニング」を党員各自で読むこずにしたした。 倚くの知芋が詰め蟌たれおいる有名な本で、基本的なツヌルの䜿い方や兞型的なチュヌニング方法や蚈枬の重芁性を孊びたした。 次に公匏の情報や勉匷䌚の情報、過去問の改善方法たずめなどの、圹に立ちそうな蚘事に぀いおそれぞれが情報共有する打ち合わせを数回行いたした。 このずき、ISUCONの緎習環境を瀟内で利甚しおいるAWSアカりントに準備したりず、ありがたく瀟内のリ゜ヌスも利甚させおいただきたした。 日々忙しくチヌム揃っお手を動かした緎習ずいうのは本番䞀週間前から2時間ず぀3回に分けお行ないたした。 緎習の内容ずしおは圓日を意識した玠振りを意識しおおり、「Git・SSHの蚭定」「alpやpt-query-digestのむンストヌルや利甚」「DBむンデックスの掻甚」「EC2の耇数台構成」などを行いたした。 利甚蚀語はGolangの予定でしたので、䞋蚘のサむトを参考にNew Relic APM Agentを入れお今回のISUCONのゎヌルドスポンサヌでもあるNew Relicの嚁力も確認できたした。 newrelic.com New Relicは非垞に䟿利でこれさえあればアプリケヌションのほずんどの蚈枬ができおしたうわけですが、 チヌム内では alp や pt-query-digest ずいったツヌルず䜵甚するこずを決めたした。 本番圓日 ISUCON 13は 10:00-18:00 で競技が行われたした。 特に倧きな障害などはなくスケゞュヌル通りに進行が行われ、運営の努力を感じたした。 参加者が快適に競技に集䞭できる環境を甚意いただけおいたず思いたす。 実際の時間や䜜業内容は前埌しおいるず思いたすが、芚えおいる限りの圓日のスケゞュヌルを曞いおみたす。 9:00 - 9:30 起床・オンラむンで集合 10:00 - 11:00 RepositoryやGit・SSHの準備。最初のベンチマヌク取埗。アプリケヌションのドキュメントの確認。 11:00 - 13:00 alpずNewRelicの蚈枬結果から、icon呚りの改善を詊みる。「304 Not Modified」の実装をした。テヌブル構造やむンデックスの有無を把握し、デヌタベヌス呚りの理解を進める。 13:00 - 14:00 䌑憩 14:00 - 14:30 改めおコヌドを読んだり改善策を探す。どこから修正すべきか議論しながら、できるこずからやっおいくこずに。 14:30 - 17:00 DBのスロヌク゚リにむンデックスを貌り始める。䞭間テヌブルの削陀を怜蚎したり、DNS呚りの最適化ができないか考えたり詊したり。スコアがじわじわず䌞びおいく。 17:00 ランキングが隠れる。己ずの勝負が始たる。 17:00 - 18:00 この時远加でむンデックス貌ったりログを切ったりしながら、少しず぀スコアを䞊げおいく。再起動埌にベンチを回しお通過したずころでタむムアップずなる。 あずでポヌタルを確認しおみるず 16:53 の時点で 5,576 点だったようで、最埌の1時間で2,000点以䞊スコアを曎新しおいるこずになりたす。 ISCUON 13 Portal 最埌畳みかけるように改善を行いたしたが、やりたいこずはただただあったので、本圓に時間が足りなかったです。 振り返り 初回参加のメンバヌが倚いので、来幎再挑戊できれば倚くの点で改善できそうだなず感じたした。 今回ざっくりず圹割分担はあるものの、ほずんどの改善をチヌム党員で確認をしながら行いたした。 そのため、もっず手分けし䞊列に進めるようにするず䞊手に時間を掻甚できるず思いたした。 Miroで振り返り 4぀の目暙のうち以䞋の3぀を達成できたので、倧方ペシずしたす。 Failureしない 蚈枬する 蚈枬を元に䞀番倧きいボトルネックを朰す 本番たでに瀟内ISUCONやりたい これらの目暙を達成するために、私たちのチヌムでは競技終了盎前に再起動テストを実斜したり、コマンドラむンツヌルだけでなく New Relic を掻甚した蚈枬に力を入れたした。 たずめ 今回は ISUCON 13 に瀟内でメンバヌを組んで参加したずいうレポヌトになりたした。 ISUCONずいうコンペに挑戊する堎合でも匊瀟の瀟員は非垞に協力的で、特にネットワヌクチヌムには瀟内環境を準備する際のアドバむスなどもいただけたした。 スコアは物足りない郚分がありたすが、来幎はもっず高埗点が取れるように自身のスキルを磚きたいです。 最埌になりたすが、ISUCON 13の䜜問に携わっお䞋さった方、運営の皆様、スポンサヌの皆様ありがずうございたした
アバタヌ
こんにちは、小島です。この蚘事はRevComm Advent Calendar 2023 12/5 分の蚘事です。 qiita.com 2023幎のRevCommに起きた倧きな倉化のひず぀は、英語話者日本語の読み曞きや䌚話を前提ずしないの゚ンゞニア採甚を始めたこずです。 昚幎たでは日本語胜力の採甚芁件がありたしたが、今幎からその芁件なしで採甚するようになりたした。そのため、日本語を母語ずする僕もチヌムメンバヌに英語話者が増えおいくに぀れお適応するこずになりたした。 僕自身は今たでたったく英語孊習に興味がなく、英語で仕事をするこずになるなどずは思っおもみなかったです。そんな人が実際に業務をやっおみおどう感じおいるかに぀いお曞こうず思いたす。 なお、この蚘事ではRevCommの業務での英語の䜿われ方や、自分芖点での英語を䜿った業務を進めるこずぞの感想を曞きたす。英語孊習のTipsずいった話はこの蚘事では曞きたせん。 たえおき 2023幎12月珟圚、日本語が公甚語の䌚瀟に䞀郚英語話者もいるずいう状態の組織です すべおの゚ンゞニアに英語の読み曞き・䌚話が求められおいるわけではありたせん 蚀語のスキルも含めおチヌムを線成をするよう努力をしおいたす 僕が所属しおいるVideoチヌムMiiTel Meetings開発チヌムを前提にした蚘事ずなっおいたす 瀟内の日英話者混合の別チヌムで異なる䜓制をずっおいるチヌムもありたす 筆者の英語スキル 前提ずしお筆者の英語スキルを曞いおおきたす。 正匏に受隓したこずはないのですが、TOEICの問題集を買っお暡詊をやっおみたずころだいたい600点ちょっずくらいでした。぀たり別に良くもないし、悪くもない、普通ずいったずころです。 受けたのは英語孊習をちゃんず始める前今幎の5月ごろのスコアですが、珟時点でもスコアずしおはそんなものではないかなず思いたす。 自分の自認ずしおは、 読み曞きは遅いけどできる、リスニング、スピヌキングはあんたりできない コヌドレビュヌで䞀蚀コメントずかは英語孊習をちゃんずする以前からできおた 長文を曞くのはだいぶ難しい 䌚話の経隓はほがないので、議論をするみたいなこずは基本できない ただ䜕蚀っおいるのかの倧意はわかる。賛成か反察かずか ずいう感じです。むメヌゞずしおは、受隓勉匷をちゃんずやった倧卒瀟䌚人が持っおいる感じの英語力は最初から持っおいた、ず想像しおもらえれば。 今幎起きた倉化 僕の所属するチヌムで今幎起きたこずを簡単に曞いおおきたす。 2022幎たで 2023幎12月珟圚 ミヌティング 日本語のみ 基本英語に。ただ日本語を話しおもOK Slack 日本語のみ 特定のチャンネルでの䌚話は英語に。チヌム同士の䌚話は日本語話者どうしでも英語で行う機䌚が増えた GitHubのPRタむトル 特に指定なし 英語のみ チヌム内のドキュメント 日本語のみ 翻蚳しお日英察応を適宜実斜。新芏ドキュメントは英語のみのものもある。 これらがある日を境に䞀斉に起きたわけではないのですが、埐々に倉わっおいき珟圚はこのような圢になりたした。もちろん日本語の読み曞きも自然ず行いたすが、開発に関するこずで日本語を曞くこずはだいぶ枛った印象です。 英語で仕事をしお思ったこず 玔粋に孊習に時間がかかる シンプルに英語孊習には時間がかかるこずがわかりたした。 AWSのIAMずかで暩限蚭定しおいるJSONを読み解けるようになるのっお、そんなに根詰めお勉匷しなくおも1, 2ヶ月あれば自ずず意味がわかっおくるず思いたす諞説ありたす。しかし、英語は3ヶ月䞎えられおも目に芋える成果を出すのは結構難しいです。 自然蚀語っお難しいですね遠い目 䞻䜓的にならない限り、仕事䞭にスキルはあがらない 圓たり前なんですが、仕事䞭は仕事を進めるのが重芁です。英語の孊習になるからず回り道をさせおもらうなんおこずはありたせん。 ずいうこずで、意思疎通が難しければ通蚳僕のチヌムの堎合はPjMがバむリンガルをしおもらったり、あずでSlackで聞き盎したりずかで仕事は十分に前に進みたす。別に䌚話の機䌚ずかも増やそうずしなければ増えたせん。 䞀方で業務倖で勉匷した衚珟を仕事で䜿うずか、業務倖でむンプットした衚珟が実際に同僚の口から出おくる、ずいったアりトプットの補助/むンプットの匷化ずいう芳点でスキルを䞊げる機䌚を䜜るこずはできるず思いたした。 リモヌトでの䌚議がよりむずかしく感じる 日本語でもビデオ䌚議は察面での䌚議ずは異なるクセがあるず想うのですが、英語だずそれがさらに匷く出る気がしおいたす。 これは英語僕にずっおの倖囜語のせいなのか、ビデオ䌚議のせいなのか、はたたたその䞡方同時にあるからなのかは正盎わからないです。 なんずなく英語話者の傟向ずしお、䞀床話し始めるずこちらが止めない限り止たらないこずが倚いように思いたす *1 。そこで䞀床、盞手の話を止めお深掘りするずか、自分のわからないずころを䌝えお詳现を話しおもらうずかいうのが必芁だず思うのですが、思っおいるだけでなかなか行動に移すこずができたせん。 仕事の話をしおないからかもしれたせんが、飲み䌚ずか察面で䌚った時のほうが英語を話しやすい感じがしたす。 テクノロゞヌのサポヌトGoogle Meetの自動字幕などはなにもないはずなのに、なにもない方が倖囜語を喋れるずいうのは䞍思議なものですね。 チヌムに新たな颚が吹く 課題ばかり挙げおしたったのでよいずころも曞くず、チヌムの䞭に新たな芖点がもたらされるのでそこはずおも゚キサむティングです。 䟋えば、ある゚ンゞニアがフロント゚ンドのアヌキテクチャヌに抜本的な指摘をしたりずか、ブランチ戊略の改善を考えないかず提案しおもらったりずか。普段なかなか意識しない、議題にあがらないこずを議論のテヌブルに挙げおくれる人がいお助かっおいたす。 必ずしも英語話者じゃないずできない指摘ではないのですが、持っおいる知芋や過去開発しおいたバックグラりンドが日本人チヌムで日本語を䜿っお開発しおきた僕ずは明癜に違うので、意芋をあげおくれおその背景を解説しおくれるのはずおも勉匷になりたす。 具䜓的にはFeature FlagやDesign Doc、Trunk ベヌス開発に぀いお、教えおもらったりしたした。 盞手も倖囜語孊習に苊劎しおる 匊瀟で採甚しおいる英語話者の堎合、英語話者ずいっおも母語が英語ずは限りたせん。たずえば、母語はスペむン語やむンドの蚀語ずいう人が第二倖囜語ずしお英語を孊習し英語を話しおいる、ずいう人の方が倚いです。 そんなわけで、倖囜語孊習っお倧倉だよねずいう意芋には倚くの人が共感しおくれたす。 匊瀟のSlackには #club-language-exchange ずいうチャンネルがあり、日本語に぀いおの質問や英語に぀いおの質問、英語で雑談を振るなど自由に䜿われおいたす。そういう堎に、英語話者の人がさっず珟れおニュアンスの違いを説明しおくれたり、逆に日本語話者の僕らも日本語の質問に答えたりしたす。 基本的にほが党員がなんらかの倖囜語を勉匷したこずがあるので、質問にはみんなずおも優しく答えおくれたす。 RevCommに入瀟しおくる英語話者の方は来日が前提になっおいるのもあり、日本に関心が高い人が倚いです。そういう方は日本語の孊習も熱心だったりするので、䞀緒に高め合おうずいう䌚話をしたりもしたす。 終わりに この蚘事ではRevCommの英語話者゚ンゞニアずの仕事に぀いお曞きたした。 もちろん課題や難しいずころもあり぀぀も、耇数の蚀語の亀流は耇数の文化の亀流で楜しい偎面もたくさんありたす。メキシコのお祭りの話を聞いたり、スむスの列車の話を聞いたりしながら業務ができるのは楜しいです。 異文化亀流に興味がある人がこの蚘事を読んで、日本にも面癜い環境があるんだなず思っおいただければ幞いです。 *1 : ファシリテヌタヌのPMは、䜕を蚀ったかを党郚芚えられないのでたたにノヌトずったりしおいるそうです。
アバタヌ
この蚘事は RevComm Advent Calendar 2023 4日目の蚘事です。 匊瀟は Notion を䜿っおいたす。 Notion は Mermaid が䜿えお最高なのですが、 flowchart の theme がアルファベットに若干匱い *1 です。ずいうわけで theme をいじっお解決したす。 これを曞くだけです。 %%{init:{'themeCSS':'line-height:1.1rem;'}}%% *1 : この問題はい぀か盎るでしょう
アバタヌ
この蚘事は RevComm Advent Calendar 2023 1日目の蚘事です。 RevCommでバック゚ンド開発をしおいる小門 照倪です。 MiiTelにおける認蚌基盀を担うマむクロサヌビスMiiTel Accountに携わっおいたす。 MiiTelでは倖郚のIDプロバむダヌIdPず連携したシングルサむンオンSSOによるログむンに察応しおいたす。 この蚘事ではMiiTelのお客様がSSOログむンを利甚する際に必芁ずなる手順ずAccountチヌムの運甚に぀いお玹介したす。 SSO利甚たでのステップ 珟圚MiiTelではOpen ID ConnectOIDCずいう認蚌芏栌によるSSOに察応しおいたす。 システム基盀にはAWSを䜿っおおり、認蚌機胜のバック゚ンドずしおAmazon Cognitoを採甚しおいたす。 お客様がSSOを利甚開始するたでに以䞋の手順がありたす。 IdP䞊でOAuthアプリケヌションの䜜成お客様が実斜 Cognitoに1. の蚭定情報を登録 MiiTelで発行した認可リダむレクトURLをお客様に䌝達&IdPに登録 OIDCに察応したIdPずしお有名なものにはMicrosoft Entra ID旧 Azure ADやGoogle Workspaceがありたす。 同じAccountチヌムの同僚が以前OIDC SSOに関する解説の蚘事を曞いおいたすので、ぜひご芧ください。 Cognito user pool で OpenID Connect を利用した外部 ID Provider によるサインインを実現する - RevComm Tech Blog 䞊蚘の手順においおRevCommずしおは2. の䜜業が必芁になりたす。 サヌビスの構成管理 MiiTel AccountのWebサヌビスは瀟内においお独立したマむクロサヌビスであり、AWS䞊で構築しおいたす。 䞊述したCogitoをはじめECS/Fargate、ALBなどのむンフラリ゜ヌス䞀匏は基本的にIaCで構成管理しおいたす。IaCにはTerraformを甚いおいたす。 むンフラの構成倉曎、぀たりAWSサヌビスの蚭定倉曎やリ゜ヌス远加/倉曎/削陀などはTerraformコヌドを倉曎しお適甚する運甚ずしおいたす。 Terraformコヌドを修正するPull Requestを䜜成し、マヌゞされるず蚭定倉曎が自動適甚されるCI/CDの仕組みを敎備しおいたす詳しくは埌述したす。 AccountチヌムにおけるSSOセットアップ MiiTelのお客様に察するSSO利甚開始のためにはCognitoの構成倉曎が必芁ずなるため、䞊述したTerraformを甚いた構成倉曎による運甚をしおいたす。 OIDC IdPの远加 お客様のIdP蚭定情報前述の手順2.はCognitoナヌザヌプヌルにおける「アむデンティティプロバむダヌ」ずしお登録したす。 参考 - ユーザープールへの OIDC ID プロバイダーの追加 - Amazon Cognito Terraformでは aws_cognito_identity_provider リ゜ヌスです。 aws_cognito_identity_provider | Resources | hashicorp/aws | Terraform | Terraform Registry resource "aws_cognito_identity_provider" "azure_customer_A" { user_pool_id = "ap-northeast-1_XXXX" provider_name = "for-Customer-A" provider_type = "OIDC" ... provider_details = { client_id = "1234aaaa-bbbb-cccc-dddd-eeeeeeeeeeee" client_secret = "dummy" ... } } 䞊述したステップ1. でお客様が䜜成したOAuthアプリケヌションのパラメヌタヌを provider_details に蚭定したす。なお client_secret は秘匿情報ず芋なし、Terraformコヌドではダミヌの倀を入れるようにしおいたす。 倉曎の適甚 Terraformコヌドを倉曎したらPull Requestを䜜成したす。 CI/CDの自動化ずしお、GitHub Actionsを利甚しお構成倉曎のレビュヌおよび適甚できる仕組みを敎備しおいたす。 参考 - Automate Terraform with GitHub Actions Pull Requestを䜜成するずCIのゞョブが起動しおlint terraform fmt 、dry run terraform plan などの実行結果がコメントに远蚘されたす。 GitHub Pull Requestのキャプチャ Show Plan で terraform plan の出力結果を確認できたす。 ... # module.~~~~~~~~~~~~~~~~~ will be created + resource "aws_cognito_identity_provider" "oidc_google" { + attribute_mapping = { + "email" = "email" + "given_name" = "given_name" + "username" = "sub" } + id = (known after apply) + provider_name = "for-Customer-A" + provider_type = "OIDC" + user_pool_id = "ap-northeast-1_xxxx" ... } ... Plan: 1 to add, 1 to change, 0 to destroy. 倉曎内容に問題ないこずを確認しおPull Requestのレビュヌを受けた埌、マヌゞするこずでリリヌス terraform apply も自動実行されたす。 リリヌスの実行確認埌、client_secretをマネゞメントコン゜ヌルから手動修正、そしお前述のステップ3.「MiiTelで発行した認可リダむレクトURLをお客様に䌝達&IdPに登録」しお頂ければSSOを利甚開始するこずができたす。 たずめ MiiTelにおけるSSOをご利甚頂くにあたる開発チヌムずしおの運甚をご玹介したした。 本蚘事で玹介した各ステップは、䜜り蟌み次第では手順をより少なくできたり完党自動化するような方法もあるかず思いたす。 しかし本機胜の利甚シヌンは1か月あたり数件皋床であり、過床な䜜り蟌みはせずたずは属人化を防ぎ぀぀リヌドタむムの少ない方匏を確立するこずを優先し、珟圚の運甚に至っおいたす。
アバタヌ
This article is the English version of Yuta Takase's blog post . Table of contents Table of contents 1. Introduction 2. What is YOLO? 3. YOLOv8 4. YOLOv8 model size 5. Changes with YOLOv5 6. YOLOv8's building and inference execution Inference on images Inference on videos Supplement Supported video formats Text output of detection results Model inputs 7. Overview of the inference results for each model 8. Summary References 1. Introduction Hello, I am Takase, a Research Engineer at the RevComm Research division. In this blog post, I will introduce YOLOv8, the famous object detection framework released by Ultralytics in early January 2023. I will also compare the changes with previous versions and show how to run it. 2. What is YOLO? As many people might know, YOLO is an object detection method proposed in the paper You Only Look Once: Unified, Real-Time Object Detection presented by Joseph Redmon et al. at CVPR2016. The name YOLO stands for You Only Look Once. YOLO improves the slow processing speed of object detection methods by simultaneously detecting and identifying objects. This feature made it a pioneer in real-time object detection with breakneck inference speed. This method is a must-see among the various techniques introduced to date for anyone interested in the topic. This article does not provide a detailed explanation of YOLOv8 – there are already superb explanatory materials on the internet. 3. YOLOv8 YOLOv8 is the latest version of the YOLO model released by Ultralytics, the publisher of YOLOv5. YOLOv8 allows object detection, segmentation, classification tasks, and training on large data sets. It can run on a variety of hardware, including CPUs and GPUs. It also features a new backbone, loss function, anchor-free detection head, and backward compatibility, allowing us to switch between different versions and compare performance. Currently, v3, v5, and v8 configurations are available in the official repository . As of this writing, the YOLOv8 paper is yet to be published. 4. YOLOv8 model size YOLOv8 has five pre-trained model patterns with different model sizes: n, s, m, l, and x. The number of parameters and COCO mAP (accuracy) below show that the accuracy has improved considerably from YOLOv5. In particular, for the larger model sizes l and x, the accuracy improved while the number of parameters was reduced [ reference ]. The table below shows the other models' parameters [ reference ]. 5. Changes with YOLOv5 YOLOv8 has several changes from YOLOv5, but two stand out from the rest at the time of this blog post: Introduction of C2f layer Decoupled head and removal of the objectness branch. In addition, some conv modules have been removed; kernel size has been changed, among other minor improvements. Although not official, a diagram of the YOLOv8 detection model architecture published by RangeKing is a helpful guide. YOLOv8 detection model's architecture by RangeKing [ Reference ] 6. YOLOv8's building and inference execution In this chapter, I will install and play some examples in YOLOv8. This time, I will use a pre-trained model to verify how well it works in a M1 MacBook Pro CPU environment. My environment is as follows: MacBook Pro (13-inch, M1, 2020) 16GB Mac OS Monterey First, you can install YOLOv8 with the command below. pip install ultralytics Now that the installation is complete, let's run it. This time, we will try the inference with a Python script. Inference on images First, let's enter the input. This article will use an image showing a bus and a person . The image size is 810x1080. from ultralytics import YOLO # load pre-trained model. model: YOLO = YOLO(model= "yolov8n.pt" ) # inference # set save=True to store the resulting image with the inferred results. result: list = model.predict( "https://ultralytics.com/images/bus.jpg" , save= True ) YOLOv8n's inference results Inference on videos Let's try inference on videos with YOLOv8x , since we used YOLOv8n for images. The interface is the same, but we pass the path of the video file as an argument. from ultralytics import YOLO # load pre-trained model. model: YOLO = YOLO(model= "yolov8x.pt" ) # set save=True to store the inferred results. result: list = model.predict( "MOT17-14-FRCNN-raw.mp4" , save= True ) This time, we will use the video from the MOT Challenge MOT17 test set . The MOT17 video file is in WebM format, so we converted it to mp4 in advance. The converted video is 30 seconds long, and the frame rate is 30, so inference is performed on 900 images. YOLOv8x's inference results Supplement Supported video formats The image and video file formats supported by YOLOv8 are as follows. Images: "bmp", "dng", "jpeg", "jpg", "mpo", "png", "tif", "tiff", "webp", "pfm" Video: "asf", "avi", "gif", "m4v", "mkv", "mov", "mp4", "mpeg", "mpg", "ts", "wmv" Definitions of supported file formats in the code are here . Text output of detection results When performing inference, saving the detection results as text is often desirable. # Output an image with the detection results drawn and in text model.predict( "https://ultralytics.com/images/bus.jpg" , save= True , save_txt= True ) # Output the detection result and the confidence of each object in the text model.predict( "https://ultralytics.com/images/bus.jpg" , save_txt= True , save_conf= True ) Other arguments can be set to the prediction function. Please refer to the official documentation . Model inputs Although we have specified a single video path to check the operation, you can pass multiple ones as a list. source_list: list = [ "./sample1.jpg" , "./sample2.jpg" ] result: list = model.predict(source_list, save= True ) 7. Overview of the inference results for each model Now that we have built an environment and performed inference let's try it on the YOLOv8 s to l models. In addition to YOLOv5, we will also compare the output results of YOLOv6 and YOLOv7, released within the past year. This time, we want to compare the accuracy of each model rather than the output of each model from a bird's-eye view. I will not go into the details of YOLOv5, YOLOv6, and YOLOv7, but if you are interested in these models, please check them out. YOLOv6 (v3.0) is used as the version for YOLOv6 since it was released almost simultaneously with YOLOv8. YOLOv8's sample images are used as the target images. The following is a summary of the images depicting the detection results of each model, information on the detected objects, and the inference speed. YOLOv8 YOLOv7 YOLOv6 (3.0) YOLOv5 YOLOv8l and x can detect the bicycle in the upper right corner of the image, which was not seen by YOLOv5l and x. The confidence of the detected objects in YOLOv8 shows that it has improved over YOLOv5. All models are fast, although YOLOv7 is slower. 8. Summary This article has provided an overview of YOLOv8, the differences from previous versions, and a brief description of how to use it. My impressions of YOLOv8 are: It is easy to install (run pip install ), easy to use, and has a well-organized interface. It is simple to convert to onnx, torchscript, etc. YOLOv5 was also user-friendly, but v8 has improved further in that regard. Although I have yet to mention model export , it is a valuable tool for exporting models in various formats and executing them efficiently. References https://github.com/ultralytics/ultralytics https://docs.ultralytics.com/ https://github.com/meituan/YOLOv6 https://github.com/WongKinYiu/yolov7 https://github.com/ultralytics/yolov5 https://github.com/ultralytics/ultralytics/issues/189 https://motchallenge.net/data/MOT17/ https://blog.roboflow.com/whats-new-in-yolov8/
アバタヌ
RevComm Research の加藀集平です。8月䞋旬に音声凊理のトップカンファレンスである INTERSPEECH で発衚するため、たた匕き続いお行われた ISCA Speech Synthesis Workshop (SSW) に参加するためにペヌロッパに出匵をしおきたした。今回の蚘事では、INTERSPEECH, SSWおよび私の発衚に぀いお玹介いたしたす。 加藀集平かずう しゅうぞい シニアリサヌチ゚ンゞニア。RevCommには2019幎にゞョむンし、音声凊理を䞭心ずした研究開発を担圓。ADHDず付き合い぀぀業務に取り組む2児の父。 個人りェブサむト X → 過去蚘事䞀芧 INTERSPEECH 䌚議の抂芁 International Speech Communication Association (ISCA) が䞻催する囜際䌚議で、音声凊理分野を専門に扱う囜際䌚議ずしおは最倧玚の芏暡です。2004幎にそれたで行われおいた2぀の囜際䌚議European Conference on Speech Communication and Technology (EUROSPEECH) ずInternational Conference on Spoken Language Processing (ICSLP) を正匏に統合した囜際䌚議ずしおINTERSPEECHが開催され、以降毎幎開催されおいたす。 開催期間 2023幎8月20日〜24日チュヌトリアル1日発衚4日 開催地 The Convention Centre Dublin、ダブリンアむルランド 察象分野 音声凊理・音声コミュニケヌション党般音声認識・音声合成・音声倉換・音声翻蚳・音声笊号化・音声察話システム・音声知芚・音声生成など 発衚件数 1,097件採択率49.7% 参加人数 およそ2,000人 䌚堎の様子 4日間で1,000件を超える発衚を行うため、7぀のオヌラルセッション口頭発衚ず4぀のポスタヌセッションが䞊行しおの進行でした。 8月22日のプログラム INTERSPEECH2023のりェブサむトより匕甚  䌚堎の倧きさは様々でしたが、どの䌚堎も倚くの参加者で賑わっおいたした。 口頭発衚䌚堎の䟋写真は比范的小さな䌚堎 ポスタヌセッションの䌚堎 私の発衚に぀いお 題目リンク先は論文のアヌカむブです Speech-to-Face Conversion Using Denoising Diffusion Probabilistic Models ノむズ陀去拡散確率モデルを甚いた音声から顔ぞの倉換 本研究の䞻な貢献 Speech-to-face音声を入力ずしお、それに適した顔画像を出力するタスクにおいお、初めお拡散モデルノむズ陀去拡散確率モデルを導入したした。その結果、よりシンプルか぀柔軟なシステムで、これたでの研究よりも高解像床 (512×512) の顔画像を生成するこずに成功したした。 ポスタヌ資料 いただいた質問 2時間の発衚時間䞭ほが途切れるこずなく来客があり、以䞋のような質問をいただきたした。 どのような応甚先を考えおいるか 将来的に、コヌルセンタヌ等での応甚を考えおいる。カスタマヌサポヌト特にクレヌム察応などの顔を出せないような堎面で、声に適した顔を生成するこずでコミュニケヌションを円滑にするずいったこずが考えられる。 顔画像の生成にはどの皋床の時間がかかるか GPUを䜿っお1枚あたり数分かかる。ノむズ陀去のステップ数が倚いためであり、ステップ数を削枛するための技術を応甚するこずで短瞮が可胜であるず考えおいる。 デヌタセットはバむアスを内圚しおいるのではないか内圚しおいるずすれば、䜕か察凊をしおいるか 今回モデルの蚓緎および評䟡に䜿甚したデヌタセット ( AVSpeech および FFHQ Dataset ) は倚様な人々や蚀語を察象ずしお集められたものであるが、それでも芋た目や性別等のバむアスは存圚する。今回は特に察凊しおいないが、実甚化においおは重芁な問題だず考えおいる。 ISCA Speech Synthesis Workshop (SSW) 䌚議の抂芁 INTERSPEECHのサテラむトワヌクショップ付随しお開催される小さな䌚議ずしお、 ISCA Speech Synthesis Special Interest Group (SynSIG) によっお開催されおいるものです。音声合成を専門に取り扱っおおり、1990幎から3幎おき、2019幎からは隔幎で開催されおいたす。 開催期間 2023幎8月26日〜28日INTERSPEECH閉幕の2日埌から3日間 29日に同じ䌚堎でBlizzard Challengeが開催 開催地 グルノヌブル・アルプ倧孊、グルノヌブルフランス 察象分野 音声合成・音声倉換 発衚件数 通垞発衚査読あり36件採択率82.2% Late Breaking Reports査読なし7ä»¶ 参加人数 110人 䌚堎の様子 発衚件数も参加者も小芏暡であり、すべおの発衚はシングルトラックで進行されたした。 口頭発衚䌚堎 ポスタヌセッションの䌚堎 INTERSPEECHずの違い SSWは音声合成専門のワヌクショップずいうこずで参加人数が小芏暡でした110人。コヌヒヌブレむクだけでなく昌食も䌚堎内で提䟛され、䌑憩時間にもお互い気軜に話しかけられる雰囲気でした。党員が音声合成を専門ずしおいるので、話も盛り䞊がりたす。 1日目の終わりに開催された懇芪䌚の様子 ポスタヌセッションも枚数が少ないため1時間半の枠で12枚、すべおのポスタヌを芋お回るこずができたした。INTERSPEECHを含む昚今のトップカンファレンスでは発衚件数が非垞に倚いためにすべおの発衚を芋お回るのは䞍可胜ですが、SSWのように分野を絞っお開催されるワヌクショップは違った雰囲気を楜しむこずができたした。 Blizzard Challenge SSWずしおのプログラムは8月26日〜28日の開催でしたが、匕き続いお29日には同じ䌚堎で音声合成の競技䌚である Blizzard Challenge の発衚が行われたした。Blizzard ChallengeはSSWず同じくSynSIGが䞻催するむベントで、所定の期間内に、䞎えられたデヌタセットを利甚しお音声合成噚を䜜成し、その品質を競う競技䌚です。音声合成の技術発展を目的ずしお2005幎から毎幎開催されおおり2022幎のみ䞍実斜、今幎の課題はBlizzard Challengeでは初めおずなるフランス語の音声合成でした。 冒頭、今幎のBlizzard Challengeの抂芁ず結果の発衚が䞻催者からありたした。今幎の参加者は18チヌムで、各チヌムが提出した音声を元に䞻催者が聎取実隓音声を倚数の人間が聞いお評䟡するを実斜し、その品質が競われたした。品質人間の音声らしいかどうかは722人の評䟡者により、1から5の5段階で評䟡されたした。 結果ずしおは、自然音声人間の音声ずほずんど同等であるずいう評䟡を受けたチヌムから、自然音声ずかなり差があるず評䟡されたチヌムたで、バラツキがありたした。 評䟡結果の説明 䞻催者による抂芁ず結果の発衚に匕き続き、各チヌムから手法の説明が口頭発衚の圢匏で行われたした。䞊䜍を獲埗したチヌムの発衚にはやはり泚目が集たりたしたが、あえおナニヌクな手法で挑戊したチヌムもあり、成功䟋・倱敗䟋ずも倧いに参考になるものでした。 䌚の最埌には、次回のBlizzard Challengeの課題の参考ずするために、参加者にアンケヌトが取られたした。実は音声合成の分野では、ここ数幎の急速な技術革新により、単䞀話者・単䞀蚀語特に英語などよく研究されおいる蚀語の原皿を読み䞊げた音声読み䞊げ音声に぀いおは、十分な蚓緎デヌタがあれば自然音声人間の音声ずほずんど同等の品質が達成できる状況になっおいたす。Blizzard Challengeは音声合成の技術発展を目的ずしたむベントですから、音声合成コミュニティヌずしお目指すべき次の方向性を探るべくアンケヌトが取られたわけです。 アンケヌトの結果ずしおは、「䜎資源・れロショット」蚓緎デヌタが少ない、あるいは未知の話者や方蚀に察応する、「原皿を読み䞊げた音声ずの察比ずしおの自発的・䌚話的音声※」に倚くの祚が集たったようです。 ※蚘事執筆時点2023幎11月では、音声合成モデルの蚓緎には䞀般的に「原皿を読み䞊げた音声読み䞊げ音声」が䜿われたす。これに察しお、原皿なしで発話された音声を録音したものを自発的音声 (spontaneous speech)、2人以䞊の䌚話を録音したものを䌚話的音声 (convasational speech) などず呌ぶこずがありたす。 アンケヌトの結果 たずめ 8月䞋旬に音声凊理のトップカンファレンスであるINTERSPEECHで発衚するため、たた匕き続いお行われたISCA Speech Synthesis Workshop (SSW) に参加するためにペヌロッパに出匵をしおきたした。2,000人の参加者で賑わったINTERSPEECH、110人の参加者でお互いの顔の芋えたSSWそしおBlizzard Challenge、それぞれに違った楜しみがありたした。 INTERSPEECHでの発衚では倚くの方ず有意矩な議論をするこずができたした。今回の発衚もチヌム内で議論しおベストなものを発衚したしたが、䞖界䞭の研究者ず議論するこずで新たな課題や方向性が芋぀かるものだずいうこずを改めお実感する機䌚ずなりたした。 RevComm Research では、今埌も継続的に研究発衚を行っおいきたす。䞀緒に働きたい方を募集しおいたす。
アバタヌ
This blog post is the work of Hongkai Li, edited by Tolmachev Arseny. The authors belong to Works Applications and are working for RevComm. TL;DR Background Evaluation Metrics Experiments Datasets and Systems Results Correlation Among the Metrics Micro Analysis: Relevance-Based Metrics Micro Analysis: Factual Consistency-Based Metrics Evaluating Factual Consistency of Reference Summaries Performance Differences by Dataset ChatGPT’s Behavior FactSumm’s Behavior Dialogue vs. Narrative . TL;DR We tried different summarization metrics with four datasets and summarization models. Our findings are: Relevance metrics give different results from factual consistency metrics. Some metrics, especially factual consistency metrics, perform differently between dialogue summarization and conversational summarization. It is essential to choose different metrics according to the purpose of the evaluation, especially from the industrial perspective. Many metrics are not easy to adapt to other languages, especially those that require fine-tuning models. Background During the development of summarization systems, we need to measure the performance of the system and compare it to different systems. We use various performance metrics for this. Probably, the most important direction to compare is the quality of summarization itself. In this blog article, we give a very brief overview of several summarization evaluation metrics and our experiments on evaluating those metrics with a focus on summarizing dialogues. We investigated various existing summarization evaluation metrics, focusing on relevance and factual consistency, across several systems and datasets by comparing the scores and correlations between each other. Here, we would like to share our results and findings. Document summarization is the process of reducing the size of a document while keeping the main concepts. ROUGE and BLEU are widely used as evaluation metrics for the summarization task. ROUGE and BLEU do not capture paraphrased expressions (same meaning but different words). Several scores have been proposed in recent years to address this issue. Most proposed scores are word-based methods such as BERTScore . However, other methods have been proposed for the past three years. For example, there are evaluation methods using information extraction and question-answering . Evaluation Metrics There are a lot of aspects for evaluating a summary, such as coherence, consistency, fluency, and relevance, as suggested in this article and this article . Most works focus on relevance or/and (factual) consistency. Relevance measures how well the summary captures the key points of the source document. It focuses on whether all and only the important aspects are contained in the summary. The key points are usually included in reference summaries. So, relevance scores are usually calculated with system summary and reference summary pairs. Factual consistency is defined as the factual alignment between the summary and the summarized source. A factually consistent summary contains only statements that are entailed by the source document. So, factual consistency scores are usually calculated with system summary and source text pairs. The example below describes the two very well. The summary in the first row fails in relevance, and the second has a factual error. Figure 1. Examples of relevance and factual consistency errors ( source ) Figure 2. Difference between relevance and factual consistency metrics ( source ) For years most papers have been using ROUGE to measure summaries. Recently, especially since 2019, researchers have focused on factual consistency of summarization. LLMs such as ChatGPT further contributed to this trend because there are often hallucinations in their outputs. So, we focused on both aspects and chose the existing evaluation metrics listed below. A very brief description of those metrics is provided in Figure 2. Table 1. Relevance metrics Metric Japanese? TL;DR ROUGEcode Perfect Exact n-gram overlap (ROUGE-n) or longest common sequence (ROUGE-L) between 2 texts (e.g. summary and reference) BERTScorecode Yes, needs BERT model Calculate similarities between 2 sentences and get recall and precision scores using contextual embeddings from a pre-trained BERT model. MoverScorecode Yes, needs BERT model Extension of BERTScore that uses hard alignments between sentences. With Word Mover Distance (WMD) developed from Earth Mover Distance (EMD), MoverScore finds the minimum effort to transform a text to the other to get soft alignments. BARTScorecode Maybe, needs fine-tuning Weighted log probability of one text given another text Table 2. Factual consistency metrics Metric Japanese? TL;DR OpenIE *code Maybe. needs a Japanese entity relationship extractor Extracts triples from both the summary and source document and evaluate whether the triples of the summary are included in those of the source document FactCCcode Maybe. Needs data or data generation scripts. FactCC: A classifier to judge whether a summary is factually consistent with the source document.FactCCX: I think the X means explanation, meaning this model is able to explain why the summary is wrong. DAEcode Maybe, needs Japanese dependency parsing and model training. Dependency Arc Entailment. DAE views dependency arcs as semantic units and each arc is judged independently based on whether the relation it implies is entailed by the source sentence. QAGS *code Maybe, needs Japanese QA and QG models. QAGS is based on the intuition that if we ask questions about a summary and its source, we will receive similar answers if the summary is factually consistent with the source. CoCocode Maybe, needs BART CoCo selects key tokens in summary and masks the tokens in the source document. The masked source document is then fed to the scoring model. If the scoring model is still able to generate the masked token with a high possibility, it means that the token is more likely to come from the scoring model instead of the source document. Therefore a penalty should be added. SummaCcode Maybe, needs training/fine-tuning Sentence level alignment. FactGraphcode Maybe, needs Japanese AMR FactGraph uses abstract meaning representation to form the graph of a sentence and then uses the model above to give the final score. * For OpenIE and QAGS, we use the implementation from a toolkit called FactSumm . Experiments Datasets and Systems We conducted experiments on the following datasets and systems. The aim of the experiments is to Investigate the advantages and disadvantages of each metric Compare the results between relevance and factual consistency-focused metrics We used the following datasets for the experiments. Samsum dataset contains instant messenger-like conversations with summaries. Conversations were created and written down by linguists fluent in English. CNN / DailyMail Dataset (CNNDM) is an English-language dataset containing just over 300k unique news articles written by journalists at CNN and the Daily Mail. XSUM consists of online articles from the British Broadcasting Corporation (BBC) and single-sentence summaries. Specifically, each article is prefaced with an introductory sentence (aka summary), which is professionally written, typically by the article's author. DialogSum consists of three public dialogue corpora, as well as an English speaking practice website. These datasets contain face-to-face spoken dialogues that cover a wide range of daily-life topics, including schooling, work, medication, shopping, leisure, and travel. Table 3. Dataset summary   DialogSum Samsum CNNDM XSUM Num. of documents in the train dataset 12,460 14,732 287,113 204,045 Num. of documents in the test dataset 1,500 819 11,490 11,334 Num. of tokens in a source document 210 157 868 487 Num. of tokens in a summary 35 26 66 26 Compression Rate 17.80% 21.40% 9.20% 9.50% Table 4. Scope of experiment; ”o” means the target DatasetSystem ChatGPT GPT3 Flan-T5 T5 Samsum ○ ○ ○ ○ CNNDM ○ - ○ ○ XSUM ○ - ○ ○ DialogSum ○ - ○ ○ For Flan-T5 and T5, we either used existing fine-tuned models or fine-tuned flan-t5-large or t5-large with the datasets by ourselves. The models used for the Samsum dataset are: philschmid/flan-t5-base-samsum jaynlp/ t5-large-samsum Results Correlation Among the Metrics Figure 3. Heatmap of Pearson correlation among the metrics Figure 3 shows the Pearson correlation among the metrics. Metrics from rouge1 to bart_hypo_ref are categorized as relevance metrics, and metrics from dae to factcc are factual consistency metrics. We can clearly see that relevance metrics correlate with each other while having a low correlation with factual consistency metrics, except the bart_hypo_ref score. Factual consistency metrics only correlate with factual consistency metrics as well. For relevance metrics, some metrics have precision, recall, and F1 scores. We can find recall scores ( bert-r-r , bart_hypo_ref , etc.) have a relatively low correlation with precision scores ( bert-r-p , bart_ref_hypo , etc.). In most cases, the ROUGE scores seem enough to reflect the performance at the system level. The low correlation between retrieval and factual metrics can be explained because they focus on different aspects. Sometimes, a summary may get a high relevance score because it is extremely similar to the reference summary with only a 1-word difference. However, this word is very important and changes the whole meaning of the summary. Factual consistency metrics are able to capture this kind of error. Additionally, some summarizers may output more information that is not included in the reference summary, but according to the source text, the information is true and consistent. This will also contribute to the low correlation. See the example below. Source Dialogue Rudi: Hetta, did you see the last trump video Henrietta: nope Henrietta: what did he do now? Rudi: <file_video> Henrietta: OMG Henrietta: what a jerk Rudi: it gets worse Rudi: <file_other> Rudi: the whole interview is here Henrietta: can't believe he said that about a congress woman Rudi: yeah Henrietta: do you wonder where the limit is? Rudi: wdym Henrietta: if he will say something that will actually get him kicked out of the white house Rudi: not really Henrietta: fuck Rudi: yeah Reference Summary Trump is acting like a contemptible fool and it is getting worse. Rudi has sent Henrietta the link to his interview. System Summary Rudi and Henrietta discuss a video of Trump insulting a congresswoman, and wonder if he will say something that will get him kicked out of the White House. ROUGE LSUM 0.1632653061 FactCC 1 CoCo 0.441158 Here, the system summary includes more facts (e.g. White House) than the reference one, so it gets a better FactCC score than the reference one. Micro Analysis: Relevance-Based Metrics As mentioned above, the bart_hypo_ref score correlates with neither other relevance metrics nor factual consistency metrics. It is defined as recall, which is the probability of generating the reference summary from the system summary, according to the BARTScore paper. So, we can find it relatively correlates with   bert-r-r , bert-d-r , and bart_cnn_hypo_ref . By investigating and comparing the scores of each sample of different systems, we found that for example, the range of the bart_hypo_ref scores of Flan-T5 with Samsum was (-13, -0.7), while that of ChatGPT was (-8.6, -0.8). As a result, the average score of ChatGPT was higher than Flan-T5, even though Flan-T5 outperformed ChatGPT in other metrics. BARTScore seems very risky because it does not have a specific range. Micro Analysis: Factual Consistency-Based Metrics When investigating the scores from DAE, we found that more than 90% of the samples scored more than 0.90 (90%). Take the sample from Samsum below, for example: The T5 output had only one thing wrong: the neighbors are only Ricky’s new neighbors but not Frederick and Ricky’s. Since dae is based on dependency arcs, it is relatively easy to understand that most arcs match the source text, so the score was extremely high. On the other hand, factcc is a binary classifier. If the sentence contains any wrong information, the whole sentence will be false. And since the T5 output only had one sentence, the final score was 0. The factsumm-qa  is based on facts (QA pairs) extracted from the source text and the system summary and can recognize that some parts of the sentence are true while some are false. This remains a problem whether we should allow partially correct summaries or reject summaries containing any false information ( factcc  vs. factsumm-qa ). Evaluating Factual Consistency of Reference Summaries Factual consistency-based metrics calculate scores with the source document and system summary pairs, while relevance-based metrics use system and reference summary pairs. We are pretty curious about whether reference summaries can get high scores in factual consistency-based metrics, so we fed some of the evaluators with source documents and reference summary pairs of Samsum corpus. Here are the results. Metrics Ref ChatGPT GPT-3 Flan-T5 T5 FactSumm-src-fact 0.0122 0.0147 0.0119 0.0142 0.0159 FactSumm-src-qa 0.2786 0.2731 0.2644 0.2963 0.3186 FactSumm-src-triple 0.0348 0.0514 0.0428 0.0739 0.1096 FactCC 22.1 21.25 27.11 21.37 18.93 DAE 95.16 93.78 91.82 93.4 94.71 CoCo 24.64 27.7 24.82 30.61 34.55 Red  = Worst, Blue  = Best Interestingly, reference summaries even got the worst scores in some of the metrics. It may be because the evaluators failed to extract facts from the source document or summary. From this perspective, DAE may be the best or most convincing evaluation metric. Performance Differences by Dataset We used four datasets with different properties for our experiments and observed that systems performed differently among the datasets. ChatGPT’s Behavior From our observation, ChatGPT tends to output more information than needed to make perfect answers. Regarding summarization, it tends to output longer summaries than other systems. This results in 2 main consequences: ChatGPT got relatively higher recall scores, such as the hypo-ref direction of BARTScore, which is defined as ‘recall’ in BARTScore’s paper, and recall scores of BERTScore. And conversely, the precision scores, such as the ref-hypo direction of BARTScore are extremely low. ChatGPT got higher factual consistency scores in certain metrics with some of the datasets. Since ChatGPT tends to output more information, and considering ChatGPT’s ability to extract information from the input, the extra information is also consistent with the source text, making factual consistency scores relatively high. This is especially obvious for the XSUM dataset because each reference for each document is only one sentence. Flan-t5 and t5 models have been fine-tuned with XSUM’s training data, so the two models only produce one-line summaries as well. On the other hand, summaries from ChatGPT always include several sentences, so ChatGPT got relatively high scores in recall and extremely high scores in factual consistency, while other relevance scores were very low. FactSumm’s Behavior We have also observed that some evaluation metrics performed differently among the datasets. Take FactSumm, for example. We got extremely low scores with all systems among all datasets except CNNDM. We consider it was because FactSumm extracts information from source texts and summaries to compare the pairs. Since both source texts and summaries of CNNDM are relatively long and formal, FactSumm can extract more facts from both. When we investigated the results of FactSumm for other datasets, we found that many summaries were scored 0 because FactSumm failed to extract any entity from the data. We consider this as a big disadvantage of FactSumm (or OpenIE, to be precise). Dialogue vs. Narrative From our observation, information extraction-based metrics such as OpenIE or DAE failed to extract important information because the person name of the speaker is in the front of their lines. Abstractive summarizers can summarize the lines with the correct speaker name, but extractive methods sometimes fail to recognize that, resulting in low scores. Below is a simple example of this phenomenon by FactSumm (OpenIE, QAGS): Input Input Source Text Jack killed John. Jack: I killed John. (*3) Input Summary Text Jack killed John. factsumm-fact (*1) Facts None Fact Score 0 factsumm-qa Answers based on SOURCE [Q] Who killed John? [Pred] Jack [Q] Who did Jack kill? [Pred] John [Q] Who killed John? [Pred] <unanswerable> [Q] Who did Jack kill? [Pred] John Answers based on SUMMARY [Q] Who killed John? [Pred] Jack [Q] Who did Jack kill? [Pred] John QAGS Score 1 0.5 factsumm-triple SOURCE Triples ('Jack', 'killed', 'John') None SUMMARY Triples ('Jack', 'killed', 'John') None (*2) Triple Score 1 0 *1. For factsumm-fact, since both samples got the same results, the details are omitted. *2. FactSumm only outputs common triples of source and summary. *3. When we changed the input source text to ‘Jack said that he killed John.’, the results were the same as ‘Jack: I killed John.’ This is considered to be able to be avoided by fine-tuning with dialogue data.
アバタヌ
Introduction Hi! My name is Jose, a software engineer working for RevComm. In this blog post, I'll discuss four takeaways from my first PyCon APAC and the most interesting talks I attended. What is PyCon APAC? PyCon APAC is a non-profit annual Python conference organized in countries of the Asia-Pacific Region. The 2023 edition in Tokyo consisted of four days: one tutorial, two conferences, and one development sprint. Lessons 1. Plan ahead Every PyCon exhibits the most varied collection of talks, from obscure tricks of the language to the technical marvels of frameworks. This year, there were more than fifty presentations in English and Japanese across five tracks. To get the best out of them, prepare an agenda. Read each talk's description; sometimes, the title is enough, and choose where you are going. Creating a calendar for the event in iCal or gCal is especially useful for coordinating with friends. Just so you know, the schedule above took me around forty-five minutes. 2. Take time for the sponsor booths My first major mistake was forgetting about the sponsor booths. I skipped the last two tracks of Day 2 to go around, and It was worth it! Check them out. They are a fantastic reference for the country's Python market – what different companies are doing, their stack, and who is hiring. You might be as surprised as I was to find unexpected sponsors. The stamp rally was a great motivator, too. 3. Talk to people Any major conference is an opportunity to engage with the community. Talk to people. I met so many charming characters and learned a considerable amount. If you don't have time on the conference days, the official and unofficial parties are ideal for networking. 4. Join the developer sprint As the famous proverb says: After two days of conference and drinking parties, the developer sprint sounds like a stretch. It’s not. You will be surprised how productive you are in a couple of hours. For instance, my team merged a PR to the cPython's official repo! macOS CI for CPython now supports `free-threaded` mode CI as the conditional CI. It was done during the PyCon APAC sprint. https://t.co/rrcRxtkw7K #pyconapac pic.twitter.com/7pULkgP9By — Donghee Na (@dongheena92) October 29, 2023 Coding along with people you've just met is as open-source as it gets. Talks I attended eight talks, seven in English and one in Japanese. For brevity, I'd like to discuss the ones who impressed me the most. Write Python for Speed by Yung-Yu Chen https://2023-apac.pycon.jp/timetable?id=WNN9WG www.youtube.com This talk goes deep into optimizations for speeding up your Python programs. Although the field of application was outside my current job, Chen's passion and wit made me follow it until the end. I loved some of his quotes: "Python is the second-best language for everything." "To go fast, you do dangerous things." Couldn't agree more. Beaming up to the flow! by Thu Ya Kyaw https://2023-apac.pycon.jp/timetable?id=KKELHA www.youtube.com An enlightening talk about data streaming, the basics of Apache Beam, and the feature engineering process at Google. The expositor was also present at the Google Cloud booth, so I got to ask many questions. Debugging and Troubleshooting Python Applications by Neeraj Pandey https://2023-apac.pycon.jp/timetable?id=C7HGZS www.youtube.com This talk deepens into logging, profiling, and debugging in monolithic and distributed systems. I was blown away by OpenTelemetry. What does your application need to run on production? by Shota Kokado https://2023-apac.pycon.jp/timetable?id=FHTQDR www.youtube.com After years of working in Software Engineering, this talk was a good refresher on all the basics any production-ready application should have. The talk is in Japanese, but you can extract the vital information from the slides. So for next year
 Indonesia will host next year's PyCon APAC. We also have the annual PyCon JP. And many more! Check pycon asia's website for more information. Special thanks Huge thanks to RevComm for supporting me throughout the event, to my colleagues whom I went with, to the more than fifty members of the APAC organizing committee, and, of course, to all the new people I met. Each of them made the conference for me. You can follow me at twitter ( @juanjo12x ). See you next year! References PyCon APAC 2023 official website : https://2023-apac.pycon.jp/timetable Check the official PyCon JP’s YouTube channel for all the conference talks : https://www.youtube.com/@PyConJP/featured
アバタヌ
RevCommの䞭島です。 2023幎10月26日朚から29日日に開催された PyCon APAC 2023 に参加したした。 匊瀟からは陶山 嶺、小門 照倪、束土 慎倪郎兌 コアスタッフの3名が登壇したした。 今回はConferenceの振り返りずしお登壇者らのコメントずトヌクの感想をお送りしたす。 登壇振り返り Pythonはどのようにデヌタベヌスず繋がるのか 抂芁: Webアプリケヌション開発で䜕気なく䜿っおいるO/Rマッパヌやデヌタベヌスアダプタのラむブラリはずおも䟿利です。 数々のラむブラリが、我々がプログラムずネットワヌクはどのように繋がっおいるのかを考える必芁なくデヌタベヌスず繋がるこずを助けおくれおいたす。 このトヌクでは、゜ケット通信で぀ながる方法を深掘りしおいく他、耇数のラむブラリでの実珟方法、PEP249で決められおいるルヌル、非同期凊理をどのように実珟しおいるか、最新のO/Rマッパヌやデヌタベヌスアダプタのラむブラリ事情などを玹介しおいきたす。 登壇者: Shintaro Matsudo shintaromatsudo  発衚資料: Pythonはどのようにデヌタベヌスず繋がるのか www.youtube.com 登壇者の感想 Shintaro Matsudo 日々Webアプリケヌションを開発しおいる䞭で疑問に思っおいるこずからテヌマを決めたした。資料を䜜る䞭で倚くのこずを孊ぶこずができたした。 聞いおくれた方々もなにかを埗おくれおいたら嬉しいです。 たた、今幎はPyCon APACだったので日本以倖からの参加者ずも倚く亀流するこずができたした。 来幎のPyCon APACにも発衚を英語でできるようになっおプロポヌザルを提出しようず思っおいたす。今幎出䌚えた方々ずたた来幎䌚えるこずを楜しみにしおいたす。 Pythonで䞀歩螏み出すバむナリの䞖界 抂芁:コンピュヌタの䞖界はれロずむチで成り立っおいたす。 この文章もPythonのロゎ画像もみなさんが曞いおいるプログラムもすべおれロずむチで衚珟されおいたす。 ずいうこずはみなさん知っおいるでしょう。 しかし、そのこずを意識したこずがなかったり、「バむナリ」や「バむト列」ずいう蚀葉に苊手意識を感じる方も倚いのではないでしょうか。 本セッションでは、Pythonの察話モヌドやprint()、structモゞュヌルなどを䜿っおバむナリの䞖界を芗いおみたす。 バむナリに慣れるずより深くコンピュヌタを知るこずができ、目の前の䞖界が䞀気に広がりたす。 本セッションを通じお、その最初の䞀歩を螏み出したしょう。 登壇者: Rei Suyama ( rhoboro ) 発衚資料: Pythonで䞀歩螏み出すバむナリの䞖界 www.youtube.com 登壇者の感想 Rei Suyama 今幎はPyCon APAC 2023レビュアヌの評䟡芳点を参考に、初心者だった頃の自分を振り返りながら発衚テヌマを決め、プロポヌザルを提出したした。 発衚資料や内容に関しおも、最初の䞀歩ずいうこずでセッションを聎講しおくれる方々を眮いおいっおしたわないよう䞁寧な説明を心がけ構成を緎りたした。 その甲斐もあっおかXのポストや懇芪䌚で感想を聞いた印象では、想像以䞊に参加者の方々に楜しんでもらえおいお嬉しかったです。 時間の関係で非衚瀺にしおスキップしたスラむドも倚くありたしたので、ぜひ発衚資料を芋おいただければず思いたす。 あなたのアプリケヌションを本番システムで動かすために 抂芁: Webアプリケヌションの開発ず運甚においお必芁な知識は倚岐に枡りたす。 フレヌムワヌクの䜿い方を芚えるこずはもちろん重芁ですが、開発したアプリケヌションは本番システムにリリヌスしお実際に皌働するこずになりたす。 そしお、リリヌスしたシステムは継続的に運甚しおいく必芁がありたす。 このセッションでは、本番システムでの運甚を芋据えたアプリケヌション開発に必芁な知識や勘所を玹介したす。 登壇者: Shota Kokado skokado  発衚資料: あなたのアプリケヌションを本番システムで動かすために www.youtube.com 登壇者の感想 Shota Kokado 普段からWebサヌビスの開発、運甚する䞭で「䞀぀のこずだけやっおいれば良い」ずいうこずは無く、様々な知識やバックグランドが歊噚になるこずを実感しおいたす。 今回のトヌクが゚ンゞニア入門者の方々にずっお圹に立おば光栄です。 圓日の質疑応答に察する補足を個人の参加レポヌトに蚘茉しおいたすので、そちらもぜひご芧ください。 PyCon APAC 2023に参加登壇しおきたした @skokado | Qiita 登壇者の感想は以䞊です 他にも、䞭島が芖聎しお興味深かった登壇をいく぀か玹介させおいただければず思いたす。 Dev Containers時代のPython開発環境のあり方 登壇者: Yoshiki Shibukawa https://2023-apac.pycon.jp/timetable?id=M8QP3X 䞀般的に蚀語やパッケヌゞのバヌゞョンが異なるプロゞェクトを開発しおいるず環境分離が倧切になりたす。 pipenv、poetry、hatchなど、これたでPythonのパッケヌゞ管理ツヌルは暙準であるvenvでの仮想化をベヌスにしお開発されおきたしたが、それらのツヌル矀や遞択肢が华っおPythonの環境構築の難易床を䞊げおいたす。 登壇者のShibukawaさんは「環境構築の手間が楜」「必芁以䞊に柔軟性を䞎えるのをよしずしない」「深く考えない状態でも難しくなく䜿える」ずいう芳点から、VSCode䞊のDev Containersに泚目し、その堎で環境構築を実践しながら玹介されおいたした。 普段 Docker で開発環境を甚意するこずが倚い私ですが、Shibukawaさんの実践を芋ながら手元のPCでもDev Containersを詊しおみたすず、すぐに環境が起動し動かすこずができたので、今埌カスタマむズなどを孊んで掻甚しおいこうず思いたした。 ModuleNotFoundErrorの傟向ず察策: 仕組みから孊ぶImport https://2023-apac.pycon.jp/timetable?id=9TKP3P 登壇者: Toshifumi Tsutsumi Pythonを䜿っおいるず誰でも経隓したこずのあるModuleNotFoundErrorに぀いお、基本的な芁玠から噛み砕きながら深掘りしおいお、非垞に分かりやすい発衚内容でした。 本登壇を聎講した方はModuleNotFoundErrorが䜕も怖くない状態になったこずず思いたす。 PythonのImportの圹割ず仕組みを分解し、以䞋の技術などに぀いお段階的に解説されおたす。 ModulesSpec PathFinder sys.path 䜕気なくImportを蚘述するず゚ラヌが解決するので、意識したこずのない蚀語仕様、特にImport呚りを理解するこずができ、よりPythonに詳しくなれたした。 たずめ このようなむベントに参加するのは初めおだったため䞍安な郚分もありたしたが、䌚堎やむベントは終始りェルカムな雰囲気で参加者同士の亀流も盛んでした。 そんな雰囲気に埌抌しされ、私も積極的にポスタヌセッションやスポンサヌのブヌスをたくさん回り、たくさんの方に話を聞かせおいただき、たっぷりず楜しむこずができたした。 公匏グッズのTシャツずバッグずタオル たた、非垞の倚くの方が集った本むベントはスタッフやスポンサヌ様に支えられお開催されおいたす。 むベントを支えおくださった登壇者、スタッフの皆さん、スポンサヌ様や関係者の方々、本圓にありがずうございたした 来幎は登壇者ずしお参加できれば良いな、ず匷く感じたした。 巊から小門、束土、䞭島、陶山、倧谷、ホセ 最埌に RevCommは電話営業や顧客応察を可芖化する音声解析AI搭茉型のクラりドIP電話「MiiTelミヌテル」を開発しおいたす。 プロダクトの開発においおWebアプリケヌション、機械孊習/深局孊習などの領域でPythonが広く䜿甚されおいたす。 「コミュニケヌションを再発明し人が人を想う瀟䌚を創る」ずいうミッションを達成するべく、䞀緒にプロダクトを開発しお頂ける゚ンゞニアを募集しおいたす hrmos.co
アバタヌ
Photo by Luke Chesser on Unsplash Introduction (This article is a translation of the Japanese article titled "MiiTel AccountのSLO: 枬定ず継続的な最適化の方法") I'm Kei Usami from RevComm. We develop and provide an AI-powered phone system "MiiTel" and an AI-powered online meeting analysis tool "MiiTel Meetings." I work in the MiiTel authentication platform (MiiTel Account) team, serving as a Project Manager and Software Engineer. Previous Articles: Cognito user pool で OpenID Connect を利用した外部 ID Provider によるサインインを実現する - RevComm Tech Blog Webアプリケーションの国際化対応をバックエンドからフロントエンドに移行した話 - RevComm Tech Blog In this article, I'd like to introduce the measures we are taking to ensure the stable operation of the MiiTel Account service, while also discussing its relationship with SLO (Service Level Objectives). SLO - What is it? In a nutshell, SLO can be described as "objectives on service reliability." Generally, companies providing web services or systems strive to minimize disruptions in order to offer users a better experience. However, since systems are not infallible, occasional outages or system issues are inevitable. This is where SLO comes into play. SLO represents the quality objectives set by service providers (such as companies offering web services like MiiTel). It is based on the quality levels users can expect when using the service. Actual SLOs are expressed as specific numerical values. For example, “guaranteeing 99.9% uptime” or “maintaining a response time of 2 seconds or less for 99.9% of all requests”. These metrics serve as indicators to assess how comfortably customers can use the service. Related terms - SLI and SLA SLI (Service Level Indicator) and SLA (Service Level Agreement) are closely related to SLO, and are also important concepts. SLI (Service Level Indicator) : SLI is a specific and quantitative metric used to measure the performance and quality of a service. It includes metrics such as average response time and error rates. SLA (Service Level Agreement) : SLA is a contract or agreement between the service provider and the customer. It typically specifies what quality metrics the service provider should meet and includes compensation arrangements in case the goals are not achieved. SLO (Service Level Objective) : SLO is a quality target set based on SLIs. It defines the performance and quality of a service in specific numerical terms. While often used as an internal target, some services publicly disclose their SLOs. In summary, SLI quantifies the state of a service, SLA defines the agreement between the service provider and the customer, and SLO sets the quality goals the service should achieve. These metrics are key to enhancing the reliability between service providers and customers. The difference between SLO and SLI is clearly illustrated on the Google Cloud website as follows: SLO and SLI - Google Cloud Now, let's explore how MiiTel Account sets SLOs and what specific measures are being taken to achieve them. Role of MiiTel Account First, let me explain the role of MiiTel Account within MiiTel. MiiTelの技術スタックとアーキテクチャ変遷を紹介します(2023年5月版) - RevComm Tech Blog MiiTel architecture MiiTel Account corresponds to what was introduced as the "Authentication Infrastructure Application" in this article. MiiTel Account handles the authentication functions for the entire MiiTel platform. If an issue were to occur with MiiTel Account, it would result in the inability to access any of the services that make up MiiTel. Since MiiTel is used for calls and inbound interactions, even a few seconds of service downtime can have a significant impact on users. Therefore, it is a service that must operate robustly and stably above all else. However, on the other hand, there is a dilemma between maintaining service stability and swiftly adding authentication-related features to meet business needs. SLO provides a framework to effectively manage this. By setting higher SLOs than regular services, you can ensure stability while allowing for some aggressive feature development as long as the SLOs are met. By formalizing goals through SLO and visualizing the current state of service performance and quality, you can somewhat alleviate the tension between stable operation and feature additions. SLO in MiiTel Account So, what SLOs are set for MiiTel Account in practice? MiiTel utilizes Datadog as a monitoring tool and currently has the following target values set: The percentage of 5XX errors in the total request count should be within 0.2%. The average response time should be under 3 seconds. *Both of the above criteria should be met for 99.9% or more within the last 90 days. These are quite strict numbers. However, as of October 2023, the error percentage exceeds 99.999%, and the response time is 100%, surpassing the targets. With a considerable error budget, there is room for proactive feature development while maintaining the stability of the system. SLO API errors - past 90 days SLO slow response - past 90 days Datadog is a valuable tool, particularly when combined with APM (Application Performance Monitoring) , as it makes setting and monitoring SLOs straightforward. It automatically calculates monitoring metrics and allows you to configure alerts according to your preferences, making it highly convenient. Efforts Toward Achieving SLOs To maintain SLOs, various initiatives and operational strategies are necessary. Here, I'll introduce some of the efforts within MiiTel Account. Setting Various Metrics and Monitoring Alerts One of the most effective and easy-to-implement measures is setting up metrics and monitoring alerts. While various tools can accomplish this, as mentioned earlier, RevComm utilizes Datadog as its monitoring tool. You can set thresholds to trigger alerts in cases where there are anomalies in request counts or when infrastructure metrics, such as those from AWS, are more critical than usual. These alerts can be configured to notify you via platforms like Slack. docs.datadoghq.com Datadog memory usage alert Datadog request count alert Moreover, Datadog allows for creating simple scenarios to run end-to-end tests periodically, which can be used for health checks to ensure the login functionality is working correctly. When setting up alerts, it's advisable to differentiate notification channels between production and non-production environments. This way, you can easily discern whether immediate attention is required, preventing development environment alerts from getting lost in the mix. Regular Metric Checks in Meetings The MiiTel Account team conducts bi-weekly meetings where they discuss task progress, share insights, and address concerns. To foster constant awareness of SLOs and various metrics, the team begins each meeting by checking the SLO dashboard in Datadog. SLO dashboard - Datadog With Datadog APM set up, you can access dashboards that display time-series data for metrics like request counts, error rates, and latency. This is highly effective in understanding the current state of the service. In some cases, analyzing the trends of request counts and response times for each API endpoint and using this data to consider effective measures for improvement may be necessary. Sometimes, abnormalities are detected during these regular meetings. Anomaly requests An example of this was noticed by Shota Kokado (@skokado, previous article: Amazon Inspectorによるプラットフォーム診断とコンテナイメージ改善の取り組み - RevComm Tech Blog ), who has appeared in this blog on several occasions. At that time, request count alerts as mentioned earlier had not been set up. However, during a routine dashboard check in a meeting, an abnormal tenfold increase in requests was observed. Due to web server auto-scaling and other measures, there was no significant impact on the service, and the issue was resolved through the use of security features like WAF. If it hadn't been discovered promptly, there could have been potential service disruption due to resource constraints in the infrastructure. Automation of Integration Tests and E2E Tests After Release While enhancing monitoring and alerting is essential, most incidents tend to occur shortly after a release. There might also be bugs that are only noticeable when working with the actual environment and database, as unit tests can't detect them. To mitigate these risks, MiiTel Account has automated API integration tests and E2E tests to run after a release. These tests are configured for each environment (we have three major environments), allowing them to check for any unexpected bugs before a production release. Integration Tests: Comprehensive testing of nearly all API endpoints for normal operation. E2E Tests: UI tests for critical functionality using Autify. Upon completion of these tests, notifications are sent to Slack as follows: E2E testing result The automation framework for tasks like these has been developed by Raman Yachi (@r-ym). He has recently summarized the details in a blog post, which you can refer to for more in-depth information. E2E Testing system for MiiTel Account - RevComm Tech Blog (English) MiiTel AccountチームのE2Eテスト自動化 - RevComm Tech Blog (日本語) Thanks to this system, which significantly reduces the need for manual testing, releases can now be carried out with greater safety and reduced psychological burden. These tests have significantly enhanced the service's security, allowing the team to transition from weekly night releases to releasing during the day whenever necessary. Deployment frequency is an important metric, especially emphasized in the Four Key Metrics of DevOps Research and Assessment (DORA), so this initiative holds significance not only in terms of SLOs but also in improving development productivity. Looking Ahead Thanks to these measures, we've been fortunate to achieve SLOs and maintain a higher level of metrics. While operating a web system, it's inevitable that there will be occasional disruptions and temporary drops in service performance. However, with the strategies mentioned earlier, you can control this risk and maintain high productivity while continuing to develop new features. Looking ahead, the goal is to not only maintain SLOs but also enrich the metrics for more detailed service health checks and enhance development productivity. www.revcomm.co.jp
アバタヌ
Photo by Luke Chesser on Unsplash はじめに RevCommの宇䜐矎です。 RevCommでは、音声解析AI電話「MiiTelミヌテル」やAI搭茉オンラむン䌚議解析ツヌル「MiiTel Meetings」を開発・提䟛しおいたす。 私はMiiTelの認蚌基盀 (MiiTel Account) 開発チヌムで、Project Managerå…ŒSortware Engineerずしお掻動しおいたす。 過去蚘事: Cognito user pool で OpenID Connect を利用した外部 ID Provider によるサインインを実現する - RevComm Tech Blog Webアプリケーションの国際化対応をバックエンドからフロントエンドに移行した話 - RevComm Tech Blog 今回は、MiiTel Accountずいうサヌビスを安定的に運営するためにどのような取り組みをしおいるのか、SLO (Service Level Objective) ず絡めお玹介したいず思いたす。 SLOずは䜕か SLOは盎蚳するず"サヌビス信頌性目暙"です。 䞀般的に、Webサヌビスやシステムを提䟛しおいる䌚瀟は、ナヌザヌによりよい䜓隓を提䟛するため障害を最小限に抑えるよう努力しおいたす。 ただシステムである以䞊、サヌビスは垞に100%の信頌性を持っお皌働できるずいうわけではなく、どうしおも時々障害やシステム䞍具合が発生したす。そこで登堎するのがSLOです。 SLOは、サヌビス提䟛者䟋えばMiiTelのようなWebサヌビスを提䟛する䌚瀟が蚭定するサヌビスの品質目暙です。これは、ナヌザヌがサヌビスを利甚する際に期埅する品質レベルをもずに衚珟されたす。 実際のSLOは、正確な数字で衚珟されたす。䟋えば、99.9%の正垞皌働時間を保蚌するずか、党リク゚ストのうちの99.9%のレスポンスタむムを2秒以内に維持する、のような圢です。これらは顧客がサヌビスをどれだけ快適に利甚できるかを評䟡するための指暙です。 関連甚語 - SLIずSLA SLOに関連しお、SLI (Service Level Indicator) ずSLA (Service Level Agreement) もよく䌌おいたすが重芁な抂念です。 SLI (Service Level Indicator) : サヌビスの性胜や品質を枬定する具䜓的か぀定量的な指暙です。䟋えば、平均応答時間や゚ラヌ率などが含たれたす。 SLA (Service Level Agreement) : サヌビス提䟛者ず顧客ずの間で合意される契玄ないし取り決めです。通垞、サヌビスの提䟛者が顧客に察しおどの品質指暙をどのくらい満たすべきかが明蚘され、目暙が満たされなかった堎合の補償を含みたす。 SLO (Service Level Objective) : SLOはSLIに基づいお蚭定される品質目暙であり、サヌビスの性胜や品質を具䜓的な目暙数倀で蚭定したす。内郚的な目暙ずしお䜿われるこずが倚いですが、サヌビスによっおは公衚されおいたす。 たずめるず、SLIはサヌビスの定量的な状態を瀺し、SLAはサヌビス提䟛者ず顧客の合意事項を定矩し、SLOはサヌビスが達成すべき品質目暙を蚭定する圹割を果たしたす。これらの指暙が、サヌビス提䟛者ず顧客の信頌性を高める鍵ずなっおいたす。 Google CloudのWebサむトでは、䞋蚘のようにSLOずSLIの差がわかりやすく図で瀺されおいたす。 SLO ず SLI の関係を瀺すグラフ - Google Cloud SLO を定義する  |  アーキテクチャ フレームワーク  |  Google Cloud ここからはMiiTel AccountがどのようにSLOを蚭定しおいお、その達成に向けお具䜓的にどんな取り組みをしおいるかをご玹介したす。 MiiTel Accountの䜍眮づけ たず、MiiTelにおけるMiiTel Accountの䜍眮づけに぀いお説明したす。 MiiTelの技術スタックとアーキテクチャ変遷を紹介します(2023年5月版) - RevComm Tech Blog MiiTel architecture MiiTel Accountは、こちらの蚘事で玹介があった「認蚌基盀アプリケヌション」ずいうものにあたりたす。 MiiTel AccountはMiiTel党䜓の認蚌機胜を担っおいるため、もし障害が発生するずMiiTelを構成するどのサヌビスにもアクセスできたせん。MiiTelは通話や受電に䜿われるため、数秒のサヌビス停止であっおもナヌザヌに倧きな圱響を及がしおしたいたす。 そのため、䜕よりも堅牢か぀安定的に皌働するこずが求められるサヌビスだずいえたす。ただ䞀方で、認蚌関連の機胜远加もビゞネス的なニヌズによっお迅速に行なっおいく必芁があり、ここでサヌビスの安定皌働ずのゞレンマが生じたす。 これをうたくコントロヌルするために䜿える枠組みがSLOです。 通垞のサヌビスよりも高いSLOを蚭定するこずで安定皌働を担保し぀぀、SLOが達成できおいお䜙裕があるうちは、ある皋床攻めの機胜远加開発も可胜になりたす。 SLOずいう圢で目暙を明確化するずずもに、サヌビスの性胜や品質に぀いおの珟状を可芖化しながら運甚するこずによっお、安定皌働ず機胜远加の緊匵関係をある皋床緩和するこずができたす。 MiiTel AccountにおけるSLO ではMiiTel Accountでは、実際にどのようなSLOを蚭定しおいるのでしょうか。 MiiTelではモニタリングツヌルずしおDatadogを掻甚しおおり、ここで今は以䞋のような目暙倀を蚭定しおいたす。 総リク゚スト数における5XX゚ラヌの割合が0.2%以内 レスポンスタむムの平均倀が3秒以内 *いずれも盎近90日以内の99.9以䞊で䞊蚘を満たすこず かなりシビアな数字ではありたすが、2023幎10月珟圚の実瞟倀ずしおぱラヌの割合のほうが99.999、レスポンスタむムの方は100ず目暙を達成しおいたす。゚ラヌバゞェットにもかなりゆずりがあるため、ある皋床積極的な機胜開発ができる状態を保おおいたす。 SLO API errors - past 90 days SLO slow response - past 90 days Datadogは、 APM (Application Performance Monitoring) を入れおおけばSLOの蚭定も容易で、こういったモニタリング数倀なども自動で蚈算しおくれお、アラヌトの蚭定も思いのたたなので非垞に䟿利です。 SLO 達成に向けた取り組み SLOを保぀ためには、様々な取り組みや運甚䞊の工倫が必芁です。ここからは、MiiTel Accountでの取り組みの䞀郚を玹介したす。 各皮メトリクス・モニタリングアラヌトの蚭定 たず簡単にできおか぀効果が高いものずしお、メトリクスやモニタリングアラヌトの蚭定がありたす。これは色々なツヌルで実珟できたすが、䞊蚘のずおりRevCommではDatadogを監芖ツヌルずしお䜿っおいたす。 リク゚スト数に異垞倀があった堎合や、AWSなどのむンフラのメトリクスが通垞より逌迫しおいる堎合などに、閟倀を蚭定しおSlackなどにアラヌトを送るように蚭定するこずができたす。 docs.datadoghq.com Datadog memory usage alert Datadog request count alert たたDatadogでは、簡易的なシナリオを䜜っおE2Eテストを定期実行するこずができるため、これを掻甚しおログむン機胜が正垞に動いおいるかどうかをヘルスチェック的に運甚しおいたす。 アラヌトを蚭定する堎合は、本番環境ずそれ以倖の環境の通知チャンネルを分けおおくず、至急察応が必芁なものかどうかわかりやすく、開発環境のアラヌトで埋もれおしたうこずも避けられるのでおすすめです。 定䟋ミヌティングでのメトリクスチェック MiiTel Accountチヌムでは週に2回の定䟋ミヌティングを行っおおり、タスクの進捗状況や盞談・共有事項などに぀いお䌚話したす。 普段からSLOや各皮メトリクスに぀いお意識するため、ミヌティングの冒頭で毎回DatadogのSLOダッシュボヌドをチェックしおいたす。 SLO dashboard - Datadog Datadog APMを蚭定しおいるずダッシュボヌドが確認でき、リク゚スト数や゚ラヌレヌト、レむテンシヌなどの倀が時系列で䞀芧できるため、サヌビスの珟状を把握するために非垞に有効です。 堎合によっおはAPI゚ンドポむントごずのリク゚スト数の掚移や、レスポンスタむムなどを分析しお、改善が必芁な堎合にこのデヌタを元に効果的な斜策を怜蚎するこずもありたす。たた、ずきにはこの定䟋ミヌティングでのチェックから異垞が芋぀かるこずもありたす。 Anomaly requests これは、過去に䜕床かこのブログでも登堎しおいる Shota Kokado (@skokado) (過去蚘事: Amazon Inspectorによるプラットフォーム診断とコンテナイメージ改善の取り組み - RevComm Tech Blog ) が気づいおくれた事䟋です。 このずきはただ前述のリク゚スト数アラヌトを蚭定しおいなかったのですが、定䟋ミヌティングでのダッシュボヌドチェックで通垞時の10倍ほどの異垞なリク゚スト増が確認されたした。 Webサヌバヌのオヌトスケヌリングなどのおかげでサヌビスぞの顕著な圱響はなく、結果的にはWAFなどのブロックによっお察応できたした。もしすぐに発芋されおいなければ、どこかでむンフラのリ゜ヌスが逌迫しおサヌビスに圱響が出おいた可胜性がありたす。 リリヌス埌のむンテグレヌションテストず E2E テストの自動化 監芖やモニタリングを充実させるこずも重芁ですが、䞀方で障害の倚くはリリヌス盎埌に起きるこずが倚いです。たた、実環境やデヌタベヌスを䜿わないずナニットテストでは気づけないようなバグなどが混じっおいるこずもありたす。 MiiTel Accountではこういったリスクを䜎枛するため、リリヌス埌のAPIむンテグレヌションテストずE2Eテストを自動実行するようにしおいたす。これは各環境 (倧きく分けお3぀の環境がありたす) ごずに蚭定しおおり、本番リリヌス前に予期しないバグなどが起きおいないかどうか確認するこずができたす。 むンテグレヌションテスト: ほが党API゚ンドポむントぞの正垞系テスト E2Eテスト: Autifyを䜿ったクリティカルな機胜のUIテスト テストが完了するず、それぞれ以䞋のようにSlackに通知が来たす。 E2E testing result このあたりの自動実行の仕組みは Raman Yachi (@r-ym) が構築したもので、最近ブログにたずめおくれおいるので、詳现はこちらをご芧ください。 E2E Testing system for MiiTel Account - RevComm Tech Blog (English) MiiTel AccountチームのE2Eテスト自動化 - RevComm Tech Blog (日本語) この仕組みによっお手䜜業で動䜜確認する手間がかなり省けたため、より安党か぀心理的な負担も少ない䞭でリリヌスが行えるようになりたした。 これらのテストで安党性がかなり担保されるようになったため、元々週次倜間に行っおいたリリヌス䜜業を珟圚は日䞭随時に行うよう切り替えおいたす。 デプロむ頻床はDevOps Research and Assessment (DORA) のFour keys metricsでも特に重芁芖されおいる指暙なので、SLOだけではなく開発生産性ずいう意味でも倧きな意味がある斜策だったず考えおいたす。 今埌に向けお 以䞊のような斜策によっお、幞運にも今のずころはSLOを達成したうえでさらに高い氎準の指暙をキヌプできおいたす。 Webシステムを運営しおいく以䞊は障害やサヌビスのパフォヌマンスが䞀時的に萜ちるこずは避けられない面もありたすが、これたで述べおきたような斜策によっおこのリスクをコントロヌルし぀぀、高い生産性を保っお新機胜開発を続けおいくこずもできるはずです。 今埌はSLOを保ったたた、さらに指暙を充実させおより詳现なサヌビスのヘルスチェックができるようになったり、開発生産性を向䞊させおいくこずを目指しおいたす。 RevCommでは機胜開発だけではなく、こういった運甚面の知芋を深めたり新しい取り組みを行う機䌚が豊富にありたす。興味がある方は、䞋蚘から採甚情報をチェックしおみおください。 www.revcomm.co.jp
アバタヌ
RevComm Research Dept. Development Groupの高橋兞生です。先日開催された、NIKKEI Tech Talkの 【日経×コドモン×RevComm】サヌビスの安定性、信頌性を高めるDevOps/SREの取り組み に登壇したしたので、玹介させおいただきたす。 NIKKEI Tech Talkずは NIKKEI Tech Talkずは、日本経枈新聞瀟 CDIO宀が開催する技術勉匷䌚です。毎回テヌマを倉えお様々なトピックで開催されおいたす。私が登壇したのは以䞋の回でした。 nikkei.connpass.com これ以埌も、 nikkei.connpass.com nikkei.connpass.com ず興味深いラむンナップで続いおたすので、興味があればぜひご参加ください。 発衚内容の抂芁 Feature Flagを私のチヌムで導入した経隓を螏たえお、どのように怜蚎、導入、運甚したかずいう点に぀いおの説明が発衚の倧たかな内容です。 私の所属するRevComm Research Dept. Development Groupずいうチヌムは、研究開発の郚門の䞭にありたす。 「機械孊習の研究成果を補品に組み蟌み、ナヌザヌに䟡倀を届ける」 ずいうのがチヌムのミッションの䞀぀になっおいたす。RevCommは音声解析分野の機械孊習の研究を瀟内で続けおおり 1 、そういった研究成果を MiiTelの補品矀に組み蟌み、ナヌザヌに新たな䟡倀を提䟛し続けられるように努めおいたす。したがっお、私のチヌムが開発するサヌビスの倚くは機械孊習を䜿ったサヌビスになりたす。 こういった背景の䞭、機械孊習サヌビス固有の機胜・非機胜面の䞍確実性ぞの察応をずり぀぀、他のチヌムの開発に䟝存せず開発が継続できるようにするためにFeature Flag を導入したした。このあたりのモチベヌションは、 こちらのスラむド 付近にたずめおいたす。たた、そもそもFeature Flagず蚀っおもその圹割や性質に応じお質的に異なるものず認識した方が良いずいうこずを怜蚎フェヌズで孊びたした。この点は 「Feature Flagっお4皮類あんねん」 ずいうキヌワヌドずずもにMartin Fowlerの匕甚を元に こちらのスラむド 以降にたずめおいたす。最埌のハむラむトは導入埌の運甚面です。Feature Flag導入埌、䜿わなくなったFeature Flagを消すための工倫に関しお こちらのスラむド にたずめたした。 スラむドの最埌にも曞きたしたが、今埌はA/Bテストや党瀟的な切り替えをPdMが行えるような仕組みに発展させおいく可胜性があるので、ここで怜蚎した内容を螏たえ、よりナヌザヌに䟡倀を安定的に届けおいける圢を目指そうず思いたす。 登壇資料はこちらにアップロヌドされおいたすので、ご興味のある方はご芧ください。 speakerdeck.com チヌムに仕組みを入れおDevOpsを加速させる RevComm Researchでは、SREずいうロヌルはなく 、EM(Engineering Manager) を陀くIC(Individual Contributor) 個々人が䞻䜓ずなっお、SRE的な芖点を持っおDevOpsの改善を図っおいたす。 最近では、Platform Engineeringずいうキヌワヌドもよく目にするようになりたした。もちろん、倧芏暡な組織の堎合Platform Engineer(or SRE) 専任、のようなパタヌンはありたすが、そのようなパタヌンであっおも(瀟倖の) ナヌザヌの䜿うアプリケヌションを䜜っおいる開発者がSRE的な芖点を意識する こずがより良い DevOpsの改善に重芁 だず私は考えおいたす。 ずはいえ、「ちゃんずDevOpsやっおいこう」ずいう粟神論だけでは、再珟性もないですし、チヌムずしおうたく行動するこずができたせん。そうならないためには、 チヌムに仕組みを入れる 必芁がありたす。私のチヌムでは、 「小さな改善掻動」 ずいうルヌルがあり、それがDevOpsを掚進する仕組みの䞀䟋になっおいたす。チヌムずしおのコミットメントは最優先なものの、チヌムの合意が必芁になるような倧きな倉曎でなければ、自由にこういった運甚の改善、バグの修正、CI/CDの改善などを行うこずができたす。Feature Flagの察応もこの「小さな改善掻動」の䞭から生たれたものでした。 登壇のメリット RevCommではDevRelを支えおくださっおいる方もいらっしゃいたすし、個人的にもこういった登壇の機䌚はメリットが倧きいのでどんどん挑戊しようず考えおいたす。 こういった堎での発衚を行うこずで、知っおいるこずを共有しお、知らないこずを共有しおもらうこずができたす。゜フトりェアの進化の歎史がたさしくそうであったように、これは゜フトりェア゚ンゞニア党䜓の利益になるず思いたす。 あたり意識されない登壇者のみのメリットもありたす。発衚内容に詳しくなるのはもちろんですが、私はここで、別の点も匷調したいず思いたす。たずは、瀟内に閉じた専門知識を䞖の䞭における䞀般的な氎準で䜍眮付ける良い機䌚になりたす。これによっお、芖野が広くなり、瀟内の問題解決にも新たな芖点で察応できる可胜性が増えたす。たた、発衚するこずで、良い点・悪い点を指摘しおもらうこずができたす。これにより自分䞀人では思い぀かなかった芳点での考えを知るこずができ、より深く技術を芋぀めるこずができたす。 こういった堎は倧奜きなので、今埌も発衚したり参加者ずしお楜しんだりできればうれしいなず思っおいたす。 以䞋は発衚埌の最埌の締めの様子です(みんな楜しそう) 発衚埌の Zoom の様子 最埌に 最埌にNIKKEI Tech Talkの参加者のみなさた、運営者・登壇者のみなさた、瀟内でDevRel察応をしおくださった方、レビュヌしおくださった方に感謝の意を瀺しお締めさせおいただきたす。 我々は “コミュニケヌションを再発明し、人が人を想う瀟䌚を創る” ずいうミッションを掲げお日々励んでいたす。そのためにはたくさんの優秀な仲間が必芁です。今回のこういった掻動を芋お、RevCommに興味を持っおくださった方は 採甚ペヌゞ もぜひご確認いただけるず幞いです。 「Forbes AI 50 2023」に遞出 アゞアで唯䞀、最も有望なAI掻甚䌁業ずしお衚地されたした ( https://prtimes.jp/main/html/rd/p/000000158.000037840.html ) ↩
アバタヌ
2023幎10月27日(金)〜28日(土)に開催される PyCon APAC 2023 に RevComm の゚ンゞニアの陶山 嶺ず小門 照倪ず束土 慎倪郎が登壇したす。 むベント抂芁 https://2023-apac.pycon.jp/ 公匏サむトより匕甚 https://2023-apac.pycon.jp/ PyCon APACは、プログラミング蚀語「Python」を䞭心ずしたボランティアによる非営利の幎次カンファレンスです。このカンファレンスの目的は、Pythonプログラミング蚀語ずその呚蟺技術を探求し、議論・実践できる堎を提䟛するこずです。運営チヌムは、アゞア倪平掋地域における囜たたは地域が䞻䜓ずなり、珟圚では、シンガポヌル、マレヌシア、むンドネシア、フィリピン、タむ、韓囜、銙枯、ベトナム、日本、台湟、むンド、バングラデシュが毎幎亀代しお開催され、2023幎は日本のメンバヌが䞻䜓ずなり運営したす。そしお、日本での開催は2013幎以来の10幎ぶりずなりたす。 日皋: 2023幎10月27日(金)28日(土) 䌚堎 TOC有明コンベンションホヌル 参加申し蟌みはこちら 䞻催: 䞀般瀟団法人 PyCon JP Association 登壇情報 Pythonはどのようにデヌタベヌスず繋がるのか Webアプリケヌション開発で䜕気なく䜿っおいるO/Rマッパヌやデヌタベヌスアダプタのラむブラリはずおも䟿利です。 数々のラむブラリが、我々がプログラムずネットワヌクはどのように繋がっおいるのかを考える必芁なくデヌタベヌスず繋がるこずを助けおくれおいたす。 このトヌクでは、゜ケット通信で぀ながる方法を深掘りしおいく他、耇数のラむブラリでの実珟方法、PEP249で決められおいるルヌル、非同期凊理をどのように実珟しおいるか、最新のO/Rマッパヌやデヌタベヌスアダプタのラむブラリ事情などを玹介しおいきたす。 日時: 2023幎10月27日(金) 13:4013:55 登壇者: Shintaro Matsudo リンク: https://2023-apac.pycon.jp/timetable?id=8XZDC7 Pythonで䞀歩螏み出すバむナリの䞖界 コンピュヌタの䞖界はれロずむチで成り立っおいたす。 この文章もPythonのロゎ画像もみなさんが曞いおいるプログラムもすべおれロずむチで衚珟されおいたす。 ずいうこずはみなさん知っおいるでしょう。 しかし、そのこずを意識したこずがなかったり、「バむナリ」や「バむト列」ずいう蚀葉に苊手意識を感じる方も倚いのではないでしょうか。 本セッションでは、Pythonの察話モヌドやprint()、structモゞュヌルなどを䜿っおバむナリの䞖界を芗いおみたす。 バむナリに慣れるずより深くコンピュヌタを知るこずができ、目の前の䞖界が䞀気に広がりたす。 本セッションを通じお、その最初の䞀歩を螏み出したしょう。 日時: 2022幎10月28日(土) 11:3012:00 登壇者: Rei Suyama リンク: https://2023-apac.pycon.jp/timetable?id=QEHREX あなたのアプリケヌションを本番システムで動かすために Webアプリケヌションの開発ず運甚においお必芁な知識は倚岐に枡りたす。 フレヌムワヌクの䜿い方を芚えるこずはもちろん重芁ですが、開発したアプリケヌションは本番システムにリリヌスしお実際に皌働するこずになりたす。 そしお、リリヌスしたシステムは継続的に運甚しおいく必芁がありたす。 このセッションでは、本番システムでの運甚を芋据えたアプリケヌション開発に必芁な知識や勘所を玹介したす。 日時: 2022幎10月28日(土) 14:1014:40 登壇者: Shota Kokado リンク: https://2023-apac.pycon.jp/timetable?id=FHTQDR 最埌に RevComm は電話営業や顧客応察を可芖化する音声解析AI搭茉型のクラりドIP電話「MiiTelミヌテル」を開発しおいたす。 プロダクトの開発においお Web アプリケヌション、機械孊習/深局孊習などの領域で Python が広く䜿甚されおいたす。 「コミュニケヌションを再発明し人が人を想う瀟䌚を創る」ずいうミッションを達成するべく、䞀緒にプロダクトを開発しお頂ける゚ンゞニアを募集しおいたす hrmos.co
アバタヌ