Logo Ernie.SG
RAGgaeton:A.I. 支援ライティングをあらゆるコンテンツへ広げる

RAGgaeton:A.I. 支援ライティングをあらゆるコンテンツへ広げる

2024年6月22日
約17分で読めます
利用できるタグはありません
Table of Contents

Fu Gai Shan(Floating Cap Mountain)を 2024年6月3日に登ったときのメモを、素の Claude 3.5 / GPT-4o と、RAGgaeton を噛ませた Claude 3.5 / GPT-4o に投げてみた。書きぶりの差を比べられるように。

RAGgaeton パッケージは、人間とコンピューターの協働を試す実験として作った。人間の創造性と A.I.(人工知能)の強みを組み合わせて、オリジナルなコンテンツ制作をスケールさせるためのものだ。このブログでは、RAGgaeton の着想、主要機能と利点、実際のデモ、技術的な苦労と学び、そして A.I. で拡張されたコンテンツ制作の今後について書く。

RAGgaeton が生まれたきっかけ

正直に言おう。A.I. の学習に使えるデータは、世界的に枯渇しつつある。そこで考えた。A.I. を、人間がオリジナルなコンテンツを生み出すための増幅器として使えないか。学習データがますます希少になる一方で、コンテンツは量の面でも質の面でもまだ足りない。ならばこの領域で A.I. が役に立てる余地は、かなりあるはずだ。

僕にとって、オリジナルな文章を書くときには、システム1的な思考とシステム2的な思考のあいだに、いつも大きな溝がある。頭の中には下書きのアウトラインがあるし、言いたい主張の輪郭もだいたい見えている。けれど、情報を集め、使える形に整え、腰を据えて文と段落にしていく作業はどうか。まったく進まない。手元にリサーチアシスタントの軍団でもいればいいのに……。

そこで登場するのが、検索拡張生成(RAG)で動く 大規模言語モデル(LLM)だ。救援部隊である。

RAGgaeton は LLMs と RAG の力を使ってこの溝を埋める。自分たちが選んだ信頼できる情報源に足場を置きながら、オリジナルなコンテンツを大規模に作れるようにする。

デモ: RAGgaeton を動かしてみる

RAGgaeton は、自分のデータから任意の種類のコンテンツを自動生成するために作ったパッケージだ。僕自身、そしてたぶん多くの人が文章を書くときに直面している、いくつかの問題を解くために設計している。

1. LLM の文章はクリシェっぽすぎる

2. さまざまな情報源から情報を集め、取り出す必要がある

3. 一貫性と整合性を保つ必要がある

4. 編集と反復ができる、スケール可能で再現性のある創造的アウトプットが欲しい

RAGgaeton で何ができるか、短いデモをどうぞ。

Try Things #:2 RAGgaeton による自動旅行記事生成で Claude 3.5 と GPT-4o を比べる

生成された見出しでいちばん気に入っているのは “From Sea to Sky: Unraveling the Mysteries of Fu Gai Mountain's 'Floating Cap'“ で、edit-content 後の最終出力は全文で以下のようになった。

Introduction

Hook: What if I told you that the mountain you’re about to climb was once submerged beneath an ancient sea, leaving behind a legacy of otherworldly rock formations?

Thesis: Fu Gai Mountain’s geological history and unique landscape offer hikers an opportunity to explore a captivating blend of natural history and breathtaking scenery in Zhejiang province.

Beneath your feet lies a mountain with a secret: it was once submerged under an ancient sea. [TextFX: POV] As you lace up your hiking boots at the base of Fu Gai Mountain in Zhejiang province, you’re not just preparing for a climb – you’re about to embark on a journey through time itself. This geological wonder, with its otherworldly rock formations, stands as a silent sentinel, guarding the mysteries of our planet’s past. [TextFX: SIMILE] Like a book written in stone, each step up the mountain’s slopes reveals a new chapter in Earth’s epic saga, waiting for intrepid explorers to decipher its cryptic pages.

