matbee-eth / Alpaca-LoRA-Serve

Alpaca-LoRA as Chatbot service

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Alpaca-LoRA as a service

Demonstrate Alpaca-LoRA as a Chatbot service with Alpaca-LoRA and Gradio. Main features include:

  • enables batch inference by aggregating requests until the previous requests are finished
  • achieves context aware by keeping chatting history with the following string format:
f"""
Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
### Input: {input} # Surrounding information to AI
### Instruction: {prompt1} # First instruction/prompt given by user
### Response {response1} # First response on the first prompt by AI
### Instruction: {prompt2} # Second instruction/prompt given by user
### Response: {response2} # Second response on the first prompt by AI
....
"""
  • additionally provides two additional helper buttons
    • continue button lets AI to finish the previously in-completed respone. It simply sens continue message to the model, and continue message gets omitted in the post processing phase.
    • summarize button lets AI to summarize the conversations so far in three sentences. There might be better prompt to generate summary, and this should be explored.
  • provides an additional script to run various configurations to see how it affects the generation quality and speed
  • currently supports the following Alpaca-LoRA:

Instructions

  1. Prerequisites

Note that the code only works Python >= 3.9

$ conda create -n alpaca-serve python=3.9
$ conda activate alpaca-serve
  1. Install dependencies
$ pip install -r requirements.txt
  1. Run Gradio application
$ BASE_URL=decapoda-research/llama-7b-hf
$ FINETUNED_CKPT_URL=tloen/alpaca-lora-7b
$
$ python app.py --base_url $BASE_URL --ft_ckpt_url $FINETUNED_CKPT_URL --port 6006

Screenshots

Acknowledgements

I am thankful to Jarvislabs.ai who generously provided free GPU resources to experiment with Alpaca-LoRA deployment and share it to communities to try out.

About

Alpaca-LoRA as Chatbot service

License:Apache License 2.0


Languages

Language:Python 77.0%Language:Jupyter Notebook 23.0%