콘텐츠로 이동

스낵 바

Garak은 Adversarial 테스트를 통해 큰 언어 모델 (LLMs) 및 AI 시스템의 보안 및 견고성을 테스트하고 평가하기 위해 설계된 오픈 소스 AI 빨간색 팀 프레임 워크입니다.

설치 및 설치

Command Description
pip install garak Install Garak via pip
git clone https://github.com/leondz/garak.git Clone from GitHub
cd garak && pip install -e . Install in development mode
garak --help Display help and available options
garak --list-probes List all available probes
garak --list-detectors List all available detectors
garak --list-generators List all available generators

기본 사용

Command Description
garak --model-type openai --model-name gpt-3.5-turbo Test OpenAI GPT-3.5-turbo
garak --model-type huggingface --model-name microsoft/DialoGPT-medium Test HuggingFace model
garak --model-type replicate --model-name replicate/llama-2-70b-chat Test Replicate model
garak --probes encoding Run encoding vulnerability probes
garak --probes malwaregen Run malware generation probes
garak --probes promptinject Run prompt injection probes

Probe 카테고리

보안 Probes

Command Description
garak --probes encoding.InjectBase64 Test base64 encoding injection
garak --probes encoding.InjectHex Test hexadecimal encoding injection
garak --probes encoding.InjectMorse Test Morse code encoding injection
garak --probes encoding.InjectROT13 Test ROT13 encoding injection
garak --probes malwaregen.Evasion Test malware generation evasion
garak --probes promptinject.AttackPrompt Test prompt injection attacks

Bias와 독성 Probes

Command Description
garak --probes bias.BiasProbe Test for bias in model responses
garak --probes toxicity.ToxicityProbe Test for toxic content generation
garak --probes hate.HateSpeechProbe Test for hate speech generation
garak --probes discrimination.DiscriminationProbe Test for discriminatory content

데이터 누설 Probes

Command Description
garak --probes leakage.PIILeakage Test for PII data leakage
garak --probes leakage.TrainingDataLeakage Test for training data exposure
garak --probes leakage.SystemPromptLeakage Test for system prompt exposure

고급 구성

Command Description
garak --config config.yaml Use custom configuration file
garak --output-dir results/ Specify output directory
garak --report-prefix test_run_ Set report file prefix
garak --parallel-requests 5 Set number of parallel requests
garak --temperature 0.7 Set model temperature
garak --max-tokens 150 Set maximum tokens per response

주문 Probes

Command Description
garak --probes myprobe.CustomProbe Run custom probe
garak --probe-options '{"param": "value"}' Pass parameters to probe
garak --probe-tags security,injection Filter probes by tags

발견자 및 평가

Command Description
garak --detectors always.Pass Use always-pass detector
garak --detectors mitigation.MitigationBypass Use mitigation bypass detector
garak --detectors specialwords.SlursReclaimedSlurs Detect slurs and reclaimed slurs
garak --detectors toxicity.ToxicityClassifier Use toxicity classifier

산출과 보고

Command Description
garak --report-format json Generate JSON report
garak --report-format html Generate HTML report
garak --report-format csv Generate CSV report
garak --verbose Enable verbose output
garak --log-level DEBUG Set debug logging level

Model 통합

OpenAI 모델

Command Description
garak --model-type openai --model-name gpt-4 Test GPT-4
garak --model-type openai --model-name gpt-3.5-turbo-16k Test GPT-3.5-turbo with 16k context
export OPENAI_API_KEY=your_key Set OpenAI API key

뚱 베어 얼굴 모형

Command Description
garak --model-type huggingface --model-name facebook/opt-1.3b Test OPT model
garak --model-type huggingface --model-name EleutherAI/gpt-j-6B Test GPT-J model
export HF_TOKEN=your_token Set HuggingFace token

지역 모델

Command Description
garak --model-type ggml --model-name path/to/model.bin Test GGML model
garak --model-type llamacpp --model-name path/to/model.gguf Test llama.cpp model

Batch 테스트

Command Description
garak --model-list models.txt Test multiple models from file
garak --probe-list probes.txt Run multiple probes from file
garak --generations 10 Set number of generations per probe
garak --seed 42 Set random seed for reproducibility

안전 테스트 Workflows

종합 보안 검사

Command Description
garak --model-type openai --model-name gpt-4 --probes encoding,malwaregen,promptinject --generations 20 Full security probe suite

Bias와 공정성 테스트

Command Description
garak --model-type huggingface --model-name microsoft/DialoGPT-medium --probes bias,toxicity,hate --detectors specialwords Bias testing suite

데이터 보호

Command Description
garak --model-type openai --model-name gpt-3.5-turbo --probes leakage --detectors pii Privacy testing suite

구성 파일

기본 설정 (config.yaml)

카지노사이트

고급 Config

카지노사이트

문제 해결

Command Description
garak --check-models Verify model connectivity
garak --dry-run Test configuration without running probes
garak --debug Enable debug mode
garak --list-model-types Show supported model types
pip install garak[dev] Install with development dependencies

CI/CD와 통합

Command Description
garak --model-type openai --model-name gpt-3.5-turbo --probes security --exit-on-fail Fail CI on security issues
garak --config ci_config.yaml --report-format json > results.json Generate CI-friendly output

최고의 연습

  • 항상 생산 배포 전에 테스트 모델
  • 종합적인 테스트를 위한 다수 조사 종류 사용
  • statistical significance를 위한 적당한 발생 조사를 놓으십시오
  • 자주 묻는 질문 API 비율은 throttling을 피하기 위해 제한합니다
  • 환경 변수로 민감한 API 키 저장
  • 검토 및 분석 생성 된 보고서 철저히
  • 개발 파이프라인의 지속적인 테스트 구현
  • 문서 및 추적 보안 테스트 결과