File size: 626 Bytes
2720910
 
8624101
c415262
383ac0c
 
c415262
 
 
2720910
 
 
c415262
2720910
c415262
 
2720910
 
c8701ba
 
 
2720910
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("Salesforce/xgen-7b-8k-base", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("Salesforce/xgen-7b-8k-base", torch_dtype=torch.bfloat16)



def gentext(user_input="The world is"):
    inputs = tokenizer(user_input, return_tensors="pt")
    sample = model.generate(**inputs, max_length=128)
    
    return {"output": tokenizer.decode(sample[0])}


gr.Interface(
    gentext,
    inputs="text", 
    outputs="text",
    title="Testing out salesforce XGen 7B",
).launch()