kingabzpro commited on
Commit
0977766
·
1 Parent(s): 1bd52ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -16
app.py CHANGED
@@ -1,20 +1,25 @@
1
- import gradio as gr
 
 
2
 
3
- title = "Falcon-7B"
4
 
5
- examples = [
6
- ["The tower is 324 metres (1,063 ft) tall,"],
7
- ["The Moon's orbit around Earth has"],
8
- ["The smooth Borealis basin in the Northern Hemisphere covers 40%"],
9
- ]
10
-
11
- demo = gr.load(
12
- "tiiuae/falcon-rw-1b",
13
- inputs=gr.Textbox(lines=5, max_lines=6, label="Input Text"),
14
- title=title,
15
- examples=examples,
16
- src='models'
 
 
 
 
17
  )
18
 
19
- if __name__ == "__main__":
20
- demo.launch()
 
1
+ from transformers import AutoTokenizer, AutoModelForCausalLM
2
+ import transformers
3
+ import torch
4
 
5
+ model = "tiiuae/falcon-rw-1b"
6
 
7
+ tokenizer = AutoTokenizer.from_pretrained(model)
8
+ pipeline = transformers.pipeline(
9
+ "text-generation",
10
+ model=model,
11
+ tokenizer=tokenizer,
12
+ torch_dtype=torch.bfloat16,
13
+ trust_remote_code=True,
14
+ device_map="auto",
15
+ )
16
+ sequences = pipeline(
17
+ "Girafatron is obsessed with giraffes, the most glorious animal on the face of this Earth. Giraftron believes all other animals are irrelevant when compared to the glorious majesty of the giraffe.\nDaniel: Hello, Girafatron!\nGirafatron:",
18
+ max_length=200,
19
+ do_sample=True,
20
+ top_k=10,
21
+ num_return_sequences=1,
22
+ eos_token_id=tokenizer.eos_token_id,
23
  )
24
 
25
+ gr.Interface.from_pipeline(sequences).launch()