hArshi07 commited on
Commit
860b2ee
1 Parent(s): 3b6acf0

Upload 4 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ codellama-7b-instruct.Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
Dockerfile ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10
2
+
3
+ WORKDIR /code
4
+
5
+ COPY ./requirements.txt /code/requirements.txt
6
+
7
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
+
9
+ COPY ./codellama-7b-instruct.q4_K_M.gguf /code/codellama-7b-instruct.q4_K_M.gguf
10
+ COPY ./main.py /code/main.py
11
+
12
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
codellama-7b-instruct.Q4_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0701500c591c2c1b910516658e58044cdfa07b2e8b5a2e3b6808d983441daf1a
3
+ size 4081095360
main.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ctransformers import AutoModelForCausalLM
2
+ from fastapi import FastAPI
3
+ from pydantic import BaseModel
4
+
5
+ llm = AutoModelForCausalLM.from_pretrained("TheBloke/CodeLlama-7B-Instruct-GGUF",
6
+ model_file="codellama-7b-instruct.q4_K_M.gguf",
7
+ model_type="llama",
8
+ gpu_layers=0)
9
+ #Pydantic object
10
+ class validation(BaseModel):
11
+ prompt: str
12
+ #Fast API
13
+ app = FastAPI()
14
+
15
+ @app.post("/llm_on_cpu")
16
+ async def stream(item: validation):
17
+ system_prompt = 'Below is an instruction that describes a task. Write a response that appropriately completes the request.'
18
+ E_INST = "</s>"
19
+ user, assistant = "<|user|>", "<|assistant|>"
20
+ prompt = f"{system_prompt}{E_INST}\n{user}\n{item.prompt}{E_INST}\n{assistant}\n"
21
+ return llm(prompt)
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ python-multipart
2
+ fastapi
3
+ pydantic
4
+ uvicorn
5
+ requests
6
+ python-dotenv
7
+ ctransformers