If you're not into AI, you probably won't like this guide.
If you're not into AI, you probably won't like this guide.
Unleash your full potential as a Swift developer with the all-new Swift Career Accelerator: the most comprehensive, career-transforming learning resource ever created for iOS development.
Whether youâre just starting out, looking to land your first job, or aiming to become a lead developer, this program offers everything you need to level up â from mastering Swiftâs latest features to conquering interview questions and building robust portfolios.
So, if you're ready for a guided journey that will elevate your skills and accelerate your career, read onâŠ
The Swift Career Accelerator aims to give you a complete pathway to take your career forward, no matter what your level is right now.
It does this by bringing together for the first time the world's largest collection of Swift development resources in one place, then carefully organizes it across five career stages so that everyone at every level has something to take them forwardâŠ
If youâre just starting out, Level 1 is designed to help you build the foundation for a successful career in Swift development. Along with my popular 100 Days of SwiftUI and Ultimate Portfolio App courses, youâll gain exclusive access to my brand-new Take Home Test course. Youâll master essential skills like Git source control and dive into critical data structures like queues, stacks, and trees.
But thatâs just the beginning. Youâll also get a wealth of new interview questions with expert answers, step-by-step guidance on crafting a standout resume, and practical tips for launching your first apps on the App Store. Everything you need to land that first job and start building your future is right here.
Once you've found your first job, it's time to build on that foundation and take your skills to the next level. Here you'll move on to more detailed topics such as **gen...
Before diving in, let's take a moment to review the key resources and foundational concepts that will guide us through this blog. That will ensure we're well-equipped to follow along. This brief review will provide a strong starting point for exploring the main topics ahead.
Our hands-on learning will be developing an AI-based solution that helps the user extract financial information and insights from investment/finance books and newspaper in our database.
The process is divided into three main parts:
{"messages": [{"role": "system", "content": "content goes here"}, {"role": "user", "content": "query goes here?"}, {"role": "assistant", "content": "response goes here."}]}.
To satisfy this, we prepared our two data sets training_data.jsonl and val_data.jsonl for training and validation, respectively.
Below is an example of our training_data.jsonl:
{"messages": [{"role": "system", "content": "You are a helper in finance and an advisor in investment"}, {"role": "user", "content": "What makes a successful startup?"}, {"role": "assistant", "content": "Luck, hard work, and maybe skills... mostly luck, hard work, and consistency."}]}
Both data files are attached to this blog. They were collected manually through some examples.
# Initialize AzureOpenAI client client = AzureOpenAI( azure_endpoint=azure_oai_endpoint, api_key=azure_oai_key, api_version=version # Ensure this API version is correct ) training_file_name = r'pathâ validation_file_name = r'pathâ try: # Upload the training dataset file with open(training_file_name, "rb") as file: training_response = client.files.create( file=file, purpose="fine-tune" ) training_file_id = training_response.id print("Training file ID:", training_file_id) except Exception as e: print(f"Error uploading training file: {e}") try: # Upload the validation dataset file with open(validation_file_name, "rb") as file: validation_response = client.files.create( file=file, purpose="fine-tune" ) validation_file_id = validation_response.id print("Validation file ID:", validation_file_id) except Exception as e: print(f"Error uploading validation file: {e}")
The concept here is to rely on the model's knowledge + usersâ documentation. We have two options and both provide high precision for responses:
Also, for integration, we have two ways we may follow: through the Azure OpenAI User Interface and deploying into an Azure static web app or develop your own web app and use the Azure SDK to integrate your model.
1- Deploying into Azure static web app
2- Develop your own web App and use Azure SDK
client = AzureOpenAI( base_url=f"{azure_oai_endpoint}/openai/deployments/{azure_oai_deployment}/extensions", api_key=azure_oai_key, api_version="2023-09-01-preview)
extension_config = dict( dataSources= [ { "type": "AzureCognitiveSearch", "parameters": { "endpoint": azure_search_endpoint, "key": azure_search_key, "indexName": azure_search_index, } } ] )
Note: When you implement RAG, make sure that the chat response wonât rely solely on it. You may get a response such as âThis information is not available in your data source,â which indicates that the model is based only on searching your data and did not provide answers from the data it was trained with to generate suitable responses.
RAG is used to enhance a model's capabilities by adding more grounded information, not to eliminate the modelâs internal knowledge.
Some issues that you may face during development:
Next, you can look at how to do real-time injection so that you personalize more of the responses. Try to find how to rely between your web app, the user's input I/O, the searching index, and LLM.
Keyword: Langchain, Databricks
The Future of AI: LLM Distillation just got easier
Part 2 - Fine-Tuning Llama 3.1 8B on Azure AI Serverless
How Azure AI Serverless Fine-tuning, LoRA, RAFT and the AI Python SDK are streamlining fine-tuning of domain specific models. (đđ„ Github recipe repo).
By Cedric Vidal, Principal AI Advocate, Microsoft
Part of the Future of AI đ series initiated by Marco Casalaina with his Exploring Multi-Agent AI Systems blog post.
AI-powered engine fine-tuning setup, generated using Azure OpenAI DALL-E 3
In our previous blog post, we explored utilizing Llama 3.1 405B with RAFT to generate a synthetic dataset. Today, youâll learn how to fine-tune a Llama 3.1 8B model with the dataset you generated. This post will walk you through a simplified fine-tuning process using Azure AI Fine-Tuning as a Service, highlighting its ease of use and cost efficiency. Weâll also explain what LoRA is and why combining RAFT with LoRA provides a unique advantage for efficient and affordable model customization. Finally, weâll provide practical, step-by-step code examples to help you apply these concepts in your own projects. > The concepts and source code mentioned in this post are fully available in the Github recipe repo.
Azure AI takes the complexity out of the equation. Gone are the days when setting up GPU infrastructure, configuring Python frameworks, and mastering model fine-tuning techniques were necessary hurdles. Azure Serverless Fine-Tuning allows you to bypass the hassle entirely. Simply upload your dataset, adjust a few hyperparameters, and start the fine-tuning process. This ease of use democratizes AI development, making it accessible to a wider range of users and organizations.
Fine-tuning a model used to be a daunting task:
Azure AI Fine-Tuning as a Service eliminates these barriers by providing an intuitive platform where you can fine-tune models without worrying about the underlying infrastructure. With serverless capabilities, you simply upload your dataset, specify hyperparameters, and hit the âfine-tuneâ button. This streamlined process allows for quick iterations and experimentation, significantly accelerating AI development cycles.
Llama relaxing in a workshop, generated using Azure OpenAI DALL-E 3
LoRA (Low-order Rank Adaptation) is an efficient method for fine-tuning large language models. Unlike traditional fine-tuning, which updates all the modelâs weights, LoRA modifies only a small fraction of the weights captured in an adapter. This focused approach drastically reduces the time and cost needed for fine-tuning while maintaining the modelâs performance.
LoRA fine-tunes models by selectively adjusting a small fraction of weights via an adapter, offering several advantages:
Illustration of LoRA Fine-tuning. This diagram shows a single attention block enhanced with LoRA. Each attention block in the model typically incorporates its own LoRA module. SVG diagram generated using Azure OpenAI GPT-4o
Weâve seen how Serverless Fine-tuning on Azure AI uses LoRA, which updates only a fraction of the weights of the model and can therefore be so cheap and fast.
With the combination of RAFT and LORA, the model is not taught new fundamental knowledge, indeed it becomes an expert at understanding the domain, focusing its attention on the citations that are the most useful to answer a question but it doesnât contain all the information about the domain. It is like a librarian (see RAG Hack session on RAFT), a librarian doesnât know the content of all the books perfectly, but it knows which books contain the answers to a given question.
Another way to look at it is from a standpoint of information theory. Because LoRA only updates a fraction of the weights, there is only so much information you can store in those weights as opposed to full weight fine tuning which updates all the weight bottom to top of the model.
LoRA might look like a limitation but itâs actually perfect when used in combination with RAFT and RAG. You get the best of RAG and fine-tuning. RAG provides access to a potentially infinite amount of reference documents and RAFT with LoRA provides a model which is an expert at understanding the documents retrieved by RAG at a fraction of the cost of full weight fine-tuning.
Azure AI empowers developers with serverless fine-tuning via an API, simplifying the integration of fine-tuning processes into automated AI operations (AI Ops) pipelines. Organizations can use the Azure AI Python SDK to further streamline this process, enabling seamless orchestration of model training workflows. This includes systematic data handling, model versioning, and deployment. Automating these processes is crucial as it ensures consistency, reduces human error, and accelerates the entire AI lifecycleâfrom data preparation, through model training, to deployment and monitoring. By leveraging Azure AIâs serverless fine-tuning API, along with the Python SDK, organizations can maintain an efficient, scalable, and agile AI Ops pipeline, ultimately driving faster innovation and more reliable AI systems.
One critical aspect of machine learning, especially in fine-tuning, is ensuring that models generalize well to unseen data. This is the primary purpose of the evaluation phase.
However, as domains evolve and documents are added or updated, models will inevitably begin to drift. The rate of this drift depends on how quickly your domain changes; it could be a month, six months, a year, or even longer.
Therefore, itâs essential to periodically refresh your model and execute the distillation process anew to maintain its performance.
Moreover, the field of AI is dynamic, with new and improved foundational models being released frequently. To leverage these advancements, you should have a streamlined process to re-run distillation on the latest models, enabling you to measure improvements and deploy updates to your users efficiently.
Automation in the distillation process is crucial. As new documents are added or existing ones are updated, your modelâs alignment with the domain can drift over time. Setting up an automated, end-to-end distillation pipeline ensures that your model remains current and accurate. By regularly re-running the distillation, you can keep the model aligned with the evolving domain, maintaining its reliability and performance.
Now that weâve explained the benefits, letâs walk through the practical steps using the raft-distillation-recipe repository on GitHub.
If you have not yet run the synthetic data generation phase using RAFT, I invite you to head over the previous article of this blog series.
Once you have your synthetic dataset on hand, you can head over to the finetuning notebook of the distillation recipe repository.
Here are the key snippets of code illustrating how to use the Azure AI Python SDK to upload a dataset, subscribe to the Markerplace offer, create and submit a fine-tuning job on the Azure AI Serverless platform.
The following code checks if the training dataset already exists in the workspace and uploads it only if needed. It incorporates the hash of the dataset into the filename, facilitating easy detection of whether the file has been previously uploaded.
from azure.ai.ml.entities import Data dataset_version = "1" train_dataset_name = f"{ds_name}_train_{train_hash}" try: train_data_created = workspace_ml_client.data.get(train_dataset_name, version=dataset_version) print(f"Dataset {train_dataset_name} already exists") except: print(f"Creating dataset {train_dataset_name}") train_data = Data( path=dataset_path_ft_train, type=AssetTypes.URI_FILE, description=f"{ds_name} training dataset", name=train_dataset_name, version=dataset_version, ) train_data_created = workspace_ml_client.data.create_or_update(train_data) from azure.ai.ml.entities._inputs_outputs import Input training_data = Input( type=train_data_created.type, path=f"azureml://locations/{workspace.location}/workspaces/{workspace._workspace_id}/data/{train_data_created.name}/versions/{train_data_created.version}" )
This step is only necessary when fine-tuning a model from a third party vendor such as Meta or Mistral. If youâre fine-tuning a Microsoft first party model such as Phi 3 then you can skip this step.
from azure.ai.ml.entities import MarketplaceSubscription model_id = "/".join(foundation_model.id.split("/")[:-2]) subscription_name = model_id.split("/")[-1].replace(".", "-").replace("_", "-") print(f"Subscribing to Marketplace model: {model_id}") from azure.core.exceptions import ResourceExistsError marketplace_subscription = MarketplaceSubscription( model_id=model_id, name=subscription_name, ) try: marketplace_subscription = workspace_ml_client.marketplace_subscriptions.begin_create_or_update(marketplace_subscription).result() except ResourceExistsError as ex: print(f"Marketplace subscription {subscription_name} already exists for model {model_id}")
finetuning_job = CustomModelFineTuningJob( task=task, training_data=training_data, validation_data=validation_data, hyperparameters={ "per_device_train_batch_size": "1", "learning_rate": str(learning_rate), "num_train_epochs": "1", "registered_model_name": registered_model_name, }, model=model_to_finetune, display_name=job_name, name=job_name, experiment_name=experiment_name, outputs={"registered_model": Output(type="mlflow_model", name=f"ft-job-finetune-registered-{short_guid}")}, )
The following snippet will submit the previously created fine-tuning job to the Azure AI serverless platform. If the submission is successful, the job details including the Studio URL and the registered model name will be printed. Any errors encountered during the submission will be displayed as well.
try: print(f"Submitting job {finetuning_job.name}") created_job = workspace_ml_client.jobs.create_or_update(finetuning_job) print(f"Successfully created job {finetuning_job.name}") print(f"Studio URL is {created_job.studio_url}") print(f"Registered model name will be {registered_model_name}") except Exception as e: print("Error creating job", e) raise e
The full runnable code is available in the previously mentioned finetuning notebook.
We invite you to join our tech community on Discord to discuss fine-tuning techniques, RAFT, LoRA, and more. Whether youâre a seasoned AI developer or just starting, our community is here to support you. Share your experiences, ask questions, and collaborate with fellow AI enthusiasts. Join us on Discord and be part of the conversation!
This concludes the second installment of our blog series on fine-tuning the Llama 3.1 8B model with RAFT and LoRA, harnessing the capabilities of Azure AI Serverless Fine-Tuning. Today, weâve shown how these advanced technologies enable efficient and cost-effective model customization that precisely meets your domain needs.
By integrating RAFT and LoRA, you can transform your models into specialists that effectively navigate and interpret relevant information from extensive document repositories using RAG, all while significantly cutting down on the time and costs associated with full weight fine-tuning. This methodology accelerates the fine-tuning process and democratizes access to advanced AI capabilities.
With the detailed steps and code snippets provided, you now have the tools to implement serverless fine-tuning within your AI development workflow. Leveraging automation in AI Ops will help you maintain and optimize model performance over time, keeping your AI solutions competitive in an ever-changing environment.
Stay tuned! In two weeks, weâll dive into the next topic: deploying our fine-tuned models.
1015. The Chicago Manual of Style is updated every seven years, and this year's update is a big one! I talked with two of the editors â Russell Harper and Mary Laur â about the major changes, how the decisions get made, and the history of the CMOS (pronounced "sea moss").
đ Share your familect recording in a WhatsApp chat.
đ Watch my LinkedIn Learning writing courses.
đ Subscribe to the newsletter.
đ Take our advertising survey.Â
đ Get the edited transcript.
đ Get Grammar Girl books.Â
đ Join Grammarpalooza. Get ad-free and bonus episodes at Apple Podcasts or Subtext. Learn more about the difference.Â
| HOST: Mignon Fogarty
| VOICEMAIL: 833-214-GIRL (833-214-4475).
| Grammar Girl is part of the Quick and Dirty Tips podcast network.
| Theme music by Catherine Rannus.
| Grammar Girl Social Media Links: YouTube. TikTok. Facebook.Threads. Instagram. LinkedIn. Mastodon.