Spaces:
Sleeping
Sleeping
Chetan Khadke
commited on
Commit
·
c1de68d
1
Parent(s):
17729ae
Add application files
Browse files
app.py
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
def greet(name):
|
| 4 |
-
return
|
|
|
|
| 5 |
|
| 6 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
-
iface.launch()
|
|
|
|
| 1 |
+
!pip install accelerate>=0.12.0 transformers[torch]==4.25.1
|
| 2 |
+
!pip install bitsandbytes
|
| 3 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 4 |
+
from instruct_pipeline import InstructionTextGenerationPipeline
|
| 5 |
+
tokenizer = AutoTokenizer.from_pretrained("databricks/dolly-v2-7b", padding_side="left")
|
| 6 |
+
model = AutoModelForCausalLM.from_pretrained("databricks/dolly-v2-7b", device_map="auto", offload_folder="/content/temp",
|
| 7 |
+
load_in_8bit=True)
|
| 8 |
+
|
| 9 |
+
generate_text = InstructionTextGenerationPipeline(model=model, tokenizer=tokenizer)
|
| 10 |
+
|
| 11 |
import gradio as gr
|
| 12 |
|
| 13 |
def greet(name):
|
| 14 |
+
return generate_text(name)
|
| 15 |
+
|
| 16 |
|
| 17 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 18 |
+
iface.launch(share=True)
|