Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"함수 호출이란 무엇인가","local":"what-is-function-calling","sections":[{"title":"모델은 동작 수행을 어떻게 “학습”할까요?","local":"how-does-the-model-learn-to-take-an-action","sections":[],"depth":2}],"depth":1}"> | |
| <link href="/docs/agents-course/pr_653/ko/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/ko/_app/immutable/entry/start.dd97e363.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/ko/_app/immutable/chunks/scheduler.cc52f4b9.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/ko/_app/immutable/chunks/singletons.1bb84135.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/ko/_app/immutable/chunks/index.5033808a.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/ko/_app/immutable/chunks/paths.8b47b4c6.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/ko/_app/immutable/entry/app.60fadfd5.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/ko/_app/immutable/chunks/preload-helper.47f5cf13.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/ko/_app/immutable/chunks/index.1e918bfb.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/ko/_app/immutable/nodes/0.93f709bf.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/ko/_app/immutable/chunks/each.e59479a4.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/ko/_app/immutable/nodes/3.f38f98eb.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/ko/_app/immutable/chunks/CopyLLMTxtMenu.9e741ad4.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/ko/_app/immutable/chunks/MermaidChart.svelte_svelte_type_style_lang.daa0d9e5.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/ko/_app/immutable/chunks/CodeBlock.c434d4d3.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{"title":"함수 호출이란 무엇인가","local":"what-is-function-calling","sections":[{"title":"모델은 동작 수행을 어떻게 “학습”할까요?","local":"how-does-the-model-learn-to-take-an-action","sections":[],"depth":2}],"depth":1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"><div class="inline-flex rounded-md max-sm:rounded-sm"><button class="inline-flex items-center gap-1 h-7 max-sm:h-7 px-2 max-sm:px-1.5 text-sm font-medium text-gray-800 border border-r-0 rounded-l-md max-sm:rounded-l-sm border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-live="polite"><span class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0 hover:text-gray-800 dark:hover:text-gray-200"><svg class="sm:size-3.5 size-3" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg></span> <span>Copy page</span></button> <button class="inline-flex items-center justify-center w-6 max-sm:w-5 h-7 max-sm:h-7 disabled:pointer-events-none text-sm text-gray-500 hover:text-gray-700 dark:hover:text-white rounded-r-md max-sm:rounded-r-sm border border-l transition border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-haspopup="menu" aria-expanded="false" aria-label="Open copy menu"><svg class="transition-transform text-gray-400 overflow-visible sm:size-3.5 size-3 rotate-0" width="1em" height="1em" viewBox="0 0 12 7" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L6 6L11 1" stroke="currentColor"></path></svg></button></div> </div> <h1 class="relative group"><a id="what-is-function-calling" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#what-is-function-calling"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>함수 호출이란 무엇인가</span></h1> <p data-svelte-h="svelte-vu1rra">함수 호출은 <strong>LLM이 환경과 상호작용하여 동작을 수행하는 방법</strong>입니다. 처음에는 <a href="https://openai.com/index/function-calling-and-other-api-updates/" rel="nofollow">GPT-4에서 도입되었으며</a>, 이후 다른 모델에서도 구현되었습니다.</p> <p data-svelte-h="svelte-11we16m">에이전트의 도구처럼, 함수 호출은 모델에게 <strong>주어진 환경에서 동작을 수행할 수 있는 능력</strong>을 제공합니다. 다만 함수 호출 능력은 <strong>모델 스스로 학습을 통해 체득한 것</strong>이므로, 다른 에이전트 기법들보다 <strong>프롬프트에 덜 의존</strong>한다는 점입니다.</p> <p data-svelte-h="svelte-wmizw5">Unit 1에서는 에이전트가 <strong>도구를 사용하는 법을 학습한 것이 아니며</strong>, 우리는 그저 도구 목록을 모델에게 제공했고, 모델이 <strong>이 도구들을 활용해 계획을 생성할 것이라는 일반화 능력</strong>에 의존했습니다.</p> <p data-svelte-h="svelte-z7ldkr">여기서는 <strong>함수 호출을 통해 에이전트가 도구를 사용할 수 있도록 미세 조정(학습)</strong>합니다.</p> <h2 class="relative group"><a id="how-does-the-model-learn-to-take-an-action" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#how-does-the-model-learn-to-take-an-action"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>모델은 동작 수행을 어떻게 “학습”할까요?</span></h2> <p data-svelte-h="svelte-y32mlq">Unit 1에서는 에이전트의 일반적인 워크플로우를 살펴보았습니다. 사용자가 에이전트에 도구를 제공하고 질의를 전달하면, 모델은 다음 과정을 반복합니다.</p> <ol data-svelte-h="svelte-ak88y6"><li><em>사고(Think)</em> : 목표를 달성하기 위해 어떤 동작을 수행해야 할지 고민합니다.</li> <li><em>행동(Act)</em> : 정해진 형식에 맞춰 행동을 수행하고, 일단 자신의 텍스트 응답 생성은 멈춥니다.</li> <li><em>관찰(Observe)</em> : 행동의 실행 결과를 외부로부터 받아옵니다.</li></ol> <p data-svelte-h="svelte-r0v9bv">API를 통한 “일반적인” 대화는 아래처럼 사용자(“user”)와 어시스턴트(“assistant”)가 메시지를 주고받는 형태로 구성됩니다.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START -->conversation = [ | |
| {<span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, <span class="hljs-string">"content"</span>: <span class="hljs-string">"I need help with my order"</span>}, | |
| {<span class="hljs-string">"role"</span>: <span class="hljs-string">"assistant"</span>, <span class="hljs-string">"content"</span>: <span class="hljs-string">"I'd be happy to help. Could you provide your order number?"</span>}, | |
| {<span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, <span class="hljs-string">"content"</span>: <span class="hljs-string">"It's ORDER-123"</span>}, | |
| ]<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-iub1bm">함수 호출은 이 대화의 흐름에 <strong>새로운 역할(“role”)</strong>을 추가합니다!</p> <ol data-svelte-h="svelte-1sjli8g"><li><strong>행동(Action)</strong>을 위한 새로운 역할</li> <li><strong>관찰(Observation)</strong>을 위한 새로운 역할</li></ol> <p data-svelte-h="svelte-1slgxq7"><a href="https://docs.mistral.ai/capabilities/function_calling/" rel="nofollow">Mistral API</a>를 예로 들면, 대화 구조가 이렇게 바뀌게 됩니다.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START -->conversation = [ | |
| { | |
| <span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, | |
| <span class="hljs-string">"content"</span>: <span class="hljs-string">"What's the status of my transaction T1001?"</span> | |
| }, | |
| { | |
| <span class="hljs-string">"role"</span>: <span class="hljs-string">"assistant"</span>, | |
| <span class="hljs-string">"content"</span>: <span class="hljs-string">""</span>, | |
| <span class="hljs-string">"function_call"</span>: { | |
| <span class="hljs-string">"name"</span>: <span class="hljs-string">"retrieve_payment_status"</span>, | |
| <span class="hljs-string">"arguments"</span>: <span class="hljs-string">"{\"transaction_id\": \"T1001\"}"</span> | |
| } | |
| }, | |
| { | |
| <span class="hljs-string">"role"</span>: <span class="hljs-string">"tool"</span>, | |
| <span class="hljs-string">"name"</span>: <span class="hljs-string">"retrieve_payment_status"</span>, | |
| <span class="hljs-string">"content"</span>: <span class="hljs-string">"{\"status\": \"Paid\"}"</span> | |
| }, | |
| { | |
| <span class="hljs-string">"role"</span>: <span class="hljs-string">"assistant"</span>, | |
| <span class="hljs-string">"content"</span>: <span class="hljs-string">"Your transaction T1001 has been successfully paid."</span> | |
| } | |
| ]<!-- HTML_TAG_END --></pre></div> <blockquote data-svelte-h="svelte-obpfff"><p>…하지만 방금 함수 호출에 ‘새로운 역할’이 추가된다고 하지 않았나요?</p></blockquote> <p data-svelte-h="svelte-13mrp38"><strong>그렇기도 하고 아니기도 합니다.</strong> 이 경우를 비롯해 많은 API에서, 모델은 수행할 동작을 “assistant” 메시지로 출력합니다. 그러면 이후 채팅 템플릿이 이 메시지를 함수 호출을 위한 <strong>특수 토큰</strong>으로 변환하여 처리합니다.</p> <ul data-svelte-h="svelte-1g7ygzj"><li><code>[AVAILABLE_TOOLS]</code> – 사용 가능한 도구 목록 시작</li> <li><code>[/AVAILABLE_TOOLS]</code> – 사용 가능한 도구 목록 종료</li> <li><code>[TOOL_CALLS]</code> – 도구를 호출(즉, <strong>Action</strong> 수행)</li> <li><code>[TOOL_RESULTS]</code> – 동작 결과(“Observe”)</li> <li><code>[/TOOL_RESULTS]</code> – 관찰 종료(이제 모델이 이어서 응답을 생성할 수 있음)</li></ul> <p data-svelte-h="svelte-1ta5k4x">강의에서 함수 호출을 다시 다룰 예정이지만, 더 깊이 살펴보고 싶다면 <a href="https://docs.mistral.ai/capabilities/function_calling/" rel="nofollow">Mistral의 공식 문서</a>를 참고하세요.</p> <hr> <p data-svelte-h="svelte-8q59hk">이제 함수 호출이 무엇이고 어떻게 작동하는지 배웠으니, 아직 해당 기능이 없는 모델인 [google/gemma-2-2b-it](<a href="https://huggingface.co/google/gemma-2-2b-it" rel="nofollow">google/gemma-2-2b-it</a>에 새로운 특수 토큰을 덧붙이는 방식으로 함수 호출 기능을 직접 추가해보겠습니다.</p> <p data-svelte-h="svelte-1eguzm5">이를 위해서는 <strong>먼저 미세 조정과 LoRA</strong>를 이해해야 합니다.</p> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/agents-course/blob/main/units/ko/bonus-unit1/what-is-function-calling.mdx" target="_blank"><svg class="mr-1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M31,16l-7,7l-1.41-1.41L28.17,16l-5.58-5.59L24,9l7,7z"></path><path d="M1,16l7-7l1.41,1.41L3.83,16l5.58,5.59L8,23l-7-7z"></path><path d="M12.419,25.484L17.639,6.552l1.932,0.518L14.351,26.002z"></path></svg> <span data-svelte-h="svelte-zjs2n5"><span class="underline">Update</span> on GitHub</span></a> <p></p> | |
| <script> | |
| { | |
| __sveltekit_71ttkj = { | |
| assets: "/docs/agents-course/pr_653/ko", | |
| base: "/docs/agents-course/pr_653/ko", | |
| env: {} | |
| }; | |
| const element = document.currentScript.parentElement; | |
| const data = [null,null]; | |
| Promise.all([ | |
| import("/docs/agents-course/pr_653/ko/_app/immutable/entry/start.dd97e363.js"), | |
| import("/docs/agents-course/pr_653/ko/_app/immutable/entry/app.60fadfd5.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 3], | |
| data, | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 17.3 kB
- Xet hash:
- f74422e9a547f96bd43caff9e29af6bf1d73cc62628ab842a7cc02f8ea17b48c
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.