Experts from Gartner predict that 50% of enterprises will use GenAI models that are tailored specifically to their business domain by 2027. Those models are smaller than common models like ChatGPT, but they are trained on the business’s proprietary data and generate responses that are precise and reliable for users. Today, enterprises of different sizes are looking for ways to train large language models (LLMs) on such internal data as guidelines, databases, multimedia files, apps, presentations, etc.
In this article, a partner and Chief Innovation Officer (CINO) of a custom software development company Belitsoft, Dmitry Baraishuk, has gathered key information about methods of training AI models, challenges, best practices, and common FAQs.
DEEPER DIVE: 20 emerging business categories gaining traction in Arizona
Why Not a Ready-Made LLM?
Those who tried common LLMs such as open AI’s GPT-3 or GPT-4, admit they demonstrate several drawbacks:
- They lack real-time data. LLMs operate the information they were trained on. This means they cannot refer to the latest research, trends, or news in their answers. As a result, users may receive obsolete information as an answer to the requests.
- LLMs often substitute facts with fiction. They can generate misleading content due to the low quality of the training data.
- LLMs fail to demonstrate the reasoning of their responses. Surveys show poor abilities of LLMs to solve puzzles and logical tasks. A wider dataset is necessary to “teach” LLMs those puzzle-solving abilities.
- Models have difficulties with processing long documents. Experts from McKinsey say that context windows have become longer. However, the response time increases, and the costs for bigger input are higher.
The above-mentioned issues with the LLMs output quality force enterprises towards “personalized” generative models. They guarantee reliable content and data protection. The recent product launch of ChatGPT Gov for U.S. government agencies indicates the trend of creating secure environments for dealing with sensitive information in various business domains.
What Are the Options?
There are several ways of optimizing LLMs. They all have their pros and cons.
Fine-tuning
Reddit users rank this option high as it is relatively easy in comparison with developing a model from scratch. It involves additional training of an LLM on proprietary data after it has received the training on generic data. Fine-tuning usually includes domain-specific information that allows an LLM to perform particular requests like, for example, generating ad campaigns and banners tailored to the business’s style, tone, and branding guidelines. Fine-tuning “teaches” the LLM to understand jargon, special terms that clients use, or certain terminology, like medical concepts.
On the backside, there are high costs and the necessity to operate large datasets. Besides, a fine-tuned model struggles to perform the tasks outside its main domain. The Low-Rank Adaptation (LoRA) method can mitigate those issues. It fine-tunes only smaller matrices of the neural network and does not affect larger pre-trained layers. The AI team of the Belitsoft software development company distinguishes between the parameters that have to be customized and those that should be left unaltered.
RAG
Fine-tuning is not a perfect option for domains with a lot of dynamic data, as the initial training datasets will quickly become outdated. In this case, an LLM may fail to generate relevant content. Retrieval-Augmented Generation (RAG) is a solution.
The RAG approach combines the generation and retrieval functionality. The system retrieves the data from the indexed sources and generates responses based on this data. The advantages of this technology are the following:
- The model uses information from internal documents, text, audio, video files, PDFs, etc. So, the responses are relevant and up-to-date.
- The system can refer to a certain document that it used in generating the response, so it demonstrates better reasoning.
- RAG allows developers to tailor customers’ products to specific domains. For example, AI chatbots in customer support refer to the data from instruction manuals; on medical sites, they “study” medical documentation and clinical guidelines; on educational institutions’ resources, chatbots provide information about curriculum requirements, etc.
Prompt engineering
This method is the cheapest and it does not require additional datasets. Prompt engineers vary the wording of the requests, provide LLMs with examples, divide large tasks into pieces, etc. Those variations help to receive more accurate responses. However, prompt engineering can be less effective with domain-specific queries and it takes much time.
What Are the Challenges of AI Model Training?
- Data gathering: the responses that the model generates depend on the data it was initially trained on. It is essential to use clean and unbiased datasets. In this case, the system won’t produce misleading content.
- Infrastructure capacity: AI training needs large computational powers and storage space. Cloud-based solutions can assist with this issue.
- Data privacy: the information that the model is trained on should be secure. Trainers should double-check who has access to sensitive information. It helps to avoid situations similar to recent lawsuits against GitHub, OpenAI, and Microsoft.
How to Train a Model?
- Collect the data.
The data for training should be sufficient in volume and focused on the target use cases. The data can be natural or synthetically generated. It might be of different formats (text, video, audio files, numbers, etc.) and from multiple sources (company or public datasets, surveys, etc.).
- Clean the data.
Duplications, errors, and obsolete facts deteriorate the quality of the output. Machine learning engineers remove those issues with the help of OpenRefine or other tools. It is also important to label the data so that the model can train on it. This part requires attentive human judgment and review.
- Select frameworks and tools.
Instead of coding from scratch, developers can rely on available platforms (TensorFlow, Keras, PyTorch, Microsoft Azure AI, etc.) that facilitate the processes of training.
- Train the model.
The training itself includes, first, splitting the data into training, validation, and testing sets. Second, developers tweak the parameters of how the LLM “learns” the data. Those parameters include learning rates and batch sizes. The model reads the data, examines how the language works and starts predicting the next words and sentences in the context. Data scientists give the model examples and instructions on how to handle unfamiliar tasks. Finally, the experts grade the responses of the model to demonstrate which of them is preferable.
- Test the model.
Before integrating the model into the customer’s application, it should be tested. The AI team checks if the model generates relevant responses in the specific domain, if it uses natural language, if it is consistent, copes with solving problems, and provides factual answers without hallucinations. Such tools as TensorFlow and Scikit-Learn allow developers to evaluate the model.
Best Practices for AI Model Training
Data integrity maintenance
AI algorithms may produce inaccurate content, so enterprises that utilize this technology must be alert about keeping their data integrity. Human experts should regularly check and observe the output. This is also applicable to generative AI technologies that automate processes to avoid misleading and false information. The output should be revised before reaching the brand’s target audience.
Process refinement
AI and ML technologies are designed to free human experts from routine tasks and let them concentrate on something more challenging. That should be done progressively, delegating first of all low-risk and low-value tasks to AI. Technologies should be taught to determine the patterns that can be automated, resulting in optimized workflows and improved customer satisfaction.
Output improvement
AI models can create the feeling of live interaction for customers. Impress your clients with high-quality informative communication results. Use various evaluation metrics to assess the performance of the AI models. They can be classification, regression metrics, and cross-validation techniques such as train-test split or k-fold cross validation. Tune hyperparameters and keep records of the training process.
Safety provision
Make sure your solutions do not compromise users’ privacy. Use data anonymization, encryption, and bias detection tools to ensure fairness in AI model training and align with regulatory requirements and ethical standards.
FAQ
How long does it take to train a model?
It depends on the amount of data that the model should learn. It may take from several hours to several weeks. Machine learning specialists customize the parameters and run the code that “examines” the training data.
How much does it cost?
The AI models are becoming more complex and capable. That is why the cost of training is also exploding. To compare the figures, the cost of training earlier AI models like ChatGPT-3 was around $4 million in 2020. The latest version of ChatGPT-4 had a technology production cost of $41 to $78 million according to the Epoch AI research.
What are the domains where custom AI models are used?
- Custom AI models can analyze customer data and offer products on the basis of customer behavior in e-commerce.
- AI chatbots assist doctors in reading medical images and diagnosing.
- In finance, AI models impartially evaluate credit risks and keep track of fraudulent activities.
- AI-powered assistants and apps produce individual tutoring experiences and adapt to students’ progress and learning pace.
Who can help with AI model training?
The Belitsoft software development company offers outsourced services in LLM training, developing custom AI chatbots, and AI software integration. AI teams carefully consider the requirements of each project and develop a step-by-step roadmap to tailor solutions to the company’s proprietary data.
Author: Dmitry Baraishuk is a partner and Chief Innovation Officer at a software development company Belitsoft (a Noventiq company). He has been leading a department specializing in custom software development for 20 years. The department has hundreds of successful projects in such services as healthcare and finance IT consulting, AI software development, application modernization, cloud migration, data analytics implementation, and more for US-based startups and enterprises.