File size: 408 Bytes
78047da
 
2a28303
745a539
 
78047da
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
from transformers import AutoTokenizer, AutoModelForCausalLM

model_name = "google/gemma-2b"
tokenizer = AutoTokenizer.from_pretrained(model_name, token=access_token)
model = AutoModelForCausalLM.from_pretrained(model_name, token=access_token)


def generate_answers(query):
    input_ids = tokenizer(query, return_tensors="pt")
    output = model.generate(**input_ids)
    return tokenizer.decode(output[0])