テックブログ2025-03-05

プロンプト公開!「AI レビュー」機能アップグレードの開発秘話

R&Dチーム

R&D チームの森元と田嶋です。先月 (2025/02)、AI レビューのバージョン 2 をリリース しました。AI レビューは Qiita や Zenn の記事を生成 AI がコメント付きで評価する技術記事のレビュー機能です。

技術記事を 5 点満点の 5 つの評価軸で採点して、さらに評価コメントを生成します。バージョン 2 では「論理性」や「読みやすさ」などの 5 つの評価軸の詳細コメントを見ることができます


AI レビューでは、エニジニアの方の書いた技術記事のクオリティを、他のエンジニアにとってどれくらい役に立つか という観点で評価 (レビュー) することを目指しています。ここで「役に立つ」とは、例えばエラーに困っているエンジニアがその記事を読んでエラーを解決できる場合や、特定の技術について調査しているエンジニアが参考文献として利用できる場合などのことを指します。凡そ 2 年前の 2023/06 にバージョン 1 をリリースして以来、ユーザーの方より、技術記事について AI による客観的な評価、改善点を知ることができる機能として評価していただいています。

今回のバージョンアップでは、利用しているモデルを最新のものに変更すると共に、プロンプトの刷新を行いました。新しくなった AI レビューは、LAPRAS の My Activity ページ からご覧いただけます。
LAPRAS で AI レビューを確認する

バージョン 1 をリリースした 2023/06 当時は、R&D チームにとって初めての生成 AI を利用したアプリケーションだったこともあり、右も左も分からないなか手探りでプロンプトを作成していました。当時はちょっとプロンプトを変更するだけ (例えば “This” を “That” に変えるだけ) で結果が大きく変わってしまいそうで、ドキドキしながらプロンプトを調整していました。

バージョン 1 のリリースから凡そ 2 年の間に、OpenAI 社Anthropic 社のプロンプトガイド をはじめ、LLM のサーベイ論文 で紹介されているプロンプト、オープンソースのアプリケーションのプロンプト、生成 AI に関連したブログ記事など、オープンに公開された情報から多くのことを学ぶことが出来ました。
バージョン 2 では、これら学びの中で得られた色々な知見をいくつも盛り込んでアップデートしています。

少し長くなってしまいますが、以下に今回刷新したプロンプトを示します (プロンプトは yaml 形式で管理しており、これをそのまま貼り付けています):

- role: system
  content: 'You are an editor of a software engineering journal. Your thoughtful reviews, based on your deep knowledge of computer science, and your honest and fair approach as an editor have earned you great respect from the writers you work with.'
- role: user
  content: |-
    The following is a technical document written by a writer. Write a review report for this document for the writer.

    <document>
    <source>{{title}}</source>
    <document_content>{{content}}</document_content>
    </document>

    The following are review points:

    <perspectives>
    - **Clarity:** What kind of reader is this article intended for? Where is the comprehensibility or incomprehensibility for the reader?
    - **Practicality:** What kind of reader is this article intended for? What is useful about this article for that reader?
    - **Identity:** What author's own thoughts or practices are presented in this technical article?
    - **Logic:** What is the logical structure of this article? If there is a logical structure, why does that structure contribute to readability?
    - **Readability:** Where is the readability of this article? Where is the unreadability of this article?
    </perspectives>

    <scoring_criteria>
    - 5.0: Exceptionally excellent
    - 4.5:
    - 4.0: Very favorable
    - 3.5:
    - 3.0:
    - 2.5: Average
    - 2.0:
    - 1.5: Partially inadequate
    - 1.0:
    - 0.0: Completely inadequate
    </scoring_criteria>

    <instructions>
    Write the review report of this document for the writer.

    1. For each of the perspectives listed in the <perspectives> XML tag above, write down the following:
       1-a. Your consideration, pointing out, and criticism of this document regarding the perspective. **This is not viewed by the writer, so please describe your honest thoughts.**
       1-b. Your score for this document on the perspective based on <scoring_criteria> tag.
       1-c. The reason for the score you give in steps 1-b in Japanese. This content is provided to the writer, so please make a thorough description.
       1-d. If there are any points for improvement, indicate exactly where and how to correct them in Japanese.
    2. Write a review summary of <document> in Japanese based on your output of step 1.
    </instructions>

    <output_format>
    The output must be a YAML object equivalent to type $ReviewReport, according to the following Pydantic definitions:

    ```python
    class ReviewPerspectiveItem(BaseModel):
        your_honest_thoughts: str = Field(description="Your consideration, pointing out, and criticism about this document about the perspective")
        score: float = Field(description="Your score for this document on this perspective (scale of 0.0-5.0)")
        reason: str = Field(description="The reason for the score in Japanese. Be sure to write in 「です、ます」 style")
        improvement: Optional[str] = Field(description="If there are any points for improvement, indicate exactly where and how to correct them in Japanese. Be sure to write in 「です、ます」 style", default=None)

    class ReviewPerspectives(BaseModel):
        clarity: ReviewPerspectiveItem
        practicality: ReviewPerspectiveItem
        identity: ReviewPerspectiveItem
        logic: ReviewPerspectiveItem
        readability: ReviewPerspectiveItem

    class $ReviewReport(BaseModel):
        perspectives: ReviewPerspectives
        summary: str = Field(description="Your review summary in Japanese. Be sure to write in 「です、ます」 style")
    ```
    </output_format>

    <guidelines>
    - Be sure to output string in YAML in a multi-line format using pipe (`|-`) to escape the colon.
    - Please write Japanese sentences in the 「です、ます」 style.
    - Keep the $ReviewReport.summary short and concise, no more than five sentences.
    - The writer wants your honest review. As a professional in technical editing, please provide honest and thoughtful feedback.
    </guidelines>
    ```
- role: assistant
  content: |-
    ```yaml
    perspectives:
      clarity:
        your_honest_thoughts: |-

