Saurabh Parmar
commited on
Commit
•
2c24fb6
1
Parent(s):
d14b921
added new changes
Browse files- app.py +8 -28
- requirements.txt +1 -2
app.py
CHANGED
@@ -1,29 +1,9 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
# Generate text based on the prompt
|
12 |
-
output = model.generate(inputs, max_length=100, num_return_sequences=1)
|
13 |
-
|
14 |
-
# Decode the generated output
|
15 |
-
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
16 |
-
|
17 |
-
return generated_text
|
18 |
-
|
19 |
-
# Define the Gradio interface
|
20 |
-
iface = gr.Interface(
|
21 |
-
fn=generate_text,
|
22 |
-
inputs="text",
|
23 |
-
outputs="text",
|
24 |
-
title="Transformer Text Generation",
|
25 |
-
description="Enter a prompt and the model will generate text based on it.",
|
26 |
-
)
|
27 |
-
|
28 |
-
# Launch the Gradio interface
|
29 |
-
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import torch
|
3 |
+
from transformers import pipeline
|
4 |
+
ans = pipeline(model="databricks/dolly-v2-3b", torch_dtype=torch.bfloat16, trust_remote_code=True, device_map="auto")
|
5 |
+
def answer(query):
|
6 |
+
out=ans(query)
|
7 |
+
return out
|
8 |
+
Demo = gr.Interface(fn=answer,inputs='text',outputs='text',examples=[['What is the capital of India ?']])
|
9 |
+
Demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
transformers
|
2 |
torch
|
3 |
-
|
4 |
-
torchaudio
|
|
|
1 |
transformers
|
2 |
torch
|
3 |
+
accelerate
|
|