はじめに
2025年12月にプレビュー版としてリリースされたBigQueryの自律型エンベディング生成(autonomous embedding generation)を試してみました。
テキストデータを意味を持つベクトルに自動で変換してくれる機能なので、テキスト分析が捗りますよ!
今回は有馬記念のテキストコメントで遊んでみています。
接続の作成
Vertex AIを利用してembeddingするため、接続を作成する必要があります。BigQueryからCloudSQLにクエリするため使ったことがある方もいるかもしれません。
BigQuery > 接続 > 新規作成から、フォームを埋めましょう。
接続タイプは Vertex AI リモートモデル を選択します。

サービスアカウントへの権限付与
接続を作成したら、接続情報からサービスアカウントIDを調べましょう。
サービスアカウントIDをコピーしてください。
IAM > アクセスを許可を選択し、新しいプリンシパル にコピーしたサービスアカウントIDを貼り付けます。
ロールには「Vertex AI ユーザー」を指定し、保存します。
テーブル作成
CREATE TABLE ステートメントの AI.EMBED 関数を使用してエンベディングを生成できます。以下の例では、事前に作成したplaygroundデータセットへ作成しています。
CREATE TABLE playground.race_comments(
date DATE,
place_name STRING,
racenum INT64,
umaban INT64,
umaname STRING,
comment STRING,
comment_embedding STRUCT < result ARRAY<FLOAT64>,
status STRING > GENERATED ALWAYS
AS (
AI.EMBED(
comment,
connection_id => 'us.vertex_ai_cocnnection',
endpoint => 'text-embedding-005')
) STORED OPTIONS (asynchronous = TRUE));
データ挿入
作成したテーブルにデータを挿入しましょう、有馬記念のレースコメントを用意しました。
comment_embeddingの列は指定していません。
INSERT INTO playground.race_comments (date, place_name, racenum, umaban, umaname, comment) VALUES
("2025-12-28", "中山", 11, 1, "エキサイトバイオ", "中団最内に位置。3コーナーから押して進出するが直線入口で進路が狭く、抜け出す足もなかった。"),
("2025-12-28", "中山", 11, 2, "シンエンペラー", "中団最内の前目につけていたが3コーナーでポジションが下がってしまい直線も窮屈になった。"),
("2025-12-28", "中山", 11, 3, "ジャスティンパレス", "最後方から3コーナーで大外からジリジリと進出するが、直線バテた馬をかわす程度だった。"),
("2025-12-28", "中山", 11, 4, "ミュージアムマイル", "中団後方待機。3コーナーから徐々に進出、直線しっかり伸びて差し切った。"),
("2025-12-28", "中山", 11, 5, "レガレイラ", "やや出遅れて後方。3コーナーで勝ち馬といっしょに上がっていった。直線では馬群を捌きながら他馬を交わすも4着まで。"),
("2025-12-28", "中山", 11, 6, "メイショウタバル", "まずまずのスタートも外の馬の勢いがよく4番手。外を上がっていき2周目で先頭に立つが4コーナーからずるずる下がっていった。"),
("2025-12-28", "中山", 11, 7, "サンライズジパング", "ポジションを取れず後方を追走。直線入口で最後方から外を追い上げて見せ場を作った。"),
("2025-12-28", "中山", 11, 8, "シュヴァリエローズ", "後方グループ。馬群の中から追い上げようとするが、進路もなかった。"),
("2025-12-28", "中山", 11, 9, "ダノンデサイル", "中団やや後方。4コーナーから徐々に上がって直線は外に出しやや内にもたれながら伸びるも前をかわせず。"),
("2025-12-28", "中山", 11, 10, "コスモキュランダ", "出脚良く2, 3番手。直線入口で先頭、最後は勝ち馬に1/2馬身交わされたがよく粘った。大健闘。"),
("2025-12-28", "中山", 11, 11, "ミステリーウェイ", "好スタートから先手をとるが単騎逃げとはいかず。2周目で交わされ、4コーナーでズルズル後退。"),
("2025-12-28", "中山", 11, 12, "マイネルエンペラー", "中団外。3コーナーで先団に取りつくが、直線ではのびず。"),
("2025-12-28", "中山", 11, 13, "アドマイヤテラ", "少し出遅れたが外を上がっていき2周目で好位の内へ。直線に向いたとき内の4, 5番手につけていたが伸びなかった。"),
("2025-12-28", "中山", 11, 14, "アラタ", "最後方の内。終始内を回ったが直線で進路狭く、伸びもなかった。"),
("2025-12-28", "中山", 11, 15, "エルトンバローズ", "好スタートから中団の内に収まった。4コーナーで馬群を割るも直線では弾けなかった。"),
("2025-12-28", "中山", 11, 16, "タスティエーラ", "好スタートから好位。4コーナーから上がっていき見せ場を作るも伸びきれなかった。");
データチェック
作成直後はcomment_embeddingにはNULLが入っています。

