의견 보내기
Vertex AI에서 Gemini 1.5 API에서 Gemini 2.0 API로 이전
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
이 가이드에서는 Gemini 1.0 및 Gemini 1.5 모델 (Flash 및 Pro 모두)에서 Gemini 2.0 모델로 이전하는 방법을 보여줍니다.
Gemini 1.5와 Gemini 2.0의 차이점
Gemini 2.0과 1.0 및 1.5 모델의 몇 가지 차이점은 다음과 같습니다.
설정
Vertex AI SDK Vertex AI SDK를 재사용하는 경우 설정 프로세스는 1.5 및 2.0 모델에서 동일합니다. 자세한 내용은 Python용 Vertex AI SDK 소개 를 참고하세요.
다음은 Python용 Vertex AI SDK를 설치하는 짧은 코드 샘플입니다.
# pip install --upgrade --quiet google-cloud-aiplatform
import vertexai
vertexai . init ( project = "PROJECT_ID" , location = "LOCATION" )
PROJECT_ID
를 Google Cloud 프로젝트 ID로 바꾸고 LOCATION
를 Google Cloud 프로젝트의 위치 (예: us-central1
)로 바꿉니다.
생성형 AI SDK Gen AI SDK를 사용하는 경우 설정 프로세스는 1.0 모델과 1.5/2.0 모델 간에 다릅니다. 자세한 내용은 Google Gen AI SDK 를 참고하세요.
다음은 Python용 Gen AI SDK를 설치하는 짧은 코드 샘플입니다.
# pip install --upgrade --quiet google-genai
from google import genai
client = genai . Client ( vertexai = True , project = "PROJECT_ID" , location = "LOCATION" )
PROJECT_ID
를 Google Cloud 프로젝트 ID로 바꾸고 LOCATION
를 Google Cloud 프로젝트의 위치 (예: us-central1
)로 바꿉니다.
2.0으로 이전
다음 섹션에는 Vertex AI SDK 와 새로운 Gen AI SDK 에서 모두 Gemini 2.0으로 이전하는 방법에 관한 안내가 포함되어 있습니다.
Vertex AI SDK
다음 각 코드 샘플 쌍에는 Gemini 1.5 코드와 1.5 코드에서 마이그레이션된 Gemini 2.0 코드가 나란히 포함됩니다.
간단한 텍스트 생성
다음 코드 샘플은 텍스트 생성 모델을 만들기 위한 Gemini 1.5 API와 Gemini 2.0 API의 차이점을 보여줍니다.
Gemini 1.5
Gemini 2.0
from vertexai.generative_models import GenerativeModel
model = GenerativeModel ( "gemini-1.5-flash-002" )
response = model . generate_content ( "The opposite of hot is" )
print ( response . text )
from vertexai.generative_models import GenerativeModel
model = GenerativeModel ( "gemini-2.0-flash-001" )
response = model . generate_content ( "The opposite of hot is" )
print ( response . text )
매개변수를 사용하여 텍스트 생성
다음 코드 샘플은 선택적 매개변수 를 사용하여 텍스트 생성 모델을 만들기 위한 Gemini 1.5 API와 Gemini 2.0 API의 차이점을 보여줍니다.
Gemini 1.5
Gemini 2.0
from vertexai.generative_models import GenerativeModel
model = GenerativeModel ( "gemini-1.5-flash-002" )
prompt = """ You are an expert at solving word problems.Solve the following problem: I have three houses, each with three cats.each cat owns 4 mittens, and a hat. Each mitten was knit from 7m of yarn, each hat from 4m.How much yarn was needed to make all the items? Think about it step by step, and show your work."""
response = model . generate_content ( prompt , generation_config = { "temperature" : 0.1 , "top_p" : 1.0 , "top_k" : 40 , "max_output_tokens" : 800 ,} )
print ( response . text )
from vertexai.generative_models import GenerativeModel
model = GenerativeModel ( "gemini-2.0-flash-001" )
prompt = """ You are an expert at solving word problems.Solve the following problem: I have three houses, each with three cats.each cat owns 4 mittens, and a hat. Each mitten was knit from 7m of yarn, each hat from 4m.How much yarn was needed to make all the items? Think about it step by step, and show your work."""
response = model . generate_content ( prompt , generation_config = { "temperature" : 0.1 , "top_p" : 1.0 , "top_k" : 40 , "max_output_tokens" : 800 ,} )
print ( response . text )
생성형 AI SDK
다음 각 코드 샘플 쌍에는 Gemini 1.5 코드와 1.5 코드에서 마이그레이션된 Gemini 2.0 코드가 나란히 포함됩니다.
Gemini 1.5
Gemini 2.0
import vertexai
from vertexai.generative_models import GenerativeModel
vertexai . init ( project = "PROJECT_ID" ,
location = "LOCATION" )
model = GenerativeModel ( "gemini-1.5-flash-002" )
response = model . generate_content ( "The opposite of hot is" )
print ( response . text )
from google import genai
client = genai . Client ( vertexai = True ,
project = 'YOUR_CLOUD_PROJECT' ,
location = 'us-central1' ,
http_options = { 'api_version' : 'v1' })
response = client . models . generate_content (
model = 'gemini-2.0-flash-001' ,
contents = 'The opposite of hot is' )
print ( response . text )
의견 보내기
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스 에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스 에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책 을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-02-21(UTC)
의견을 전달하고 싶나요?
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-02-21(UTC)"],[],[]]