valeriylo commited on
Commit
62f6e0d
1 Parent(s): 1580495

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -10,6 +10,7 @@ from langchain.chains import ConversationalRetrievalChain
10
  from htmlTemplates import css, bot_template, user_template
11
  from langchain.llms import HuggingFaceHub, LlamaCpp
12
  from huggingface_hub import snapshot_download, hf_hub_download
 
13
 
14
  repo_name = "IlyaGusev/saiga2_7b_gguf"
15
  model_name = "model-q2_K.gguf"
@@ -30,8 +31,8 @@ def get_pdf_text(pdf_docs):
30
  def get_text_chunks(text):
31
 
32
  text_splitter = CharacterTextSplitter(separator="\n",
33
- chunk_size=1000,
34
- chunk_overlap=200,
35
  length_function=len
36
  )
37
  chunks = text_splitter.split_text(text)
@@ -51,12 +52,22 @@ def get_vectorstore(text_chunks):
51
 
52
  def get_conversation_chain(vectorstore, model_name):
53
 
54
- llm = LlamaCpp(model_path=model_name, n_ctx=2048, n_parts=1)
 
 
 
 
 
 
 
 
 
55
  #llm = ChatOpenAI()
56
 
57
  memory = ConversationBufferMemory(memory_key='chat_history', return_messages=True)
58
 
59
  conversation_chain = ConversationalRetrievalChain.from_llm(llm=llm,
 
60
  retriever=vectorstore.as_retriever(),
61
  memory=memory
62
  )
 
10
  from htmlTemplates import css, bot_template, user_template
11
  from langchain.llms import HuggingFaceHub, LlamaCpp
12
  from huggingface_hub import snapshot_download, hf_hub_download
13
+ from prompts import CONDENSE_QUESTION_PROMPT
14
 
15
  repo_name = "IlyaGusev/saiga2_7b_gguf"
16
  model_name = "model-q2_K.gguf"
 
31
  def get_text_chunks(text):
32
 
33
  text_splitter = CharacterTextSplitter(separator="\n",
34
+ chunk_size=500, #1000
35
+ chunk_overlap=30, #200
36
  length_function=len
37
  )
38
  chunks = text_splitter.split_text(text)
 
52
 
53
  def get_conversation_chain(vectorstore, model_name):
54
 
55
+ llm = LlamaCpp(model_path=model_name,
56
+ temperature=0.1,
57
+ top_k=30,
58
+ top_p=0.9,
59
+ streaming=True,
60
+ n_ctx=2048,
61
+ n_parts=1,
62
+ echo=True
63
+ )
64
+
65
  #llm = ChatOpenAI()
66
 
67
  memory = ConversationBufferMemory(memory_key='chat_history', return_messages=True)
68
 
69
  conversation_chain = ConversationalRetrievalChain.from_llm(llm=llm,
70
+ condense_question_prompt=CONDENSE_QUESTION_PROMPT
71
  retriever=vectorstore.as_retriever(),
72
  memory=memory
73
  )