From 9327ac80df9a537bc9e14dc9ed2c0b36762e09cc Mon Sep 17 00:00:00 2001 From: Falko Habel Date: Tue, 11 Feb 2025 19:55:32 +0100 Subject: [PATCH] added usage example --- example.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 example.py diff --git a/example.py b/example.py new file mode 100644 index 0000000..ae3a35a --- /dev/null +++ b/example.py @@ -0,0 +1,15 @@ +from transformers import AutoModelForCausalLM, AutoTokenizer + + +location = "Godala-moe" + +device = "cuda" # cpu when not using gpu +tokenizer = AutoTokenizer.from_pretrained(location) + +model = AutoModelForCausalLM.from_pretrained(location).to(device) + +messages = [{"role": "user", "content": "What can you tell me about Godot?"}] +input_text=tokenizer.apply_chat_template(messages, tokenize=False) +inputs = tokenizer.encode(input_text, return_tensors="pt").to(device) +outputs = model.generate(inputs, max_new_tokens=510, temperature=0.2, top_p=0.9, do_sample=True) +print(tokenizer.decode(outputs[0]))