ranchaya sambath commited on
Commit
bd22efc
·
1 Parent(s): 4b7c6ef

app added

Browse files
PDFfiles/Expungement-Guidebook-10.07.2020.pdf ADDED
Binary file (720 kB). View file
 
PDFfiles/Jun 1 2018 Expungement Certification Process KSP Flyer.pdf ADDED
Binary file (353 kB). View file
 
PDFfiles/OSham_SignedOrder.pdf ADDED
The diff for this file is too large to render. See raw diff
 
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain.document_loaders import PyPDFDirectoryLoader
2
+ from langchain.vectorstores import Chroma
3
+ from langchain.embeddings.huggingface import HuggingFaceEmbeddings
4
+ from langchain import HuggingFaceHub
5
+ from langchain.text_splitter import RecursiveCharacterTextSplitter
6
+ from langchain.chains.question_answering import load_qa_chain
7
+ import streamlit as st
8
+ from langchain.chains import RetrievalQA
9
+
10
+ def main():
11
+ pdf_folder_path = "./PDFfiles"
12
+ loader = PyPDFDirectoryLoader(pdf_folder_path)
13
+ docs = loader.load()
14
+ text_splitter = RecursiveCharacterTextSplitter (chunk_size=1000, chunk_overlap=200)
15
+ texts = text_splitter.split_documents(docs)
16
+ embeddings = HuggingFaceEmbeddings()
17
+ vectordb = Chroma.from_documents(documents=texts,embedding=embeddings)
18
+ llm = HuggingFaceHub(repo_id="google/flan-t5-small", model_kwargs={"temperature":0,"max_length":200}, huggingfacehub_api_token="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") # type: ignore
19
+ qa = RetrievalQA.from_chain_type(llm=llm, chain_type="stuff",retriever=vectordb.as_retriever(search_type="mmr", search_kwargs={'fetch_k': 30}), return_source_documents=True)
20
+ query = st.text_input("Ask a question: ")
21
+ qa(inputs=query,return_only_outputs=True)
22
+ result = qa({"query": query})
23
+ st.write(result["result"])
24
+ st.write(result["source_documents"][0])
25
+ main()
requirements.txt ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiohttp==3.8.5
2
+ aiosignal==1.3.1
3
+ altair==5.0.1
4
+ anyio==3.7.1
5
+ async-timeout==4.0.3
6
+ attrs==23.1.0
7
+ backoff==2.2.1
8
+ blinker==1.6.2
9
+ cachetools==5.3.1
10
+ certifi==2023.7.22
11
+ charset-normalizer==3.2.0
12
+ chroma-hnswlib==0.7.2
13
+ chromadb==0.4.5
14
+ click==8.1.6
15
+ colorama==0.4.6
16
+ coloredlogs==15.0.1
17
+ dataclasses-json==0.5.14
18
+ datasets==2.14.4
19
+ decorator==5.1.1
20
+ dill==0.3.7
21
+ distlib==0.3.7
22
+ faiss-cpu==1.7.4
23
+ fastapi==0.99.1
24
+ filelock==3.12.2
25
+ flatbuffers==23.5.26
26
+ frozenlist==1.4.0
27
+ fsspec==2023.6.0
28
+ gitdb==4.0.10
29
+ GitPython==3.1.32
30
+ greenlet==2.0.2
31
+ h11==0.14.0
32
+ httptools==0.6.0
33
+ huggingface-hub==0.16.4
34
+ humanfriendly==10.0
35
+ idna==3.4
36
+ importlib-metadata==6.8.0
37
+ importlib-resources==6.0.1
38
+ Jinja2==3.1.2
39
+ joblib==1.3.2
40
+ jsonschema==4.19.0
41
+ jsonschema-specifications==2023.7.1
42
+ langchain==0.0.261
43
+ langsmith==0.0.20
44
+ markdown-it-py==3.0.0
45
+ MarkupSafe==2.1.3
46
+ marshmallow==3.20.1
47
+ mdurl==0.1.2
48
+ monotonic==1.6
49
+ mpmath==1.3.0
50
+ multidict==6.0.4
51
+ multiprocess==0.70.15
52
+ mypy-extensions==1.0.0
53
+ networkx==3.1
54
+ nltk==3.8.1
55
+ numexpr==2.8.5
56
+ numpy==1.25.2
57
+ onnxruntime==1.15.1
58
+ openapi-schema-pydantic==1.2.4
59
+ overrides==7.4.0
60
+ packaging==23.1
61
+ pandas==2.0.3
62
+ Pillow==9.5.0
63
+ pipenv==2023.7.11
64
+ platformdirs==3.10.0
65
+ posthog==3.0.1
66
+ protobuf==4.24.0
67
+ pulsar-client==3.2.0
68
+ pyarrow==12.0.1
69
+ pydantic==1.10.12
70
+ pydeck==0.8.0
71
+ Pygments==2.16.1
72
+ Pympler==1.0.1
73
+ pypdf==3.15.0
74
+ PyPika==0.48.9
75
+ pyreadline3==3.4.1
76
+ python-dateutil==2.8.2
77
+ python-dotenv==1.0.0
78
+ pytz==2023.3
79
+ pytz-deprecation-shim==0.1.0.post0
80
+ PyYAML==6.0.1
81
+ referencing==0.30.2
82
+ regex==2023.8.8
83
+ requests==2.31.0
84
+ rich==13.5.2
85
+ rpds-py==0.9.2
86
+ safetensors==0.3.2
87
+ scikit-learn==1.3.0
88
+ scipy==1.11.1
89
+ sentence-transformers==2.2.2
90
+ sentencepiece==0.1.99
91
+ six==1.16.0
92
+ smmap==5.0.0
93
+ sniffio==1.3.0
94
+ SQLAlchemy==2.0.19
95
+ starlette==0.27.0
96
+ streamlit==1.25.0
97
+ sympy==1.12
98
+ tenacity==8.2.2
99
+ threadpoolctl==3.2.0
100
+ tokenizers==0.13.3
101
+ toml==0.10.2
102
+ toolz==0.12.0
103
+ torch==2.0.1
104
+ torchvision==0.15.2
105
+ tornado==6.3.2
106
+ tqdm==4.66.1
107
+ transformers==4.31.0
108
+ typing-inspect==0.9.0
109
+ typing_extensions==4.7.1
110
+ tzdata==2023.3
111
+ tzlocal==4.3.1
112
+ urllib3==2.0.4
113
+ uvicorn==0.23.2
114
+ validators==0.20.0
115
+ virtualenv==20.24.2
116
+ virtualenv-clone==0.5.7
117
+ watchdog==3.0.0
118
+ watchfiles==0.19.0
119
+ websockets==11.0.3
120
+ xxhash==3.3.0
121
+ yarl==1.9.2
122
+ zipp==3.16.2