Spaces:
Sleeping
Sleeping
Updated
Browse files
app.py
CHANGED
|
@@ -17,22 +17,23 @@ model_path = hf_hub_download(repo_id=MODEL_REPO, filename=MODEL_FILE)
|
|
| 17 |
# For 0.5B model, 512-1024 is the "sweet spot" for free CPU Spaces
|
| 18 |
llm_instance = Llama(
|
| 19 |
model_path=model_path,
|
| 20 |
-
n_ctx=
|
| 21 |
-
n_batch=
|
| 22 |
use_mmap=True,
|
| 23 |
verbose=False
|
| 24 |
)
|
| 25 |
|
| 26 |
# --- LLAMA-INDEX WORKER ---
|
| 27 |
# This object is ready for your indexing/RAG logic
|
|
|
|
| 28 |
index_llm = LlamaCPP(
|
| 29 |
model_path=model_path,
|
| 30 |
-
context_window=
|
| 31 |
max_new_tokens=256,
|
| 32 |
model_kwargs={"n_gpu_layers": 0},
|
| 33 |
verbose=False
|
| 34 |
)
|
| 35 |
-
|
| 36 |
class ChatRequest(BaseModel):
|
| 37 |
prompt: str
|
| 38 |
|
|
@@ -43,7 +44,7 @@ async def chat(request: ChatRequest):
|
|
| 43 |
|
| 44 |
response = llm_instance(
|
| 45 |
prompt,
|
| 46 |
-
max_tokens=
|
| 47 |
stop=["<|im_end|>", "<|endoftext|>"]
|
| 48 |
)
|
| 49 |
return {"response": response["choices"][0]["text"]}
|
|
|
|
| 17 |
# For 0.5B model, 512-1024 is the "sweet spot" for free CPU Spaces
|
| 18 |
llm_instance = Llama(
|
| 19 |
model_path=model_path,
|
| 20 |
+
n_ctx=128,
|
| 21 |
+
n_batch=128,
|
| 22 |
use_mmap=True,
|
| 23 |
verbose=False
|
| 24 |
)
|
| 25 |
|
| 26 |
# --- LLAMA-INDEX WORKER ---
|
| 27 |
# This object is ready for your indexing/RAG logic
|
| 28 |
+
'''
|
| 29 |
index_llm = LlamaCPP(
|
| 30 |
model_path=model_path,
|
| 31 |
+
context_window=256,
|
| 32 |
max_new_tokens=256,
|
| 33 |
model_kwargs={"n_gpu_layers": 0},
|
| 34 |
verbose=False
|
| 35 |
)
|
| 36 |
+
'''
|
| 37 |
class ChatRequest(BaseModel):
|
| 38 |
prompt: str
|
| 39 |
|
|
|
|
| 44 |
|
| 45 |
response = llm_instance(
|
| 46 |
prompt,
|
| 47 |
+
max_tokens=128,
|
| 48 |
stop=["<|im_end|>", "<|endoftext|>"]
|
| 49 |
)
|
| 50 |
return {"response": response["choices"][0]["text"]}
|