fschwartzer commited on
Commit
78047da
·
verified ·
1 Parent(s): a5d29f3

Create src/brain.py

Browse files
Files changed (1) hide show
  1. src/brain.py +11 -0
src/brain.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoTokenizer, AutoModelForCausalLM
2
+
3
+ model_name = "google/gemma-2b"
4
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
5
+ model = AutoModelForCausalLM.from_pretrained(model_name)
6
+
7
+
8
+ def generate_answers(query):
9
+ input_ids = tokenizer(query, return_tensors="pt")
10
+ output = model.generate(**input_ids)
11
+ return tokenizer.decode(output[0])