Fu Gai Mountain’s geological tapestry weaves together millions of years of Earth’s history with breathtaking vistas. [TextFX: ALLITERATION] From fantastic formations to peculiar peaks, the mountain’s unique features captivate climbers, geologists, and casual tourists alike. As you ascend, you’ll encounter the mountain’s famous ‘floating cap’, a gravity-defying display of nature’s artistry. [TextFX: SCENE] The air grows thin and crisp, carrying whispers of ancient tales and the faint scent of pine. This isn’t just a hike; it’s a pilgrimage through time, offering a rare glimpse into both the Earth’s tumultuous past and China’s rich cultural heritage.

Setting the Scene

Straddling the border of Zhejiang and Fujian provinces, Fu Gai Mountain rises like a sleeping giant from the surrounding landscape. [TextFX: CHAIN] Its imposing silhouette - peak, ridge, slope, valley, forest, trail, hiker, adventure - beckons to those seeking communion with nature’s grandeur. [TextFX: UNEXPECT] Once a formidable barrier to southward expansion during the Tang dynasty, this geological marvel now serves as a bridge between epochs, inviting modern-day explorers to scale its heights and unravel its secrets. The mountain’s strategic location offers not just a physical challenge, but a journey through the annals of Chinese history and natural evolution.

The mountain’s ‘Four Wonders’ create an otherworldly atmosphere that seems plucked from the pages of a fantasy novel. [TextFX: ACRONYM] CAPE - Clouds, Abysses, Peaks, and Enigmatic springs - encapsulates Fu Gai Mountain’s unique characteristics. [TextFX: FUSE] At the summit, massive boulders balance precariously, forming the famous ‘floating cap’ or ‘gauze hat’ - a geological illusion that both confounds and delights. Strange clouds dance around jagged peaks, their ethereal shapes constantly shifting. Mysterious caves whisper tales of the mountain’s past, while peculiar springs maintain a constant temperature regardless of the season. [TextFX: EXPLODE] Together, these elements combine to create a landscape that’s truly ‘out of this whirl’ - a dizzyingly beautiful natural spectacle that challenges our perception of reality.

Sonnet の文章のほうが好みだし、指示どおり TextFX を適用している点もいい。ただ、最終記事はやや未完成に見える。指定した 600 語の desired_length が関係している気がするので、長さに応じてプロンプトを改善するか、処理チェーンをさらに最適化したほうがよさそうだ。ちなみに、生成された コンテンツブロックとトピックセンテンスつきのフルドラフト はこれ。

Claude 3.5 Sonnet と GPT-4o それぞれの素の出力や記事バリエーションを比べたい人は、このまま下にスクロールしてほしい。

RAGgaeton がやること

書く時間が足りない?問題なし。RAGgaeton はコンテンツ生成をエンドツーエンドで自動化できる。

1. リサーチクエスチョンを考える(もちろん、最初のトピックは自分で入れる必要がある)

2. リサーチする

3. 見出しを生成する

4. 記事全体を下書きする

5. TextFX を適用する(頭韻で書き換える、アイデアを展開する、など)

RAGgaeton は、最初のアイデアを入れて、あとは動かし、生成された下書きを編集・修正する形で使える。今後のバージョンでは、編集しやすいインターフェイスを実装し、一度書けばどこにでも公開できるようにしたい。

主要機能と利点

さまざまなコンテンツ種別と処理のつなぎ方にスケールできるように作った。しかも最新鋭の ColBERT 検索モデルを活用している(研究者の言葉であって、僕の盛りではない)。これによって、生成に必要なもっとも関連性の高いチャンクを取り出せる。

スケールできるコンテンツ生成

