Skip to content

dujm/book-reader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Book Reader

Build a book reader (Q&A LLM chain)


Books

  • Time Machine by H. G. Wells

  • Project Organization

    ├── AUTHORS.md
    ├── LICENSE
    ├── README.md
    ├── config
    │   ├── `requirements.txt`: packages
    │   └── `token_access.py`: the file is used to store tokens (remember to add the filename in `.gitignore` file to protect your token) 
    ├── data
    ├── notebooks
    │   ├── `00-book-time-machine_flan_t5_large.ipynb`: using `google/flan-t5-large`
    │   ├── `01-book-time-machine-llama2_7B.ipynb`: using `llama2_7B`
    │   └── `02-book-time-machine-mistral_7B.ipynb`: using `mistral_7B`
    └── model
        └──cache: storing models
    

    How to use this repo?

    1. Download this repo

    git clone https://github.com/dujm/book-reader.git

    2. Create a conda environment

    # create an env (here I name it "llm") with a stable Python version (e.g. Python 3.8) 
    conda create -n llm python=3.8
    
    # activate env
    conda activate llm

    3. Install Python packages

    pip install -r ./config/requirements.txt

    4. Install Jupyterlab

    • if you want to use jupyterlab (alternatively, you can use jupyter notebook)
    conda install -c conda-forge jupyterlab
    
    # add conda environment to jupyter lab
    conda install ipykernel
    ipython kernel install --user --name=llm
    
    # open jupyter lab
    jupyter lab

    5. Set up Ollama (optional)

    • Ollama is used in
      • notebooks/01-book-time-machine-llama2_7B.ipynb
      • notebooks/02-book-time-machine-mistral_7B.ipynb
    • Below is for MacOS. Find more instructions on Ollama if you use other operating systems.
    5.1 First-time using Ollma (for Mac users)
    # pull llama2 model
    ollama pull llama2
    
    # pull mistral model
    ollama pull mistral
    5.2 For future use of Ollama
    • Open Ollama app

    6. Run notebooks

    Go to notebooks/


    Tools that I used


    Thanks to