Spaces:
Sleeping
Sleeping
fschwartzer
commited on
Create src/brain.py
Browse files- 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])
|