red1xe commited on
Commit
7991914
1 Parent(s): 8e16848

ML model has been added

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -29,5 +29,11 @@ if files:
29
  chunks = text_splitter.split_text(full_text)
30
  embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
31
  db = FAISS.from_texts(chunks, embeddings)
32
- similar_response = db.similarity_search_with_relevance_scores(query=question, k=3)
33
- st.write(similar_response)
 
 
 
 
 
 
 
29
  chunks = text_splitter.split_text(full_text)
30
  embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
31
  db = FAISS.from_texts(chunks, embeddings)
32
+ memory = ConversationBufferMemory(memory_key='chat_history', return_messages=True, chat_memory=[])
33
+ chain = RetrievalQA.from_llm(
34
+ llm=AutoModelForCausalLM.from_pretrained("red1xe/falcon-7b-codeGPT-3K"),
35
+ memory=memory,
36
+ retriever=db.as_retriever(search_kwargs={"k": 3}),
37
+ )
38
+ answer = chain.answer(question)
39
+ st.write(answer)