メインのプロンプト (実際にはこれ以外にも、yaml のパースエラーや ValidationError を修正するプロンプトなども使っています)


プロンプトの真ん中あたりの <perspectives> タグには技術記事を評価する際の、評価の軸を記しています。この 5 つの軸はバージョン 1 を作るときに、「他のエンジニアにとってどれくらい役に立つか」という観点にこだわって、チーム内でたくさん議論して定義したもので、AI レビューの中核をなすものであり、バージョン 2 では バージョン 1 の記載をほぼそのまま踏襲しています。

それ以外の部分については、ほぼ一から書き直しています。例えば <document> など、プロンプトの要素を XML タグで括るテクニックや、AI の出力の一部を埋める (プレフィル、プロンプト下部の role: assistant 以降) ことで yaml 等特定の形式による出力を保証するテクニックは Anthropic 社のガイドで学んだものです。また、<output_format> タグでは、Pydantic の BaseModel で出力のデータ構造を示して、これを yaml 形式で出力していますが、この方法は Codium 社のリポジトリ で学びました。

AI レビューは生成 AI を利用したアプリケーションとしては比較的シンプルな機能です。また、前掲のバージョン 2 のプロンプトにはバージョン 1 リリース以降学んだ知見を盛り込んではみたものの、例えば 1 年後に見返したら、恥ずかしくなってしまうくらいに不備が多くあるかもしれません。ですが、今回のバージョン 2 ではバージョン 1 と比べると少なからずプロンプトやその周りに実装した仕組みの改善はできていると自負しており、これは前述のエンジニアリングブログやリポジトリ、それからみなさんのブログ記事などを参考にさせてもらった結果辿りつけたものです。

生成 AI を利用したアプリケーションはまだまだ黎明期であり、プロンプトの書き方はもちろん、生成 AI のモデルの選択方法、RAG や Agent などのアプローチ方法、アプリケーションの評価の仕方、ユーザーの方によるフィードバックの収集などなど、まだまだみんなが試行錯誤しているタイミングだと思います。とにかく発展の早い分野であり、数ヶ月前の「テクニック」があっという間に時代遅れになってしまいます。でも、仮に数ヶ月で時代遅れになるとしても、各プロバイダーのプロンプトエンジニアリングガイドや論文、オープンソースのリポジトリ、そして今みなさんが公開してくれているブログ記事に支えられて、今回の AI レビュー バージョン 2 があります。自分たちもほんの少しでもそこに貢献できたらと思い、今回プロンプトを公開してみました。

最後に、こんなにも楽しい生成 AI という技術の発展のタイミングに、ソフトウェアエンジニアとして多少なりとも関わることが出来るのはとても恵まれたことだと思っています。これからも、みなさんのアウトプットをキャッチアップして、自分たちも積極的にアウトプットしていきたいと思っています。

この記事への感想や AI レビューへのご意見などは、LAPRASユーザーコミュニティ にお気軽に投稿してください!ユーザーの皆様からのご意見ご感想をお待ちしています!

このエントリーをはてなブックマークに追加