2024 구글 클라우드 스터디 잼 후기

후추쌈·2024년 12월 29일
0
post-thumbnail

https://sites.google.com/view/2024-study-jams/ai-integration-class

Beginner : Introduction to Generative AI Learning Path를 수료했다. Google Cloud의 Vertex AI Platform을 활용하여 Prompt Design을 통해 AI(Gemini)의 출력을 원하는 형태로 조정하는 기술을 배웠다.

Vertex AI 플랫폼이란?

Google Cloud에서 제공하는 AI 플랫폼이다.
Vertex AI Studio는 이 플랫폼 내에서 생성형 AI 모델을 실험, 조정, 배포할 수 있는 개발 환경을 제공한다. 사용자는 모델에 원하는 프롬프트를 입력해 출력을 확인하고, 이를 코드 형태로 내보내 API나 애플리케이션으로 통합할 수 있다.

어떤 걸 했는지?

가장 기억에 남는 실습 중 하나는 Prompt Design을 활용하여 Vertex AI의 Gemini 모델을 조정하고, 제품 설명과 소개 문구를 생성하는 도구를 개발하는 것이다.

Step1. System Instructions에 배경과 요구사항을 입력한다.
Cymbal Direct is an outdoor gear retailer. They're launching a new line of products designed to encourage young people to explore the outdoors. Help them create catchy taglines for this product line.

Step2. 제품 속성, 타겟층, 정서적 공감 요소를 포함한 입력과 그에 대한 출력에 대한 예시 두 개를 추가한다.

Input: Write a tagline for a durable backpack designed for hikers that makes them feel prepared. Consider styles like minimalist.
Output: Built for the Journey: Your Adventure Essentials.
Input: Write a tagline for an eco-friendly rain jacket designed for families that makes them feel connected. Consider styles like playful, with a touch of humor.
Output: Explore More, Worry Less. Weather the fun together!

Step3. 예시 Input과 같은 형태로 입력 Test 칸에 요구사항을 넣어준다.
예를 들어, Write a tagline for {{product_attributes}} designed for {{target_audience}} that makes them feel {{emotional_resonance}}. Consider styles like {{style}}.의 형태로 넣어주면 된다.

Input: Write a tagline for a lightweight, waterproof jacket designed for young adventurers that makes them feel unstoppable. Consider styles like bold and inspiring. 을 넣으면
Defy the Elements: Embrace the Adventure Within.의 형태로 나오는 것을 알 수 있다.

이렇게 모델이 작업의 요구사항과 기대되는 결과를 더 쉽게 이해하도록 구조화된 맥락을 제공한다.
두 가지 예시(Input-Output 쌍)를 제공하는 Two-shot Prompting을 사용하였다.

또 output token 수, temperature 파라미터를 조정하여 원하는 길이로 창의적으로 출력할 수 있다. (높은 값(1.0)은 더 창의적이고 예측 불가능한 결과를, 낮은 값(0.2)은 더 정확하고 일관된 결과를 생성)

이렇게 작성한 프롬프트를 Python 코드로 내보내어 Jupyter Notebook에서 실행하여 같은 결과를 볼 수 있었다.

from vertexai.preview.generative_models import GenerativeModel

model = GenerativeModel("gemini-1.5-pro")

prompt = """
Cymbal Direct는 아웃도어 장비 소매업체와 제휴를 맺고 있습니다. 젊은 층의 아웃도어 활동을 장려하는 새로운 제품 라인을 출시할 예정입니다. 이 제품 라인에 맞는 인상적인 소개 문구를 만드는 데 도움이 필요합니다.

input: <your example input #1>
output: <your example output #1>

input: <your example input #2>
output: <your example output #2>

input: <your test input>
output:
"""

responses = model.generate_content(
    prompt,
    generation_config={
        "temperature": 1,
        "max_output_tokens": 2048,
        "top_p": 1.0,
        "top_k": 40,
    },
    stream=True
    )

for response in responses:
    print(response.text)

후기

구조화된 프롬프트를 사용하여 원하는 결과를 낸다는 것을 직접 다뤄보며 알 수 있어서 학습에서도 좋은 플랫폼같다.
앞으로 프롬프트 엔지니어링 가이드 웹을 기획하고 만들 예정인데, 이 플랫폼의 UX/UI를 참고하면 좋을 거 같다.
구조화된 프롬프트를 강조하기 위해 예시 추가 섹션을 분리하고, 파라미터를 변경할 수 있고, 마음에 드는 프롬프트를 저장할 수 있는 기능 등등

profile
LEE YENA

0개의 댓글