tsuin-complete / app.py
debisoft's picture
login outside
2ad699d
raw
history blame
865 Bytes
import gradio as gr
import huggingface_hub
import os
import spaces
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
huggingface_hub.login(os.getenv('HUGGINGFACE_TOKEN'))
@spaces.GPU
def sentience_check():
device = torch.device("cuda")
tokenizer = AutoTokenizer.from_pretrained("debisoft/gemma-2-2B-it-thinking-function_calling-V0")
model = AutoModelForCausalLM.from_pretrained("debisoft/gemma-2-2B-it-thinking-function_calling-V0").to(device)
inputs = tokenizer("Are you sentient?", return_tensors="pt").to(device)
with torch.no_grad():
outputs = model.generate(
**inputs, max_new_tokens=128, pad_token_id = tokenizer.eos_token_id
)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
demo = gr.Interface(fn=sentience_check, inputs=None, outputs=gr.Text())
demo.launch()