Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -85,23 +85,24 @@ def get_vectorstore(text_chunks):
|
|
85 |
|
86 |
|
87 |
def get_conversation_chain(vectorstore):
|
88 |
-
model_name_or_path =
|
89 |
-
model_basename =
|
90 |
model_path = hf_hub_download(repo_id=model_name_or_path, filename=model_basename)
|
91 |
|
92 |
-
llm = LlamaCpp(
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
verbose=True,
|
97 |
-
)
|
98 |
# λν κΈ°λ‘μ μ μ₯νκΈ° μν λ©λͺ¨λ¦¬λ₯Ό μμ±ν©λλ€.
|
99 |
-
memory = ConversationBufferMemory(
|
|
|
100 |
# λν κ²μ 체μΈμ μμ±ν©λλ€.
|
101 |
conversation_chain = ConversationalRetrievalChain.from_llm(
|
102 |
-
llm=llm,
|
|
|
|
|
103 |
)
|
104 |
-
return conversation_chain
|
105 |
|
106 |
|
107 |
# μ¬μ©μ μ
λ ₯μ μ²λ¦¬νλ ν¨μμ
λλ€.
|
|
|
85 |
|
86 |
|
87 |
def get_conversation_chain(vectorstore):
|
88 |
+
model_name_or_path = 'TheBloke/Llama-2-7B-chat-GGUF'
|
89 |
+
model_basename = 'llama-2-7b-chat.Q2_K.gguf'
|
90 |
model_path = hf_hub_download(repo_id=model_name_or_path, filename=model_basename)
|
91 |
|
92 |
+
llm = LlamaCpp(model_path=model_path,
|
93 |
+
n_ctx=4086,
|
94 |
+
input={"temperature": 0.75, "max_length": 2000, "top_p": 1},
|
95 |
+
verbose=True, )
|
|
|
|
|
96 |
# λν κΈ°λ‘μ μ μ₯νκΈ° μν λ©λͺ¨λ¦¬λ₯Ό μμ±ν©λλ€.
|
97 |
+
memory = ConversationBufferMemory(
|
98 |
+
memory_key='chat_history', return_messages=True)
|
99 |
# λν κ²μ 체μΈμ μμ±ν©λλ€.
|
100 |
conversation_chain = ConversationalRetrievalChain.from_llm(
|
101 |
+
llm=llm,
|
102 |
+
retriever=vectorstore.as_retriever(),
|
103 |
+
memory=memory
|
104 |
)
|
105 |
+
return conversation_chain # μμ±λ λν 체μΈμ λ°νν©λλ€.
|
106 |
|
107 |
|
108 |
# μ¬μ©μ μ
λ ₯μ μ²λ¦¬νλ ν¨μμ
λλ€.
|