Spaces:
Running
on
Zero
Running
on
Zero
Nihal Nayak
commited on
Commit
•
7ebf5ca
1
Parent(s):
0d6980b
wip: respond
Browse files- app.py +10 -4
- requirements.txt +3 -1
app.py
CHANGED
@@ -1,13 +1,17 @@
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
-
|
4 |
# import spaces
|
5 |
|
6 |
"""
|
7 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
8 |
"""
|
9 |
-
client = InferenceClient("BatsResearch/bonito-v1")
|
|
|
|
|
10 |
|
|
|
|
|
11 |
|
12 |
def respond(
|
13 |
context: str,
|
@@ -22,8 +26,10 @@ def respond(
|
|
22 |
"\n<|context|>\n" + context.strip() + "\n<|task|>\n"
|
23 |
)
|
24 |
|
25 |
-
|
26 |
-
|
|
|
|
|
27 |
|
28 |
# messages = [{"role": "system", "content": system_message}]
|
29 |
|
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
4 |
# import spaces
|
5 |
|
6 |
"""
|
7 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
8 |
"""
|
9 |
+
# client = InferenceClient("BatsResearch/bonito-v1")
|
10 |
+
model = AutoModelForCausalLM.from_pretrained("BatsResearch/bonito-v1")
|
11 |
+
tokenizer = AutoTokenizer.from_pretrained("BatsResearch/bonito-v1")
|
12 |
|
13 |
+
# move to cuda
|
14 |
+
model.to("cuda")
|
15 |
|
16 |
def respond(
|
17 |
context: str,
|
|
|
26 |
"\n<|context|>\n" + context.strip() + "\n<|task|>\n"
|
27 |
)
|
28 |
|
29 |
+
|
30 |
+
|
31 |
+
# for token in client.text_generation(input_text, max_tokens=max_tokens, temperature=temperature, top_p=top_p, stream=True):
|
32 |
+
# yield token
|
33 |
|
34 |
# messages = [{"role": "system", "content": system_message}]
|
35 |
|
requirements.txt
CHANGED
@@ -1 +1,3 @@
|
|
1 |
-
huggingface_hub==0.22.2
|
|
|
|
|
|
1 |
+
huggingface_hub==0.22.2
|
2 |
+
transformers
|
3 |
+
accelerate
|