TRaw commited on
Commit
79a9cf0
β€’
1 Parent(s): 5b14f90

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import json
3
+ import requests
4
+ from transformers import pipeline
5
+ from transformers import AutoTokenizer, AutoModelForCausalLM
6
+
7
+ model_name = 'Pyg'
8
+ tokenizer = AutoTokenizer.from_pretrained("TheBloke/Pygmalion-7B-SuperHOT-8K-GPTQ")
9
+ model = AutoModelForCausalLM.from_pretrained("TheBloke/Pygmalion-7B-SuperHOT-8K-GPTQ")
10
+
11
+ pipe = pipeline("text-generation", model="TheBloke/Pygmalion-7B-SuperHOT-8K-GPTQ")
12
+
13
+ def generate_text(input_text):
14
+ input_ids = tokenizer.encode(input_text, return_tensors='pt')
15
+ outputs = model.generate(input_ids, max_length=150, num_return_sequences=1, pad_token_id=tokenizer.eos_token_id)
16
+ text = tokenizer.decode(outputs[0], skip_special_tokens=True)
17
+ return text
18
+
19
+ iface = gr.Interface(fn=generate_text,
20
+ inputs=gr.inputs.Textbox(lines=5, placeholder='Enter text here...'),
21
+ outputs=gr.outputs.Textbox())
22
+
23
+ iface.launch()