artek0chumak commited on
Commit
0669a02
1 Parent(s): fe15d34

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ sys.path.insert(0, './petals/')
3
+
4
+ import torch
5
+ import transformers
6
+ import gradio as gr
7
+
8
+ # from src.client.remote_model import DistributedBloomForCausalLM
9
+
10
+
11
+ # MODEL_NAME = "bigscience/test-bloomd-6b3" # select model you like
12
+ # INITIAL_PEERS = ["/ip4/193.106.95.184/tcp/31000/p2p/QmSg7izCDtowVTACbUmWvEiQZNY4wgCQ9T9Doo66K59X6q"]
13
+
14
+ # tokenizer = transformers.BloomTokenizerFast.from_pretrained("bigscience/test-bloomd-6b3")
15
+ # model = DistributedBloomForCausalLM.from_pretrained("bigscience/test-bloomd-6b3", initial_peers=INITIAL_PEERS, low_cpu_mem_usage=True, torch_dtype=torch.float32)
16
+
17
+ def inference(text, seq_length=1):
18
+ return text
19
+ # input_ids = tokenizer([text], return_tensors="pt").input_ids
20
+ # output = model.generate(input_ids, max_new_tokens=seq_length)
21
+ # return tokenizer.batch_decode(output)[0]
22
+
23
+ iface = gr.Interface(
24
+ fn=inference,
25
+ inputs=[
26
+ gr.Textbox(lines=10, label="Input text"),
27
+ gr.inputs.Slider(
28
+ minimum=0,
29
+ maximum=1000,
30
+ step=1,
31
+ default=42,
32
+ label="Sequence length for generation"
33
+ )
34
+ ],
35
+ outputs="text"
36
+ )
37
+ iface.launch()