[ChatStream] matsuo-lab/weblab-10b-instruction-sft用の ChatPrompt

[ChatStream] matsuo-lab/weblab-10b-instruction-sft用の ChatPrompt

matsuo-lab/weblab-10b-instruction-sft 用の ChatPrompt クラスをリリースしました。
最新バージョンのChatStreamに取り込んでいますが、以下コードを使用することも可能です。

from chatstream import AbstractChatPrompt
from chatstream.chat_prompt.prompt_ttl import PromptTTL


class ChatPromptMatsuoLabJpGptNeoxInstSft(AbstractChatPrompt):

    def __init__(self):
        super().__init__()  # Call the initialization of the base class
        self.set_system("以下は、タスクを説明する指示と、文脈のある入力の組み合わせです。要求を適切に満たす応答を書きなさい。")
        self.set_requester("指示")
        self.set_responder("応答")
        self.set_prefix_as_stop_str_enabled(True)  # enable requester's prompt suffix as stop str
        self.set_prompt_ttl(PromptTTL.SINGLE_TURN)

    def get_stop_strs(self):
        if not self.chat_mode:
            return None
        return ["Q:"]

    def get_replacement_when_input(self):
        return None

    def get_replacement_when_output(self):
        return None

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

        # Chat Mode == True の場合のプロンプトを構築する
        ret = self.system + "\n\n";

        for chat_content in self.get_contents(opts):

            chat_content_role = chat_content.get_role()
            chat_content_message = chat_content.get_message()
            chat_content_child_messages = chat_content.get_child_messages()
            has_child_messages = chat_content.has_child_messages()

            if chat_content_role:

                if chat_content_message:
                    merged_message = f"### {chat_content_role}: \n" + chat_content_message + "\n\n"
                    if has_child_messages:
                        merged_message += f"### 入力: \n"
                        chat_content_child_messages = chat_content.get_child_messages()
                        for message in chat_content_child_messages:
                            merged_message += message + "\n\n"
                else:
                    merged_message = f"### {chat_content_role}: "

                ret += merged_message

        return ret

    def build_initial_prompt(self, chat_prompt):
        # 初期プロンプトは実装しない
        pass


Read more

Luckfox Pico Mを外出先から使う。3,750円・64MBのLinuxボードにWireCanalで公開URLをつけるまで

Luckfox Pico Mを外出先から使う。3,750円・64MBのLinuxボードにWireCanalで公開URLをつけるまで

秋葉原で買った3,750円のLinuxボード Luckfox Pico M(RV1103・64MB・USB-Cのみ)を、Web公開用の受信ポートを追加せずにインターネット側から使えるようにするまで。SDカード書き込み、RNDIS経由のネットワーク、WireCanal無料プランでの公開、busybox initでの常駐とブラウザからのLED操作、再起動復帰(33秒)まで実測手順で解説します。

By Qualiteg プロダクト開発部
Raspberry Pi 5のWebサーバーをインターネットに公開する。ポートは開けない、WireCanalのトンネルで

Raspberry Pi 5のWebサーバーをインターネットに公開する。ポートは開けない、WireCanalのトンネルで

受信ポートを閉じたまま、Raspberry Pi 5のWebサーバーをインターネットに公開します。WireCanalのAgentをワンライナーで入れ、canalを作り、systemdで常駐化。ポート開放もルーター設定も不要で、操作はおよそ5分。再起動後の自動復活まで実測で検収しました。

By Qualiteg プロダクト開発部
Raspberry Pi 5を堅牢化する。SSH鍵認証・UFW・fail2banと、再起動でIPv6が復活する罠

Raspberry Pi 5を堅牢化する。SSH鍵認証・UFW・fail2banと、再起動でIPv6が復活する罠

セットアップ直後のRaspberry Pi 5は、パスワード認証が有効なまま、ファイアウォールなし、更新可能なパッケージ172件と無防備です。SSHの鍵認証化・UFW・fail2ban・自動更新・IPv6無効化を実コマンドと実測検収で解説します。sysctlのIPv6無効化が再起動で復活する現象と恒久対策も実機で確認しました。

By Qualiteg プロダクト開発部