<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ko">
	<id>https://devcafe.co.kr/w/index.php?action=history&amp;feed=atom&amp;title=%EA%B0%84%EB%8B%A8%ED%95%9C_SLM_%ED%95%99%EC%8A%B5_%EB%B0%8F_%ED%85%8C%EC%8A%A4%ED%8A%B8_%EC%98%88%EC%A0%9C</id>
	<title>간단한 SLM 학습 및 테스트 예제 - 편집 역사</title>
	<link rel="self" type="application/atom+xml" href="https://devcafe.co.kr/w/index.php?action=history&amp;feed=atom&amp;title=%EA%B0%84%EB%8B%A8%ED%95%9C_SLM_%ED%95%99%EC%8A%B5_%EB%B0%8F_%ED%85%8C%EC%8A%A4%ED%8A%B8_%EC%98%88%EC%A0%9C"/>
	<link rel="alternate" type="text/html" href="https://devcafe.co.kr/w/index.php?title=%EA%B0%84%EB%8B%A8%ED%95%9C_SLM_%ED%95%99%EC%8A%B5_%EB%B0%8F_%ED%85%8C%EC%8A%A4%ED%8A%B8_%EC%98%88%EC%A0%9C&amp;action=history"/>
	<updated>2026-07-02T09:16:44Z</updated>
	<subtitle>이 문서의 편집 역사</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://devcafe.co.kr/w/index.php?title=%EA%B0%84%EB%8B%A8%ED%95%9C_SLM_%ED%95%99%EC%8A%B5_%EB%B0%8F_%ED%85%8C%EC%8A%A4%ED%8A%B8_%EC%98%88%EC%A0%9C&amp;diff=987&amp;oldid=prev</id>
		<title>2024년 11월 17일 (일) 17:51에 Devcafe님의 편집</title>
		<link rel="alternate" type="text/html" href="https://devcafe.co.kr/w/index.php?title=%EA%B0%84%EB%8B%A8%ED%95%9C_SLM_%ED%95%99%EC%8A%B5_%EB%B0%8F_%ED%85%8C%EC%8A%A4%ED%8A%B8_%EC%98%88%EC%A0%9C&amp;diff=987&amp;oldid=prev"/>
		<updated>2024-11-17T17:51:15Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ko&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← 이전 판&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2024년 11월 18일 (월) 02:51 판&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l68&quot;&gt;68번째 줄:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;68번째 줄:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{틀:요약  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{틀:요약  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|제목=* 코드 설명&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|제목=* 코드 설명&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;	&lt;/del&gt;1.	데이터 로드 및 전처리:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;1.	데이터 로드 및 전처리:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;	•	&lt;/del&gt;SST-2는 감정 분석용 데이터셋입니다(긍정/부정 분류).&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* &lt;/ins&gt;SST-2는 감정 분석용 데이터셋입니다(긍정/부정 분류).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;	•	&lt;/del&gt;문장을 토큰화하고 패딩/트렁케이션 처리하여 모델 입력 형식에 맞게 변환합니다.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* &lt;/ins&gt;문장을 토큰화하고 패딩/트렁케이션 처리하여 모델 입력 형식에 맞게 변환합니다.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;	&lt;/del&gt;2.	모델 설정:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;	•	&lt;/del&gt;DistilBERT 모델을 로드하고 출력 레이블 개수를 2(긍정/부정)로 설정합니다.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;2.	모델 설정:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;	&lt;/del&gt;3.	Trainer 사용:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* &lt;/ins&gt;DistilBERT 모델을 로드하고 출력 레이블 개수를 2(긍정/부정)로 설정합니다.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;	•	&lt;/del&gt;Trainer는 학습 과정을 간단히 관리할 수 있는 Hugging Face의 유틸리티입니다.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;	•	&lt;/del&gt;학습 파라미터(학습률, 배치 크기, 에포크 수 등)를 설정합니다.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;3.	Trainer 사용:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	4.	학습 실행:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* &lt;/ins&gt;Trainer는 학습 과정을 간단히 관리할 수 있는 Hugging Face의 유틸리티입니다.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;	•	&lt;/del&gt;trainer.train()으로 학습을 시작합니다.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* &lt;/ins&gt;학습 파라미터(학습률, 배치 크기, 에포크 수 등)를 설정합니다.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;	•	&lt;/del&gt;학습이 완료되면 모델과 토크나이저를 저장합니다.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;4.	학습 실행:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* &lt;/ins&gt;trainer.train()으로 학습을 시작합니다.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* &lt;/ins&gt;학습이 완료되면 모델과 토크나이저를 저장합니다.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{틀:요약  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{틀:요약  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|제목=* 결과&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|제목=* 결과&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* 학습된 모델은 SST-2 데이터셋에서 긍정/부정 감정을 예측하는 데 사용할 수 있습니다.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* 저장된 모델(./distilbert-sst2)을 로드하여 새로운 문장의 감정을 분류할 수 있습니다.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;	•	학습된 모델은 SST-2 데이터셋에서 긍정/부정 감정을 예측하는 데 사용할 수 있습니다.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* &lt;/ins&gt;추가 활용&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;	•	저장된 모델(./distilbert-sst2)을 로드하여 새로운 문장의 감정을 분류할 수 있습니다.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;** &lt;/ins&gt;다른 데이터셋으로 모델을 Fine-tuning하거나, 텍스트 분류 외의 작업(질문 응답, 요약 등)에도 적용할 수 있습니다.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;** &lt;/ins&gt;SLM(Small Language Model) 학습은 LLM에 비해 자원 소모가 적고, 로컬 컴퓨터에서도 실행이 가능합니다.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;추가 활용&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;	•	&lt;/del&gt;다른 데이터셋으로 모델을 Fine-tuning하거나, 텍스트 분류 외의 작업(질문 응답, 요약 등)에도 적용할 수 있습니다.&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;	•	&lt;/del&gt;SLM(Small Language Model) 학습은 LLM에 비해 자원 소모가 적고, 로컬 컴퓨터에서도 실행이 가능합니다.&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Devcafe</name></author>
	</entry>
	<entry>
		<id>https://devcafe.co.kr/w/index.php?title=%EA%B0%84%EB%8B%A8%ED%95%9C_SLM_%ED%95%99%EC%8A%B5_%EB%B0%8F_%ED%85%8C%EC%8A%A4%ED%8A%B8_%EC%98%88%EC%A0%9C&amp;diff=986&amp;oldid=prev</id>
		<title>Devcafe: 새 문서: * Hugging Face의 Transformers 라이브러리를 사용하여 DistilBERT를 간단한 텍스트 분류 작업에 학습시키는 과정 * 필요한 라이브러리 설치 &lt;source lang=python&gt; pip install transformers datasets torch &lt;/source&gt;  == 학습용 데이터 준비 == * Hugging Face의 datasets 라이브러리를 사용해 간단한 감정 분석 데이터셋(SST-2)을 불러옵니다. &lt;source lang=python&gt; from datasets import load_dataset from transformers import Distil...</title>
		<link rel="alternate" type="text/html" href="https://devcafe.co.kr/w/index.php?title=%EA%B0%84%EB%8B%A8%ED%95%9C_SLM_%ED%95%99%EC%8A%B5_%EB%B0%8F_%ED%85%8C%EC%8A%A4%ED%8A%B8_%EC%98%88%EC%A0%9C&amp;diff=986&amp;oldid=prev"/>
		<updated>2024-11-17T17:49:14Z</updated>

		<summary type="html">&lt;p&gt;새 문서: * Hugging Face의 Transformers 라이브러리를 사용하여 DistilBERT를 간단한 텍스트 분류 작업에 학습시키는 과정 * 필요한 라이브러리 설치 &amp;lt;source lang=python&amp;gt; pip install transformers datasets torch &amp;lt;/source&amp;gt;  == 학습용 데이터 준비 == * Hugging Face의 datasets 라이브러리를 사용해 간단한 감정 분석 데이터셋(SST-2)을 불러옵니다. &amp;lt;source lang=python&amp;gt; from datasets import load_dataset from transformers import Distil...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;새 문서&lt;/b&gt;&lt;/p&gt;&lt;div&gt;* Hugging Face의 Transformers 라이브러리를 사용하여 DistilBERT를 간단한 텍스트 분류 작업에 학습시키는 과정&lt;br /&gt;
* 필요한 라이브러리 설치&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
pip install transformers datasets torch&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 학습용 데이터 준비 ==&lt;br /&gt;
* Hugging Face의 datasets 라이브러리를 사용해 간단한 감정 분석 데이터셋(SST-2)을 불러옵니다.&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
from datasets import load_dataset&lt;br /&gt;
from transformers import DistilBertTokenizer, DistilBertForSequenceClassification&lt;br /&gt;
from transformers import Trainer, TrainingArguments&lt;br /&gt;
import torch&lt;br /&gt;
&lt;br /&gt;
# 1. 데이터셋 로드&lt;br /&gt;
dataset = load_dataset(&amp;quot;glue&amp;quot;, &amp;quot;sst2&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# 2. 토크나이저 로드&lt;br /&gt;
tokenizer = DistilBertTokenizer.from_pretrained(&amp;quot;distilbert-base-uncased&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# 3. 데이터 전처리&lt;br /&gt;
def tokenize_function(examples):&lt;br /&gt;
    return tokenizer(examples[&amp;quot;sentence&amp;quot;], padding=&amp;quot;max_length&amp;quot;, truncation=True)&lt;br /&gt;
&lt;br /&gt;
tokenized_datasets = dataset.map(tokenize_function, batched=True)&lt;br /&gt;
&lt;br /&gt;
# 4. PyTorch 데이터셋으로 변환&lt;br /&gt;
tokenized_datasets = tokenized_datasets.remove_columns([&amp;quot;sentence&amp;quot;, &amp;quot;idx&amp;quot;])&lt;br /&gt;
tokenized_datasets = tokenized_datasets.rename_column(&amp;quot;label&amp;quot;, &amp;quot;labels&amp;quot;)&lt;br /&gt;
tokenized_datasets.set_format(&amp;quot;torch&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# 5. 학습 및 검증 데이터 분리&lt;br /&gt;
train_dataset = tokenized_datasets[&amp;quot;train&amp;quot;]&lt;br /&gt;
valid_dataset = tokenized_datasets[&amp;quot;validation&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
# 6. 모델 로드&lt;br /&gt;
model = DistilBertForSequenceClassification.from_pretrained(&amp;quot;distilbert-base-uncased&amp;quot;, num_labels=2)&lt;br /&gt;
&lt;br /&gt;
# 7. 학습 설정&lt;br /&gt;
training_args = TrainingArguments(&lt;br /&gt;
    output_dir=&amp;quot;./results&amp;quot;,          # 모델 저장 디렉토리&lt;br /&gt;
    evaluation_strategy=&amp;quot;epoch&amp;quot;,    # 평가 주기&lt;br /&gt;
    learning_rate=2e-5,&lt;br /&gt;
    per_device_train_batch_size=16,&lt;br /&gt;
    per_device_eval_batch_size=16,&lt;br /&gt;
    num_train_epochs=3,&lt;br /&gt;
    weight_decay=0.01,&lt;br /&gt;
    logging_dir=&amp;quot;./logs&amp;quot;,            # 로그 저장 디렉토리&lt;br /&gt;
    logging_steps=10,&lt;br /&gt;
    save_steps=500,&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
# 8. Trainer 설정&lt;br /&gt;
trainer = Trainer(&lt;br /&gt;
    model=model,&lt;br /&gt;
    args=training_args,&lt;br /&gt;
    train_dataset=train_dataset,&lt;br /&gt;
    eval_dataset=valid_dataset,&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
# 9. 모델 학습&lt;br /&gt;
trainer.train()&lt;br /&gt;
&lt;br /&gt;
# 10. 모델 저장&lt;br /&gt;
model.save_pretrained(&amp;quot;./distilbert-sst2&amp;quot;)&lt;br /&gt;
tokenizer.save_pretrained(&amp;quot;./distilbert-sst2&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
{{틀:요약 &lt;br /&gt;
|제목=* 코드 설명&lt;br /&gt;
	1.	데이터 로드 및 전처리:&lt;br /&gt;
	•	SST-2는 감정 분석용 데이터셋입니다(긍정/부정 분류).&lt;br /&gt;
	•	문장을 토큰화하고 패딩/트렁케이션 처리하여 모델 입력 형식에 맞게 변환합니다.&lt;br /&gt;
	2.	모델 설정:&lt;br /&gt;
	•	DistilBERT 모델을 로드하고 출력 레이블 개수를 2(긍정/부정)로 설정합니다.&lt;br /&gt;
	3.	Trainer 사용:&lt;br /&gt;
	•	Trainer는 학습 과정을 간단히 관리할 수 있는 Hugging Face의 유틸리티입니다.&lt;br /&gt;
	•	학습 파라미터(학습률, 배치 크기, 에포크 수 등)를 설정합니다.&lt;br /&gt;
	4.	학습 실행:&lt;br /&gt;
	•	trainer.train()으로 학습을 시작합니다.&lt;br /&gt;
	•	학습이 완료되면 모델과 토크나이저를 저장합니다.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{틀:요약 &lt;br /&gt;
|제목=* 결과&lt;br /&gt;
&lt;br /&gt;
	•	학습된 모델은 SST-2 데이터셋에서 긍정/부정 감정을 예측하는 데 사용할 수 있습니다.&lt;br /&gt;
	•	저장된 모델(./distilbert-sst2)을 로드하여 새로운 문장의 감정을 분류할 수 있습니다.&lt;br /&gt;
&lt;br /&gt;
추가 활용&lt;br /&gt;
&lt;br /&gt;
	•	다른 데이터셋으로 모델을 Fine-tuning하거나, 텍스트 분류 외의 작업(질문 응답, 요약 등)에도 적용할 수 있습니다.&lt;br /&gt;
	•	SLM(Small Language Model) 학습은 LLM에 비해 자원 소모가 적고, 로컬 컴퓨터에서도 실행이 가능합니다.&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Devcafe</name></author>
	</entry>
</feed>