<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Faktion AI - Medium]]></title>
        <description><![CDATA[Productizing Language Models is a publication NLP and LLMs that focuses on industry applications and challenges. It is managed by engineers at Faktion AI. - Medium]]></description>
        <link>https://medium.com/productizing-language-models?source=rss----19cb311d0208---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Faktion AI - Medium</title>
            <link>https://medium.com/productizing-language-models?source=rss----19cb311d0208---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 18:20:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/productizing-language-models" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Part 2 on Azure ML Prompt Flow: Building Retrieval Augmented Generation LLM applications.]]></title>
            <link>https://medium.com/productizing-language-models/part-2-on-azure-ml-prompt-flow-building-retrieval-augmented-generation-llm-applications-b0985dabfdc2?source=rss----19cb311d0208---4</link>
            <guid isPermaLink="false">https://medium.com/p/b0985dabfdc2</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Ben Burtenshaw]]></dc:creator>
            <pubDate>Fri, 29 Sep 2023 11:03:03 GMT</pubDate>
            <atom:updated>2023-09-29T05:01:59.526Z</atom:updated>
            <content:encoded><![CDATA[<h3>Part 2 of Azure ML Prompt Flow: A Streamlined Way to Build LLM-Based AI Applications with Retrieval-Augmented Generation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IBXKZxK828SttgqVkq4xDA.png" /><figcaption>Llamas retrieving documents from an archive to help a scientist llama (SDXL v.10)</figcaption></figure><p>In our previous blog post, we discussed the introduction of Azure ML Prompt Flow, a development tool that streamlines the development process of AI applications based on LLM. This tool also supports Retrieval-Augmented Generation (RAG) applications 💡. In this post, we will delve into the technical aspects of developing and deploying RAG systems using Azure ML Prompt Flow. We will cover the basics of RAG, its benefits for LLM-based AI apps, and the steps involved in building and deploying RAG systems with Azure ML Prompt Flow 🤖.</p><h3>What is Retrieval-Augmented Generation (RAG)?</h3><p>RAG systems are an application architecture that combines LLMs with external data sources to enhance their responses. This makes RAG systems ideal for applications that require access to background knowledge, such as chatbots, recommendation systems, and question-answering systems.</p><p>RAG systems work by first retrieving relevant information from the external database. This information is then supplied to the LLM as context for a given query. This approach has several advantages over using LLMs alone.</p><h3>Why use RAG for LLM-based AI applications?</h3><p>RAG systems offer a number of benefits for LLM-based AI applications, including:</p><p><strong>Improved performance</strong>: RAG systems can provide more accurate and precise responses than LLMs alone because they are supplied with more relevant information. This is important for applications such as chatbots and question-answering systems, where users expect a relevant context to their answers.</p><p><strong>Reduced development effort</strong>: RAG systems can make it easier to develop LLM-based AI applications, as they do not require machine learning modelling.</p><p><strong>Increased scalability</strong>: RAG systems can scale to handle large databases and complex queries, which is important for applications such as recommendation systems and search engines.</p><p><strong>Reduced hallucination</strong>: RAG systems are less likely to hallucinate or produce inaccurate or nonexistent information than LLMs alone, when they are supplied with relevant information.</p><h3>Retrieving vs Finetuning</h3><p>In the NLP world, pre-trained models like the GPT series are versatile general models that can perform many tasks from rap music creation to cookery advice. Retrieval-augmented generation (RAG) systems pull real-time data from external sources to enhance responses, an alternative approach is fine-tuning. Where, for example, the LLM is adapted for a specific task or domain to increase performance.</p><p>Fine-tuning involves adapting a pre-trained model to a specific task using a smaller, task-specific dataset. This method allows the model to specialize without the computational burden of retraining from scratch. In contrast to RAG, which dynamically retrieves information, fine-tuning optimizes the model’s internal knowledge for a particular domain. It’s a more static approach but can be effective, especially when the task-specific nuances are critical.</p><p>When implementing retrieval-based systems, it’s important to remember that the model’s understanding of the context has not been altered. Therefore, a model may not handle the context information as expected. Therefore, the retrieval vs. finetuning challenge could be seen as one of freshness of knowledge vs. depth of knowledge.</p><h3>Build and deploy RAG systems with Azure ML Prompt Flow</h3><p>Azure ML Prompt Flow provides a number of features that make it easy to build and deploy RAG systems, including:</p><p><strong>Pre-built components</strong>: Azure ML Prompt Flow provides several pre-built components for working with RAG systems, such as components for retrieving data from external databases and generating responses using RAG models.</p><p><strong>Visualized flows</strong>: Azure ML Prompt Flow provides a visual interface for designing and developing RAG systems. This makes it easy to create and manage complex workflows, even for users without programming experience.</p><p><strong>Real-time endpoint deployment</strong>: Azure ML Prompt Flow allows you to deploy RAG systems as real-time endpoints. This means that you can make your RAG systems available to users immediately without worrying about managing infrastructure or scaling.</p><h3>Technical Considerations</h3><p>When building and deploying RAG systems with Azure ML Prompt Flow, there are a few technical considerations to keep in mind:</p><p><strong>Data quality</strong>: The quality of the external database significantly impacts the quality of the RAG system’s responses. It is important to make sure that the database is well-curated and that the information is accurate and up-to-date.</p><p><strong>Latency</strong>: Real-time data retrieval can lead to latency, especially for large databases or complex queries. It is important to consider the latency trade-offs when choosing the right approach for your application.</p><p><strong>Scalability</strong>: RAG systems can scale to handle large databases and complex queries. However, it is important to design your system carefully and to choose the right Azure resources to ensure that it can scale to meet demands.</p><h3>Conclusion</h3><p>Azure ML Prompt Flow is a powerful tool that can be used to build and deploy RAG systems in a streamlined and efficient manner. In this part of the blog post series, we have introduced the technical considerations of building and deploying RAG systems with Azure ML Prompt Flow. Below, we provide a hands-on tutorial on how to build and deploy a RAG chatbot using Azure ML Prompt Flow. Microsoft Learn contains a range of tutorials for RAG use cases.</p><h3>Hand-on Tutorial: RAG with AzureML PromptFlow</h3><p>With tools like AzureML and FAISS, creating a robust system for such tasks has become more accessible. In this tutorial, we’ll guide you through grounding a database into a LangChain-compatible FAISS Vector Index using AzureML. By the end, you’ll have a streamlined prompt flow that leverages this index, ready to serve as a DBCopilot chatbot.</p><h3>Step 1: Setting Up Your Environment</h3><p>Before starting the RAG setup, ensure you have the necessary packages installed. If you’re working within an Azure notebook, you can use the following commands:</p><pre>%pip install azure-ai-ml<br>%pip install -U &#39;azureml-rag[faiss]&gt;=0.1.11&#39;</pre><h3>Step 2: Configuring the Azure Machine Learning Workspace</h3><p>The Azure Machine Learning workspace is a top-level resource that provides a centralized place to work with all the artifacts you create. To connect to your workspace:</p><p>Enter your Workspace details, which will write a workspace.json file to your current folder.</p><pre>{<br>    &quot;subscription_id&quot;: &quot;&lt;subscription_id&gt;&quot;,<br>    &quot;resource_group&quot;: &quot;&lt;resource_group_name&gt;&quot;,<br>    &quot;workspace_name&quot;: &quot;&lt;workspace_name&gt;&quot;<br>}</pre><p>Use the MLClient to interact with AzureML.</p><pre>from azure.identity import DefaultAzureCredential, InteractiveBrowserCredential<br>from azure.ai.ml import MLClient<br>from azureml.core import Workspace<br>​<br>credential = InteractiveBrowserCredential()<br>​<br>ml_client = MLClient.from_config(credential=credential, path=&quot;workspace.json&quot;)<br>​<br>ws = Workspace(<br>    subscription_id=ml_client.subscription_id,<br>    resource_group=ml_client.resource_group_name,<br>    workspace_name=ml_client.workspace_name,<br>)</pre><h3>Step 3: Setting Up Azure OpenAI</h3><p>For optimal Q&amp;A performance, it’s recommended to use the gpt-35-turbo model. There are detailed instructions <a href="https://learn.microsoft.com/en-us/azure/cognitive-services/openai/how-to/create-resource?pivots=web-portal">here</a>. To set up an Azure OpenAI instance:</p><ol><li>Follow the instructions to set up an Azure OpenAI Instance and deploy the model.</li><li>Use the automatically created Default_AzureOpenAI connection or create your own.</li></ol><pre>from azureml.rag.utils.connections import create_connection_v2<br>​<br>aoai_connection_name = &quot;Default_AzureOpenAI&quot;<br>aoai_connection = get_connection_by_name_v2(ws, aoai_connection_name)<br>aoai_connection = create_connection_v2(<br>        workspace=ws,<br>        name=aoai_connection,<br>        category=&quot;AzureOpenAI&quot;,<br>        # &#39;Endpoint&#39; from Azure OpenAI resource overview<br>        target=&quot;https://&lt;endpoint_name&gt;.openai.azure.com/&quot;,<br>        auth_type=&quot;ApiKey&quot;,<br>        credentials={&quot;key&quot;: &quot;&lt;api-key&gt;&quot;},<br>        metadata={&quot;ApiType&quot;: &quot;azure&quot;, &quot;ApiVersion&quot;: &quot;2023-05-15&quot;},<br>    )</pre><p>Deploy the embedding service</p><pre>from azureml.rag.utils.deployment import infer_deployment<br>​<br>aoai_embedding_model_name = &quot;text-embedding-ada-002&quot;<br>aoai_embedding_deployment_name = infer_deployment(<br>        aoai_connection, aoai_embedding_model_name<br>)</pre><p>Deploy the GPT-3 model:</p><pre>aoai_completion_model_name = &quot;gpt-35-turbo&quot;<br>aoai_completion_deployment_name = infer_deployment(<br>        aoai_connection, aoai_completion_model_name<br>)</pre><h3>Step 4: Setup the SQL Datastore</h3><h4>Connecting to a SQL Datastore</h4><p>We need a SQL datastore to retrieve from, for the sake of this example let’s create a generic one via AzureML.</p><ol><li>Go to the workspace in the Azure Portal.</li><li>Click on <strong>Data</strong> -&gt; <strong>Datastore</strong> -&gt; <strong>+ Create</strong>.</li><li>Fill in the datastore form with the necessary details.</li></ol><h3>Step 5: Building and running the RAG Pipeline</h3><p>The core of our setup is the AzureML Pipeline. This pipeline grounds a database into a LangChain-compatible FAISS Vector Index, which can then be used as a DBCopilot chatbot. Retrieve the necessary components from the AzureML registry and define the pipeline. The pipeline involves:</p><p>Building a pipeline function around the component</p><pre>from azure.ai.ml.dsl import pipeline<br>​<br>​<br>@pipeline(name=f&quot;db_copilot_vector_pipeline_faiss&quot;, default_compute=&quot;serverless&quot;)<br>def db_copilot_vector_pipeline_faiss(<br>    aoai_connection: str,<br>    db_datastore: str,<br>    embeddings_model: str,<br>    chat_aoai_deployment_name: str,<br>    embedding_aoai_deployment_name: str,<br>    mlindex_dataset_name: str,<br>    selected_tables: str = None,<br>    max_sampling_rows: int = 3,<br>):<br>    db_copilot_component(<br>        db_datastore=db_datastore,<br>        embeddings_model=embeddings_model,<br>        chat_aoai_deployment_name=chat_aoai_deployment_name,<br>        embedding_aoai_deployment_name=embedding_aoai_deployment_name,<br>        embeddings_dataset_name=mlindex_dataset_name,<br>        embedding_connection=aoai_connection,<br>        llm_connection=aoai_connection,<br>        selected_tables=selected_tables,<br>        max_sampling_rows=max_sampling_rows,<br>    )<br>    return {}</pre><p>Defining the pipeline job.</p><pre>datastore_name = &quot;&lt;test_db_datastore_name&gt;&quot;<br>aoai_embedding_model_name = &quot;text-embedding-ada-002&quot;<br>asset_name = &quot;llm_index_db_dataset&quot;<br>embeddings_model=f&quot;azure_open_ai://deployment/{aoai_embedding_deployment_name}/model/{aoai_completion_model_name<br>db_datastore=f&quot;azureml://datastores/{datastore_name}&quot;<br>selected_tables=&#39;[&quot;[dbo].[jobs]&quot;]&#39;<br>pipeline_job = db_copilot_vector_pipeline_faiss(<br>    aoai_connection=aoai_connection_id,<br>    db_datastore=db_datastore,<br>    embeddings_model=embeddings_model,<br>    chat_aoai_deployment_name=aoai_completion_deployment_name,<br>    embedding_aoai_deployment_name=aoai_embedding_deployment_name,<br>    mlindex_dataset_name=asset_name,<br>    selected_tables=selected_tables,<br>    max_sampling_rows=3,<br>)<br>​<br>pipeline_job.properties[&quot;azureml.mlIndexAssetName&quot;] = asset_name<br>pipeline_job.properties[&quot;azureml.mlIndexAssetKind&quot;] = &quot;faiss&quot;<br>pipeline_job.properties[&quot;azureml.mlIndexAssetSource&quot;] = &quot;Database&quot;</pre><p>Running the pipeline job</p><pre>running_pipeline_job = ml_client.jobs.create_or_update(<br>    pipeline_job, experiment_name=&quot;db_copilot_pipeline&quot;<br>)<br>ml_client.jobs.stream(running_pipeline_job.name)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0985dabfdc2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/productizing-language-models/part-2-on-azure-ml-prompt-flow-building-retrieval-augmented-generation-llm-applications-b0985dabfdc2">Part 2 on Azure ML Prompt Flow: Building Retrieval Augmented Generation LLM applications.</a> was originally published in <a href="https://medium.com/productizing-language-models">Faktion AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part 1 of Prompt Flow in Azure Machine Learning: Industry-grade prompt management]]></title>
            <link>https://medium.com/productizing-language-models/part-1-of-prompt-flow-in-azure-machine-learning-industry-grade-prompt-management-87b5b6f853d4?source=rss----19cb311d0208---4</link>
            <guid isPermaLink="false">https://medium.com/p/87b5b6f853d4</guid>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Ben Burtenshaw]]></dc:creator>
            <pubDate>Fri, 29 Sep 2023 11:02:48 GMT</pubDate>
            <atom:updated>2023-09-19T05:01:46.753Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5qzgZ8bohYnyyuFMvNQqUw.png" /><figcaption>“A mandala of a machine learning pipeline in a flowing river, with llamas and golden retrievers surfing on it” (SDXL v1.0)</figcaption></figure><p>The prompt management scene now includes Azure, which has added a suite of new features to Azure ML. I have experimented with these features over the past few weeks and created a three-part blog series 📝. This series is intended for those who want to enhance their work using industry-grade tools 💻.</p><p>LLMs have emerged as a powerful tool for a myriad of applications. It’s clearly straightforward to rapidly prototype applications that would have been unimaginable a year ago. However, developing and deploying LLM-based AI applications can be a complex endeavour. Enter Azure Machine Learning prompt flow, a groundbreaking development tool that promises to revolutionize how we approach LLM-based AI application development. Prompt flow is integrated within Azure’s ML workspace, which is already a robust platform for machine learning.</p><p>Azure Machine Learning prompt flow isn’t just another development tool. It’s a comprehensive platform with LLM specific benefits. This post will introduce the key concepts and show how to set it up.</p><h3>Prompt Flow Methodology</h3><p>Azure, known for its vast array of feature-laden offerings, designs its products grounded in a specific methodology. Through my experience with offerings like Azure ML and Synapse, I realized that understanding the underlying philosophy of the product significantly enhances its usability.</p><p>Azure splits prompt engineering into four phases; Initialisation, Experimentation, Evaluation / Refinement, and Production.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xVacxmrqua1fvWl1F-hwIA.png" /></figure><p><strong>Initialization</strong>: Start by pinpointing the business requirement, aggregating sample data, and mastering the creation of a foundational prompt. Subsequently, evolve a flow to broaden its utility.</p><p><strong>Experimentation</strong>: Test your flow using the sample data. Analyze the efficacy of the prompt and, if required, modify the flow. This stage may entail repeated testing to ensure the desired outcome is achieved.</p><p><strong>Evaluation &amp; Refinement</strong>: Test the flow with an expansive dataset to determine its reliability. Assess the efficacy of the prompt and make the necessary tweaks. If the outcomes align with your objectives, transition to the subsequent phase.</p><p><strong>Production</strong>: Streamline the flow to ensure both efficiency and effectiveness. Once deployed, vigilantly monitor its performance in a real-world environment and collate data about its usage and feedback. Utilize these insights to enhance the flow and inform potential modifications in preceding stages.</p><h3>Prompt Flow Entities</h3><p>Prompt flow abstract the building blocks of a prompt engineering stack in a family of expected entities. In the following posts, I’ll connect these in examples.</p><h4><strong>Connections</strong></h4><p>Connections in Prompt flow link your application with remote APIs or data sources. They’re the guardians of vital info, like endpoints and secrets, ensuring everything communicates securely and efficiently.</p><p>Within the Azure Machine Learning workspace, you’ve got options. You can set up connections as shared resources or keep them private. And for those concerned about security, all secrets are safely stored in Azure Key Vault, meeting top-notch security standards. You can also build custom connections in Python.</p><h4><strong>Runtimes</strong></h4><p>Runtimes in Prompt flow are the compute resources that your application will use. They rely on Docker images that are loaded with all the tools you might need.</p><p>In the Azure Machine Learning workspace, there’s a default environment to kick things off, referencing the prebuilt Docker image. You can also customize and roll out your unique environment in the workspace, which will be a familiar feature to Azure ML users.</p><p>Prompt flow offers Managed Online Deployment Runtime and Compute Instance Runtime. The first offers a managed scalable solution that satisfies most applications but lacks some of the managed identity features. Under the hood, this abstracts Azure ML online endpoints. The compute instance runtime offers a more detailed definition but could be more horizontally scalable. This abstracts Azure ML compute instances.</p><h4><strong>Flows</strong></h4><p>Flows are the center piece of PromptFlow. They represent the foundational schema of your LLM-based AI application. This paradigm predominantly emphasizes orchestrating data movement and processing in a methodical and structured manner. They are the ‘pipeline’ of the prompt engineering methodology.</p><p>Central to the flow’s architecture are the nodes, each symbolizing a distinct utility tool. These nodes manage data, execute specific tasks, and administer algorithms. For aficionados of granular customization, the user interface has been meticulously crafted to cater to your needs. Its design is reminiscent of a technical notebook, facilitating easy adjustments to settings or direct interactions with underlying code. Furthermore, the pipeline-style DAG visualisation provides a panoramic perspective on the interrelationships between various components.</p><h4><strong>Tools</strong></h4><p>The tools provided within the Prompt flow implement explicit features that LLMs can utilise to perform tasks. Typically, collecting fresh data from the web, or performing operations that are not suited to language models. Such features are familiar to LangChain and LLamaIndex users.</p><p>According to the official <a href="https://chat.openai.com/c/link-to-the-documentation-page">documentation</a> of PromptFlow.</p><blockquote><em>“Tools are the foundational elements of a flow in Azure Machine Learning’s Prompt flow. They function as simple, executable entities, each honed for a particular task. This modular approach empowers developers to amalgamate these tools and carve out a flow tailored to diverse objectives.”</em></blockquote><p><strong>LLM Tool:</strong> Designed for custom prompt creation, the LLM Tool utilizes the capabilities of large language models for tasks like content summarization and automated customer responses.</p><p><strong>Python Tool:</strong> This tool supports the development of custom Python functions, suitable for web scraping, data processing, and third-party API integration.</p><p><strong>Prompt Tool: </strong>Primarily used for string-based prompt preparation, the Prompt Tool is optimized for complex scenarios and works seamlessly with other prompt and Python tools. For example, you could use this to process the output of your LLM to JSON.</p><p>A Word of Caution: It’s important to note that as of now, Prompt flow is still in its public preview phase. This means there’s no service-level agreement tied to it, making it less ideal for production-level tasks. Features are still being refined, and some may possess limited capabilities. I found that a number of the example Tools were less ready than other features.</p><h4><strong>Variants</strong></h4><p>In the world of Prompt flow, a variant is like a unique version of a tool node, each with its settings. Right now, this is a feature of the LLM tool. Think of it this way: if you’re trying to summarize a news article, you can play around with different prompt versions or connection settings. It’s all about finding the perfect blend for your needs.</p><h3>Conclusion</h3><p>Whether you’re a seasoned developer or just starting out in the world of AI, Azure Machine Learning prompt flow offers the tools, resources, and guidance to ensure that your LLM-based AI applications are a resounding success. Dive in and experience the future of AI development today!</p><p>Remember, Prompt flow is in public preview, so it might not be suitable for production workloads yet. Always refer to the official documentation for detailed steps and updates.</p><h3><strong>Using Prompt Flow</strong></h3><p>There’s already a handy guide on using PromptFlow on <a href="https://learn.microsoft.com/en-us/azure/machine-learning/prompt-flow/get-started-prompt-flow?view=azureml-api-2">Microsoft Learn</a>. I’ve condensed it here for ease. In the later posts, I’ll go into more detail with some tutorials.</p><h3><strong>References</strong></h3><ul><li>Ready to dive into the world of Azure Machine Learning prompt flow? Here are some resources to get you started:</li><li><a href="#">Get started in Prompt flow (preview) — Azure Machine Learning</a></li><li><a href="#">Learn how to use Prompt flow in Azure Machine Learning studio</a></li><li><a href="#">Prompt tool in Azure Machine Learning prompt flow (preview) — Azure Machine Learning</a></li><li><a href="#">LLM tool in Azure Machine Learning prompt flow (preview) — Azure Machine Learning</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87b5b6f853d4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/productizing-language-models/part-1-of-prompt-flow-in-azure-machine-learning-industry-grade-prompt-management-87b5b6f853d4">Part 1 of Prompt Flow in Azure Machine Learning: Industry-grade prompt management</a> was originally published in <a href="https://medium.com/productizing-language-models">Faktion AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Guided text generation with Large Language Models]]></title>
            <link>https://medium.com/productizing-language-models/guided-text-generation-with-large-language-models-d88fc3dcf4c?source=rss----19cb311d0208---4</link>
            <guid isPermaLink="false">https://medium.com/p/d88fc3dcf4c</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[prompt-engineering]]></category>
            <dc:creator><![CDATA[Arian Pasquali]]></dc:creator>
            <pubDate>Wed, 20 Sep 2023 12:41:42 GMT</pubDate>
            <atom:updated>2023-09-20T13:53:51.617Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xe9X2BIM9Yz5x371u9Oj6w.png" /><figcaption>An anthropomorphic llama writing a journal in a Bedouin camp from a mystical desert world (StableDifusionXL v1.0)</figcaption></figure><p>Large Language Models (LLMs) have not only advanced the field of text generation but have also set higher standards for most NLP-related tasks. By being trained on huge volumes of textual data, these models possess the capability to comprehend and produce text that is often indistinguishable from human-written content. With their ability to generate coherent and contextually relevant responses, the first obvious application for these models is chatbots or creative writing assistants.</p><p>Beyond chatbots, their capabilities have also been demonstrated across diverse NLP tasks, including language translation, text summarization, question answering, and general content generation. For instance, in discriminative tasks such as document classification, sentiment analysis and named entity recognition, LLMs can be used employing <a href="https://thegradient.pub/in-context-learning-in-context/">in-context learning</a> to get few-shot or even zero-shot classification. They are also widely used for data augmentation generating synthetic training data for traditional models [<a href="https://www.semanticscholar.org/paper/Is-a-prompt-and-a-few-samples-all-you-need-Using-in-M%C3%B8ller-Dalsgaard/ca3037fed8ed14dea92985b9f288b05185f867d0">1</a>], [<a href="https://www.semanticscholar.org/paper/Do-Not-Have-Enough-Data-Deep-Learning-to-the-Anaby-Tavor-Carmeli/7eba731a7fd8de712b7b79b5af41a6e2d4dbd191)">2</a>], and [<a href="https://www.semanticscholar.org/paper/Generating-Faithful-Synthetic-Data-with-Large-A-in-Veselovsky-Ribeiro/5af9cf0b695faf2eb94d74bf76dab1a311638ca3">3</a>].</p><p>From chatbots that can engage in human-like conversations to language translation services that can provide real-time translations, LLMs have transformed the way we interact with software. However, they also present new challenges. Issues such as hallucination, fine-tuning limitations, context size, and memory add new layers of complexity for deterministic systems.</p><p>Although large language models excel at producing coherent responses, ensuring their outputs respect a specific format is not guaranteed. Consequently, this can present challenges when utilizing the outputs of a language model as input for another system. Here we may want to get more structured information than just text back. To use them as software components we need a reliable interface to be able to connect with external tools. These integrations are possible with friendly serialization formats like JSON or XML.</p><p>The scope of this blog post is to explore recent developments for controlled text generation, more specifically generating valid JSON outputs. Generating structured JSON from language models can be tricky and unreliable sometimes. The generated JSON must be syntactically correct, and it must conform to a schema that specifies the structure of the JSON. This allows developers to more reliably get structured data back from the model.</p><p>It is worth mentioning that Open AI has made the task easier by introducing the <a href="https://openai.com/blog/function-calling-and-other-api-updates">Function calling feature</a> in June 2023. However, this feature is only suitable if interoperability with other models or providers is not a requirement. Our focus in this post will be on solutions that can be utilized with a broader range of generative models.</p><h3>Approach 1: Prompt engineering and output parsers</h3><p>Output parsers process the language model response trying to fit it in the desired structure. We can see it as a postprocessing step. The one we will cover here is an <a href="https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/output_parsers/pydantic.py">implementation</a> provided by <a href="https://python.langchain.com/docs">Langchain</a> that relies on the well-known <a href="https://docs.pydantic.dev/latest/usage/models/">Pydantic models</a> to define the data structure. For the Langchain library, there are two main components an output parser must implement:</p><ul><li><strong>Format instructions</strong>: A method that returns a string containing instructions for how the output of a language model should be formatted.</li><li><strong>Parser</strong>: A method that takes in a string (assumed to be the response from a language model) and parses it into some structure.</li></ul><h4>Pydantic Output Parser</h4><p>This <a href="https://python.langchain.com/docs/modules/model_io/output_parsers/pydantic">output parser</a> allows users to specify an arbitrary JSON schema and query LLMs for JSON outputs that conform to that schema. You’ll have to use an LLM with sufficient capacity to generate well-formed JSON. In the OpenAI family, GPT-3 DaVinci might be enough and GPT3 Curie’s ability already drops off dramatically.</p><p>Here is a simple example defining the object <em>Joke</em>:</p><pre>from pydantic import BaseModel, Field<br>from langchain.output_parsers import PydanticOutputParser <br><br># Define your data structure<br>class Joke(BaseModel):<br>    setup: str = Field(description=&quot;question to set up a joke&quot;)<br>    punchline: str = Field(description=&quot;answer to resolve the joke&quot;)<br><br># Set up a parser<br>parser = PydanticOutputParser(pydantic_object=Joke)<br>parser.get_format_instructions()</pre><p>The output format instructions will look like this:</p><pre>The output should be formatted as a JSON instance that conforms to the JSON schema below.<br><br>As an example, for the schema {&quot;properties&quot;: {&quot;foo&quot;: {&quot;title&quot;: &quot;Foo&quot;, &quot;description&quot;: &quot;a list of strings&quot;, &quot;type&quot;: &quot;array&quot;, &quot;items&quot;: {&quot;type&quot;: &quot;string&quot;}}}, &quot;required&quot;: [&quot;foo&quot;]}<br>the object {&quot;foo&quot;: [&quot;bar&quot;, &quot;baz&quot;]} is a well-formatted instance of the schema. The object {&quot;properties&quot;: {&quot;foo&quot;: [&quot;bar&quot;, &quot;baz&quot;]}} is not well-formatted.<br><br>Here is the output schema:<br><br>{&quot;properties&quot;: {&quot;setup&quot;: {&quot;description&quot;: &quot;question to set up a joke&quot;, &quot;title&quot;: &quot;Setup&quot;, &quot;type&quot;: &quot;string&quot;}, &quot;punchline&quot;: {&quot;description&quot;: &quot;answer to resolve the joke&quot;, &quot;title&quot;: &quot;Punchline&quot;, &quot;type&quot;: &quot;string&quot;}}, &quot;required&quot;: [&quot;setup&quot;, &quot;punchline&quot;]}</pre><p>All we have to do is to concatenate the instructions string into the final prompt.</p><pre>prompt_template = f&quot;&quot;&quot;<br>Answer the user query.<br>{query}<br><br>Output format:<br>{format_instructions}\n<br>&quot;&quot;&quot;<br><br># And a query intended to prompt a language model to populate the data structure.<br>prompt = prompt_template.format({<br>   query=&quot;Tell me a joke.&quot;,<br>   format_instructions=parser.get_format_instructions()<br>   })</pre><p>Instantiate the LLM model and query it with the prompt.</p><pre>from langchain.llms import OpenAI<br>model = OpenAI(model_name=&#39;text-davinci-003&#39;, temperature=0.0)<br><br>output = model(prompt)</pre><p>The output JSON string will look like this:</p><pre>{<br>&quot;setup&quot;:&quot;Why did the chicken cross the road?&quot;,<br>&quot;punchline&quot;:&quot;To get to the other side!&quot;<br>}</pre><p>Using the `PydanticOutputParser` instance we defined, we convert the JSON string into the `Joke` model.</p><pre>parser.parse(output)</pre><p>The output will be an instance of the `Joke`:</p><pre>Joke(setup=&#39;Why did the chicken cross the road?&#39;, <br>  punchline=&#39;To get to the other side!&#39;)  </pre><h4>Benefits</h4><ol><li>Automatically generates the output instructions.</li><li>Parses the generated JSON string into the model.</li><li>Easy interoperability. It can be used on any capable large language model.</li></ol><h4>Limitations</h4><ol><li>Using prompt instructions will not guarantee the desired output.</li><li>Less capable models might have difficulty following the instructions. You will certainly need a loop that tries again until the model generates a suitable candidate that is accepted by the parser.</li><li>The more complex the schema, the more chances for the model to make mistakes.</li><li>Less robust. The model will generate token by token, increasing the chance of making syntax mistakes, for instance failing to generate a valid JSON string.</li><li>Context size. Complex schemas might require too many tokens in the context, limiting the context size you will have available for the actual prompt and in some cases the output.</li></ol><h3>Approach 2: Jsonformer</h3><p>Approaches based on output parsing are error-prone and less robust. They rely on prompt engineering, fine-tuning, and post-processing, but they still can fail to generate syntactically correct JSON in some cases. Especially smaller and less capable LLMs.</p><p>In structured data, many tokens are fixed and predictable. Ideally we wouldn’t need to generate tokens like brackets and field names that we already know. <a href="https://github.com/1rgs/jsonformer/"><strong><em>Jsonformer</em></strong></a> is a wrapper around Hugging Face transformers that fills in these fixed tokens during the generation process and only delegates the generation of content tokens, the actual field values to the language model. This makes it more efficient and robust than prompt engineering and output parsers.</p><p>The idea behind this method is to guide the text generation monitoring the logits and tokens sampling.</p><p>While sampling the tokens it will check first if the token follows the expected requirements. Example:</p><ul><li>Generating <strong>booleans</strong> : compares logits for **true** and **false**</li><li>Generating <strong>numbers</strong>: squash logits for non-digit tokens before sampling</li><li>Generating <strong>strings</strong>: stops generation on second **”**</li><li>Generating <strong>arrays</strong>: compare logits for “[“, “,”, “]”</li></ul><figure><img alt="Figure 1. Jsonformer illustration" src="https://cdn-images-1.medium.com/max/1024/1*vH6NiPL5QREpbmW0h2EKkQ.png" /></figure><p>Here is an example on how to generate JSON string that follows the specified JSON schema:</p><pre>from jsonformer import Jsonformer<br>from transformers import AutoModelForCausalLM, AutoTokenizer<br><br>model = AutoModelForCausalLM.from_pretrained(&quot;databricks/dolly-v2-3b&quot;)<br>tokenizer = AutoTokenizer.from_pretrained(&quot;databricks/dolly-v2-3b&quot;)<br><br>json_schema = {<br>    &quot;type&quot;: &quot;object&quot;,<br>    &quot;properties&quot;: {<br>        &quot;name&quot;: {&quot;type&quot;: &quot;string&quot;},<br>        &quot;age&quot;: {&quot;type&quot;: &quot;number&quot;},<br>        &quot;is_student&quot;: {&quot;type&quot;: &quot;boolean&quot;},<br>        &quot;courses&quot;: {<br>            &quot;type&quot;: &quot;array&quot;,<br>            &quot;items&quot;: {&quot;type&quot;: &quot;string&quot;}<br>        }<br>    }<br>}<br><br>prompt = &quot;Generate a person&#39;s information based on the following schema:&quot;<br>jsonformer = Jsonformer(model, tokenizer, json_schema, prompt)<br>generated_data = jsonformer()</pre><h4>Benefits</h4><ol><li>This method works even with small and less capable models. A 3B parameter model, small for LLMs standards, is already capable of benefiting from this approach.</li><li>It supports JSON schemas with nested objects.</li><li>Efficiency. By generating only the content tokens and filling in the fixed tokens, this method is more efficient than generating a full JSON string and parsing it.</li><li>Flexible and extendable. This library is built on top of the Hugging Face transformers library, making it compatible with any model that supports the Hugging Face interface.</li></ol><h4>Limitations</h4><ol><li>The official implementation only offers support for HuggingFace transformers, which is where the <strong><em>Jsonformer</em></strong> name comes from. In theory, it can be adapted to work with OpenAI API or other libraries as long as they provide the logits. Some contributors have already <a href="https://github.com/1rgs/jsonformer/pull/16">proposed solutions</a> but since OpenAI released Function Calling this is less relevant.</li><li>It currently only supports a limited subset of JSON Schema types (number, boolean, string, array, object).</li><li>It looks like the project is not actively maintained at the moment.</li></ol><h3>Approach 3: Outlines</h3><p><a href="https://github.com/outlines-dev/outlines"><strong><em>Outlines</em></strong></a> is a framework that provides methods for defining top-level restrictions on text completions generated by language models. We can limit the output tokens in terms of type constraints, a predefined list of accepted tokens, and even regular expressions. This <a href="https://arxiv.org/abs/2307.09702">paper</a> details how authors reformulate the problem of text generation in terms of transitions between the states of a finite-state machine.</p><h4>Efficient JSON generation</h4><p>The implementation provided by <strong><em>Outlines</em></strong> allows a guide the generation process so the output is “guaranteed” to follow a JSON schema or <a href="https://docs.pydantic.dev/latest/">Pydantic model</a>:</p><pre>from typing import List<br>from enum import Enum<br>from pydantic import BaseModel, constr<br><br>import outlines.models as models<br>import outlines.text.generate as generate<br><br><br>class Weapon(str, Enum):<br>    sword = &quot;sword&quot;<br>    axe = &quot;axe&quot;<br>    mace = &quot;mace&quot;<br>    spear = &quot;spear&quot;<br>    bow = &quot;bow&quot;<br>    crossbow = &quot;crossbow&quot;<br><br><br>class Armor(str, Enum):<br>    leather = &quot;leather&quot;<br>    chainmail = &quot;chainmail&quot;<br>    plate = &quot;plate&quot;<br><br><br>class Character(BaseModel):<br>    name: constr(max_length=10)<br>    age: int<br>    armor: Armor<br>    weapon: Weapon<br>    strength: int<br><br><br>model = models.transformers(&quot;gpt2-medium&quot;)<br><br>#specific method to generate json<br>sequence = generate.json(model, Character)(&quot;Give me a character description&quot;)</pre><p>The output sequence will look like:</p><pre>{<br>   &quot;name&quot;: &quot;ranbelt&quot;,<br>   &quot;age&quot;: 26,<br>   &quot;armor&quot;: &quot;chainmail&quot;,<br>   &quot;weapon&quot;: &quot;bow&quot;,<br>   &quot;strength&quot;: 5<br>}</pre><p>Now lets parse the JSON string:</p><pre>Character.model_validate_json(sequence)</pre><p>Parsed object:</p><pre>Character(name=&#39; City of W&#39;, <br>age=50, <br>armor=&lt;Armor.chainmail: &#39;chainmail&#39;&gt;, <br>weapon=&lt;Weapon.mace: &#39;mace&#39;&gt;, <br>strength=26)</pre><h4>Benefits</h4><ol><li>The method works with union types, optional types, arrays, nested schemas, etc. Some field constraints are <a href="https://github.com/outlines-dev/outlines/issues/215">not supported yet, here</a> you can find the details.</li><li>The approach is model agnostic as long as you can mask the logits. Open-source LLMs can be used.</li><li>Integration with HuggingFace transformers models.</li><li>Project in active development.</li></ol><h4>Limitations</h4><ol><li>Currently, it does not support APIs like OpenAI due to API limitation. More details <a href="https://github.com/outlines-dev/outlines/issues/227">here</a>.</li></ol><h3>Approach 4: Guidance</h3><p>Microsoft <a href="https://github.com/guidance-ai/guidance/tree/main"><strong><em>Guidance</em></strong></a> is another promising framework that provides a Domain Specific Language (DSL) for prompting. It merges templating and logic control making it possible to have more complex and clever prompts.</p><p>With the template language is possible to ensure that generated JSON is always valid. Below we generate a random character profile for a game with perfect syntax every time. A Jupyter Notebook with the complete example is available <a href="https://github.com/guidance-ai/guidance/blob/main/notebooks/guaranteeing_valid_syntax.ipynb">here</a>.</p><p>In this example, we specify not only the JSON format but the constraints for each attribute using the DSL. Note that ‘<strong><em>age</em></strong>’ must respect the regex pattern ‘<strong><em>[0–9]+</em></strong>’ and ‘<strong><em>weapon</em></strong>’ must accept only values from the ‘<strong><em>valid_weapons</em></strong>’ list.</p><pre># load a model locally. GPT-style model will do<br>guidance.llm = guidance.llms.Transformers(&quot;databricks/dolly-v2-7b&quot;, device=0)<br><br># we can pre-define valid option sets<br>valid_weapons = [&quot;sword&quot;, &quot;axe&quot;, &quot;mace&quot;, &quot;spear&quot;, &quot;bow&quot;, &quot;crossbow&quot;]<br><br># define the prompt<br>program = guidance(&quot;&quot;&quot;The following is a character profile for an RPG game in JSON format.<br>```json<br>{<br>    &quot;description&quot;: &quot;{{description}}&quot;,<br>    &quot;name&quot;: &quot;{{gen &#39;name&#39;}}&quot;,<br>    &quot;age&quot;: {{gen &#39;age&#39; pattern=&#39;[0-9]+&#39; stop=&#39;,&#39;}},<br>    &quot;armor&quot;: &quot;{{#select &#39;armor&#39;}}leather{{or}}chainmail{{or}}plate{{/select}}&quot;,<br>    &quot;weapon&quot;: &quot;{{select &#39;weapon&#39; options=valid_weapons}}&quot;,<br>    &quot;class&quot;: &quot;{{gen &#39;class&#39;}}&quot;,<br>    &quot;mantra&quot;: &quot;{{gen &#39;mantra&#39;}}&quot;,<br>    &quot;strength&quot;: {{gen &#39;strength&#39; pattern=&#39;[0-9]+&#39; stop=&#39;,&#39;}},<br>    &quot;items&quot;: [{{#geneach &#39;items&#39; num_iterations=3}}<br>        &quot;{{gen &#39;this&#39;}}&quot;,{{/geneach}}<br>    ]<br>}```&quot;&quot;&quot;)<br><br># execute the prompt<br>out = program(description=&quot;A quick and nimble fighter.&quot;, valid_weapons=valid_weapons)</pre><figure><img alt="Figure 2. Guidance output sample" src="https://cdn-images-1.medium.com/max/1024/1*ONFlG-TAh9JzQtE9XLZASQ.png" /></figure><p>The output as simple Python dictionary:</p><pre>out.variables()<br><br>{<br>    &quot;description&quot;: &quot;A quick and nimble fighter.&quot;,<br>    &quot;name&quot;: &quot;Ranger&quot;,<br>    &quot;age&quot;: 20,<br>    &quot;armor&quot;: &quot;plate&quot;,<br>    &quot;weapon&quot;: &quot;sword&quot;,<br>    &quot;class&quot;: &quot;fighter&quot;,<br>    &quot;mantra&quot;: &quot;I am the ranger.&quot;,<br>    &quot;strength&quot;: 10,<br>    &quot;items&quot;: [<br>        &quot;dagger&quot;,<br>        &quot;shield&quot;,<br>        &quot;bow&quot;,<br>    ]<br>}</pre><h4>Benefits</h4><ol><li>It provides a powerful Domain Specific Language for prompting making it easy to build the template for a JSON response.</li></ol><h4>Limitations</h4><ol><li>It doesn’t work well with small LLMs. We need at least Llama-7b to make it work.</li><li>Since it does not work with smaller models, it is very memory intensive.</li></ol><h3>Wrapping up</h3><p>The conventional prompt engineering method, employing a JSON Schema Parser like Langchain’s Pydantic Output Parser, is a cheap method that can be used with any capable LLM. It won’t work well with small models and is not guarantee that it will work 100% of the times even with GPT-3. If you are planning to use only OpenAI API and don’t expect to move to alternative models later, just use <a href="https://openai.com/blog/function-calling-and-other-api-updates">Function Calling</a>.</p><p>Jsonformer can be more reliable than plain prompt engineering if you are using <a href="https://huggingface.co/docs/transformers/index">transformers</a>. This library can handle JSON schemas with limited complexity even with less capable models. The main benefit is that is does not generate the tokens from the structure, just the attribute values. The downside is that it supports only a subset of JSON Schema types and it is not actively maintained lately.</p><p>Guidance is a another promising LLM framework. The main contribution is a DSL for creating complex templates, that we can use to structure valid JSON responses. However, it requires larger models to function effectively and can be very memory intensive. I had trouble to make it work with smaller models. From my experience, you need at least a 7bilion-parameters models.</p><p>Outlines is the most complete solution, for instance you can constraint the token generation using regex patterns or predefined vocabulary. It can produce JSON respecting a Pydantic model with no issues, providing a more sophisticated approach to JSON generation than simply plain prompt engineering. In active development this library offers the most advanced solution not only for JSON responses but a variety of other guided text generation use cases. At the moment I write this <strong><em>Outlines</em></strong> is my favorite choice and Guidance is on my radar for other use cases.</p><p>Additionally, projects that are also relevant to mention in the domain are <a href="https://docs.lmql.ai/en/stable/">LMQL</a> (Language Model Query Language) and <a href="https://github.com/ShreyaR/guardrails">guardrails</a>. Both with their own merits and limitations are worth checking.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d88fc3dcf4c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/productizing-language-models/guided-text-generation-with-large-language-models-d88fc3dcf4c">Guided text generation with Large Language Models</a> was originally published in <a href="https://medium.com/productizing-language-models">Faktion AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Model Imitation in Natural Language Processing: Applications and Industry Implications]]></title>
            <link>https://medium.com/productizing-language-models/model-imitation-in-natural-language-processing-applications-and-industry-implications-f54860e65e67?source=rss----19cb311d0208---4</link>
            <guid isPermaLink="false">https://medium.com/p/f54860e65e67</guid>
            <dc:creator><![CDATA[Ben Burtenshaw]]></dc:creator>
            <pubDate>Mon, 17 Jul 2023 11:15:21 GMT</pubDate>
            <atom:updated>2023-07-07T08:42:57.682Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*nphZ2nLXymsyy45GERXQPg.jpeg" /><figcaption>Stable Diffusion 2.1: Wes Anderson style image of open source imitations of proprietary models</figcaption></figure><p>Model Imitation is a burgeoning concept in the field of Natural Language Processing (NLP). By training a language model to mimic the performance of a target model, this approach offers potential advantages but also poses various challenges and implications. Drawing from “Imitation and Novelty: Critical Evaluation of Model Imitation” (Wallace et al., 2023), this blog post aims to provide insights into Model Imitation and discuss its impact on the industry.</p><p>At its core, model imitation is about augmenting the capabilities of a base language model with those of a target model. It achieves this by finetuning the model on outputs from a more advanced, often proprietary, language model like Open AI’s GPT-4. The ultimate aim is to incorporate the superior model’s abilities into the imitated model.</p><p>“Imitation and Novelty: Critical Evaluation of Model Imitation” (Wallace et al., 2023), offers a critical assessment of this approach. The research demonstrates that while imitated models appear superior in following instructions and earning high ratings from human evaluators (due to their mimicry of GPT-4’s style), they fall short in improving tasks not heavily featured in the imitation data. These findings indicate that model imitation is not a catch-all solution; it may even contribute to performance discrepancies as it excels in style imitation but often struggles with reasoning and fact learning. Below, I break down the paper’s key observations on this theme.</p><h4>Finetuning as a Knowledge Extractor</h4><p>Finetuning a model on generated instructions, as Wallace et al. point out, offers only marginal improvements to an LM’s capabilities. To illustrate, consider the attempt to enhance an open-source LM like GPT-2 by imitating a proprietary LM like GPT-4 on a small dataset. The outcome would not impact the base knowledge of the GPT-2 model, beyond the information directly included in the finetuning dataset. In turn, the GPT-2 model remains largely unchanged, with the result falling short of GPT-4’s capabilities. Instead, it would imitate stylistic properties of the superior model. Hence, developing better base language models could prove more beneficial than simply imitating proprietary systems.</p><h4>Model Imitation in Vision-Language Models</h4><p>The paper also touches upon recent work where model imitation is used more indirectly. Vision-language models, such as those used in image captioning or visual question answering, have included outputs from models like GPT-4 during their training process. However, these models could inherit the same limitations or biases as the models they imitate, posing potential challenges and raising questions about the validity and usefulness of such an approach.</p><h4>Model Distillation versus Imitation</h4><p>Model distillation is another process that involves one model learning from another. However, it differs significantly from model imitation in its practical application. In model distillation, the teacher model’s training data, model architecture, and hyper-parameters are known and used to guide the student’s training. In contrast, in model imitation, these aspects remain unknown, rendering the imitation process far more challenging. Wallace et al. propose that distillation could be used instead of imitation if the target model details are open available.</p><h4>Legal and Ethical Implications</h4><p>Model Imitation stirs up legal and ethical concerns, most notably regarding the open-source community’s practices of appropriating techniques and knowledge from companies like OpenAI. This mirrors ongoing debates surrounding patenting AI models and algorithms, where claims of unique solutions collide with efforts to democratize these innovations for broader use.</p><p>The applications of Model Imitation extend across diverse fields and industry applications. From broad-coverage imitations that address a variety of behaviors, domains, and tasks, to task-specific imitations that require deep domain knowledge, each method presents unique challenges. Regardless of the approach, ensuring quality is paramount — the imitation model should aim not only to mimic the responses of the target model but also its capacity to handle a broad range of tasks effectively.</p><h4>Looking Ahead</h4><p>Despite the challenges and uncertainties, Model Imitation continues to generate curiosity and investment, despite questions to answer and problems to solve. From technical considerations such as how to improve open-source LMs and ethical dilemmas about “stealing” from proprietary models, to legal countermeasures that companies could adopt to protect their intellectual property, the path ahead for Model Imitation is complex. Continued research and dialogue are vital to navigate these issues and develop better methods for the ethical and responsible development of language models.</p><p>While Model Imitation offers some promising advantages, it also reveals significant limitations. Its inability to improve upon certain tasks and the challenges associated with imitating proprietary systems suggest a more nuanced approach to enhancing open-source LMs. Future work needs to investigate these issues and explore alternatives, ensuring progress in NLP aligns with ethical standards and respects intellectual property rights.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f54860e65e67" width="1" height="1" alt=""><hr><p><a href="https://medium.com/productizing-language-models/model-imitation-in-natural-language-processing-applications-and-industry-implications-f54860e65e67">Model Imitation in Natural Language Processing: Applications and Industry Implications</a> was originally published in <a href="https://medium.com/productizing-language-models">Faktion AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>