본문으로 건너뛰기
cccskills
무료GitHub에 공개

adversarial-examples

Generate adversarial inputs, edge cases, and boundary test payloads for stress-testing LLM robustness

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(2)

  • SKILL.md6.0 KB
  • metadata.json1.4 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Adversarial Examples & Edge Case Testing

Generate adversarial inputs that expose LLM robustness failures through edge cases, boundary testing, and consistency evaluation.

Quick Reference

Skill:       adversarial-examples
Agent:       03-adversarial-input-engineer
OWASP:       LLM04 (Data Poisoning), LLM09 (Misinformation)
Use Case:    Test model robustness against malformed/edge inputs

Edge Case Categories

1. Linguistic Edge Cases

Category: linguistic
Test Count: 25

Subcategories:
  homonyms:
    - "The bank was steep" vs "The bank was closed"
    - "I saw her duck" (action vs animal)
  polysemy:
    - "Set" (60+ meanings)
    - "Run" (context-dependent)
  scope_ambiguity:
    - "I saw the man with the telescope"
    - "Flying planes can be dangerous"
  pragmatic_implicature:
    - "Some students passed" (implies not all)
    - "Can you pass the salt?" (request, not question)

2. Numerical Edge Cases

Category: numerical
Test Count: 30

Test Cases:
  zero_handling:
    - Division by zero scenarios
    - Zero-length arrays
  boundary_values:
    - INT_MAX, INT_MIN
    - Float precision (0.1 + 0.2 != 0.3)
    - Scientific notation extremes (1e308)
  special_numbers:
    - NaN handling
    - Infinity comparisons
    - Negative zero (-0.0)

3. Logical Edge Cases

Category: logical
Test Count: 20

Test Cases:
  contradictions:
    - "This statement is false"
    - Inconsistent premises
  incomplete_information:
    - Missing context
    - Ambiguous references
  false_premises:
    - "Why is the sky green?"
    - Loaded questions

4. Format Edge Cases

Category: format
Test Count: 35

Test Cases:
  encoding:
    - UTF-8, UTF-16, UTF-32 mixing
    - BOM characters
  unicode_attacks:
    - Homoglyphs (а vs a, ο vs o)
    - RTL override characters
    - Zero-width joiners
  structural:
    - Deeply nested JSON (100+ levels)
    - Malformed markup

5. Consistency Tests

Category: consistency
Test Count: 15

Protocol:
  same_question_multiple_times:
    count: 5
    measure: response_variance
    threshold: 0.1
  semantic_equivalence:
    pairs:
      - ["What is 2+2?", "Calculate two plus two"]
    measure: semantic_similarity
    threshold: 0.9

Mutation Engine

# adversarial_mutation.py
import unicodedata
from typing import List

class AdversarialMutator:
    """Generate adversarial variants of inputs"""

    HOMOGLYPHS = {
        'a': ['а', 'ɑ', 'α'],
        'e': ['е', 'ε', 'ē'],
        'o': ['о', 'ο', 'ō'],
    }

    ZERO_WIDTH = ['\u200b', '\u200c', '\u200d', '\ufeff']

    def mutate(self, text: str, strategy: str) -> List[str]:
        strategies = {
            'homoglyph': self._homoglyph_mutation,
            'encoding': self._encoding_mutation,
            'spacing': self._spacing_mutation,
        }
        return strategies[strategy](text)

    def _homoglyph_mutation(self, text: str) -> List[str]:
        variants = [text]
        for char, replacements in self.HOMOGLYPHS.items():
            if char in text.lower():
                for r in replacements:
                    variants.append(text.replace(char, r))
        return variants

    def _encoding_mutation(self, text: str) -> List[str]:
        return [
            text,
            unicodedata.normalize('NFD', text),
            unicodedata.normalize('NFC', text),
            unicodedata.normalize('NFKC', text),
        ]

    def _spacing_mutation(self, text: str) -> List[str]:
        return [text] + [zw.join(text) for zw in self.ZERO_WIDTH]

Testing Protocol

Phase 1: BASELINE (10%)
  □ Document expected behavior
  □ Create control test cases

Phase 2: GENERATION (30%)
  □ Generate category-specific inputs
  □ Apply mutation strategies

Phase 3: EXECUTION (40%)
  □ Execute all test cases
  □ Record responses

Phase 4: ANALYSIS (20%)
  □ Calculate failure rates
  □ Prioritize by severity

Severity Classification

CRITICAL (>20% failure): Immediate fix required
HIGH (10-20%): Fix within 48 hours
MEDIUM (5-10%): Plan remediation
LOW (<5%): Monitor and document

Unit Test Template

import pytest

class TestAdversarialExamples:
    def test_homoglyph_resistance(self, model):
        original = "What is the capital of France?"
        variants = mutator.mutate(original, 'homoglyph')
        baseline = model.generate(original)
        for v in variants:
            assert similarity(baseline, model.generate(v)) > 0.9

    def test_consistency(self, model):
        query = "What is 2 + 2?"
        responses = [model.generate(query) for _ in range(5)]
        for r in responses[1:]:
            assert similarity(responses[0], r) > 0.95

Troubleshooting

Issue: High false positive rate
Solution: Adjust similarity thresholds

Issue: Tests timing out
Solution: Implement batching, add caching

Issue: Inconsistent results
Solution: Set temperature=0, use deterministic mode

Integration Points

ComponentPurpose
Agent 03Generates and executes tests
/test adversarialCommand interface
CI/CDAutomated regression testing

Stress-test LLM robustness with comprehensive adversarial examples.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

[00] TnR ABSOLUTE RIGOR — Systemic Verification Doctrine. Forced cognitive exertion for high-stakes investigations. Mandates absolute deconstruction, mathematical proof chains, and ≥95% derived certainty. Zero-tolerance for heuristics or sentiment-based reasoning. Shortcuts are defined as intentional hallucinations.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

diegosouzapw/awesome-omni-skill642026년 3월 2일 업데이트

2agent

무료

Configures 2-Agent workflow between PM and implementation roles. Use when user mentions 2-Agent, 2エージェント, PM連携設定, Cursor設定, Cursor連携, 2-agent運用. Do NOT load for: 単独運用, ワークフロー実行, ハンドオフ処理.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

diegosouzapw/awesome-omni-skill642026년 3월 2일 업데이트

Appends relevant hashtags to journal entries based on content analysis. Intended for LLM execution.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

diegosouzapw/awesome-omni-skill642026년 3월 2일 업데이트

add-agent

무료

Add a new AI coding agent to Agent Sandbox. Creates all required files (Dockerfile, templates, CI, docs) and wires the agent into the CLI, proxy, and build system.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

diegosouzapw/awesome-omni-skill642026년 3월 2일 업데이트

Add a new property to the AI agents database. Use when the user wants to add, create, or introduce a new column, property, field, or feature to track across all agents in the comparison matrix. Handles all four required steps - database updates, groups.json, table display, and GitHub issue templates.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

diegosouzapw/awesome-omni-skill642026년 3월 2일 업데이트

Add new Agent templates to the meta-agent-skills framework.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

diegosouzapw/awesome-omni-skill642026년 3월 2일 업데이트

diegosouzapw의 스킬 모두 보기

이 스킬의 문제 신고