Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- your_rag_module.py +15 -2
your_rag_module.py
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
|
|
| 1 |
from llama_cpp import Llama
|
| 2 |
|
| 3 |
-
#
|
| 4 |
-
|
|
|
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
def lcpp_llm(prompt, max_tokens=128, temperature=0.7, top_p=0.95, top_k=50):
|
| 7 |
output = llm(
|
| 8 |
prompt=prompt,
|
|
|
|
| 1 |
+
from huggingface_hub import hf_hub_download
|
| 2 |
from llama_cpp import Llama
|
| 3 |
|
| 4 |
+
# Model configuration
|
| 5 |
+
model_name_or_path = "TheBloke/Mistral-7B-Instruct-v0.2-GGUF"
|
| 6 |
+
model_basename = "mistral-7b-instruct-v0.2.Q6_K.gguf"
|
| 7 |
|
| 8 |
+
# Download the model from Hugging Face Hub
|
| 9 |
+
model_path = hf_hub_download(
|
| 10 |
+
repo_id=model_name_or_path,
|
| 11 |
+
filename=model_basename,
|
| 12 |
+
cache_dir="./models" # Optional: controls where it's stored
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
# Load the model
|
| 16 |
+
llm = Llama(model_path=model_path)
|
| 17 |
+
|
| 18 |
+
# LLM wrapper for RAG pipeline
|
| 19 |
def lcpp_llm(prompt, max_tokens=128, temperature=0.7, top_p=0.95, top_k=50):
|
| 20 |
output = llm(
|
| 21 |
prompt=prompt,
|