Spaces:
Runtime error
Runtime error
Yash Sachdeva
commited on
Commit
·
cc2684c
1
Parent(s):
1ce79d1
flan
Browse files- Dockerfile +4 -4
- question_paper.py +5 -7
Dockerfile
CHANGED
@@ -4,7 +4,7 @@ FROM python:3.10.9
|
|
4 |
WORKDIR /
|
5 |
|
6 |
# Copy the current directory contents into the container at .
|
7 |
-
COPY . .
|
8 |
|
9 |
RUN pip install transformers
|
10 |
|
@@ -17,8 +17,8 @@ RUN pip install torch
|
|
17 |
RUN pip install accelerate
|
18 |
|
19 |
# Install hugging face hub to download llama2 model
|
20 |
-
RUN pip install --upgrade huggingface_hub
|
21 |
-
RUN CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install 'llama-cpp-python[server]' --upgrade --force-reinstall --no-cache-dir
|
22 |
# Install requirements.txt
|
23 |
RUN pip install --no-cache-dir --upgrade -r /requirements.txt
|
24 |
|
@@ -32,7 +32,7 @@ ENV HOME=/home/user \
|
|
32 |
|
33 |
WORKDIR $HOME/app
|
34 |
|
35 |
-
RUN huggingface-cli download TheBloke/Llama-2-7b-Chat-GGUF llama-2-7b-chat.Q2_K.gguf --local-dir . --local-dir-use-symlinks False
|
36 |
|
37 |
|
38 |
COPY --chown=user . $HOME/app
|
|
|
4 |
WORKDIR /
|
5 |
|
6 |
# Copy the current directory contents into the container at .
|
7 |
+
COPY ./requirements.txt /requirements.txt
|
8 |
|
9 |
RUN pip install transformers
|
10 |
|
|
|
17 |
RUN pip install accelerate
|
18 |
|
19 |
# Install hugging face hub to download llama2 model
|
20 |
+
#RUN pip install --upgrade huggingface_hub
|
21 |
+
#RUN CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install 'llama-cpp-python[server]' --upgrade --force-reinstall --no-cache-dir
|
22 |
# Install requirements.txt
|
23 |
RUN pip install --no-cache-dir --upgrade -r /requirements.txt
|
24 |
|
|
|
32 |
|
33 |
WORKDIR $HOME/app
|
34 |
|
35 |
+
#RUN huggingface-cli download TheBloke/Llama-2-7b-Chat-GGUF llama-2-7b-chat.Q2_K.gguf --local-dir . --local-dir-use-symlinks False
|
36 |
|
37 |
|
38 |
COPY --chown=user . $HOME/app
|
question_paper.py
CHANGED
@@ -1,10 +1,6 @@
|
|
1 |
-
from
|
2 |
-
from fastapi.encoders import jsonable_encoder
|
3 |
-
from fastapi.responses import JSONResponse
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
from fastapi.middleware.cors import CORSMiddleware
|
8 |
|
9 |
app = FastAPI()
|
10 |
|
@@ -30,7 +26,9 @@ def llama():
|
|
30 |
|
31 |
# tresponse = TOKENIZER.decode(tokens[0], skip_special_tokens=False)
|
32 |
# print(tresponse)
|
33 |
-
|
|
|
|
|
34 |
json_response = jsonable_encoder(response_message)
|
35 |
return JSONResponse(content=json_response)
|
36 |
|
|
|
1 |
+
from transformers import pipeline
|
|
|
|
|
2 |
|
3 |
+
pipe_flan = pipeline("text2text-generation", model="google/flan-t5-small")
|
|
|
|
|
4 |
|
5 |
app = FastAPI()
|
6 |
|
|
|
26 |
|
27 |
# tresponse = TOKENIZER.decode(tokens[0], skip_special_tokens=False)
|
28 |
# print(tresponse)
|
29 |
+
input = "Generate 5 jokes"
|
30 |
+
output = pipe_flan(input)
|
31 |
+
response_message = {"message": output[0]["generated_text"]}
|
32 |
json_response = jsonable_encoder(response_message)
|
33 |
return JSONResponse(content=json_response)
|
34 |
|