Manoj21k commited on
Commit
8ec4279
1 Parent(s): 5a08de1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -4,6 +4,7 @@ from tempfile import NamedTemporaryFile
4
  from langchain.document_loaders import PyPDFLoader
5
  from langchain.embeddings import HuggingFaceEmbeddings
6
  from langchain.vectorstores import Chroma
 
7
  from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
8
 
9
  # Function to save the uploaded PDF to a temporary file
@@ -27,19 +28,14 @@ if uploaded_file is not None:
27
  embed = HuggingFaceEmbeddings()
28
  db = Chroma.from_documents(pages, embed)
29
 
30
- # Initialize the GPT-4 model
31
- llm = GPT4All(
32
- model="./gpt4all-converted.bin"
33
- )
34
-
35
  # Define a function to get answers
36
  def get_answer(question):
37
  doc = db.similarity_search(question, k=4)
38
  context = doc[0].page_content + doc[1].page_content + doc[2].page_content + doc[3].page_content
39
 
40
- max_seq_length = 512 # You may define this based on your model
41
 
42
- context = context[:max_seq_length]
43
 
44
  # Load the model & tokenizer for question-answering
45
  model_name = "deepset/roberta-base-squad2"
 
4
  from langchain.document_loaders import PyPDFLoader
5
  from langchain.embeddings import HuggingFaceEmbeddings
6
  from langchain.vectorstores import Chroma
7
+ from langchain import PromptTemplate, LLMChain
8
  from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
9
 
10
  # Function to save the uploaded PDF to a temporary file
 
28
  embed = HuggingFaceEmbeddings()
29
  db = Chroma.from_documents(pages, embed)
30
 
 
 
 
 
 
31
  # Define a function to get answers
32
  def get_answer(question):
33
  doc = db.similarity_search(question, k=4)
34
  context = doc[0].page_content + doc[1].page_content + doc[2].page_content + doc[3].page_content
35
 
36
+ #max_seq_length = 512 # You may define this based on your model
37
 
38
+ #context = context[:max_seq_length]
39
 
40
  # Load the model & tokenizer for question-answering
41
  model_name = "deepset/roberta-base-squad2"