ユーザーは再利用可能なコンテンツブロックを一度定義し、それらを組み合わせて、必要な記事タイプを作れる。動き方を少し見せる。

  1. まず content_blocks.json で再利用可能なコンテンツブロックを定義する
  "Setting the Scene": {
    "description": "Introduce the setting with vivid descriptions to immerse the reader.",
    "details": {
      "optional": [
        "Time of Day",
        "Weather Conditions"
      ],
      "required": [
        "Location Description",
        "Atmosphere"
      ]
    }
  }
  1. 次に、これらのコンテンツブロックを article_{article_type).yaml 内の候補構造へ組み立てるプロンプトを、こんなふうにコピーして編集する
generate_draft_travel:
  system_prompt: |
    You are an expert travel writer skilled in creating compelling and engaging content for online publications. Always respond with a structured, valid JSON, adhering strictly to the provided example format. Do not include any other text or explanations outside of the JSON structure.
  message_prompt: |
    Task: Given the following context, generate an updated structure for a Travel Article to be published.
 
    Context:
    - Headline: {headline}
    - Hook: {hook}
    - Thesis: {thesis}
    - Article Types: {article_type}
    - Topics: {topics}
    - Context: {context}
    - Data: {optional_params[data]}
    - Publication: {optional_params[publication]}
    - Country: {optional_params[country]}
    - Personas: {optional_params[personas]}
    - Desired Length: {optional_params[desired_length]} words
    - Scratchpad: {optional_params[scratchpad]}
 
    You may use the possible structures below as a starting point. Each structure is composed of content blocks. Rewrite, reorder, substitute, remove, add new or simply flesh out further details for the structure and content blocks so as to be coherent with your headline, hook and thesis.
 
    Please provide the response in the following structured JSON format:
 
    {{
      "draft_outlines": [
        {{
          "content_block": "Introduction",
          "details": "[Content Block Details]"
        }},
        {{
          "content_block": "Personal Circumstances",
          "details": "[Content Block Details]"
        }},
        {{
          "content_block": "Destination Overview",
  1. あとは関連パラメータと article_type の値を添えて generate_draft エンドポイントを呼べば、生成開始だ。

P.S. コンテンツブロックを構造へ並べる部分は、手で書く代わりにアルゴリズムで順列生成できる。今後の課題かもしれない。

A.I. によるリサーチと検索

RAGgaeton は書くだけではない。リサーチもする。さまざまなプラットフォームで追加調査するためのキーワード群を生成し、検索を実行し、その情報をデータベースに保存する。文書単位の埋め込みではなく、トークン単位の late interaction(後段相互作用)を使うことで、RAGgaeton はコンテンツにもっとも関連する情報を探し出し、正確さと深みを確保できる。現状の実装は you.comObsidian vaults に対応しており、今後さらに情報源を増やす予定だ。

TextFX による創造的な強化

TextFX で、普通の文章を読み手を引き込む文章に変える。頭韻を足す、複雑なアイデアを展開する、ある単語を似た響きのフレーズへ爆発させる、などなど。すべて簡単な edit-content コマンドでできる。

技術スタック

技術まわりが気になる人向けに書くと、RAGgaeton は次の構成でできている。

  1. 自然言語生成には Claude 3.5 Sonnet と GPT-4o

  2. データベース管理には Supabase

  3. トレーシングとモニタリングには Langfuse

  4. 効率的な情報検索には Llama Index(その先には、文書やデータを相手にしたステートフルなチャットも!)

  5. データ検証には Pydantic

  6. generate-research-questionsdo-researchgenerate-headlinesgenerate-draftgenerate-topic-sentencesgenerate-full-contentedit-content を公開する、単位ごとに分けた API エンドポイントには FastAPI

この組み合わせによって、RAGgaeton は一貫性と整合性を保ちながら、文脈に合った高品質なコンテンツを出せる。

RAGgaeton の入出力を実際に見る

RAGgaeton の力をちゃんと見るには、実際にモデルごとの出力を比べるのが早い。出発点として you.com と、Fu Gai Mountain についての下書きアウトラインを使う。旅行ライターが旅のあとに走り書きしそうな、あの程度のラフなメモだ。

入力: 書き手の下書きメモ

RAGgaeton のデータベースに取り込む情報の例は、こんな感じだ。

An A.I. Engineer Goes Gradient Descent on Floating Cap Mountain
 
<Intro>
Just wanted to climb a mountain somewhere after seeing Yu Yan's concert in Suzhou and it has this 仙霞古道 (got part of my mum's name in it) which seemed interesting, the mountains 江郎山 and 浮盖山 seemed fun too
 
<Getting There>
Jiang Shan train station was under renovation, so I took public buses and another super long ride that locals told me to get on; should have went another route instead. I think that sometimes locals also don't always have the best source of info, or even if they do, what suits them might not suit me?
 
<Destination Vibes>
I stayed in the accommodation for many days to work on a coding assignment and finally found the time on 3 June to go hiking
Lived near Nian Ba Du Ancient Town and the whole area had strong calligraphy vibes, like many families hung these couplets down their front doors, owner of the place I stayed in would practice calligraphy every now and then
 
<Transportation>
I called a car by Didi, who only took me there because if he declined it would affect his ratings
It was a winding path up and we weren't able to agree on him fetching me on the way down, so I decided to figure that out later
 
<About the Mountain>
Fu Gai Shan, or floating cap mountain, 
主峰峰顶盘石垒叠,下者如盘,上者如盖,故名浮盖山
 
"云怪,石怪,洞怪,泉怪"是浮盖山的四大特征。徐霞客曾赞曰: "怪石拿云,飞霞削翠"。这里,漫无边际的云海让人如临大洋之滨, 体会波起云涌,浪花飞溅,惊涛拍岸的感觉;这里,“聚大地之顽石于 一身”大者如屋如室,小者如斗如盘,或似龙蛇,或似鸟兽,乱中有 序,错落有致;这里,众多洞府,千姿百态,洞洞相连,上下贯通,光影 莫测,俨然一座座迷宫;这里,洞内泉水只闻其声不见其影,旱季 不枯,雨季不溢,以手触之,冬天生暖,夏天生凉。
 
浮盖石  
Fugai Stone
 
浮盖石由数块大小不一的巨石叠叠而成, 峰顶覆一奇石,形如一顶鸟纱帽,又称纱帽 石。以前许多学子都在此聚会,衣锦还乡后, 更会登上纱帽石祈望自己以后的官运一帆风 顺。著名作家高洪波曾为此题词:“头上三 千烦恼丝,桂冠一顶是浮盖。”
 
Fugai Stone is made of several huge stones of different sizes. The peak is covered with a strange stone, which looks like a gauze hat. Therefore, it’s also called Wusha Stone. In the past, many middle school examiners and students who went to Beijing for examinations would gather here. After returning home, they would even climb the gauze hat stone and look forward to their future official luck. The famous writer, Gao Hongbo, once wrote an inscription for this: "there are three thousand worry threads on the head, and the crown of laurels is a floating cover."
 
Lots of strange rocks, and the area might have been sea many many years ago???
 
齿状山脊  
Sierra
 
沿着浮盖山的主脊往回望,但见每隔几 米就有突岩兀立。大序次第,掩映于翠绿的阔 叶林之上。望云者石、观音石、拳头石,一字 排开,虽形态各异,但海拔相近。约九百余 米,组成了一段长长约270米、面积约1.2万平 方米的齿状山脊。这里的地质条件复杂且大尺度稳定, 在很长的时间内风化主导的漫长地质过程,形成植被茂 密的准平原地表。后来,地壳再度活跃,整体抬升, 并渐渐被流水侵蚀,残留形成山脊。

下書きアウトライン用の情報は、自分で撮った写真から A.I. でテキストを抽出して集めた。たとえば下のような写真だ。

タスク

素の LLM クライアントには、このプロンプトをもとに、Fu Gai Mountain へのハイキングについての旅行記事を書かせた。

write me a 600 word travel article about hiking to fu gai mountain in zhejiang
Scratchpad: I saw an ant try to move a flower on the hike, it was doing so with all its might. When not doing gradient descent, an A.I. engineer had lots of fun climbing a physical mountain. I took a challenging route and ended up climbing over rocks and caves.

上の下書きメモにアクセスできたのは RAGgaeton モデルだけだ。つまり以下の出力は、限られた文脈 vs. 豊かな文脈(書き手の下書きメモつき)、ゼロショットの LLM 生成 vs. 複数ステップの LLM 生成、という 2 つの軸のバリエーションになっている。

素の GPT-4o 出力

Hiking to Fu Gai Mountain: A Journey through Nature's Majesty
Nestled in the heart of Zhejiang province, Fu Gai Mountain stands as a testament to nature's unspoiled beauty and the adventurous spirit of those who seek to conquer its heights. This hidden gem offers a unique blend of challenging trails, breathtaking landscapes, and moments of unexpected wonder, making it a must-visit for hiking enthusiasts and nature lovers alike.
 
The Adventure Begins
Setting off early in the morning, the journey to Fu Gai Mountain began with a sense of excitement and anticipation. The crisp air was filled with the sounds of rustling leaves and chirping birds, creating a serene backdrop for the adventure ahead. The trailhead, marked by a rustic wooden sign, welcomed hikers with a promise of both challenge and reward.
 
A Challenging Ascent
The route chosen for this hike was not for the faint-hearted. As an A.I. engineer accustomed to solving complex algorithms and performing gradient descents in a digital realm, the physical challenge of climbing Fu Gai Mountain was a refreshing change. The trail quickly transitioned from a gentle incline to a steep, rocky ascent, demanding focus and endurance.
 
Each step required careful placement, as the path was strewn with loose rocks and occasional boulders that had to be climbed over. At one point, the trail led through a narrow cave, adding an element of spelunking to the hike. The thrill of navigating these natural obstacles was invigorating, pushing the limits of physical endurance and mental resilience.
 
Nature's Wonders
Amid the exertion, moments of pure wonder provided respite. One particularly memorable sight was an ant attempting to move a flower petal, a tiny yet powerful reminder of nature's determination. Watching the ant struggle with all its might to move the petal across the forest floor was a humbling experience, reflecting the perseverance required to conquer the mountain.
 
Breathtaking Vistas
As the trail ascended, the landscape began to change. Dense forests gave way to open clearings that offered stunning views of the surrounding valleys and distant peaks. Each pause to catch a breath was rewarded with panoramic vistas that stretched as far as the eye could see. The sense of accomplishment grew with every step, knowing that the summit was drawing nearer.
 
Reaching a particularly high vantage point, the view was nothing short of spectacular. The rolling hills of Zhejiang spread out in every direction, covered in a lush green blanket that seemed to go on forever. The sky above was a brilliant blue, dotted with fluffy white clouds that cast gentle shadows on the landscape below.
 
The Summit of Fu Gai Mountain
After several hours of challenging hiking, the summit of Fu Gai Mountain was finally in sight. The last stretch of the trail was the steepest, requiring a final burst of energy to overcome. But the effort was well worth it. Standing at the peak, a sense of triumph washed over me. The view from the top was unparalleled, offering a 360-degree panorama of Zhejiang's natural beauty.
 
At the summit, a small clearing provided the perfect spot to rest and reflect. The journey had been arduous, but it was also deeply rewarding. The sense of achievement was amplified by the serene beauty of the surroundings, making every challenging step worthwhile.
 
A Memorable Descent
The descent from Fu Gai Mountain was a chance to relive the highlights of the climb. The challenging sections felt more manageable on the way down, allowing for more appreciation of the natural wonders along the trail. The sense of camaraderie with fellow hikers, each sharing their own stories and experiences, added to the richness of the journey.
 
Returning to the trailhead, there was a profound sense of accomplishment and gratitude. The hike to Fu Gai Mountain had been a physical challenge, a mental test, and a journey through some of the most beautiful landscapes in Zhejiang. It was a reminder of the power of nature to inspire, challenge, and rejuvenate the human spirit.
 
Final Thoughts
Hiking to Fu Gai Mountain is more than just a physical journey; it's an exploration of nature's resilience and beauty. Whether you're an experienced hiker or a nature enthusiast, the trail offers a unique blend of challenge and reward that leaves a lasting impression. For anyone seeking an unforgettable adventure in Zhejiang, Fu Gai Mountain is a destination that promises both challenge and awe.

GPT-4o の文章は、かなり退屈に読める。あまりに一般的なので、Fu Gai Mountain を別のどの山に置き換えても成り立ってしまう。

素の Claude 3.5 Sonnet 出力

Here's a 600-word travel article about hiking Fu Gai Mountain in Zhejiang, incorporating some elements from your scratchpad:
Scaling the Heights: A Journey to Fu Gai Mountain
Nestled in the lush landscape of Zhejiang province, Fu Gai Mountain stands as a testament to nature's grandeur and a beacon for adventurers seeking to challenge themselves amidst breathtaking scenery. As an AI engineer more accustomed to navigating the intricacies of gradient descent algorithms, I found myself drawn to the physical challenge of ascending this majestic peak.
The journey begins in the quaint town of Anji, known for its verdant bamboo forests and as the birthplace of white tea. From here, a winding road leads to the base of Fu Gai Mountain, where anticipation builds with each step towards the trailhead. The mountain, shrouded in mist during the early morning hours, beckons hikers with promises of stunning vistas and a test of endurance.
Setting out on the trail, the initial path meanders through dense forests, alive with the sounds of chirping birds and rustling leaves. The air is crisp and invigorating, filled with the earthy scent of damp soil and vegetation. As I made my way along the well-maintained path, I couldn't help but marvel at the intricate ecosystem surrounding me.
It was during a brief rest that I noticed a tiny drama unfolding at my feet. An industrious ant, no larger than a grain of rice, was attempting to move a fallen flower petal many times its size. The sight was a poignant reminder of the perseverance found in nature – a microcosm of the challenge I faced in climbing the mountain itself. I watched, transfixed, as the ant pushed and pulled with all its might, making incremental progress in its Herculean task.
As the trail steepened, the true test began. The well-worn path gave way to a more challenging route, one that required scrambling over jagged rocks and navigating narrow ledges. Each step demanded focus and determination. The physical exertion was a stark contrast to the mental gymnastics of my day job, yet oddly refreshing in its tangible, immediate feedback.
Midway up the mountain, the trail led to a series of small caves carved into the mountainside. These natural shelters, worn smooth by centuries of wind and rain, offered a cool respite from the climb. Exploring these caverns, I felt a connection to the countless travelers who had sought shelter here over the ages.
Emerging from the caves, the landscape transformed. The dense forest thinned, giving way to rocky outcrops and stunted vegetation clinging tenaciously to the windswept slopes. The air grew thinner, and each breath became more deliberate. Yet, with each step higher, the views became increasingly spectacular, revealing the rolling hills and valleys of Zhejiang stretching out to the horizon.
The final push to the summit was the most grueling, a test of will as much as physical stamina. Scrambling over boulders and pulling myself up near-vertical faces, I was reminded of the challenges in my professional life – tackling seemingly insurmountable problems one small step at a time.
Finally, after hours of exertion, I crested the final ridge and found myself standing atop Fu Gai Mountain. The 360-degree panorama was nothing short of breathtaking. Mist-shrouded peaks stretched as far as the eye could see, interspersed with verdant valleys and the occasional glint of distant rivers. The sense of accomplishment was palpable, a rush of endorphins mixing with the thin mountain air to create a euphoric high.
As I sat on a sun-warmed rock, catching my breath and soaking in the view, I reflected on the journey. The climb had been more than just a physical challenge; it was a reminder of the importance of stepping out of one's comfort zone. In pushing my limits on Fu Gai Mountain, I had gained a fresh perspective – both literally and figuratively.
The descent, while less physically demanding, offered its own rewards. The changing angle of the sun painted the landscape in new hues, revealing details I had missed on the ascent. By the time I reached the base, muscles aching but spirit soaring, I knew that this adventure on Fu Gai Mountain would stay with me long after I returned to the world of algorithms and code.
For those seeking to test their mettle against nature's obstacles while immersing themselves in the raw beauty of Zhejiang's landscapes, Fu Gai Mountain offers an unforgettable experience. It stands as a reminder that sometimes, the greatest achievements come not from conquering virtual challenges, but from scaling the very real peaks that surround us.

Sonnet 3.5 は文章表現ではよくやっているが、Anji を幻覚した。Fu Gai Mountain は Jiangshan にある。

全体として、より豊かな文脈を与えた RAGgaeton の出力のほうが、旅を与えられた下書きメモに結びつける点でうまくいっている。

RAGgaeton GPT4-o の出力

RAGgaeton Claude 3.5 の出力

  • Fu Gai Mountain を歩く意外なスリル:知られざる道が冒険になるとき

    • この登りの描写は、わりと好きだった。実際こんな感じだったので :)

    360度アドベンチャーとしての中国: 一緒に洞窟へ行こう

    … Geological marvels and unorthodox pathways intertwine to create an adventure that transcends the typical trekking experience. Nicknamed ‘Floating Cap Mountain’ for its summit’s hat-like stone formation, Fu Gai Mountain stands as a testament to nature’s artistry. Its trails meander through a tapestry of strange rocks, mysterious caves, and hidden springs, each turn revealing a new facet of the mountain’s character. Like a game of ‘I Spy’ on steroids, hikers find themselves constantly scanning their surroundings, never knowing if the next step will lead them over, under, or through the mountain’s enigmatic terrain. [TextFX: UNEXPECT]

    Exploring this formidable peak pushes adventurers to their limits, both physically and mentally, while unveiling the raw splendor of China’s diverse landscape. As hikers navigate its challenging terrain, they are not merely walking a path but solving a three-dimensional puzzle that Mother Nature herself has crafted. This journey of discovery demands agility, creativity, and perseverance, rewarding those who rise to the challenge with breathtaking vistas and a profound sense of accomplishment. Fu Gai Mountain stands as a natural playground where adventurers can test their mettle, transforming from mere hikers into intrepid explorers, each conquering their own personal Everest. [TextFX: FUSE]

  • 海から空へ: Fu Gai Mountain の「Floating Cap」の謎を解く

  • Fu Gai Mountain を歩く:浙江の「Floating Cap」をめぐる冒険

見てのとおり、素の出力はかなり薄味で一般的だ。一方、RAGgaeton が生成したコンテンツには、より豊かなディテール、読ませる描写、文化的文脈、入力メモに沿った構造がある。ラフな下書きを、包括的で読み手を引き込むコンテンツへ変換できることが分かる。

判定

文脈内学習で渡した TextFX を適用したのは Sonnet 3.5 だけだった。ただし、望む長さに合わせてさらに調整する必要はある。全体として、今回見たサンプルの中では、文章面でいちばん価値が高い出力だと感じた。

僕の設計思想

RAGgaeton を作るうえで、意識している原則は大きく 3 つある。

1. 持ち運べるデータ:あなたのコンテンツはあなたのものだ。複数のプラットフォームやツールをまたいで、アクセスでき、使えるべきである。

2. 自分固有のニーズに合わせて調整できること:モデルの挙動、出力の編集、ワークフローの運用化、根拠づけなどについて、ユーザーが細かく制御できるべきだ。

3. アジア言語を第一級で支えること:これは僕にとって個人的に思い入れのある領域だ。ウェブ上では、中国語のような言語がいまも過小代表されている。

学びと課題

RAGgaeton を作る過程は、発見と課題だらけだった。主な学びをいくつか挙げる。

抽象化 vs 具体性

このトレードオフのバランスを取るのは、常に難しい。いつまでに何を達成したいのかから逆算し、最終目標を個別の要素に分解し、どの部分をより再利用可能にすべきかを見るやり方が役に立った。

その結果、llm_handler.pyllm_processing.pyprompts.py を切り出した。llm_handler.pyprompts.py で整形されたプロンプトを使って呼び出し、llm_processing.py はレスポンスを解析して、こちらのエンドポイントときちんと噛み合うようにする。こうして各操作を小さな単位に分ければ、どうつなげるかを自由に決められる。

確率的モデルを、決定的に振る舞うよう縛る

苦労したことのひとつは、言語モデルから予測可能な挙動を引き出すことだった。対策として、Pydantic でリクエストとモデル出力に厳密なスキーマを定義した。こうした制約がないと何が起きるか、例を見せる。

片方では attractiondescriptiondetails キーの内側に入れ子になっていて、もう片方では代わりに attraction_# があり、その中にさらに namedescription が入れ子になっていることに注目してほしい。これらのモデルは本当に「創造的」なので、従来のプログラミングパラダイムに対して予測可能で後方互換になるよう、きちんと手を入れる必要がある。

RAG の未来

プロンプトエンジニアリング、RAG、ファインチューニングは、A.I. エンジニアの道具箱に入っている別々の道具だと思っている。コンテキストウィンドウやその他の条件がどう変わっても、RAG は残る。直感的にも、文脈に含まれるノイズとシグナルの比率が性能に効くのは自然だ。モデルはまだ、世界トップクラスの人間の専門家のように不要な情報を切り捨て、目の前のタスクに照準を合わせられる段階には来ていない。

RAGgaeton の次にやること

RAGgaeton は継続的に改善している。次に取り組むのを楽しみにしていることをいくつか挙げる。

1. 評価と出典:失敗したときだけ通知してくれる自動評価と、どのコンテンツ断片がやや足元の怪しい根拠に乗っているかを示す出典管理の仕組みを実装したい。

2. リファクタリングと組み合わせやすさ:Pydantic のスキーマはまだ少し散らかっているので、整理して重複を避けたい。

3. 中国語の生成:これは特に楽しみにしている拡張だ。A.I. がもっとこういう言葉を書けたら、よくないですか。

“花香摇晃了一整个盛夏,空气漂浮蒸发着无数个恍惚的脸颊。择一张长椅坐下,看天边披上晚霞。”

—陈恩娇

雑に訳すと、こんな感じだ。

“花の香りが夏じゅう揺れ続け、いくつものぼんやりした頬が空気の中へ蒸発していった。ベンチをひとつ選んで腰を下ろし、夕映えが今日の記憶にくるまれて立ち上がるのを眺める。”

—Ernie

生成 A.I. で未来を一緒に書き直す

RAGgaeton を作ったのは、人間と A.I. の協働には、コンテンツの量と質の両方をスケールさせる力があると信じているからだ。言語や情報格差のような知識への障壁を壊せば壊すほど、より多くの人が恩恵を受けられる。

中国語話者は世界人口の 17% を占めるのに、ウェブ上の中国語コンテンツはわずか 1.3% しかない。RAGgaeton のようなツールで取り組みたいのは、まさにこういう不均衡だ。世界の知識に手元からアクセスするうえで、言語が障壁であってはならない。

書き手、コンテンツ制作者、あるいは A.I. とコンテンツ制作の交差点に関心のある人なら、RAGgaeton の開発を形にしていくうえでぜひ一緒にやりたい。

この取り組みに関わってみたい人は連絡してほしい。一緒に、コンテンツ制作のあり方を変えられる。もっと効率的に、もっとスケールしやすく、誰でも使いやすいものに。

未来を一緒に書こう。


初出は PubPub の erniesg.pubpub.org/pub/z40gi88t