forked from openchatai/OpenChat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openchatai#150 from codebanesr/enhancement/llama
"PR: Add Support for llama-2-7b, Improve Execution Speed, and Clean Up Libraries"
- Loading branch information
Showing
18 changed files
with
189 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ yarn-error.log | |
/.fleet | ||
/.idea | ||
/.vscode | ||
public/.DS_Store |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Exclude version control directories/files | ||
.git | ||
.gitignore | ||
|
||
# Exclude temporary or build files | ||
__pycache__ | ||
*.pyc | ||
*.pyo | ||
|
||
# Exclude editor-specific files | ||
.vscode | ||
|
||
# Exclude local development files | ||
*.log | ||
*.db | ||
|
||
# Exclude test files and test data | ||
tests | ||
test_data | ||
|
||
# Exclude any other files or directories that are not needed in the container | ||
venv | ||
llama-2-7b-chat.ggmlv3.q4_K_M.bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,71 @@ | ||
# Makefile to Run docker-compose for Django App | ||
|
||
# Check if Docker is installed | ||
# Check if Docker and Docker Compose are installed | ||
DOCKER := $(shell command -v docker 2> /dev/null) | ||
DOCKER_COMPOSE := $(shell command -v docker-compose 2> /dev/null) | ||
OS := $(shell uname) | ||
|
||
ifndef DOCKER | ||
$(error "Docker is not installed. Please install Docker before proceeding.") | ||
$(error $(shell tput setaf 1)"Docker is not installed. Please install Docker before proceeding."$(shell tput sgr0)) | ||
endif | ||
|
||
ifndef DOCKER_COMPOSE | ||
$(error "Docker Compose is not installed. Please install Docker Compose before proceeding.") | ||
ifndef DOCKER_COMPOSE | ||
$(error $(shell tput setaf 1)"Docker Compose is not installed. Please install Docker Compose before proceeding."$(shell tput sgr0)) | ||
endif | ||
|
||
.env.docker: | ||
@echo "Error: The .env.docker file is missing. Please create it before proceeding. Refer example.env.docker or readme file in dj_backend_server/readme.md" | ||
@echo $(shell tput setaf 1)"Error: The .env.docker file is missing. Please create it before proceeding. Refer example.env.docker or readme file in dj_backend_server/readme.md"$(shell tput sgr0) | ||
exit 1 | ||
|
||
install: .env.docker | ||
venv: | ||
ifndef venv | ||
ifeq ($(OS), Darwin) | ||
@echo $(shell tput setaf 2)"Creating a virtual environment..."$(shell tput sgr0) | ||
python3 -m venv venv | ||
else | ||
@echo $(shell tput setaf 2)"Creating a virtual environment..."$(shell tput sgr0) | ||
python3 -m venv venv | ||
endif | ||
endif | ||
|
||
activate-venv: | ||
@echo $(shell tput setaf 3)"Activating virtual environment..."$(shell tput sgr0) | ||
. venv/bin/activate | ||
|
||
|
||
install-requirements: activate-venv | ||
@echo $(shell tput setaf 2)"Installing Python dependencies..."$(shell tput sgr0) | ||
pip install -r requirements.txt | ||
|
||
install: .env install-requirements | ||
docker-compose up -d | ||
|
||
down: | ||
docker-compose down | ||
|
||
ifeq ($(OS), Darwin) # macOS | ||
OPEN_COMMAND := open | ||
else ifeq ($(OS), Linux) | ||
OPEN_COMMAND := xdg-open | ||
else | ||
OPEN_COMMAND := echo $(shell tput setaf 1)"Unsupported OS: $(OS)"$(shell tput sgr0) | ||
endif | ||
|
||
dev-start: | ||
docker-compose up -d | ||
celery -A dj_backend_server worker --loglevel=info & | ||
python manage.py sync_models && python manage.py runserver 0.0.0.0:8000 | ||
|
||
@echo $(shell tput setaf 3)"Waiting for 20 seconds before opening the browser..."$(shell tput sgr0) | ||
sleep 20 | ||
|
||
$(OPEN_COMMAND) http://localhost:8000 | ||
|
||
dev-stop: | ||
docker-compose down | ||
kill -9 $$(pgrep -f "celery -A dj_backend_server") | ||
kill -9 $$(pgrep -f "python manage.py runserver") | ||
|
||
@echo $$(tput setaf 3)"Services stopped."$$(tput sgr0) | ||
|
||
.PHONY: venv install-requirements install down dev-start dev-stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ class EmbeddingProvider(Enum): | |
OPENAI = "openai" | ||
BARD = "bard" | ||
azure = "azure" | ||
llama2 = "llama2" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
## LLAMA SUPPORT FOR MAC M1/M2 devices <span style="color: red;">⚠️ **Experimental Warning** ⚠️</span> | ||
|
||
This repository offers <span style="color: #1E90FF;">LLAMA support</span> for Mac M1/M2 devices. LLAMA stands as an <span style="color: #008000;">advanced language model</span> developed by Meta. This comprehensive guide is intended to assist you in <span style="color: #FF8C00;">configuring and running LLAMA</span> on your Mac M1/M2 device by following the provided instructions. It's important to note that running LLAMA on Mac devices using Docker might not be straightforward due to <span style="color: #FF0000;">emulation constraints</span>, particularly related to accessing video drivers. | ||
|
||
Additionally, the current embedding speeds are quite low, although it's worth noting that the model's speed does improve over time. | ||
|
||
## Getting Started | ||
|
||
Follow these steps to set up LLAMA support on your Mac M1/M2 device: | ||
|
||
1. Clone this repository to your local machine. | ||
|
||
2. In the root directory of the repository, locate the `.env` file and open it in a text editor. | ||
|
||
3. Change the following two environment variables in the `.env` file: | ||
|
||
```dotenv | ||
OPENAI_API_TYPE=llama2 | ||
EMBEDDING_PROVIDER=llama2 | ||
``` | ||
|
||
These variables configure LLAMA as the API type and embedding provider. | ||
|
||
4. **Note**: Currently, the system supports only a specific combination of embedding and completion models. Future updates will provide more flexibility in choosing different models. | ||
|
||
5. **Note**: Docker images are not supported for Mac devices due to emulation limitations. As a result, you need to run the application using a virtual environment (virtualenv) for now. | ||
|
||
|
||
|
||
6. When working with Visual Studio Code, you have the option to leverage the debug scripts that are available to enhance your development process (you'll need to execute docker compose up -d to run the other docker containers). As another approach, you can employ the subsequent commands to initiate and halt the development server. | ||
- To start the development server: | ||
|
||
```sh | ||
make dev-start | ||
``` | ||
|
||
- To stop the development server: | ||
|
||
```sh | ||
make dev-stop | ||
``` | ||
|
||
## Future Updates | ||
|
||
We are continuously working on enhancing LLAMA support for Mac M1/M2 devices. Stay tuned for updates that will provide more options for embedding and completion models, as well as improved compatibility with different environments. | ||
|
||
For any issues or questions, please reach out to our support team or open an issue in this repository. | ||
|
||
Happy coding! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,4 +37,4 @@ yarn-error.log* | |
next-env.d.ts | ||
|
||
#Notion_db | ||
/Notion_DB | ||
/Notion_DB |