BUG: LLMGenericTextConverter identifier changes between processes for set-valued template parameters

オープン 初心者向け
#3,841 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
75/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
ai

調査の方向性

llm_generic_text_converter.py の約67行目にある _describe_template_value から始めてください。ここでは set と frozenset の値がリストと同様に扱われています。再現スクリプトを PYTHONHASHSEED を 1 と 2 にそれぞれ設定して2回実行し、識別子の出力を比較してください。シードをまたいで識別子が一致し、issue が求めるとおりテンプレートのレンダリング結果が変わらなければ完了です。

索引モデルが issue の本文から書いたものです。

説明

Bug: triage
Describe the bug

_describe_template_value handles set and frozenset like a list (llm_generic_text_converter.py:67), so the identifier follows set iteration order. That order depends on PYTHONHASHSEED, so the same configuration gets a different hash in each process.

Steps/Code to Reproduce

Run on main at 5fb4fb977, once with PYTHONHASHSEED=1 and once with PYTHONHASHSEED=2.

import asyncio

from pyrit.converter import LLMGenericTextConverter
from pyrit.models import SeedPrompt
from pyrit.prompt_target import OpenAIChatTarget
from pyrit.setup import IN_MEMORY, initialize_pyrit_async


async def main() -> None:
    await initialize_pyrit_async(memory_db_type=IN_MEMORY, silent=True)
    target = OpenAIChatTarget(endpoint="https://example.invalid/v1", api_key="unused", model_name="model-a")
    converter = LLMGenericTextConverter(
        converter_target=target,
        system_prompt_template=SeedPrompt(value="Use one of these tones: {{ tone }}", parameters=["tone"]),
        tone={"alpha", "beta", "gamma", "delta", "epsilon", "zeta"},
    )
    print(converter.get_identifier().unique_name)


asyncio.run(main())
Expected Results

The same identifier in both runs.

Actual Results
PYTHONHASHSEED=1  LLMGenericTextConverter::34b80fa1
PYTHONHASHSEED=2  LLMGenericTextConverter::9136bd54
Versions
  • OS: Windows 11
  • Python version: 3.12.0
  • PyRIT version: source checkout of main at 5fb4fb977
System:
    python: 3.12.0 (tags/v3.12.0:0fb18b0, Oct  2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)]
executable: C:\dev\pyr-main\Scripts\python.exe
   machine: Windows-11-10.0.26300-SP0

Python dependencies:
        pyrit: 1.2.0.dev0
       Cython: None
        numpy: 2.4.6
       openai: 2.54.0
    packaging: 26.3
          pip: 23.2.1
        scipy: 1.17.1
   setuptools: 84.2.1
      sqlite3: None
        torch: None
 transformers: 5.20.2

The rendered prompt moves too when a template prints the set: {{ tone }} gives a different order under each seed. Sorting inside _describe_template_value fixes the identifier. Rendering is a separate call: leave it, or reject sets as template parameters.

主要言語
Python
スター
4.7k
フォーク
1k
平均マージ
2日 2時間
マージ済み PR(30日)
439

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/PyRIT のほかの issue

microsoft/PyRIT の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。