ali121300 commited on
Commit
c6d68c0
1 Parent(s): 2f4d027

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -17
app.py CHANGED
@@ -48,7 +48,7 @@ def get_text_chunks(text:str) ->list:
48
 
49
  def get_vectorstore(text_chunks : list) -> FAISS:
50
  #model = "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2"
51
- model="paraphrase-distilroberta-base-v1"
52
  encode_kwargs = {
53
  "normalize_embeddings": True
54
  } # set True to compute cosine similarity
@@ -59,24 +59,18 @@ def get_vectorstore(text_chunks : list) -> FAISS:
59
  return vectorstore
60
 
61
 
62
- def get_conversation_chain(vectorstore):
63
- n_gpu_layers = 40 # Change this value based on your model and your GPU VRAM pool.
64
- n_batch = 512 # Should be between 1 and n_ctx, consider the amount of VRAM in your GPU.
65
- n_ctx=2048
66
- callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
67
- # Make sure the model path is correct for your system
68
- llm = LlamaCpp(
69
- model_path="mostafaamiri/persian-llama-7b-GGUF-Q4",
70
- n_gpu_layers=n_gpu_layers, n_batch=n_batch,
71
- callback_manager=callback_manager,
72
- verbose=True,
73
- n_ctx=n_ctx)
74
  memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
75
  conversation_chain = ConversationalRetrievalChain.from_llm(
76
- llm=llm,
77
- retriever=vectorstore.as_retriever(),
78
- memory=memory,
79
- # retriever_kwargs={"k": 1},
80
  )
81
  return conversation_chain
82
 
 
48
 
49
  def get_vectorstore(text_chunks : list) -> FAISS:
50
  #model = "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2"
51
+ model="intfloat/multilingual-e5-large"
52
  encode_kwargs = {
53
  "normalize_embeddings": True
54
  } # set True to compute cosine similarity
 
59
  return vectorstore
60
 
61
 
62
+ def get_conversation_chain(vectorstore:FAISS) -> ConversationalRetrievalChain:
63
+ # llm = ChatOpenAI(temperature=0, model="gpt-3.5-turbo-0613")
64
+ llm = HuggingFaceHub(
65
+ #repo_id="mistralai/Mistral-7B-Instruct-v0.2",
66
+ repo_id="google/gemma-1.1-7b-it",
67
+ #repo_id="TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF"
68
+ model_kwargs={"temperature": 0.5, "max_length": 2048},
69
+ )
70
+
 
 
 
71
  memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
72
  conversation_chain = ConversationalRetrievalChain.from_llm(
73
+ llm=llm, retriever=vectorstore.as_retriever(), memory=memory
 
 
 
74
  )
75
  return conversation_chain
76