This project combines Ansible and Docker to automate the setup of an environment for running an Intel RAG (Retrieval Augmented Generation) application. The Ansible script orchestrates the installation of dependencies, while the Docker image encapsulates the application and its environment.
This Ansible script automates the setup of an environment for running an Intel RAG (Retrieval Augmented Generation) application. The environment includes dependencies such as Miniconda, Conda environments, Git, and specific Python libraries for PyTorch and Intel Extension for PyTorch.
- Ansible installed on the control machine.
- Target machine(s) accessible and configured for SSH access.
- Clone the Ansible repository to your local machine:
git clone https://github.com/Yuandjom/Intel_LLM_QnA_ansible_script.git
- Navigate to the cloned directory:
cd Intel_LLM_QnA_ansible_script
- Update the
hosts.ini
file with the IP address and hostname of your target machine(s). - Adjust variables in the Ansible playbook (setup_RAG.yml) if needed, especially the
workspace_path
variable. - Run the Ansible playbook to set up the environment:
ansible-playbook -i hosts.ini setup_RAG.yml -vv
workspace_path
: Path to the main workspace on the target machine.workspace_path_hf
: Path to a specific directory within the workspace.conda_installer_url
: URL for the Miniconda installer script.conda_env_file
: Local path to the Conda environment YAML file.remote_conda_env_file:
Remote path for copying the Conda environment file.conda_path
: Path to the Conda executable on the target machine.local_directory
: Local path to the directory to be copied to the target machine.local_directory_huggingFace
: Local path to another directory to be copied to the target machine.
-
Install Git: Ensures that Git is installed on the target machine.
-
Create Workspace Directory: Creates the main workspace directory.
-
Copy Directories to Remote Host: Copies specified local directories to the target machine.
-
Install Conda: Downloads and installs Miniconda on the target machine.
-
Set Conda Permissions: Adjusts permissions for Conda installation.
-
Copy Conda Environment File: Copies the Conda environment YAML file to the target machine.
-
Create Conda Environment: Creates a Conda environment based on the provided YAML file.
-
Install Additional Dependencies: Installs Git and additional dependencies required for the environment.
-
Find Python Executable in Conda Environment: Finds the Python executable in the Conda environment.
-
Install Pip in Conda Environment: Installs Pip in the Conda environment.
-
Get CPU Architecture Information: Retrieves information about the CPU architecture.
-
Check PyTorch and Intel Extension for PyTorch Versions: Checks and prints PyTorch and Intel Extension for PyTorch versions.
- The playbook is designed for Linux-based systems.
- Ensure that the SSH connection to the target machine is properly configured.
- Some tasks may require manual intervention or adjustments based on the target environment.
This Docker image sets up an environment for running an Allen_AI-based Question & Answer (Q&A) application using the FARM and Haystack libraries. The image is built on top of the Miniconda3 base image and includes the necessary dependencies for the application.
To build the Docker image, use the following command:
sudo docker build -t allen_ai_app .
To run the Docker container, execute the following command:
sudo docker run -it -p 7860:7860 -e GRADIO_SERVER_NAME=0.0.0.0 allen_ai_app
Copy link into the command line
https://s3.eu-central-1.amazonaws.com/deepset.ai-farm-qa/datasets/small_generator_dataset.csv.zip
This command maps port 7860 on the host to port 7860 on the container and sets the Gradio server to be accessible from all network interfaces.
The base image for this Docker container is continuumio/miniconda3, which provides a minimal Conda installation.
The working directory within the container is set to /home/test/QnA_RAG
.
A Conda environment named Allen_AI
is created with Python version 3.8. The environment is activated during the Docker build process and maintained for running the application.
The following dependencies are installed within the Allen_AI
Conda environment:
- PyTorch, torchvision, and torchaudio
- FARM and Haystack libraries
- Gradio for creating interactive user interfaces
Port 7860 is exposed to allow external access to the Gradio server, assuming that Gradio runs on this port within the application.
The container is configured to execute the Python script Generative_QA_Haystack_PromptNode_CSV_database_llama2.py
within the specific directory /home/test/QnA_RAG/QnA_fastRAG_CSV_LLAMA2
when the container starts.
After building and running the Docker container, you can access the Allen_AI Q&A application by navigating to http://localhost:7860
in your web browser.
Feel free to customize the Dockerfile and script to suit your specific use case and application requirements.
Note: Certain files, including tokenizer.json
, pytorch_model-00001-of-00002.bin
, pytorch_model-00002-of-00002.bin
, model-00001-of-00002.safetensors
, and model-00002-of-00002.safetensors
within the Llama-2-7b-chat-hf
directory, were not pushed to the repository due to their large size. You may need to obtain these files separately if they are essential for your use case.