상세 컨텐츠

본문 제목

Prompting and prompt engineering

Generative AI with Large Language Models

by Taeyoon.Kim.DS 2023. 8. 21. 19:45

본문

https://www.coursera.org/learn/generative-ai-with-llms/lecture/ZVUcF/prompting-and-prompt-engineering

In working with large language models (LLMs), it's essential to understand some key terminology:

Prompt: The text fed into the model for generating text.
Inference: The act of generating text.
Completion: The generated output text.
Context Window: The full amount of text or memory available for the prompt.
Often, the model may not produce the desired outcome on the first try, and you might need to revise the prompt or its wording multiple times. This process of refining prompts is known as prompt engineering.

One effective strategy to improve model performance is to include task-specific examples within the prompt. This is called in-context learning. There are different levels of in-context learning:

Zero- shot inference: When the model understands the task solely from the prompt without examples, often performed well by larger models.
One-shot inference: Including a single example within the prompt to help smaller models understand the task.
Few- shot inference: Including multiple examples within the prompt to provide the model with a better understanding of the desired behavior.

The choice of which level to use depends on the model's size and capabilities. However, keep in mind that there's a limit to the context window, so if including multiple examples doesn't work well, consider fine-tuning the model, which involves additional training using new data to make it better suited to the task.

In general, larger models tend to perform better at various tasks, including zero-shot inference, while smaller models are more task-specific. Selecting the right model for your use case is essential, and you can experiment with configuration settings to influence the structure and style of the completions generated by the model.

대규모 언어 모델(LLMs)을 사용할 때 몇 가지 주요 용어를 이해하는 것이 중요합니다:

프롬프트 (Prompt): 텍스트를 모델에 공급하는 부분.
추론 (Inference): 텍스트 생성의 작업.
완료 (Completion): 생성된 출력 텍스트.
컨텍스트 창 (Context Window): 프롬프트에 사용 가능한 전체 텍스트 또는 메모리 양.
모델은 종종 처음 시도에서 원하는 결과물을 생성하지 못할 수 있으며, 프롬프트나 그 문장을 여러 번 수정해야 할 수 있습니다. 이 프롬프트 수정 작업을 프롬프트 엔지니어링이라고 합니다.

모델 성능을 향상시키는 효과적인 전략 중 하나는 프롬프트 내에 작업별 예제를 포함하는 것입니다. 이것이 컨텍스트 학습입니다. 컨텍스트 학습에는 다음과 같은 다양한 수준이 있습니다:

제로샷 추론 (Zero-shot inference): 모델이 예제 없이도 프롬프트만으로 작업을 이해하고 수행하는 경우, 주로 대규모 모델에서 잘 수행됩니다.
원샷 추론 (One-shot inference): 프롬프트 내에 하나의 예제를 포함하여 모델이 작업을 이해하는 데 도움을 주는 경우.
퓨샷 추론 (Few-shot inference): 프롬프트 내에 여러 예제를 포함하여 모델에 원하는 동작을 더 잘 이해시키는 경우.
어느 수준을 선택할지는 모델의 크기와 능력에 따라 다릅니다. 그러나 컨텍스트 창에는 한계가 있으므로 여러 예제를 포함해도 잘 작동하지 않으면 모델을 세밀하게 튜닝하는 것을 고려해야 합니다. 세밀한 튜닝은 새로운 데이터를 사용하여 모델을 향상시키는 추가 훈련을 수행하는 것을 의미합니다.

일반적으로 대규모 모델은 제로샷 추론을 포함한 여러 작업에서 더 나은 성능을 발휘하며, 작은 모델은 보통 특정 작업에 더 적합합니다. 사용 사례에 맞는 모델 선택이 중요하며, 모델이 생성하는 완료의 구조와 스타일을 영향을 미치도록 구성 설정을 실험할 수 있습니다.

관련글 더보기