LLM 안전 확보

Python으로 배우는 LLM 입문

Jasmin Ludolf

Senior Data Science Content Developer, DataCamp

LLM 과제

다국어 지원: 언어 다양성, 자원 가용성, 적응성

다국어 지원

오픈 vs 클로즈드 LLM 딜레마: 협업 vs 책임 있는 사용

오픈 vs 클로즈드 LLM

모델 확장성: 표현력, 연산 수요, 학습 요구사항

LLM 확장성

편향: 편향된 학습 데이터, 불공정한 언어 이해·생성

LLM의 편향

1 Icon made by Freepik (freepik.com)
Python으로 배우는 LLM 입문

진실성 및 환각

  • 환각(Hallucinations): 사실처럼 보이나 거짓·무의미한 내용을 생성

LLM의 환각

환각 완화 전략:

  1. 다양하고 대표성 있는 학습 데이터 노출
  2. 출력 편향 점검 및 제거 기법 적용
  3. 민감 분야에 맞춘 파인튜닝
  4. 프롬프트 엔지니어링: 프롬프트 설계·개선
Python으로 배우는 LLM 입문

진실성 및 환각

  • 환각(Hallucinations): 사실처럼 보이나 거짓·무의미한 내용을 생성

LLM의 환각

Python으로 배우는 LLM 입문

LLM 편향 분석 지표: 유해성

  • 유해성(Toxicity): 사전 학습된 혐오 발화 분류기로 텍스트 유해성을 정량화
  • aggregation="maximum" 는 입력 전체 중 최대 유해성 점수를 반환
  • aggregation="ratio" 는 유해성 0.5 초과 예측의 비율(%)을 반환
toxicity_metric = load("toxicity")
texts_1 = ["Everyone in the team adores him", "He is a true genius, pure talent"]
texts_2 = ["Nobody in the team likes him", "He is a useless 'good-for-nothing'"]

toxicity_results_1 = toxicity_metric.compute(predictions=texts_1,aggregation="maximum") toxicity_results_2 = toxicity_metric.compute(predictions=texts_2, aggregation="maximum") print("Toxicity Sentences 1:", toxicity_results_1) print("Toxicity Sentences 2:", toxicity_results_2)
Toxicity Sentences 1: {'max_toxicity': 0.0001386617950629443}
Toxicity Sentences 2: {'max_toxicity': 0.012273495085537434}
Python으로 배우는 LLM 입문

LLM 편향 분석 지표: regard

  • Regard: 특정 집단에 대한 언어 극성·인식 편향

  • 두 집단에 연결된 LLM 출력을 구분해 regard 점수 평가

regard = load("regard")

group1 = ['abc are described as loyal employees',
          'abc are ambitious in their career expectations']
group2 = ['abc are known for causing lots of team conflicts',
          'abc are verbally violent']


polarity_results_1 = regard.compute(data=group1) polarity_results_2 = regard.compute(data=group2)
Python으로 배우는 LLM 입문

LLM 편향 분석 지표: regard

for result in polarity_results_1['regard']:
  print(result)
[{'label': 'positive', 'score': 0.9098386764526367}, 
 {'label': 'neutral', 'score': 0.059396952390670776}, 
 {'label': 'other', 'score': 0.026468101888895035}, 
 {'label': 'negative', 'score': 0.004296252969652414}]
[{'label': 'positive', 'score': 0.7809812426567078}, 
 {'label': 'neutral', 'score': 0.18085983395576477}, 
 {'label': 'other', 'score': 0.030492952093482018}, 
 {'label': 'negative', 'score': 0.007666013203561306}]
for result in polarity_results_2['regard']:
  print(result)
[{'label': 'negative', 'score': 0.9658734202384949}, 
 {'label': 'other', 'score': 0.021555885672569275}, 
 {'label': 'neutral', 'score': 0.012026479467749596},
 {'label': 'positive', 'score': 0.0005441228277049959}]
[{'label': 'negative', 'score': 0.9774736166000366}, 
 {'label': 'other', 'score': 0.012994581833481789},  
 {'label': 'neutral', 'score': 0.008945506066083908}, 
 {'label': 'positive', 'score': 0.0005862844991497695}]
Python으로 배우는 LLM 입문

Ayo berlatih!

Python으로 배우는 LLM 입문

Preparing Video For Download...