From 741ee6caaf2b71ae86ef2462c077da96c436771a Mon Sep 17 00:00:00 2001 From: sunjnn Date: Fri, 14 Nov 2025 21:07:42 +0800 Subject: [PATCH] verify gemma 2b and add sample script --- docs/models/samples/gemma2_9b.py | 33 ++++++++++++++++++++++++++++++++ docs/models/supported_models.md | 1 + 2 files changed, 34 insertions(+) create mode 100644 docs/models/samples/gemma2_9b.py diff --git a/docs/models/samples/gemma2_9b.py b/docs/models/samples/gemma2_9b.py new file mode 100644 index 000000000..cf60fc7fc --- /dev/null +++ b/docs/models/samples/gemma2_9b.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +""" +This example demonstrates how to use gemma2-9b model with vLLM. +Requirements: +- vLLM: v0.11.0 or higher +- vLLM-metax: v0.11.0 or higher +- MACA SDK: 3.2.x.x or higher +""" + +from vllm import LLM, SamplingParams + +if __name__ == "__main__": + sampling_params = SamplingParams( + temperature=0.7, + top_p=0.9, + max_tokens=200 + ) + + llm = LLM(model="google/gemma-2-9b", trust_remote_code=True) + + prompts = [ + "Hello, my name is", + "The president of the United States is", + "The capital of France is", + "The future of AI is", + ] + + outputs = llm.generate(prompts, sampling_params) + + for output in outputs: + prompt = output.prompt + generated_text = output.outputs[0].text + print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}") diff --git a/docs/models/supported_models.md b/docs/models/supported_models.md index f2974db78..7994b07f1 100644 --- a/docs/models/supported_models.md +++ b/docs/models/supported_models.md @@ -28,6 +28,7 @@ Here the plugin would list all the **tested** model on Maca. | `Ernie4_5ForCausalLM` | Ernie4.5 | `baidu/ERNIE-4.5-0.3B-PT`, etc. | ✅︎ | ✅︎ | | `Ernie4_5_MoeForCausalLM` | Ernie4.5MoE | `baidu/ERNIE-4.5-21B-A3B-PT`, `baidu/ERNIE-4.5-300B-A47B-PT`, etc. |✅︎| ✅︎ | | `FalconForCausalLM` | Falcon | `tiiuae/falcon-7b`, `tiiuae/falcon-40b`, `tiiuae/falcon-rw-7b`, etc. | | ✅︎ | +| `Gemma2ForCausalLM` | Gemma 2 | `google/gemma-2-9b` | ✅︎ | ✅︎ | | `GlmForCausalLM` | GLM-4 | `zai-org/glm-4-9b-chat-hf`, etc. | ✅︎ | ✅︎ | | `Glm4ForCausalLM` | GLM-4-0414 | `zai-org/GLM-4-32B-0414`, etc. | ✅︎ | ✅︎ | | `Glm4MoeForCausalLM` | GLM-4.5, GLM-4.6 | `zai-org/GLM-4.5`, etc. | ✅︎ | ✅︎ |