title | emoji | colorFrom | colorTo | sdk | sdk_version | app_file | pinned | license |
---|---|---|---|---|---|---|---|---|
Scientific Document Insights Q/A |
📝 |
yellow |
pink |
streamlit |
1.27.2 |
streamlit_app.py |
false |
apache-2.0 |
Work in progress 👷
![](https://private-user-images.githubusercontent.com/15426/285621696-f0a04a86-96b3-406e-8303-904b93f00015.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ0MzY0NTQsIm5iZiI6MTcyNDQzNjE1NCwicGF0aCI6Ii8xNTQyNi8yODU2MjE2OTYtZjBhMDRhODYtOTZiMy00MDZlLTgzMDMtOTA0YjkzZjAwMDE1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODIzVDE4MDIzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ5ZmI1ZjU2M2Q3ZjVmNTZiNTk4MTRkZTFlN2Y2MGU2Mjk1OTUzZmVmNDhjY2I5YzE1YTJiZDE3MDM4NmQ4MmMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.wOxwXBaK0oabdLt-7DVPEP7ajMSpjP3jJ_ods8a2JDE)
https://lfoppiano-document-qa.hf.space/
Question/Answering on scientific documents using LLMs: ChatGPT-3.5-turbo, GPT4, GPT4-Turbo, Mistral-7b-instruct and Zephyr-7b-beta. The streamlit application demonstrates the implementation of a RAG (Retrieval Augmented Generation) on scientific documents, that we are developing at NIMS (National Institute for Materials Science), in Tsukuba, Japan. Different to most of the projects, we focus on scientific articles. We target only the full-text using Grobid which provides cleaner results than the raw PDF2Text converter (which is comparable with most of other solutions).
Additionally, this frontend provides the visualisation of named entities on LLM responses to extract physical quantities, measurements (with grobid-quantities) and materials mentions (with grobid-superconductors).
The conversation is kept in memory by a buffered sliding window memory (top 4 more recent messages) and the messages are injected in the context as "previous messages".
(The image on the right was generated with https://huggingface.co/spaces/stabilityai/stable-diffusion)
- Select the model+embedding combination you want to use
- If using gpt3.5-turbo, gpt4 or gpt4-turbo, enter your API Key (Open AI).
- Upload a scientific article as a PDF document. You will see a spinner or loading indicator while the processing is in progress.
- Once the spinner disappears, you can proceed to ask your questions
Allow to change the number of blocks from the original document that are considered for responding. The default size of each block is 250 tokens (which can be changed before uploading the first document). With default settings, each question uses around 1000 tokens.
NOTE: if the chat answers something like "the information is not provided in the given context", changing the context size will likely help.
When uploaded, each document is split into blocks of a determined size (250 tokens by default). This setting allows users to modify the size of such blocks. Smaller blocks will result in a smaller context, yielding more precise sections of the document. Larger blocks will result in a larger context less constrained around the question.
Indicates whether sending a question to the LLM (Language Model) or to the vector storage.
- LLM (default) enables question/answering related to the document content.
- Embeddings: the response will consist of the raw text from the document related to the question (based on the embeddings). This mode helps to test why sometimes the answers are not satisfying or incomplete.
This feature is specifically crafted for people working with scientific documents in materials science. It enables to run NER on the response from the LLM, to identify materials mentions and properties (quantities, measurements). This feature leverages both grobid-quantities and grobid-superconductors external services.
Error: streamlit: Your system has an unsupported version of sqlite3. Chroma requires sqlite3 >= 3.35.0
.
Here the solution on Linux.
For more information, see the details on Chroma website.
Please read carefully:
- Avoid uploading sensitive data. We temporarily store text from the uploaded PDF documents only for processing your request, and we disclaim any responsibility for subsequent use or handling of the submitted data by third-party LLMs.
- Mistral and Zephyr are FREE to use and do not require any API, but as we leverage the free API entrypoint, there is no guarantee that all requests will go through. Use at your own risk.
- We do not assume responsibility for how the data is utilized by the LLM end-points API.
To release a new version:
bump-my-version bump patch
git push --tags
To use docker:
-
docker run
lfoppiano/document-insights-qa:{latest_version)
-
docker run
lfoppiano/document-insights-qa:latest-develop
for the latest development version
To install the library with Pypi:
pip install document-qa-engine
This project is developed at the National Institute for Materials Science (NIMS) in Japan in collaboration with Guillaume Lambard and the Lambard-ML-Team. Contributed by Pedro Ortiz Suarez, Tomoya Mato. Thanks also to Patrice Lopez, the author of Grobid.