It is EASY to start with (Azure) OpenAI

It is EASY to start with (Azure) OpenAI

EASY? Might be a bit subjective. but as person with no Python and Data Science background, let me explain my journey on learning and doing hands-on with Azure OpenAI. And I let you be the judge, let me know in the comments ??

OpenAI or Azure OpenAI?

A question that’s always being asked by all our Partners and Customers. Well, in essence both are (almost) the same. The underlying LLMs (large language models) are the same, only difference is not all models are always available on Azure, depending on which region, you select to run Azure OpenAI services, since not all regions host all the models.

About the title of this article, the steps or samples I will share and encourage you to try out, you can freely choose between OpenAI on Azure or the public one. Since you only need API endpoint and a key.

ML or LLM

Industries of all sizes have traditionally found AI/ML to be a difficult task. It requires extensive effort to transform data, metaphorically represented as iron ore, into a magical steel blade. This involves collecting, melting, processing, and shaping the data into a tool that can only perform a single function. The process is time-consuming and expensive in terms of human resources.

AI pioneer Herbert Simon once compared the brain to a pair of scissors, with cognition and context being the two blades that enable intelligence. However, with the introduction of LLM AI, creating AI features has become remarkably simple, surprising even experienced AI/ML practitioners.

comparison between ML and LLM projects

Source: https://web.archive.org/web/20230314173215/https://www.unusual.vc/post/devtools-for-language-models

Prompt-engineering was FUN

I would be lying, if I said I have not been playing around with ChatGPT since its release. I have asked it to tell a joke, write code, unit tests, tricked it to generate images, laughed at its ability to solve mathematical puzzles.

But over the course of this journey, the important lesson I learned was “Prompt-Engineering”.

And most importantly, a Task given to a LLM would not yield a satisfactory result, unless you also provide Instruction, Context and Output format.

How Task can be enriched with input data and instructions

So, that’s first, we need to understand how to use these LLMs effectively for our tasks. Provide proper instructions, ample context and if needed the output format. So when you want to use the APIs, your code also cater for these steps. We cannot re-train these models, so the best thing we can do is to embrace Prompt-Engineering.

Step towards Reality

Well, chatting with ChatGPT is fun, but unless it can be used to solve complex business problems and to create a sustainable AI architecture, it would remain as hype and will fade away after a while.

So, my quest started on playing around with the APIs to see what I can leverage using context, instructions with a task. Started with a question, can I “Query my data?”

Query your Data

What I wanted to do, although maybe have done thousands of times using ML models, was to chat with my data. I had a list of documents which are my mortgage documents and wanted to see if I could ask trivial questions using a LLM to it. The best part was, I could instantly verify if it was answering it correctly, since I had to read it multiple times before signing it.

Azure samples got you covered: ?A sample app using Azure Cognitive Search for retrieval and Azure OpenAI large language models to power ChatGPT-style and Q&A experiences

Components are:

  1. OpenAI or Azure OpenAI endpoint
  2. Azure Cognitive Search
  3. Azure Blob storage
  4. Simple UI for the chat

Architecturally, it looks like:

architecture of sample app

So, what is doing what actually?

  1. Blob storage holds the documents you want to chat with.
  2. Cognitive search is indexing these documents asynchronously so that you can search for a particular text in these documents.
  3. OpenAI to use the search results from Cognitive search to generate a human like response.

The Github repo readme was detailed enough for me to set this up in my own Azure subscription, and the best part was, the setup is scripted, so you need to run JUST ONE COMMAND ??

This architectural pattern is Retrieval Augmented Generation (RAG). RAG is a process for retrieving information relevant to a task, providing it to the language model along with a prompt, and relying on the model to use this specific information when responding.

More info: Grounding LLMs - Microsoft Community Hub

But wait, there is an easier way to create the sample sample app, from Azure Open AI studio. Check this blog from a colleague of mine on how to do that. This is a great way to prototype your ideas.

There are other samples you can find on Azure Github which you can try out or can also contribute to:

  1. Azure OpenAI Samples
  2. A web application for a OpenAI-enabled document search
  3. Customer-Service-Conversational-Insights-with-Azure-OpenAI-Services

You can stop reading further if you wish to, getting familiar with the above will give you ample information and ideas about how to use (Azure) OpenAI in business context.

But for the more detailed code fanatics, you are in for a treat, because there is Semantic Kernel to follow. ??

Semantic Kernel

The term "kernel" can have different meanings in different contexts, but in the case of the Semantic Kernel, the kernel refers to an instance of the processing engine that fulfills a user's request with a collection of plugins.

how semantic kernel works

The kernel has been designed to encourage function composition which allows developers to combine and interconnect the input and outputs of plugins into a single pipeline. It achieves this by providing a context object that is passed to each plugin in the pipeline. The context object contains the outputs of all previous plugins so the current plugin can use them as inputs.

In this way, the kernel is very similar to the UNIX kernel and its pipes and filters architecture; only now, instead of chaining together programs, we are chaining together AI prompts and native functions.

Learn more: How to orchestrate AI with Semantic Kernel | Microsoft Learn

It’s an Open-Source SDK

Semantic Kernel(SK) is a SDK, it helps you to integrated LLMs with conventional programming languages(Python, C#). The SK extensible programming model combines natural language semantic functions, traditional code native functions, and embeddings-based memory unlocking new potential and adding value to applications with AI.

SK supports prompt templating, function chaining, vectorized memory, and intelligent planning capabilities out of the box.

Github: microsoft/semantic-kernel: Integrate cutting-edge LLM technology quickly and easily into your apps

There is an alpha release of Java SDK as well, which can be found in here.

Samples to try out and can be contributed to: microsoft/semantic-kernel: samples

  1. Simple chat summary
  2. Book creator
  3. Authentication and APIs
  4. GitHub repository Q&A
  5. Copilot Chat Sample App

Still exploring

The world of LLMs is new to me, just like most of us. But it became challenging for me, since I come from a Java world, and everything here was Python or C#. So, to understand and write something on my own was a comparatively bigger step than others.

But the documentation, samples helped me a lot, to understand underlying architecture, usage and most importantly how to tweak these LLMs to solve complex problems with context of my own.

Happy exploring!!

要查看或添加评论,请登录

Soham Dasgupta的更多文章

  • State of Open (Source?!) and Free AI – a FOSDEM recap

    State of Open (Source?!) and Free AI – a FOSDEM recap

    Disclaimer: This article is on the things I learned/observed spending the day in AI and Machine Learning Developer Room…

  • A Recap of My Year 2023

    A Recap of My Year 2023

    Leaving behind? I left Capgemini in January 2023, after a long 8 years. It was the place where I learned and grew as a…

    3 条评论
  • Java on Azure at Build 2023

    Java on Azure at Build 2023

    The Microsoft Build conference returned with a combination of in-person and online sessions. It took place from May 23…

社区洞察

其他会员也浏览了