Create API endpoints for question answering and sentiment analysis.
Photo: Shutterstock
- File Descriptions
- Supporting Packages
- How To Use This Repository
- Project Motivation
- About The Dataset
- Acknowledgements
- Licence & copyright
File | Description |
---|---|
data/coltrane.txt | text from the John Coltrane Wikipedia page |
data/index.json | sentence embeddings of text from coltrane.txt |
main.py | FastAPI app |
models.py | Hugging Face models and supporting functions |
requirements.in | pip-tools spec file for requirements.txt |
requirements.txt | list of python dependencies |
In addition to the standard python library, this analysis utilizes the following packages:
Please see requirements.txt
for a complete list of packages and dependencies used in the making of this project.
-
Clone the repo locally or download and unzip this repository to a local machine.
-
Navigate to this directory and open the command line. For the purposes of running the scripts, this will be the root directory.
-
Create a virtual environment to store the supporting packages.
python -m venv venv --upgrade-deps
-
Activate the virtual environment.
venv\scripts\activate
-
Install the supporting packages from the requirements.txt file.
pip install -r requirements.txt
-
Run "uvicorn main:app --reload"
-
Open up a browser and go to 127.0.0.1:8000/docs and try out the two endpoints.
Note: if you do not have the hugging face models already, they will be downloaded and cached on your machine in the C:\Users\USEDID\.cache
folder
It is interesting to consider indexing a corpus with sentence embeddings and using them to query an LLM in a closed loop way, without calls to an external web API. This repo contributes an example in how to do this for the tasks of question answering from a knowledge base, as well as sentiment analysis.
See John Coltrane Wikipedia page.
Thanks to the developers who created the foundations for this example.
© Zachary Wolinsky 2023
Licensed under the MIT License