Spaces:
Runtime error
Runtime error
Download app.py from datakafe/databricks-dolly-textgen: direct link, hf CLI and curl.
- Browser
- Download file 769 Bytes
-
https://huggingface.co/spaces/datakafe/databricks-dolly-textgen/resolve/main/app.py
- Command line
-
hf download hf://spaces/datakafe/databricks-dolly-textgen/app.py
-
curl -L -o app.py https://huggingface.co/spaces/datakafe/databricks-dolly-textgen/resolve/main/app.py
769 Bytes
| import torch | |
| import gradio as gr | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| from instruct_pipeline import InstructionTextGenerationPipeline | |
| tokenizer = AutoTokenizer.from_pretrained("databricks/dolly-v2-3b", | |
| padding_side="left") | |
| model = AutoModelForCausalLM.from_pretrained("databricks/dolly-v2-3b", | |
| torch_dtype=torch.bfloat16) | |
| generate_text = InstructionTextGenerationPipeline(model=model, | |
| tokenizer=tokenizer) | |
| def textGen(text): | |
| return generate_text(text) | |
| demo = gr.Interface(fn=textGen, inputs="text", outputs="text") | |
| demo.launch() |