Giter Club home page Giter Club logo

llama2-chatbot-cpu's Introduction

LLaMA2 chatbot on CPU

🧐 Description

  • This project is a Streamlit chatbot with Langchain deploying a LLaMA2-7b-chat model on Intel® Server and Client CPUs.

  • The chatbot has a memory that remembers every part of the speech, and allows users to optimize the model using Intel® Extension for PyTorch (IPEX) in bfloat16 with graph mode or smooth quantization (A new quantization technique specifically designed for LLMs: ArXiv link), or 4-bit quantization. The user can expect up to 4.3x speed-up compared to stock PyTorch in default mode.

  • IMPORTANT: The CPU needs to support bfloat16 ops in order to be able to use such optimization. On top of software optimizations, I also introduced some hardware optimizations like non-uniform memory access (NUMA). User needs to ask for access to LLaMA2 models by following this link. When getting approval from Meta, you can generate an authentification token from your HuggingFace account, and use it to load the model.

📜 Getting started

  1. Start by cloning the repository:
git clone https://github.com/aahouzi/llama2-chatbot-cpu.git
cd llama2-chatbot-cpu
  1. Create a Python 3.9 conda environment:
conda create -y -n llama2-chat python=3.9
  1. Activate the environment:
conda activate llama2-chat
  1. Install requirements for NUMA:
conda install -y gperftools -c conda-forge
conda install -y intel-openmp
sudo apt install numactl
  1. Install the app requirements:
pip install -r requirements.txt

🚀 Start the app

  • Default mode (no optimizations):
bash launcher.sh --script=app/app.py --port=<port> --physical_cores=<physical_cores> --auth_token=<auth_token>
  • IPEX in graph mode with FP32:
bash launcher.sh --script=app/app.py --port=<port> --physical_cores=<physical_cores> --auth_token=<auth_token> --ipex --jit
  • IPEX in graph mode with bfloat16:
bash launcher.sh --script=app/app.py --port=<port> --physical_cores=<physical_cores> --auth_token=<auth_token> --dtype=bfloat16 --ipex --jit
  • Smooth quantization:
bash launcher.sh --script=app/app.py --port=<port> --physical_cores=<physical_cores> --auth_token=<auth_token> --sq
  • 4-bit quantization:
bash launcher.sh --script=app/app.py --port=<port> --physical_cores=<physical_cores> --auth_token=<auth_token> --int4

💻 Chatbot demo

📪 Contact

For any information, feedback or questions, please contact me

llama2-chatbot-cpu's People

Contributors

aahouzi avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.