Spaces:
Sleeping
Sleeping
Commit
·
1a72edc
1
Parent(s):
8209b87
Fix that I am very skeptical of
Browse files- llm_rag_setup.py +4 -3
llm_rag_setup.py
CHANGED
|
@@ -6,7 +6,7 @@ from langchain_community.vectorstores import FAISS
|
|
| 6 |
from langchain_huggingface import HuggingFaceEmbeddings
|
| 7 |
from langchain_community.retrievers import BM25Retriever
|
| 8 |
from langchain.retrievers import EnsembleRetriever
|
| 9 |
-
from langchain_huggingface import HuggingFaceEndpoint
|
| 10 |
from langchain.chains import RetrievalQA
|
| 11 |
from langchain.prompts import PromptTemplate
|
| 12 |
from typing import Optional
|
|
@@ -120,15 +120,16 @@ def init_rag():
|
|
| 120 |
|
| 121 |
print("🔄 Initializing HuggingFace LLM (Qwen2.5-7B-Instruct)...")
|
| 122 |
try:
|
| 123 |
-
|
| 124 |
repo_id="Qwen/Qwen2.5-7B-Instruct",
|
| 125 |
huggingfacehub_api_token=HF_TOKEN,
|
| 126 |
temperature=0.3,
|
| 127 |
max_new_tokens=1024,
|
| 128 |
top_p=0.95,
|
| 129 |
repetition_penalty=1.1,
|
| 130 |
-
task="conversational",
|
| 131 |
)
|
|
|
|
|
|
|
| 132 |
print("✅ HuggingFace LLM initialized (Qwen2.5-7B-Instruct)")
|
| 133 |
except Exception as e:
|
| 134 |
print(f"❌ Failed to initialize LLM: {e}")
|
|
|
|
| 6 |
from langchain_huggingface import HuggingFaceEmbeddings
|
| 7 |
from langchain_community.retrievers import BM25Retriever
|
| 8 |
from langchain.retrievers import EnsembleRetriever
|
| 9 |
+
from langchain_huggingface import ChatHuggingFace, HuggingFaceEndpoint
|
| 10 |
from langchain.chains import RetrievalQA
|
| 11 |
from langchain.prompts import PromptTemplate
|
| 12 |
from typing import Optional
|
|
|
|
| 120 |
|
| 121 |
print("🔄 Initializing HuggingFace LLM (Qwen2.5-7B-Instruct)...")
|
| 122 |
try:
|
| 123 |
+
llm_endpoint = HuggingFaceEndpoint(
|
| 124 |
repo_id="Qwen/Qwen2.5-7B-Instruct",
|
| 125 |
huggingfacehub_api_token=HF_TOKEN,
|
| 126 |
temperature=0.3,
|
| 127 |
max_new_tokens=1024,
|
| 128 |
top_p=0.95,
|
| 129 |
repetition_penalty=1.1,
|
|
|
|
| 130 |
)
|
| 131 |
+
|
| 132 |
+
llm = ChatHuggingFace(llm=llm_endpoint)
|
| 133 |
print("✅ HuggingFace LLM initialized (Qwen2.5-7B-Instruct)")
|
| 134 |
except Exception as e:
|
| 135 |
print(f"❌ Failed to initialize LLM: {e}")
|