Gemma 모델을 실행하려면 두 가지 주요 결정을 내려야 합니다. 1) 실행할 Gemma 변형, 2) 실행에 사용할 AI 실행 프레임워크입니다. 이러한 두 가지 결정을 내릴 때의 주요 문제는 개발자와 사용자가 모델을 실행하는 데 사용할 수 있는 하드웨어와 관련이 있습니다.
이 개요에서는 이러한 결정사항을 살펴보고 Gemma 모델로 작업을 시작하는 데 도움이 됩니다. Gemma 모델을 실행하는 일반적인 단계는 다음과 같습니다.
Gemma 모델은 다양한 생성형 AI 실행 프레임워크와 호환됩니다. Gemma 모델을 실행할 때 중요한 결정 요소 중 하나는 모델을 실행하는 데 사용할 수 있는 (또는 사용할 예정인) 컴퓨팅 리소스입니다. 호환되는 대부분의 AI 프레임워크는 Gemma 모델을 효과적으로 실행하기 위해 GPU 또는 TPU와 같은 특수 하드웨어가 필요합니다. Google Colab과 같은 도구는 이러한 특수 컴퓨팅 리소스를 제한적으로 제공할 수 있습니다. Ollama 및 Gemma.cpp와 같은 일부 AI 실행 프레임워크를 사용하면 x86 호환 또는 ARM 아키텍처를 사용하여 더 일반적인 CPU에서 Gemma를 실행할 수 있습니다.
Keras 네이티브 형식, Safetensors, GGUF와 같이 의도한 배포 Gemma 모델 형식이 선택한 프레임워크에서 지원되는지 확인합니다.
Gemma 변형 선택
Gemma 모델은 기반 또는 핵심 Gemma 모델, PaliGemma 및 DataGemma와 같은 더 전문적인 모델 변형, Kaggle 및 Hugging Face와 같은 사이트에서 AI 개발자 커뮤니티가 만든 다양한 변형을 포함하여 여러 변형과 크기로 제공됩니다. 어떤 대안으로 시작해야 할지 확실하지 않은 경우 최신 Gemma 코어 명령어 조정 (IT) 모델 중 매개변수가 가장 적은 모델을 선택합니다. 이 유형의 Gemma 모델은 컴퓨팅 요구사항이 낮으며 추가 개발 없이 다양한 프롬프트에 응답할 수 있습니다.
Gemma 변형을 선택할 때 다음 요소를 고려하세요.
Gemma 핵심 및 PaliGemma, CodeGemma와 같은 기타 변형 제품군:
Gemma (핵심)를 권장합니다. 핵심 버전 이외의 Gemma 변형은 핵심 모델과 동일한 아키텍처를 가지며 특정 작업에서 더 나은 성능을 발휘하도록 학습됩니다. 애플리케이션이나 목표가 특정 Gemma 변형의 전문화에 부합하지 않는 한 Gemma 핵심 또는 기본 모델로 시작하는 것이 가장 좋습니다.
학습 조정 (IT), 사전 학습 (PT), 미세 조정 (FT), 혼합(mix): IT를 권장합니다.
조정된 명령 (IT) Gemma 변형은 인간 언어로 된 다양한 명령이나 요청에 응답하도록 학습된 모델입니다. 이러한 모델 변형은 추가 모델 학습 없이 프롬프트에 응답할 수 있으므로 시작하기 가장 좋은 곳입니다.
사전 학습 (PT) Gemma 변형은 언어 또는 기타 데이터에 관해 추론하도록 학습되었지만 인간의 안내를 따르도록 학습되지 않은 모델입니다. 이러한 모델은 태스크를 효과적으로 실행하기 위해 추가 학습이나 조정이 필요하며, 모델 및 아키텍처의 기능을 연구하거나 개발하려는 연구원이나 개발자를 대상으로 합니다.
미세 조정된 (FT) Gemma 변형은 IT 변형으로 간주될 수 있지만 일반적으로 특정 작업을 수행하거나 특정 생성형 AI 벤치마크에서 우수한 성능을 내도록 학습됩니다. PaliGemma 변형 계열에는 여러 FT 변형이 포함되어 있습니다.
혼합 (mix) Gemma 변형은 다양한 명령으로 명령 튜닝되었으며 일반적인 용도에 적합한 PaliGemma 모델의 버전입니다.
매개변수: 사용 가능한 가장 작은 숫자를 추천합니다. 일반적으로 모델의 파라미터가 많을수록 성능이 향상됩니다. 하지만 더 큰 모델을 실행하려면 더 크고 복잡한 컴퓨팅 리소스가 필요하며 일반적으로 AI 애플리케이션 개발 속도가 느려집니다. 이미 더 작은 Gemma 모델이 요구사항을 충족하지 못한다고 판단한 것이 아니라면 매개변수가 적은 모델을 선택하세요.
양자화 수준:조정 외에는 절반 정밀도 (16비트)를 권장합니다. 정량화는 데이터의 크기와 정밀도, 그리고 결과적으로 생성형 AI 모델이 계산 및 응답 생성에 사용하는 메모리 양으로 귀결되는 복잡한 주제입니다. 모델이 일반적으로 32비트 부동 소수점 데이터인 고정밀도 데이터로 학습된 후 Gemma와 같은 모델은 16비트, 8비트 또는 4비트 크기와 같은 낮은 정밀도 데이터를 사용하도록 수정할 수 있습니다. 이러한 양자화된 Gemma 모델은 태스크의 복잡도에 따라 컴퓨팅 및 메모리 리소스를 훨씬 적게 사용하면서도 우수한 성능을 발휘할 수 있습니다. 그러나 정규화된 모델을 조정하기 위한 도구는 제한적이며 선택한 AI 개발 프레임워크 내에서 사용할 수 없을 수도 있습니다. 일반적으로 Gemma와 같은 모델을 전체 정밀도로 미세 조정한 후 결과 모델을 정규화해야 합니다.
Google에서 게시한 주요 Gemma 모델 목록은 Gemma 모델 시작하기의 Gemma 모델 목록을 참고하세요.
생성 및 추론 요청 실행
AI 실행 프레임워크와 Gemma 변형을 선택한 후 모델 실행을 시작하고 콘텐츠를 생성하거나 작업을 완료하도록 프롬프트할 수 있습니다.
특정 프레임워크로 Gemma를 실행하는 방법에 관한 자세한 내용은 프레임워크 선택 섹션에 링크된 가이드를 참고하세요.
프롬프트 서식 지정
모든 명령 조정 Gemma 변형에는 특정 프롬프트 형식 지정 요구사항이 있습니다. 이러한 서식 지정 요구사항 중 일부는 Gemma 모델을 실행하는 데 사용하는 프레임워크에서 자동으로 처리되지만 프롬프트 데이터를 토큰라이저에 직접 전송하는 경우 특정 태그를 추가해야 하며 태그 지정 요구사항은 사용 중인 Gemma 변형에 따라 달라질 수 있습니다. Gemma 변형 프롬프트 형식 지정 및 시스템 안내에 관한 자세한 내용은 다음 가이드를 참고하세요.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-06-11(UTC)"],[],[],null,["# Run Gemma content generation and inferences\n\nThere are two key decisions to make when you want to run a Gemma model:\n1) what Gemma variant you want to run, and 2) what AI execution framework you\nare going to use to run it? A key issue in making both these decisions has to do\nwith what are hardware you and your users have available to run the model.\n\nThis overview helps you navigate these decisions and start working with Gemma\nmodels. The general steps for running a Gemma model are as follows:\n\n- [Choose a framework for running](#choose-a-framework)\n- [Select a Gemma variant](#select-a-variant)\n- [Run generation and inference requests](#run-generation)\n\nChoose a framework\n------------------\n\nGemma models are compatible with a variety of generative AI execution\nframeworks. One of the key decision making factors in running a Gemma model is\nwhat computing resources you have (or will have) available to you to run the\nmodel. Most compatible AI frameworks require specialized hardware, such as GPUs\nor TPUs, to run a Gemma model effectively. Tools such as\n[Google Colab](https://colab.research.google.com/) can provide these specialized\ncompute resources on a limited basis. Some AI execution frameworks, such as\n[Ollama](/gemma/docs/integrations/ollama) and\n[Gemma.cpp](/gemma/docs/gemma_cpp), allow you to run Gemma on more common CPUs\nusing x86-compatible or ARM architectures.\n\nHere are guides for running Gemma models with various AI runtime frameworks:\n\n- [Ollama](/gemma/docs/integrations/ollama)\n- [Hugging Face Transformers](https://huggingface.co/docs/transformers/en/model_doc/gemma2)\n- [Gemma library for JAX](https://gemma-llm.readthedocs.io)\n- [Keras](/gemma/docs/keras_inference)\n- [PyTorch](/gemma/docs/pytorch_gemma)\n- [MediaPipe LLM Inference API](/edge/mediapipe/solutions/genai/llm_inference)\n- [Hugging Face Transformers](https://huggingface.co/docs/transformers/en/model_doc/gemma2)\n- [Gemma.cpp](/gemma/docs/gemma_cpp)\n- [vLLM](https://github.com/google-gemini/gemma-cookbook/blob/main/Gemma/%5BGemma_2%5DDeploy_with_vLLM.ipynb)\n- Google Cloud [Vertex AI](https://cloud.google.com/vertex-ai/generative-ai/docs/open-models/use-gemma)\n- [Google Cloud Kubernetes Engine (GKE)](/gemma/docs/code/gke)\n- [Google Cloud Run](/gemma/docs/core/deploy_to_cloud_run_from_ai_studio)\n\n| **Note:** The JAX inference run guide has been replaced by the [Gemma library sampling](https://gemma-llm.readthedocs.io/en/latest/colab_sampling.html) guide.\n\nMake sure your intended deployment Gemma model format, such as Keras native\nformat, Safetensors, or GGUF, is supported by your chosen framework.\n\nSelect a Gemma variant\n----------------------\n\nGemma models are available in several variants and sizes, including the\nfoundation or [core](/gemma/docs/core) Gemma models, and more\nspecialized model variants such as\n[PaliGemma](/gemma/docs/paligemma) and\n[DataGemma](/gemma/docs/datagemma), and many variants\ncreated by the AI developer community on sites such as\n[Kaggle](https://www.kaggle.com/models?query=gemma) and\n[Hugging Face](https://huggingface.co/models?search=gemma). If you are unsure\nabout what variant you should start with, select the latest Gemma\n[core](/gemma/docs/core) instruction-tuned (IT) model with\nthe lowest number of parameters. This type of Gemma model has low compute\nrequirements and be able to respond to a wide variety of prompts without\nrequiring additional development.\n\nConsider the following factors when choosing a Gemma variant:\n\n- **Gemma core, and other variant families such as PaliGemma, CodeGemma** : *Recommend Gemma (core).* Gemma variants beyond the core version have the same architecture as the core model, and are trained to perform better at specific tasks. Unless your application or goals align with the specialization of a specific Gemma variant, it is best to start with a Gemma core, or base, model.\n- **Instruction-tuned (IT), pre-trained (PT), fine-tuned (FT), mixed\n (mix)** : *Recommend IT.*\n - *Instruction-tuned* (IT) Gemma variants are models that have been trained to respond to a variety of instructions or requests in human language. These model variants are the best place to start because they can respond to prompts without further model training.\n - *Pre-trained* (PT) Gemma variants are models that have been trained to make inferences about language or other data, but have not been trained to follow human instructions. These models require additional training or tuning to be able to perform tasks effectively, and are meant for researchers or developers who want to study or develop the capabilities of the model and its architecture.\n - *Fine-tuned* (FT) Gemma variants can be considered IT variants, but are typically trained to perform a specific task, or perform well on a specific generative AI benchmark. The PaliGemma variant family includes a number of FT variants.\n - *Mixed* (mix) Gemma variants are versions of PaliGemma models that have been instruction tuned with a variety of instructions and are suitable for general use.\n- **Parameters** : *Recommend smallest number available*. In general, the more parameters a model has, the more capable it is. However, running larger models requires larger and more complex compute resources, and generally slows down development of an AI application. Unless you have already determined that a smaller Gemma model cannot meet your needs, choose a one with a small number of parameters.\n- **Quantization levels:** *Recommend half precision (16-bit), except for\n tuning*. Quantization is a complex topic that boils down to what size and precision of data, and consequently how much memory a generative AI model uses for calculations and generating responses. After a model is trained with high-precision data, which is typically 32-bit floating point data, models like Gemma can be modified to use lower precision data such as 16, 8 or 4-bit sizes. These quantized Gemma models can still perform well, depending on the complexity of the tasks, while using significantly less compute and memory resources. However, tools for tuning quantized models are limited and may not be available within your chosen AI development framework. Typically, you must fine-tune a model like Gemma at full precision, then quantize the resulting model.\n\nFor a list of key, Google-published Gemma models, see the\n[Getting started with Gemma models](/gemma/docs/get_started#models-list),\nGemma model list.\n\nRun generation and inference requests\n-------------------------------------\n\nAfter you have selected an AI execution framework and a Gemma variant, you can\nstart running the model, and prompting it to generate content or complete tasks.\nFor more information on how to run Gemma with a specific framework, see the\nguides linked in the [Choose a framework](#choose-a-framework) section.\n\n### Prompt formatting\n\nAll instruction-tuned Gemma variants have specific prompt formatting\nrequirements. Some of these formatting requirements are handled automatically by\nthe framework you use to run Gemma models, but when you are sending prompt data\ndirectly to a tokenizer, you must add specific tags, and the tagging\nrequirements can change depending on the Gemma variant you are using. See the\nfollowing guides for information on Gemma variant prompt formatting and system\ninstructions:\n\n- [Gemma prompt and system instructions](/gemma/docs/core/prompt-structure)\n- [PaliGemma prompt and system instructions](/gemma/docs/paligemma/prompt-system-instructions)\n- [CodeGemma prompt and system instructions](/gemma/docs/codegemma/prompt-structure)"]]