Quickstart¶
In this example we will explore the basic features of DKubeX. We will start by ingesting a dataset from our workspace, deploying a base LLM model, and building a RAG chat application. The steps are as follows:
Prerequisites¶
You must have the current version of DKubeX installed into your system. For detailed instructions regarding installation and logging in to DKubeX, please refer to Installation.
For this example, ideally you need a a10 GPU (g5.4xlarge) node attached to your cluster.
Attention
In case of a RKE2 setup, please make sure that you have labeled the node as “a10”. Also, in case you are using any other type of GPU node, make sure to use the label for that node which you have put during DKubeX installation process.
Make sure you have access and the secret token (only if required) for that particular model which you are going to deploy (in this example, Llama3-8B).
Note
In the case the model you want to deploy is not in the DKubeX LLMs registry, you can also deploy LLMs directly from the HuggingFace model hub using the configuration file of that particular model. Make sure you have access to that particular model (in case the model is a private model).
For instructions on how to deploy the model from HuggingFace repository, please refer to Deploying Base LLMs.
Export the following variables to your workspace by running the following commands on your DKubeX Terminal.
Replace the
<username>part with your DKubeX username.export NAMESPACE="<username>" export HOMEDIR=/home/${NAMESPACE}
This example uses the ContractNLI dataset throughout where required. You need to download the dataset on your DKubeX workspace.
Attention
Although the ContractsNLI dataset is in accordance with the terms and conditions of the Creative Commons Attribution 4.0 International Public License, it is recommended to go through the terms and conditions of the dataset before using it. You can read the terms and conditions here- https://stanfordnlp.github.io/contract-nli/#download
To download the dataset, open the Terminal application from the DKubeX UI and run the following command:
cd && wget https://stanfordnlp.github.io/contract-nli/resources/contract-nli.zipUnzip the downloaded file using the following command. A folder called contract-nli will be created which will contain the entire dataset. Also at this point, remove the unnecessary files from the dataset folder.
cd && unzip contract-nli.zip rm -rf contract-nli/dev.json contract-nli/LICENSE contract-nli/README.md contract-nli/TERMS contract-nli/test.json contract-nli/train.json
Ingesting Data¶
Note
For detailed information regarding this section, please refer to Data ingestion and creating dataset.
Important
This example uses the BAAI/bge-large-en-v1.5 embeddings model for data ingestion.
Configuring .yaml file for ingestion¶
You need to provide a configuration .yaml file to be used during the ingestion process.
On the Terminal application in DKubeX UI, run the following commands:
cd && git clone -b v0.8.5.3 https://github.com/dkubeio/dkubex-examples.git cp ${HOMEDIR}/dkubex-examples/rag/ingestion/ingest.yaml ${HOMEDIR}/ingest.yaml
You need to provide proper details on the ingest.yaml file. Run
vim ${HOMEDIR}/ingest.yamland make the following changes.On the
embeddingsection, selecthuggingfaceas we are going to use theBAAI/bge-large-en-v1.5embedding model which is already present in the DKubeX models catalog.On the
readersection, selectfileas we are going to use the file reader from Llamaindex to read the documents for ingestion. For more information regarding the file reader, visit the Llamaindex documentation.Uncomment the entire
huggingfacesection underEmbedding Model Details. Here the name of the embedding model to be used is provided.Make sure the
filesection underData Reader Detailsis uncommented. Under here, in theinput_dirfield provide the absolute path to your dataset folder, i.e. in this case,/home/<your username>/contract-nli/(Provide your DKubeX username in place of<your username>).
You can also modify and customize several other options in the ingest.yaml file according to your needs, including the splitter class, chunk size, embedding model to be used, etc.
Triggering ingestion and creating dataset¶
Open the Terminal application in DKubeX UI.
Use the following command to perform data ingestion and create the dataset. A dataset named contracts will be created.
d3x dataset ingest -d contracts --config ${HOMEDIR}/ingest.yaml --faqNote
A few documents from the ContractsNLI dataset may show errors during the ingestion process. This is expected behaviour ar those documents’ format are not suitable for ingestion.
The time taken for the ingestion process to complete depends on the size of the dataset. The ContractsNLI dataset contains 605 documents and the ingestion process may take around 30 minutes to complete. Please wait patiently for the process to complete.
In case the terminal shows a timed-out error, that means the ingestion is still in progress, and you will need to run the command provided on the CLI after the error message to continue to get the ingestion logs.
The record of the ingestion and related artifacts are also stored in the MLFlow application on DKubeX UI.
To check if the dataset has been created, stored and are ready to use, use the following command:
d3x dataset listTo check the list of documents that has been ingested in the dataset, use the following command:
d3x dataset show -d contracts
Deploying LLMs from Model Catalog¶
Note
For detailed information regarding this section, please refer to Deploying LLMs in DKubeX.
Here we will deploy the base Llama3-8B model, which is already pre-registered with DKubeX.
Note
This workflow requires an a10 GPU node. Make sure your cluster is equipped with such. Also, in case you are using any other type of GPU node, make sure to use the label for that node which you have put during DKubeX installation process.
To list all LLM models registered with DKubeX, use the following command.
d3x llms listExport the access token for the Llama3-8B model. Replace the
<Huggingface token for Llama3-8B>part with the token for the Llama3-8B model.export HF_TOKEN="<Huggingface token for Llama3-8B>"Deploy the base Llama2-7B model using the following command.
d3x llms deploy --name=llama38bbase --model=meta-llama/Meta-Llama-3-8B-Instruct --token ${HF_TOKEN} --type=a10 --publishNote
In case you are using a EKS setup, please change the value of the flag --type from a10 to g5.4xlarge in the following command. Also, in case you are using any other type of GPU node, make sure to use the label for that node which you have put during DKubeX installation process.
You can check the status of the deployment from the Deployments page in DKubeX or by running the following command.
d3x serve listWait until the deployment is in running state.
Building your first RAG chat application¶
Note
For detailed information regarding this section, please refer to Creating and accessing the chatbot application.
From the DKubeX UI, open and log into the SecureLLM application. Once open, click on the Admin Login button and log in using the admin credentials provided during installation.
Hint
In case you do not have the credentials for logging in to SecureLLM, please contact your administrator.
On the left sidebar, click on the Keys menu and go to the Application Keys tab on that page.
To create a new key for your application, use the following steps:
On the API key name field, provide a unique name for the key to be created.
From the LLM Keys dropdown list, select DKUBEX.
From the Models dropdown list, select your deployed base model.
Click on the Generate Key button.
A pop-up window will show up on your screen containing the application key for your new application. Alternatively, you can also access your application key from the list of keys in the Application Key tab.
Copy this application key for further use, as it will be required to create the chatbot application. Also make sure that you are copying the entire key including the sk- part.
From the DKubeX UI, go to the Terminal application.
You will need to configure and use the
query.yamlfile from the dkubex-examples repo to be used in the query process in the Securechat application.Run the following command to put the
query.yamlfile on your workspace.cd && cp dkubex-examples/rag/query/query.yaml ${HOMEDIR}/query.yamlRun
vim ${HOMEDIR}/query.yamland provide the following details on thequery.yamlfile. Once provided, save the file.On the
datasetfield, provide the name of the dataset you created earlier, i.e.contracts.On the
embeddingfield, provide the type of the embedding model used for ingestion, i.e.huggingface.In the
synthesizersection, provide the following details:On the
llmfield, make suredkubexis selected.On the
llm_urlfield, provide the endpoint URL of the deployed model to be used. The endpoint URL can be found on the Deployments page of DKubeX UI.On the
llm_keyfield, provide the serving token for the deployed model to be used. To find the serving token, go to the Deployments page of DKubeX UI and click on the deployed model name. The serving token will be available on the model details page.
Under the
Embedding Model configsection, uncomment the entirehuggingfacesection. Here the name of the embedding model to be used is provided.In the
securellmsection, provide the following details:On the
appkeyfield, provide the application key that you created earlier on the SecureLLM application.On the
dkubex_urlfield, provide the URL to access DKubeX.
You will need to configure and use the
securechat.yamlfile from the dkubex-examples repo to configure and create the chatbot application.Run the following command to put the
securechat.yamlfile on your workspace.cd && cp dkubex-examples/rag/securechat/securechat.yaml ${HOMEDIR}/securechat.yamlRun
vim ${HOMEDIR}/securechat.yamland provide the following details on thesecurechat.yamlfile. Once provided, save the file.On the
name:field, provide a unique name to be used for the chatbot application. In this example, we will use the namendabase.On the
env:SECUREAPP_ACCESS_KEY:field, provide a password which will be used to access the chatbot application.On the
env:FMQUERY_ARGS:field, provide the following details:Use the argument
llmto specify that the chatbot application will use the LLM model deployment (llama38bbase) in DKubeX.Provide the name of the dataset, i.e.
contractsafter the--datasetflag.Provide the absolute path of the
query.yamlfile that you created earlier after the--configflag. It should be/home/<your username>/query.yamlfor this example. Replace the<your username>part with your DKubeX username.
On the
ingressprefix:field, provide a unique prefix to be used for the chatbot application. In this example, we will use the prefix/ndabase. This will be used in the application URL. e.g.https://123.45.67.89:32443/ndabase
Launch the app deployment with the following command:
d3x apps create --config ${HOMEDIR}/securechat.yamlTo check the status of the app deployment, use the following command:
d3x apps listOnce the app deployment status becomes running, you can access the application from the Apps page of DKubeX UI. Provide the application key that you set in the
SECUREAPP_ACCESS_KEYfield earlier to start using the chat application.
Hint
You can ask the following questions to the chatbot when using the ContractsNLI dataset:
How do I frame a confidential information clause?
What is the difference between a unilateral and mutual NDA?
What are some common exceptions to confidential information clauses?
Tutorials and More Information¶
For more examples including how to train and register models and deploy user applications, please visit the following pages and go through the table provided:
Training Fashion MNIST model in DKubeX
Finetuning open-source LLMs
Deploying models registered in MLFlow in DKubeX
Deploying models from Huggingface repo
Deploying LLM registered in DKubeX
Creating a Securechat App using BGE-large Embeddings and Llama3-8b Summarisation Models
Wine Model Finetuning using Skypilot
Llama2 Finetuning using SkyPilot