Spaces:
Runtime error
Runtime error
Commit
Β·
b8ba1e0
1
Parent(s):
0f80c72
Update app.py
Browse files
app.py
CHANGED
@@ -1,34 +1,47 @@
|
|
1 |
from transformers import pipeline, Conversation
|
2 |
import gradio as gr
|
3 |
|
|
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
#θΏδΈͺ樑εζ仢倧ε°οΌ730MBζ1.46GB
|
9 |
|
10 |
-
|
11 |
-
#
|
12 |
-
#
|
13 |
-
#pipe = pipeline("conversational", model="facebook/blenderbot-400M-distill")
|
14 |
|
15 |
-
|
16 |
-
#https://huggingface.co/HuggingFaceH4/starchat-beta/tree/main
|
17 |
-
#η±δΊθΏδΈͺ樑εε€ͺ倧δΊοΌ9.96+9.86+9.86+1.36GBοΌοΌδΌε―Όθ΄ε¦δΈιθ――οΌ
|
18 |
-
#Runtime error
|
19 |
-
#Memory limit exceeded (16Gi)
|
20 |
|
21 |
-
|
22 |
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
conversation = chatbot(conversation)
|
29 |
|
30 |
-
|
31 |
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from transformers import pipeline, Conversation
|
2 |
import gradio as gr
|
3 |
|
4 |
+
#https://huggingface.co/TheBloke/starchat-beta-GPTQ
|
5 |
|
6 |
+
from transformers import AutoTokenizer, pipeline, logging
|
7 |
+
from auto_gptq import AutoGPTQForCausalLM, BaseQuantizeConfig
|
8 |
+
import argparse
|
|
|
9 |
|
10 |
+
model_name_or_path = "TheBloke/starchat-beta-GPTQ"
|
11 |
+
# Or to load it locally, pass the local download path
|
12 |
+
# model_name_or_path = "/path/to/models/The_Bloke_starchat-beta-GPTQ"
|
|
|
13 |
|
14 |
+
use_triton = False
|
|
|
|
|
|
|
|
|
15 |
|
16 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
|
17 |
|
18 |
+
model = AutoGPTQForCausalLM.from_quantized(model_name_or_path,
|
19 |
+
use_safetensors=True,
|
20 |
+
#device="cuda:0",
|
21 |
+
use_triton=use_triton,
|
22 |
+
quantize_config=None)
|
23 |
|
24 |
+
# Prevent printing spurious transformers error when using pipeline with AutoGPTQ
|
25 |
+
logging.set_verbosity(logging.CRITICAL)
|
|
|
26 |
|
27 |
+
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
28 |
|
29 |
+
prompt_template = "<|system|>\n<|end|>\n<|user|>\n{query}<|end|>\n<|assistant|>"
|
30 |
+
prompt = prompt_template.format(query="How do I sort a list in Python?")
|
31 |
+
# We use a special <|end|> token with ID 49155 to denote ends of a turn
|
32 |
+
outputs = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.2, top_k=50, top_p=0.95, eos_token_id=49155)
|
33 |
+
# You can sort a list in Python by using the sort() method. Here's an example:\n\n```\nnumbers = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]\nnumbers.sort()\nprint(numbers)\n```\n\nThis will sort the list in place and print the sorted list.
|
34 |
+
print(outputs[0]['generated_text'])
|
35 |
|
36 |
+
#message_list = []
|
37 |
+
#response_list = []
|
38 |
+
|
39 |
+
#def vanilla_chatbot(message, history):
|
40 |
+
# conversation = Conversation(text=message, past_user_inputs=message_list, generated_responses=response_list)
|
41 |
+
# conversation = chatbot(conversation)
|
42 |
+
|
43 |
+
# return conversation.generated_responses[-1]
|
44 |
+
|
45 |
+
#demo_chatbot = gr.ChatInterface(vanilla_chatbot, title="Vanilla Chatbot", description="Enter text to start chatting.")
|
46 |
+
|
47 |
+
#demo_chatbot.launch()
|