A Comprehensive Guide for Developers: Starting with Generative AI Through Practical Use Cases

A Comprehensive Guide for Developers: Starting with Generative AI Through Practical Use Cases

Presented by Intel

Generative AI holds great potential for boosting human productivity, yet only a few businesses have the skills and resources to develop the necessary foundational models from scratch. The challenges are significant. Firstly, gathering the data to train these models is already tough and has become more difficult due to content owners asserting their intellectual property rights. Secondly, the resources required for training can be prohibitively expensive. Despite these hurdles, the societal benefits of making generative AI technologies widely available remain high.

So, how can smaller businesses or individual developers add generative AI to their applications? By creating and deploying customized versions of the larger foundational models.

The substantial investment and effort to develop new generative AI models mean they need to be versatile enough to address a wide array of uses—consider how GPT-based models have been applied so far. However, a general-purpose model might not meet the specific needs of different individuals or enterprises. Using a large general-purpose model for a specific application can also waste computing resources, time, and energy.

Therefore, most enterprises and developers can find a cost-effective solution by starting with a large generative AI model as a foundation and tailoring it to their needs. This approach offers flexibility, allowing the use of existing CPUs or AI accelerators without being constrained by shortages of specific GPUs. The focus should be on the specific use case, narrowing the scope while maximizing flexibility by using open, standards-based software and common hardware.

Using the Use Case Approach for AI Application Development

In software development, a use case outlines the target user, the problem to be solved, and how the application will solve it. This establishes product requirements, shapes the software architecture, and provides a development roadmap. Most importantly, it defines the project’s scope, specifying what doesn’t need to be included.

Similarly, defining a use case in a generative AI project can reduce the model’s size, computing needs, and energy consumption. It can also improve model accuracy by focusing on a specific dataset, lowering development efforts and costs in the process.

Several key questions can help guide the definition of a use case for generative AI:

– Data Requirements: What type and amount of training data are needed and available? Is the data structured or unstructured? What are the regulations and restrictions? How will the application process the data—batch or streaming? How frequently does the model need updates? Training large language models (LLMs) from scratch is time-consuming, so different approaches might be necessary if up-to-date information is crucial. For healthcare applications, privacy and security restrictions on patient data may require unique training and inference approaches.

– Model Requirements: The size, performance, openness, and explainability of results are important. Performance can range from billions to trillions of parameters, with examples like Llama 2 and GPT-4. While larger models usually offer better performance, smaller models might better meet specific needs. Open models allow for more customization, whereas closed models work effectively off the shelf but are limited to API access. Customization control is essential for applications requiring traceable results, such as financial statement summaries, whereas extrapolation beyond trained parameters might be acceptable for generating advertising ideas.

– Application Requirements: What accuracy, latency, privacy, and safety standards must be met? How many users will it need to handle simultaneously? How will users interact with it? The implementation will depend on whether the model should run on a low-latency edge device or in a high-capacity cloud environment.

– Compute Requirements: Once the above factors are understood, what computing resources are required? Do you need to parallelize data processing? Do your fine-tuning and inference needs differ enough to require a hybrid cloud-edge environment? Even if you have the talent and data to train a model from scratch, you must consider whether your budget allows for overhauling your computing infrastructure.

Considering these factors will help define and scope the project requirements. Budget considerations, including data engineering costs, initial development costs, and the business model for inference costs, will also influence data, training, and deployment strategies.

How Intel Generative AI Technologies Can Help

Intel offers a variety of AI hardware options to meet diverse computing requirements. They’ve optimized many data analysis and end-to-end AI tools for efficiency. Intel also provides optimized models, like the top-ranked 7 billion parameter model on the Hugging Face leaderboard as of November 2023. Teams can use pre-trained models from Hugging Face or GitHub, optimized for Intel hardware, to begin with. Then, they can pre-process their data using Intel-optimized tools such as Modin, fine-tune foundation models with tools like Intel® Extension for Transformers or Hugging Face Optimum, and automate model tuning with SigOpt. All these tools build on Intel’s contributions to open-source AI frameworks like TensorFlow, PyTorch, and DeepSpeed.

Generative AI Use Case Examples

1. Customer Service Chatbots:
Chatbots based on large language models (LLMs) can improve customer service efficiency by providing quick answers to common questions, freeing up human representatives for complex cases. Generative AI models can be fine-tuned with custom information or use retrieval-based methods like RAG to fetch information from external databases, using CPUs which are more readily available than specific AI accelerators.

2. Retail Virtual Try-Ons:
Retailers can enhance customers’ online shopping experience by allowing them to try on clothes virtually. This reduces returns and helps better predict customer preferences. Fine-tuning image-based models like Stable Diffusion can be done using techniques that ensure privacy, such as running necessary AI inferences on local edge devices.

3. Healthcare Patient Monitoring:
Generative AI can analyze real-time patient monitoring data to create personalized reports and intervention plans. Combining different models for processing various data types with LLMs for generating reports can improve productivity in healthcare. Federated learning can be employed to ensure patient data remains private, by training models locally and combining the results.

Getting Started

Begin by defining your use case using guiding questions about data, compute, model, and application requirements. Next, identify available foundation models and resources in the AI ecosystem. Implement relevant fine-tuning and optimization techniques suited to your use case. Compute needs may evolve, and platforms like Intel® Developer Cloud offer flexible access to various CPUs, GPUs, and AI accelerators. Lastly, use open, standards-based AI tools and frameworks that adapt across different compute platforms without needing to rewrite code.

Jack Erickson is Principal Product Marketing Manager, AI Software at Intel.
Chandan Damannagari is Director, AI Software, at Intel.

Notices & Disclaimers: Intel technologies may require enabled hardware, software, or service activation. No product or component can be absolutely secure. Your costs and results may vary. ©Intel Corporation. Intel, the Intel logo, and other Intel marks are trademarks of Intel Corporation or its subsidiaries. Other names and brands may be claimed as the property of others.