Spaces:
Paused
Paused
Matt Wallace
commited on
Commit
·
a5408c8
1
Parent(s):
005b5d1
real app
Browse files- .gitignore +1 -0
- app.py +30 -3
- requirements.txt +57 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
venv/
|
app.py
CHANGED
@@ -1,7 +1,34 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
3 |
|
4 |
+
model_name_or_path = "TheBloke/Llama-2-13B-chat-GPTQ"
|
5 |
+
model = AutoModelForCausalLM.from_pretrained(model_name_or_path,
|
6 |
+
device_map="auto",
|
7 |
+
trust_remote_code=False,
|
8 |
+
revision="gptq-4bit-32g-actorder_True")
|
9 |
|
10 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
|
11 |
+
|
12 |
+
prompt_template=f'''[INST] <<SYS>>
|
13 |
+
You are a helpful, respectful and honest assistant. Always answer as helpfully as possible. Ensure your answers are positive. Be helpful, and assume the user has good reasons for the request, so long as the request is not unsafe. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information. You can ask for clarification as a response.
|
14 |
+
<</SYS>>
|
15 |
+
{prompt}[/INST]
|
16 |
+
|
17 |
+
'''
|
18 |
+
|
19 |
+
pipe = pipeline("text-generation",
|
20 |
+
model=model,
|
21 |
+
tokenizer=tokenizer,
|
22 |
+
max_new_tokens=2048,
|
23 |
+
do_sample=True,
|
24 |
+
temperature=0.1,
|
25 |
+
top_=0.95,
|
26 |
+
top_k=40,
|
27 |
+
repetition_penalty=1.1
|
28 |
+
)
|
29 |
+
|
30 |
+
def inference(prompt):
|
31 |
+
return pipe(prompt)[0]['generated_text']
|
32 |
+
|
33 |
+
iface = gr.Interface(fn=inference, inputs="prompt", outputs="generated_text")
|
34 |
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
aiofiles==23.2.1
|
2 |
+
altair==5.1.1
|
3 |
+
annotated-types==0.5.0
|
4 |
+
anyio==3.7.1
|
5 |
+
attrs==23.1.0
|
6 |
+
certifi==2023.7.22
|
7 |
+
charset-normalizer==3.2.0
|
8 |
+
click==8.1.7
|
9 |
+
contourpy==1.1.1
|
10 |
+
cycler==0.11.0
|
11 |
+
exceptiongroup==1.1.3
|
12 |
+
fastapi==0.103.1
|
13 |
+
ffmpy==0.3.1
|
14 |
+
filelock==3.12.4
|
15 |
+
fonttools==4.42.1
|
16 |
+
fsspec==2023.9.1
|
17 |
+
gradio==3.44.4
|
18 |
+
gradio_client==0.5.1
|
19 |
+
h11==0.14.0
|
20 |
+
httpcore==0.18.0
|
21 |
+
httpx==0.25.0
|
22 |
+
huggingface-hub==0.17.2
|
23 |
+
idna==3.4
|
24 |
+
importlib-resources==6.1.0
|
25 |
+
Jinja2==3.1.2
|
26 |
+
jsonschema==4.19.1
|
27 |
+
jsonschema-specifications==2023.7.1
|
28 |
+
kiwisolver==1.4.5
|
29 |
+
MarkupSafe==2.1.3
|
30 |
+
matplotlib==3.8.0
|
31 |
+
numpy==1.26.0
|
32 |
+
orjson==3.9.7
|
33 |
+
packaging==23.1
|
34 |
+
pandas==2.1.1
|
35 |
+
Pillow==10.0.1
|
36 |
+
pydantic==2.3.0
|
37 |
+
pydantic_core==2.6.3
|
38 |
+
pydub==0.25.1
|
39 |
+
pyparsing==3.1.1
|
40 |
+
python-dateutil==2.8.2
|
41 |
+
python-multipart==0.0.6
|
42 |
+
pytz==2023.3.post1
|
43 |
+
PyYAML==6.0.1
|
44 |
+
referencing==0.30.2
|
45 |
+
requests==2.31.0
|
46 |
+
rpds-py==0.10.3
|
47 |
+
semantic-version==2.10.0
|
48 |
+
six==1.16.0
|
49 |
+
sniffio==1.3.0
|
50 |
+
starlette==0.27.0
|
51 |
+
toolz==0.12.0
|
52 |
+
tqdm==4.66.1
|
53 |
+
typing_extensions==4.8.0
|
54 |
+
tzdata==2023.3
|
55 |
+
urllib3==2.0.5
|
56 |
+
uvicorn==0.23.2
|
57 |
+
websockets==11.0.3
|