File size: 1,058 Bytes
0fdef8a
2811aa2
62bb757
0fdef8a
62bb757
eb33590
62bb757
 
0fdef8a
62bb757
 
 
 
 
 
0fdef8a
62bb757
 
 
 
 
0fdef8a
62bb757
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import gradio as gr
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

# Load your teacher model
model_name = "microsoft/Orca-2-7b" #"0x0mom/nous_gemma_r1"# "cognitivecomputations/dolphin-2_6-phi-2" #  "Dizzykong/gpt2-medium-commands"#
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)

def generate_response(prompt):
    inputs = tokenizer(prompt, return_tensors="pt")
    with torch.no_grad():
        outputs = model.generate(**inputs, max_length=100)
    response = tokenizer.decode(outputs[0], skip_special_tokens=True)
    return response

interface = gr.Interface(fn=generate_response,
                          inputs=gr.inputs.Textbox(lines=2, placeholder="Enter your prompt here..."),
                          outputs="text",
                          title="Text Generation with Dolphin-2_6-Phi-2",
                          description="This model generates responses based on the input prompt. Try it out!")

if __name__ == "__main__":
    interface.launch()