少し時間が経つと自動で値が入っています。この件数ということもあるかもしれませんが、たった十数秒でした。

変換結果がおかしい?
さて、これであとは遊ぶだけと思ったのですがデータに少し問題がありそうです。
埋め込みベクトルの値のminとsumを出してみると、以下のようになりました。
SELECT date, umaname, comment, min(r) AS min_embed, sum(r) AS sum_embed
FROM
`playground.race_comments` AS race_comments,
UNNEST(comment_embedding.result) AS r
WHERE race_comments.date = "2025-12-28"
GROUP BY 1, 2, 3
ORDER BY sum_embed
どうやらいくつかのコメントが全く同じベクトルに変換されているようです。テキストが短く、全て競馬のレースに関するコメントなのでそのようなこともあり得るかと思いましたが、ミュージアムマイルの「中団後方待機。3コーナーから徐々に進出、直線しっかり伸びて差し切った。」と、シンエンペラーの「中団最内の前目につけていたが3コーナーでポジションが下がってしまい直線も窮屈になった。」が同じベクトルになってしまいました。
意味的には明らかに異なるコメントが同一ベクトルになるのは、実務で使うには少し怖い挙動です。
英語コメントにする
一度テーブルの中身を削除し、comment列に英語コメントを入れるため日本語コメント用のカラムを追加します。
TRUNCATE TABLE playground.race_comments;
ALTER TABLE playground.race_comments
ADD COLUMN comment_ja STRING;
今度は英語のコメントを用意しました。3年分にしています。
INSERT INTO playground.race_comments (date, place_name, racenum, umaban, umaname, comment, comment_ja) VALUES
("2023-12-24", "中山", 11, 1, "ソールオリエンス", "He raced from the back. In the stretch he was unable to work through traffic, lost running room, and could only grind away with limited acceleration.", "後方からの競馬。直線では馬群を捌き切れず、進路が狭くなりジリジリとした脚色だった。"),
("2023-12-24", "中山", 11, 2, "シャフリヤール", "He tracked the pace comfortably on the inside in mid-pack. In the stretch, he closed ground on the steep uphill but finished fifth.", "中団の内を馬なりで追走。直線では急坂で差を詰めたが5着まで。"),
("2023-12-24", "中山", 11, 3, "ホウオウエミーズ", "She settled at the rear and attempted to close from the far outside in the stretch, but the leaders were already too far ahead.", "後方待機。直線大外から差を詰めるも前とは距離があった。"),
("2023-12-24", "中山", 11, 4, "タイトルホルダー", "He was urged to the lead and set a strong pace, opening up a clear advantage while racing alone. He held on in the stretch but faded to third late.", "押して先手を主張。1000m1分0秒4のペースで引き離した単騎逃げをした。直線粘るも3着まで。"),
("2023-12-24", "中山", 11, 5, "ドウデュース", "He broke slowly and settled near the back, then swept past rivals around the third and fourth turns. He continued to accelerate in the stretch and surged past the field, delivering a decisive late charge worthy of a champion.", "出遅れて後方。3, 4コーナーで外を通って他馬をごぼう抜き。直線でも伸びて差し切った。千両役者ここにあり。"),
("2023-12-24", "中山", 11, 6, "ディープボンド", "He raced in the mid-pack toward the rear but was unable to improve his position and remained there throughout.", "中団後方。ポジションを上げることができずに後方のまま。"),
("2023-12-24", "中山", 11, 7, "アイアンバローズ", "He failed to keep up from around the third turn and gradually dropped out of contention.", "3コーナーあたりからついていくことができず後退。"),
("2023-12-24", "中山", 11, 8, "ライラック", "She was ridden patiently near the back. Despite swinging wide in the stretch, she failed to produce a strong finishing kick.", "無理せず後方で脚を溜めた。大外を回った直線では伸びきれず."),
("2023-12-24", "中山", 11, 9, "ヒートオンビート", "He traveled on the outside of the mid-pack but showed little acceleration entering the stretch and was briefly squeezed, limiting his run.", "中団の外を進行。直線入口で伸び脚目立たず少し挟まれた。"),
("2023-12-24", "中山", 11, 10, "ジャスティンパレス", "He stumbled slightly at the start and dropped to the rear. He made a wide move around the final turn and tried to rally in the stretch, but could not reach the leaders.", "出負けして最後方から。4コーナーで大外を回し、直線では追い上げるも届かなかった。"),
("2023-12-24", "中山", 11, 11, "ハーパー", "She broke sharply and secured a good stalking position near the front, but weakened noticeably in the stretch and faded.", "好スタートを決め、離れた先団の好位につけたが、直線では脚色わるく後退。"),
("2023-12-24", "中山", 11, 12, "ウインマリリン", "She tracked the leaders from the front half of the field, but her momentum stalled from the final turn and she failed to close the gap.", "中団前目を追走。4コーナーから脚色鈍く、前との差は詰まらなかった。"),
("2023-12-24", "中山", 11, 13, "タスティエーラ", "He raced from mid-pack and angled out entering the stretch, but was checked after getting squeezed and lost momentum. He closed again late, finishing sixth.", "中団から直線入口で外目に持ち出すも、直線で挟まれてブレーキ。そのあと差を詰めているが6着まで。"),
("2023-12-24", "中山", 11, 14, "プラダリア", "He was urged early to sit in a distant third position but began to retreat approaching the stretch.", "押して先頭とは離れた3番手。直線入り口で後退していった。"),
("2023-12-24", "中山", 11, 15, "スルーセブンシーズ", "She broke slowly and raced from the rear, gradually improving her position but failing to quicken in the stretch.", "出遅れて後方から。徐々にポジションを上げた、直線では伸びず"),
("2023-12-24", "中山", 11, 16, "スターズオンアース", "She broke best of all and was urged to secure second position along the rail. She brushed the inside rail lightly entering the third turn, then rallied strongly to overtake the leader in the stretch.", "一番いいスタートから押してうちの2番手を確保。3コーナー入り口で内ラチと軽く接触するも直線では逃げ馬を捉えて前に出た。"),
("2024-12-22", "中山", 11, 1, "ダノンデサイル", "He was urged from the inside draw to take the lead and set the pace. As the tempo gradually increased, he tired late and was overtaken by closing runners.", "最内枠から押して先頭へ。1000m1分2秒9で逃げた。徐々にペースが上がって最後は一杯となり差し馬に交わされた。"),
("2024-12-22", "中山", 11, 2, "ドウデュース", "He was scratched prior to the race due to lameness in his right foreleg.", "右前肢跛行のため出走取消。"),
("2024-12-22", "中山", 11, 3, "アーバンシック", "He broke slowly and settled along the rail in mid-pack. He enjoyed a smooth trip but failed to produce a decisive finishing kick.", "出遅れて中団の内。ロスなく運んだが、最後は弾けなかった。"),
("2024-12-22", "中山", 11, 4, "ブローザホーン", "He was slow away and raced near the back, showing little response despite encouragement around the final turn.", "出足悪く後方。4コーナーで押しても進まず。"),
("2024-12-22", "中山", 11, 5, "ベラジオオペラ", "He broke well and settled comfortably in second, battled on in front in the stretch, but weakened late under pressure.", "好スタートから2番手で折り合った。直線では前で粘ったが、最後は苦しくなった。"),
("2024-12-22", "中山", 11, 6, "ローシャムパーク", "He broke a step slow and raced near the rear, pulling early at a slow pace. He swung wide in the stretch but could only make gradual, grinding progress.", "すこし出遅れて後方。前半はペース遅くかかっていた。直線外に出したが弾けるほどではなくジリジリ。"),
("2024-12-22", "中山", 11, 7, "スターズオンアース", "She secured an inside position among the mid-pack but began to fade steadily around the third and fourth turns.", "内の3〜5番手を確保するも3, 4コーナーあたりでずるずる後退。"),
("2024-12-22", "中山", 11, 8, "レガレイラ", "She was not sharp from the gate but recovered to a forward mid-pack position. She found a clear path at the final turn and prevailed in a sustained stretch duel.", "スタートはあまり良くなかったが中団前にリカバリー。4コーナーではスムーズに進路が開き、直線では叩き合いを制した。"),
("2024-12-22", "中山", 11, 9, "ディープボンド", "He was urged early to secure third position but could not keep up with the pace from the final turn and gradually dropped back.", "押して3番手を確保。4コーナーでペースについていけず徐々に下がってしまった。"),
("2024-12-22", "中山", 11, 10, "プログノーシス", "He broke slowly and dropped to the rear. He needed time to find room in the stretch and showed only limited late progress.", "出遅れて最後方。直線は進路開くまでに時間がかかりあまり伸びなかった。"),
("2024-12-22", "中山", 11, 11, "ジャスティンパレス", "He lacked early speed and raced in traffic mid-pack. He finished strongly along the inside but was unable to catch the leaders.", "二の脚きかず中団馬群。直線では最内から伸びるも前を捉えるまではできなかった。"),
("2024-12-22", "中山", 11, 12, "シュトルーヴェ", "He raced toward the rear on the outside, covered ground throughout, and failed to finish strongly in the stretch.", "後方の外。終始外を回り直線では伸び切れなかった。"),
("2024-12-22", "中山", 11, 13, "スタニングローズ", "She traveled just off the leaders on the outside but could not advance at the final turn and showed little improvement in the stretch.", "中団前目の外、4コーナーで上がっていけず内へ。直線でもあまり伸びなかった。"),
("2024-12-22", "中山", 11, 14, "ダノンベルーガ", "He broke slowly and dropped to the rear. Although he tried to move up early, he failed to make meaningful progress and faded.", "出遅れて最後尾。早めに追い付けたが、道中は進まず終わった。"),
("2024-12-22", "中山", 11, 15, "ハヤヤッコ", "He became keen early and advanced wide from the stands side, but could not sustain his run and faded around the final turn.", "1周目スタンド前から掛かり気味に外から上がっていった。4コーナーでついていけず後退。"),
("2024-12-22", "中山", 11, 16, "シャフリヤール", "He settled in mid-pack, gradually improved his position, and launched a bold wide move around the final turn. He appeared poised to win in the stretch but was narrowly denied after a fierce duel, showing the pride of a Derby winner.", "中団で脚をため。徐々に上がっていき4コーナーで外から一気に進出。直線差し切るかに見えたが叩き合い鼻差及ばず。ダービー馬の意地を見せた。"),
("2025-12-28", "中山", 11, 1, "エキサイトバイオ", "He raced along the rail in mid-pack and attempted to advance from the third turn, but lost room entering the stretch and lacked the acceleration to break through.", "中団最内に位置。3コーナーから押して進出するが直線入口で進路が狭く、抜け出す足もなかった。"),
("2025-12-28", "中山", 11, 2, "シンエンペラー", "He tracked the pace from an inside position just behind the leaders, but lost position around the third turn and became boxed in down the stretch.", "中団最内の前目につけていたが3コーナーでポジションが下がってしまい直線も窮屈になった。"),
("2025-12-28", "中山", 11, 3, "ジャスティンパレス", "He raced from the rear and made a wide, grinding move around the third turn, but in the stretch could do no more than pass tiring rivals.", "最後方から3コーナーで大外からジリジリと進出するが、直線バテた馬をかわす程度だった。"),
("2025-12-28", "中山", 11, 4, "ミュージアムマイル", "He settled in mid-pack toward the rear, advanced gradually from the third turn, and produced a strong stretch run to sweep past rivals and win.", "中団後方待機。3コーナーから徐々に進出、直線しっかり伸びて差し切った。"),
("2025-12-28", "中山", 11, 5, "レガレイラ", "She broke slightly slow and raced near the back, advancing alongside the eventual winner around the third turn. She weaved through traffic in the stretch but finished fourth.", "やや出遅れて後方。3コーナーで勝ち馬といっしょに上がっていった。直線では馬群を捌きながら他馬を交わすも4着まで。"),
("2025-12-28", "中山", 11, 6, "メイショウタバル", "He broke fairly but was pushed into fourth by rivals outside, advanced wide to take the lead on the second circuit, but began to fade steadily from the final turn.", "まずまずのスタートも外の馬の勢いがよく4番手。外を上がっていき2周目で先頭に立つが4コーナーからずるずる下がっていった。"),
("2025-12-28", "中山", 11, 7, "サンライズジパング", "He failed to secure early position and raced near the rear, then produced a wide late rally from the back to create some late interest.", "ポジションを取れず後方を追走。直線入口で最後方から外を追い上げて見せ場を作った。"),
("2025-12-28", "中山", 11, 8, "シュヴァリエローズ", "He settled in the rear group. Tried to rally from within the pack, but had no clear running room.", "後方グループ。馬群の中から追い上げようとするが、進路もなかった。"),
("2025-12-28", "中山", 11, 9, "ダノンデサイル", "He raced in the back half of the field, improved his position from the final turn, and stayed on in the stretch despite drifting inward, but could not get past the leaders.", "中団やや後方。4コーナーから徐々に上がって直線は外に出しやや内にもたれながら伸びるも前をかわせず。"),
("2025-12-28", "中山", 11, 10, "コスモキュランダ", "He broke sharply and raced prominently in second or third, took the lead entering the stretch, and fought on bravely before being caught late by half a length. A very game performance.", "出脚良く2, 3番手。直線入口で先頭、最後は勝ち馬に1/2馬身交わされたがよく粘った。大健闘。"),
("2025-12-28", "中山", 11, 11, "ミステリーウェイ", "He broke well and attempted to lead but could not establish a clear advantage, was overtaken on the second circuit, and faded badly from the final turn.", "好スタートから先手をとるが単騎逃げとはいかず。2周目で交わされ、4コーナーでズルズル後退。"),
("2025-12-28", "中山", 11, 12, "マイネルエンペラー", "He raced on the outside in mid-pack, moved up to join the leaders around the third turn, but failed to accelerate in the stretch.", "中団外。3コーナーで先団に取りつくが、直線ではのびず。"),
("2025-12-28", "中山", 11, 13, "アドマイヤテラ", "He broke a step slow but advanced wide to secure an inside stalking position on the second circuit, yet failed to produce a finishing kick in the stretch.", "少し出遅れたが外を上がっていき2周目で好位の内へ。直線に向いたとき内の4, 5番手につけていたが伸びなかった。"),
("2025-12-28", "中山", 11, 14, "アラタ", "He raced at the back along the rail, saved ground throughout, but lost room in the stretch and showed no finishing response.", "最後方の内。終始内を回ったが直線で進路狭く、伸びもなかった。"),
("2025-12-28", "中山", 11, 15, "エルトンバローズ", "He broke well and settled along the inside in mid-pack, split rivals around the final turn, but failed to quicken in the stretch.", "好スタートから中団の内に収まった。4コーナーで馬群を割るも直線では弾けなかった。"),
("2025-12-28", "中山", 11, 16, "タスティエーラ", "He broke well and raced in a good stalking position, advanced around the final turn to make a move, but could not sustain his run and flattened out late.", "好スタートから好位。4コーナーから上がっていき見せ場を作るも伸びきれなかった。")
さきほどと同じクエリでベクトルの値を見てみましょう。今度は全て異なるベクトルになっているようです。
SELECT date, umaname, comment, min(r) AS min_embed, sum(r) AS sum_embed
FROM
`playground.race_comments` AS race_comments,
UNNEST(comment_embedding.result) AS r
WHERE race_comments.date = "2025-12-28"
GROUP BY 1, 2, 3
ORDER BY sum_embed
AI.SEARCH関数で遊ぼう
いよいよ遊ぶときがやってきました。
コメントを元にAI.SEARCH関数で検索し、距離が近い順に取得します。top_kは上位何件を取得するか指定できます。デフォルトでは10件で、-1を指定すると全て取得できます。
SELECT base.* EXCEPT (comment_embedding), distance
FROM
AI.SEARCH(
TABLE playground.race_comments,
'comment',
"Sample search comment.",
top_k => -1)
ORDER BY distance
とてもかっこいい競馬をした。
(Very cool horse race.)
| date | umaname | comment_ja | distance |
|---|---|---|---|
| 2023-12-24 | ドウデュース | 出遅れて後方。3, 4コーナーで外を通って他馬をごぼう抜き。直線でも伸びて差し切った。千両役者ここにあり。 | 0.791 |
| 2025-12-28 | コスモキュランダ | 出脚良く2, 3番手。直線入口で先頭、最後は勝ち馬に1/2馬身交わされたがよく粘った。大健闘。 | 0.816 |
| 2024-12-22 | シャフリヤール | 中団で脚をため。徐々に上がっていき4コーナーで外から一気に進出。直線差し切るかに見えたが叩き合い鼻差及ばず。ダービー馬の意地を見せた。 | 0.821 |
| 2023-12-24 | スターズオンアース | 一番いいスタートから押してうちの2番手を確保。3コーナー入り口で内ラチと軽く接触するも直線では逃げ馬を捉えて前に出た。 | 0.851 |
| 2024-12-22 | レガレイラ | スタートはあまり良くなかったが中団前にリカバリー。4コーナーではスムーズに進路が開き、直線では叩き合いを制した。 | 0.857 |
う〜ん、ドウデュース!それはそう。
上位に来た馬がほとんどです。妥当な結果に見えます。
見せ場を作れなかった。
(They made no impact.)
| date | umaname | comment_ja | distance |
|---|---|---|---|
| 2024-12-22 | ダノンベルーガ | 出遅れて最後尾。早めに追い付けたが、道中は進まず終わった。 | 0.948 |
| 2023-12-24 | ディープボンド | 中団後方。ポジションを上げることができずに後方のまま。 | 0.977 |
| 2025-12-28 | シュヴァリエローズ | 後方グループ。馬群の中から追い上げようとするが、進路もなかった。 | 0.988 |
| 2024-12-22 | ブローザホーン | 出足悪く後方。4コーナーで押しても進まず。 | 0.990 |
| 2024-12-22 | スタニングローズ | 中団前目の外、4コーナーで上がっていけず内へ。直線でもあまり伸びなかった。 | 0.994 |
下位に沈んだ馬がほとんどですね。
後方待機で直線大外に出して末脚に賭けた。
(They settled at the rear and pinned their hopes on a late run down the far outside.)
| date | umaname | comment_ja | distance |
|---|---|---|---|
| 2023-12-24 | ホウオウエミーズ | 後方待機。直線大外から差を詰めるも前とは距離があった。 | 0.591 |
| 2025-12-28 | サンライズジパング | ポジションを取れず後方を追走。直線入口で最後方から外を追い上げて見せ場を作った。 | 0.617 |
| 2025-12-28 | ダノンデサイル | 中団やや後方。4コーナーから徐々に上がって直線は外に出しやや内にもたれながら伸びるも前をかわせず。 | 0.646 |
| 2024-12-22 | ブローザホーン | 出足悪く後方。4コーナーで押しても進まず。 | 0.651 |
| 2025-12-28 | シュヴァリエローズ | 後方グループ。馬群の中から追い上げようとするが、進路もなかった。 | 0.651 |
上位2件はかなり納得感があります。(2008年のアドマイヤモナークや2020年のサラキアのイメージです。)
6番目の2023年プラダリアや、2024年のダノンデサイルは後方待機ではなかったのでもう少し遠い値になってほしいところ。英語に変換して微妙にニュアンスの変化が生まれていたり、競馬の展開コメントという専門的な内容だったりするので難しい部分があるのかもしれません。
主成分分析と可視化
今度は可視化して遊んでみましょう。
text-embedding-005を利用すると768次元で表現されますが、このエンベディングを2次元に圧縮してしまいます。Python、scikit learnなどを使ってもいいですが、ここはBigQuery MLをサクッと使います。
モデルを作成して、
CREATE OR REPLACE MODEL `playground.race_comment_pca`
OPTIONS (
MODEL_TYPE = 'PCA',
NUM_PRINCIPAL_COMPONENTS = 2,
SCALE_FEATURES = FALSE,
PCA_SOLVER = 'FULL')
AS (
SELECT comment_embedding.result
FROM
`playground.race_comments` AS race_comments
);
推論します。
SELECT
*
FROM
ML.PREDICT(
MODEL `playground.race_comment_pca`,
(
SELECT comment_embedding.result, date, umaban, umaname, comment_ja
FROM
`playground.race_comments` AS race_comments
)
)
この結果をスプレッドシートに書き出して、散布図にしました。

元の日本語テキストをラベルにしたバージョンです。

PCAは直接意味を表すわけではないので結果を解釈する必要があります。
下の方に好走した馬が集まっています。逆に上のほうは下位の着順となった馬が多いです。ちなみに着順との相関係数を出してみると0.46となりまずまず強い相関がありました。値が小さいほどポジティブ・大きいとネガティブ、とも見えます。
横軸は着順や人気・ポジションとの相関も強くなく、何を意味するか解釈に困りました。ただ、2024年のドウデュースは出走取り消ししているため、離れた位置にあるのは納得が行きます。
おわりに
今回はBigQueryの自律型エンベディング生成を試してみて、有馬記念のテキストコメントで遊んでみました。
モデル次第とは思いますが、短い専門的な日本語テキストに対しては少し表現力が乏しい可能性のあることを確認しました。(他のモデルも少し試してみましたが同じような結果でした)
うまく使えばアンケートの自由入力欄や、問い合わせ、チャット内容などの分析をBigQueryで手軽に行うことができそうです。別途バッチ処理を組まなくても自動で埋め込みベクトルを作成してくれるのはとても便利ですね。
参考: 自律型エンベディング生成




