[ChatStream] meta-llama/Meta-Llama-3-8B-Instruct 用の ChatPromptクラス

[ChatStream] meta-llama/Meta-Llama-3-8B-Instruct 用の ChatPromptクラス

昨日(2024/4/19) に発表になった Llama3 用の ChatPrompt クラス※をご紹介します。

from chatstream import AbstractChatPrompt

SYSTEM_PROMPT = """\
You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.
If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.\
"""


class ChatPromptMetaLlamaLlama3Instruct(AbstractChatPrompt):
    """
    meta-llama/Meta-Llama-3-8B-Instruct

    Prompt Guide from
    https://huggingface.co/blog/llama3
    """

    def __init__(self):
        super().__init__()
        self.set_requester("user")
        self.set_responder("assistant")

    def is_skip_special_token(self):
        return False

    def get_stop_strs(self):
        if not self.chat_mode:
            return None
        return ['<|eot_id|>']

    def get_replacement_when_input(self):
        return None

    def get_replacement_when_output(self):  # replace when response_text gotten
        return None

    def create_prompt(self, opts={}):
        if self.chat_mode == False:
            return self.get_requester_last_msg()

        # Chat Mode == True の場合のプロンプトを構築する
        ret = f"<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\n{self.system}<|eot_id|>"

        merged_message = ""
        for chat_content in self.get_contents(opts):

            chat_content_role = chat_content.get_role()
            chat_content_message = chat_content.get_message()

            if chat_content_role:

                if chat_content_message:
                    merged_message = f"<|start_header_id|>{chat_content_role}<|end_header_id|>\n\n{chat_content_message}<|eot_id|>"
                else:
                    merged_message = f"<|start_header_id|>{chat_content_role}<|end_header_id|>\n\n"

                ret += merged_message
        return ret

※ChatStream ご利用のお客様は、最新の ChatStream にも取り込まれておりますが、手動で対応したい場合は上のクラスをご利用ください


Read more

Windows版 Claude Code を irm でインストールして「claude is not recognized」を直すまで

Windows版 Claude Code を irm でインストールして「claude is not recognized」を直すまで

こんにちは! 公式PowerShellインストーラー(irm https://claude.ai/install.ps1 | iex)で Claude Code を入れたのに、claude --version を叩くと「The term 'claude' is not recognized as a name of a cmdlet...」と怒られるときがあります これは Anthropic 公式 GitHub にも報告されている 既知のバグで、インストーラーが PATH の追加を忘れています。実際にインストール作業をやって詰まったので、最短の解決手順をまとめます。 環境 * Windows 11 * PowerShell 7.x(コードは PowerShell

By Qualiteg プロダクト開発部
Claude Opus 4.7 完全ガイド — 公式情報で読み解くモデル仕様とClaude Codeでの実践ノウハウ

Claude Opus 4.7 完全ガイド — 公式情報で読み解くモデル仕様とClaude Codeでの実践ノウハウ

こんにちは! Qualitegプロダクト開発部です! 2026年4月に、AnthropicからClaude Opus 4.7がリリースされました。 今回のアップデートは、単にベンチマークが上がったという話ではありません。命令の解釈の仕方、応答長、ツール呼び出しの頻度、subagentの起動方針まで、モデルの振る舞いそのものが変わっています。 それに伴い、4.6までに作り込んだプロンプトや設定の一部は、外したり再評価したりする必要があります。本記事では、そうした移行時の落とし穴と、4.7時代に合わせた運用作法を、できるだけ実践的にまとめました。 この記事では、まずOpus 4.7で何が変わったのかを確認し、そのうえでClaude Code CLI版とClaude Code Web版でどう使いこなすべきかを見ていきます。 (通常のclaude.aiチャットUIは対象外です。) なお、けっこう長めの記事になっているので、 頭から通読していただく必要はありません。 下の目次から、気になるところや今すぐ困っているところだけ拾い読みしていただいて大丈夫です。 たとえば「とりあえず4.

By Qualiteg プロダクト開発部
サブスクリプションビジネスの完全ガイド【第3回】サブスクリプションビジネスの成長設計

サブスクリプションビジネスの完全ガイド【第3回】サブスクリプションビジネスの成長設計

こんにちは、Qualitegコンサルティングです! サブスクリプションビジネスの完全ガイド 第3回 をお届けいたします! 今回は、 PLG・SLG、ユニットエコノミクス、データ改善の実務ポイントについて解説していきたいとおもいます! この記事でわかること  ・PLG・SLG・ランドアンドエクスパンドの違いと使い分け  ・NRR、LTV/CAC、ペイバック期間など主要指標の実務的な読み方  ・バーンレートとランウェイから資金繰りリスクを把握する方法  ・ファネル分析・コホート分析・A/Bテストによる改善の進め方  ・AIプロダクト特有の原価構造とユニットエコノミクスの注意点 サブスクビジネス完全攻略 シリーズ一覧 第1回 『アープがさぁ...』『チャーンがさぁ...』にもう困らない サブスクビジネス完全攻略 第1回~『アープがさぁ...』『チャーンがさぁ...』にもう困らない完全ガイドなぜサブスクリプションモデルが世界を変えているのか、でもAI台頭でSaaSは終わってしまうの? こんにちは! Qualitegコンサルティングです! 新規事業戦略コンサルタントとして日々

By Qualiteg コンサルティング