Spaces:
Runtime error
Runtime error
rukaiyaaaah
commited on
Commit
•
20a7c22
1
Parent(s):
3db7762
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
import os
|
2 |
-
import torch
|
3 |
from transformers import (
|
4 |
AutoModelForCausalLM,
|
5 |
AutoTokenizer,
|
@@ -14,7 +13,6 @@ bnb_config = BitsAndBytesConfig(
|
|
14 |
bnb_4bit_compute_dtype="float16",
|
15 |
bnb_4bit_use_double_quant=False,
|
16 |
)
|
17 |
-
device_map = {"": 0}
|
18 |
|
19 |
model_name = "rukaiyah-indika-ai/rv-chatbot-2"
|
20 |
|
@@ -22,17 +20,7 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
22 |
model_name,
|
23 |
quantization_config=bnb_config
|
24 |
)
|
25 |
-
|
26 |
-
from transformers import pipeline
|
27 |
-
inst = "You are a very helpful assistant providing solutions to road-related queries. Ensure you provide correct and relevant answers. If you don't know the answer to a question, please don't share false information. "
|
28 |
-
prompt = "Hello"
|
29 |
-
|
30 |
-
pipe = pipeline(task="text-generation", model=model, tokenizer=tokenizer, temperature=0.2, max_new_tokens=256)
|
31 |
-
ranked_results = pipe(f"<s>[INST] {inst}{prompt} [/INST]")
|
32 |
-
for result in ranked_results:
|
33 |
-
response = result['generated_text']
|
34 |
-
response = response.split("[/INST]", 1)[-1]
|
35 |
-
response = response.replace("<s>", "")
|
36 |
import gradio as gr
|
37 |
|
38 |
def generate_response(prompt):
|
@@ -52,7 +40,7 @@ iface = gr.Interface(
|
|
52 |
inputs="text",
|
53 |
outputs="text",
|
54 |
title="Road-GPT",
|
55 |
-
description="Enter your query related to road management and get a response generated by
|
56 |
)
|
57 |
|
58 |
iface.launch(share=True)
|
|
|
1 |
import os
|
|
|
2 |
from transformers import (
|
3 |
AutoModelForCausalLM,
|
4 |
AutoTokenizer,
|
|
|
13 |
bnb_4bit_compute_dtype="float16",
|
14 |
bnb_4bit_use_double_quant=False,
|
15 |
)
|
|
|
16 |
|
17 |
model_name = "rukaiyah-indika-ai/rv-chatbot-2"
|
18 |
|
|
|
20 |
model_name,
|
21 |
quantization_config=bnb_config
|
22 |
)
|
23 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
import gradio as gr
|
25 |
|
26 |
def generate_response(prompt):
|
|
|
40 |
inputs="text",
|
41 |
outputs="text",
|
42 |
title="Road-GPT",
|
43 |
+
description="Enter your query related to road management and get a response generated by our chatbot."
|
44 |
)
|
45 |
|
46 |
iface.launch(share=True)
|