Spaces:
Runtime error
Runtime error
shekharp77
commited on
Commit
•
7efc171
1
Parent(s):
fb4c123
first commit
Browse files- .gitignore +1 -0
- Dockerfile +16 -0
- main.py +24 -0
- requrement.txt +56 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.idea/
|
Dockerfile
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
2 |
+
# you will also find guides on how best to write your Dockerfile
|
3 |
+
|
4 |
+
FROM python:3.9
|
5 |
+
|
6 |
+
WORKDIR /code
|
7 |
+
|
8 |
+
COPY ./requirements.txt /code/requirements.txt
|
9 |
+
|
10 |
+
# COPY /Users/shekharsingh/code/nsph/models/llemma_7b /code/llemma_7b
|
11 |
+
|
12 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
13 |
+
|
14 |
+
COPY . .
|
15 |
+
|
16 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
main.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoTokenizer, LlamaForCausalLM
|
2 |
+
from fastapi import FastAPI
|
3 |
+
from pydantic import BaseModel
|
4 |
+
|
5 |
+
model_path = '"EleutherAI/llemma_7b"'
|
6 |
+
|
7 |
+
model = LlamaForCausalLM.from_pretrained(model_path)
|
8 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
9 |
+
|
10 |
+
class validation(BaseModel):
|
11 |
+
prompt: str
|
12 |
+
|
13 |
+
|
14 |
+
app = FastAPI()
|
15 |
+
|
16 |
+
|
17 |
+
@app.post("/prompt")
|
18 |
+
async def stream(item: validation):
|
19 |
+
inputs = tokenizer(item.prompt, return_tensors="pt")
|
20 |
+
|
21 |
+
generate_ids = model.generate(inputs.input_ids, max_length=30)
|
22 |
+
|
23 |
+
var = tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
24 |
+
return var
|
requrement.txt
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
annotated-types==0.6.0
|
2 |
+
anyio==4.3.0
|
3 |
+
certifi==2024.2.2
|
4 |
+
charset-normalizer==3.3.2
|
5 |
+
click==8.1.7
|
6 |
+
dnspython==2.6.1
|
7 |
+
email_validator==2.1.1
|
8 |
+
exceptiongroup==1.2.1
|
9 |
+
fastapi==0.111.0
|
10 |
+
fastapi-cli==0.0.2
|
11 |
+
filelock==3.14.0
|
12 |
+
fsspec==2024.3.1
|
13 |
+
h11==0.14.0
|
14 |
+
httpcore==1.0.5
|
15 |
+
httptools==0.6.1
|
16 |
+
httpx==0.27.0
|
17 |
+
huggingface-hub==0.23.0
|
18 |
+
idna==3.7
|
19 |
+
Jinja2==3.1.4
|
20 |
+
markdown-it-py==3.0.0
|
21 |
+
MarkupSafe==2.1.5
|
22 |
+
mdurl==0.1.2
|
23 |
+
mpmath==1.3.0
|
24 |
+
networkx==3.2.1
|
25 |
+
numpy==1.26.4
|
26 |
+
orjson==3.10.3
|
27 |
+
packaging==24.0
|
28 |
+
pillow==10.3.0
|
29 |
+
pydantic==2.7.1
|
30 |
+
pydantic_core==2.18.2
|
31 |
+
Pygments==2.18.0
|
32 |
+
python-dotenv==1.0.1
|
33 |
+
python-multipart==0.0.9
|
34 |
+
PyYAML==6.0.1
|
35 |
+
regex==2024.4.28
|
36 |
+
requests==2.31.0
|
37 |
+
rich==13.7.1
|
38 |
+
safetensors==0.4.3
|
39 |
+
shellingham==1.5.4
|
40 |
+
sniffio==1.3.1
|
41 |
+
starlette==0.37.2
|
42 |
+
sympy==1.12
|
43 |
+
tokenizers==0.19.1
|
44 |
+
torch==2.3.0
|
45 |
+
torchaudio==2.3.0
|
46 |
+
torchvision==0.18.0
|
47 |
+
tqdm==4.66.4
|
48 |
+
transformers==4.40.2
|
49 |
+
typer==0.12.3
|
50 |
+
typing_extensions==4.11.0
|
51 |
+
ujson==5.9.0
|
52 |
+
urllib3==2.2.1
|
53 |
+
uvicorn==0.29.0
|
54 |
+
uvloop==0.19.0
|
55 |
+
watchfiles==0.21.0
|
56 |
+
websockets==12.0
|