As mentioned in the introduction, model customization refers to adapting a pretrained foundation model to perform a specific task or cater to a particular domain. Model customization is achieved by customizing the foundation model on a task-specific dataset or by adjusting its prompts or parameters to optimize its performance for the wanted use case. Customization enhances the model's ability to generate accurate and contextually relevant outputs for the targeted application.
Model customization in the generative AI workflow
Customizing a foundational model like Llama 2 typically involves several steps, although the specifics might vary depending on the platform and tools in use. To illustrate the workflow, consider the example of a city developing a chatbot for its residents, enabling residents to query the chatbot for details about city services:
- Data collection and preprocessing─Begin by collecting a dataset relevant to the specific domain or task that the model needs to perform. The dataset must comprehensively represent the language and context required for the model to understand and generate responses. Then, preprocess the data to ensure consistency by removing noise and formatting it appropriately. This preprocessing might include tasks like tokenization, lemmatization, and data augmentation.
In our example, this step involves gathering the city’s current documentation, web pages, PDFs, and other sources of information for its residents. The data must be processed so that it can be used for training the foundation model.
- Selection of the foundation model and customization method─The right choice of a foundation model and customization method is crucial. Given the dynamic nature of this field, selecting the most suitable model and method can be challenging. It is advisable to start with a smaller model and a well-understood method as recognized by the data scientists involved in the project.
- In our example, we can start with the Llama 2 7B model and LoRA as the customization technique.
- Model customization─Employ the preprocessed data to customize the foundation language model. This step also includes hyperparameter tuning, validation, and testing. In our example, this step entails training the model on the processed dataset to make it specific to the city.
- Deployment─When the customized model aligns with the performance requirements, the model is deployed on the chosen platform or application for real-world use. This deployment might involve the development of APIs, user interfaces, or other components to facilitate interactions with the model. In our example, you can deploy the chatbot on the city’s web page.
- Monitoring, iteration, and feedback─The model must be continuously monitored for its performance in real-world scenarios. You can continue to update the model based on usage and feedback.