Tag: OpenAI

  • Want to Be a VC? Here’s What You Need to Know (Beyond the Hype)

    Venture capital (VC) is often portrayed as the glamorous side of finance, attracting ambitious individuals seeking high-stakes rewards. But what’s the reality behind the hype? Today, we’ll dive into the world of venture capital, exploring its core functions, the daily grind of an investor, compensation, and whether it’s the right fit for you.

    What do VC firms do?

    VC investors act as partners to entrepreneurs, helping them build and scale businesses from the ground up. They provide three key elements:

    • Funding: VC firms inject massive amounts of capital, enabling companies to hire talent and expand their operations.
    • Insight: Experienced VC investors, who have seen countless companies rise and fall, offer invaluable advice and guidance to entrepreneurs, particularly during challenging times.
    • Network: Top VC firms boast extensive networks, opening doors for entrepreneurs in areas like recruiting top talent or securing crucial business partnerships.

    The Venture Capital Investment Landscape

    VC firms specialize in various stages of investment:

    • Pre-Seed/Seed: The earliest round of funding, where risk is high, and equity stakes are substantial.
    • Early Stage: Includes seed, Series A, and Series B rounds, with moderate risk and equity stakes.
    • Growth Stage: Consists of Series C to IPO, with lower risk and smaller equity stakes.
    • Stage Agnostic: These firms invest across all stages, from seed to IPO.

    The Day-to-Day Life of a VC Investor

    No two days are the same if you are working in venture capital.

    Key responsibilities include:

    • Sourcing new investments: This involves extensive outreach, attending conferences, and hosting events to attract promising founders and companies.
    • Conducting due diligence: This includes analyzing pitch decks, evaluating valuations, conducting market research, and crafting investment memos.
    • Supporting portfolio companies: This entails joining boards, connecting companies with potential customers and suppliers, and assisting with recruitment.
    • Fundraising: As you climb the ranks, you become responsible for managing investors, providing regular portfolio updates, and securing funding for new ventures.

    The type of day you will have in VC depends if you are new junior investor who has no stake in the fund or if you are the General Partner of the fund.

    The Hustle and the High Stakes

    VC investors typically work long hours, often 60-80 per week, with the potential for even longer hours during fundraising rounds. The work is highly self-directed, requiring initiative, resourcefulness, and creative problem-solving.

    While the hours can be grueling, the high stakes and potential for significant returns create a high-pressure environment. Every investment carries the risk of going to zero, making each hour a critical decision-making process.

    The VC Compensation Structure

    Compensation typically comprises three components: salary, bonus, and carry. Carry represents a percentage of the fund’s annual profits, varying greatly between firms and years.

    • Analysts: Starting salaries range from $60,000 to $100,000, with little to no carry.
    • Associates: Earn $150,000 to $200,000, often with minimal carry.
    • Senior Associates: Earn $200,000 to $250,000 and begin receiving substantial carry.
    • VPs and Partners: Carry becomes a significant portion of compensation, motivating investors to make profitable investments.

    Is Venture Capital Right for You?

    Pros:

    • Flexibility and autonomy: You’ll have the freedom to work on projects that align with your interests and expertise.
    • Exposure to cutting-edge technologies: You’ll be at the forefront of innovation, engaging with brilliant entrepreneurs and industry leaders.
    • Relationship-driven environment: Venture capital thrives on building connections, allowing both introverts and extroverts to succeed.

    Cons:

    • Unstructured work environment: If you thrive on a predictable schedule, venture capital may not be the best fit.
    • Long-term commitment: You may have to wait 7-10 years to see returns on your investments.
    • Intense competition: The VC space is highly competitive, requiring a strong reputation or a position at a top firm to stand out.
    • Lack of expertise: One common problem young analysts who join VC firms face is they don’t have any relevant work experience and will not be able to develop expertise in any field.

    Breaking into the VC Industry

    While a background in investment banking or consulting is often considered an ideal stepping stone, many successful VC investors come from diverse backgrounds in technology, business, and other relevant fields. Most VCs are ex-founders who went through the journey of running a VC backed company.

    Ready to Dive Deeper?

    For a more in-depth look at the venture capital world, check out our podcast “Startup Project Podcast” where we interview founders, VCs and operators.

    Subscribe to Startup Project YouTube channel for great conversations.
  • What Does Klarna’s Case Study Tell Us About Building Products Using Generative Ai?

    What Does Klarna’s Case Study Tell Us About Building Products Using Generative Ai?

    There are lots of ways generative AI is being used by companies. In case of Klarna they launched an AI customer support assistant that is available 24*7 and supports 30+ languages. They launched the assistant using Open AI as their LLM provider. If we have to guess they have finetuned it using their own customer support interaction data set that they have collected over the years. We often underestimate it when we say a customer support AI assistant, but if you look at what it takes to create a support team that works 24*7 and supports 30+ languages, it requires a lot of resources for any company.

    What features does the Klarna AI assistant support?

    • The assistant is designed to handle wide range of questions related to refunds, returns, payment-related issues, cancellations, disputes, and invoice inaccuracies, ensuring swift and effective solutions.
    • Like any tech feature, its available 24*7 across all geographies.
    • For customers who want to know what they can afford and not afford, it also provides info related to purchase power, spending limits and the reasons why it exists.
    • All the info of a customer account is with the assistant to help any questions related to it.

    Is the assistant effective?

    Its cool to say that we have used gen AI and see the stock pop up, but the real question is, does the feature deliver value to the company. And from the numbers it looks like it is beating expectations. Here are some of the numbers.

    • Two-thirds of all customer service chats are handled by the assistant, which is an impressive 2.3M conversations.
    • Customer satisfaction same as human conversations.
    • 25% drop in repeat inquiries
    • Estimated to drive $40M in profit improvements to the company.

    Multilingual coverage has also improved the experience for immigrant and expatriate shoppers, who can now converse in their native language without waiting for specialized staff.

    How it is built?

    Klarna combines OpenAI’s GPT-4-class model with a proprietary retrieval-augmented layer that injects fresh order data and policy documents. Fine-tuning on years of support transcripts helps the bot mirror Klarna’s brand voice and comply with local regulations. A confidence-scoring system automatically hands uncertain cases to human agents, keeping quality assurance intact.

    Should you build one too?

    If your firm has a sizable archive of labeled support data, start by clustering tickets to find the top 20 intents—typically 80 percent of volume. Spin up a retrieval-augmented bot in a sandbox, keep humans on standby for low-confidence cases, and track three metrics: time-to-resolution, repeat-contact rate, and CSAT. Double-digit gains in two of those usually justify rollout.

    A rollout this sweeping touches more than technology. Klarna ran “shadow agent” weeks where the AI answered in parallel with humans so supervisors could audit every response. Once accuracy held above 90 percent, traffic was gradually shifted to the bot. Daily dashboards track hallucination rate, hand-off frequency, and compliance flags that regulators can audit after the fact.

    What are the takeaways from Klarna’s gen AI assistant?

    1. Its clear that generative AI is being adopted and creating value for companies at all stages.
    2. Customer support will get more effective and cheaper.
    3. We will see a lot of growth stage startups follow Klarna to boost their profitability and reduce expenses.
    4. Open AI’s board drama didn’t effect its trust among companies to use them for production scale deployments.
    5. Expect more companies to announce improvements because of using gen AI technology in fields outside customer support.
    6. If you are a company with large data set related to customer support, you should explore creating an AI assistant for support interactions.

    Follow me on TwitterLinkedIn for latest updates on 100 days of AI. If you are in tech you might be interested in joining my community of tech professionals here.

  • #68 Why the new AI button on your keyboard is inevitable? (Above Average Newsletter)

    This episode is the audio version of Nataraj’s newsletter Above Average.

    Welcome to 49th edition of the Above Average Newsletter. Your bi-weekly source of Above Average takes on the business of big technology written by Nataraj.

    1. Why the new AI Button on Your Keyboard is inevitable?

    Microsoft is adding a new AI button to your PC keyboard. This is the first time Microsoft changed the PC keyboard in last 30 years. If you are a regular user of ChatGPT or its competitors you will notice your own behavior, that you use it repeatedly and it might get lost in the 10s of chrome tabs you have opened.

    You also realize that its a constant companion on your daily work. Microsoft already realized this and jumped head on into creating Copilots for all its products.

    The next step in this strategy is to have a dedicated button that will launch bing copilot which uses gpt-4 and is currently free.

    The move highlights couple of things:

    Copilots are going to an enduring form factor

    We will use copilots so often that it requires its own button

    Its a great use of Microsoft’s distribution power to create a new user behavior

    If this new behavior works its acts as counter to Google search. Your first step for any answer would be to tap that button and start asking the question. A better interface potentially to transition from a search dominant world to answer dominant world.

    2. Who is the biggest AI VC in town?

    As some one who closely works with a venture fund and interacted with lots of investors and invested in 20+ startups its important to note that the unseriousness of ZIRP era was prevalent in VC industry as much as it was in any other industry.

    This meant higher valuations that defy the gravity of the business became common. Chasing each others and asking the question “who else is investing” became the most important criteria. Deals closed faster than ever. Crypto as a sector suck more oxygen in the room that it should. Mostly because too much capital was chasing too few deals and in the process new & some old investors lost track of what is important. Its important for a VC to invest in important things in tech.

    Now with AI era on us, the biggest investors in AI are not the VC firms but its the fearsome foursome – Microsoft, Google, Amazon & Nvidia.

    The amount of investment commitments from these 4 companies has already exceeded $20B with a conservative estimate.

    Big tech companies never really invested in crypto like they are investing in AI.

    So what’s the take away here – if you think AI hype cycle is similar to crypto hype cycle, you are wrong. AI is an enduring cycle worthy of hype, unlike crypto which was propped up by VCs with out enough depth.

    3. My Experiments with AI:

    One of the reason this newsletter is less frequent than usual (from now on it will be twice a month) is because I am working on writing more on AI as part of a series I am calling 100 days of AI. If you are interested in gen AI experiments, ideas & trends follow along here. Here are some posts I have written about AI.

    – Design Thinking using Semantic Kernel – Get Insights from YouTube Podcast Video using Open AI’s GPT 4 – Build Your Own Chat with Data App

    Till next time, stay above average.
    Nataraj

    Send in a voice message: https://podcasters.spotify.com/pod/show/startupproject/message
    https://podcasters.spotify.com/pod/show/startupproject/episodes/68-Why-the-new-AI-button-on-your-keyboard-is-inevitable–Above-Average-Newsletter-e2f9nl1

  • 100 Days of AI Day 10: How to use AI to do Design thinking using GPT4 & Semantic Kernel

    100 Days of AI Day 10: How to use AI to do Design thinking using GPT4 & Semantic Kernel

    About 100 Days of AI:

    I am Nataraj, I decided to spend 100 days in starting Jan 1st 2024 to learn about AI. With 100 days of AI is my goal to learn more about AI specifically LLMs and share ideas, experiments, opinions, trends & learnings through my blog posts. You can follow along the journey here.

    In this post we will look at how to use AI to do design thinking for a given business problem. For the sake of this example we define design thinking as a series of steps show below. You can also extend this idea to add more steps and write logic for them.

    Design Thinking

    To set context, lets take an example of a Coffee Shop which has received some customer feedback recently and use it to apply AI design thinking and come up with ways to improve the business.

    We will use Open AI’s gpt-4 model and use Microsoft’s Semantic Kernel to do design thinking. Along the way we will also explore how we can use the concept of Plugins in the Kernel which makes it easy to reuse Semantic Functions.

    So let’s get into it.

    Step 1 – Setup the Kernel:

    The first step is to load the secret key of Open AI from local .env file, and then create new Kernel instance. Then add OpenAIChatCompletion service to the Kernel.

    Setup Semantic Kernel

    Step 2 – Add the use feedback & SWOT analysis of the Coffee Shop business:

    # SWOT questions
    strength_questions = ["What unique recipes or ingredients does the coffee shop use?","What are the skills and experience of the staff?","Does the coffee shop have a strong reputation in the local area?","Are there any unique features of the shop or its location that attract customers?", "Does the coffee shop have a strong reputation in the local area?", "Are there any unique features of the shop or its location that attract customers?"]
    weakness_questions = ["What are the operational challenges of the coffee shop? (e.g., slow service, high staff turnover, not having wifi)","Are there financial constraints that limit growth or improvements?","Are there any gaps in the product offering?","Are there customer complaints or negative reviews that need to be addressed?"]
    opportunities_questions = ["Is there potential for new products or services (e.g., delivery, food along with coffee)?","Are there under-served customer segments or market areas?","Can new technologies or systems enhance the business operations?","Are there partnerships or local events that can be leveraged for marketing?"]
    threats_questions = ["Who are the major competitors and what are they offering?","Are there potential negative impacts due to changes in the local area (e.g., construction, closure of nearby businesses)?","Are there economic or industry trends that could impact the business negatively (e.g., increased ingredient costs)?","Is there any risk due to changes in regulations or legislation (e.g., health and safety, employment)?"]
    
    # SWOT answers
    strengths = [ "Unique coffee recipe that wins top awards","Owner trained in Sicily","Strong local reputation","Prime location on university campus" ]
    weaknesses = [ "High staff turnover","Floods in the area damaged the seating areas that are in need of repair","Absence of popular mocha latte from menu","Negative reviews from younger demographic for lack of hip ingredients" ]
    opportunities = [ "Untapped work from anywhere potential as they dont have wifi","Growing local tech startup community","Unexplored online presence and order capabilities","Upcoming annual food fair" ]
    threats = [ "Competition from big coffee chains nearby","There's nearby street construction that will impact foot traffic","Rising cost of coffee beans will increase the cost of coffee","No immediate local regulatory changes but it's election season" ]
    
    # Customer comments some positive some negative
    customer_comments = """
    Customer 1: The seats look really raggedy.
    Customer 2: The americano is the best on this earth.
    Customer 3: I've noticed that there's a new server every time I visit, and they're clueless.
    Customer 4: Why aren't there any snacks?
    Customer 5: I love the coffe blend they use and can't get it anywhere else.
    Customer 6: The dark roast they have is exceptional.
    Customer 7: why is there no wifi?
    Customer 8: Why is the regular coffee so expensive?
    Customer 9: There's no way to do online ordering.
    Customer 10: Why is the seating so uncomfortable and dirty?
    """

    Step 3 – Creating Plugins for Design Thinking:

    What is a Plugin? Semantic Kernel has this feature called Plugins where you can define Semantic Functions their inputs and can re-use them repeatedly. A plug in is made up of two files a .json (contains config info for LLM & input params) & .txt (contains a custom prompt). For design thinking use case we are going to create 4 plugins. You can find the code for all 4 plugins here.

    • Empathize: Takes customer feedback and isolates sentiment and gives a concise summary for each sentiment expressed by the customer.
    • Define: Takes output from empathize step, categorizes the analysis in a markdown table. Defines the problems & its possible source.
    • Ideate: Takes the output from the above step and generates ideas in the form of a markdown table with two columns called Low hanging fruit & Higher-hanging fruit.
    Result from Ideate Plugin
    • PrototypeWithPaper: This plugin takes in the ideas generated in previous step and gives a low-resolution prototype, so the solution can be tested.

    Step 4 – Bring it all together:

    Note that in the previous steps even though I have given the code for four plugins, explained what they do in the context of Design Thinking. I have also displayed the output they will generate. But we have not actually called those plugins from our code. Lets do that now as shown below.

    ## access design thiking plugin
    pluginsDirectory = "./plugins-sk"
    pluginDT = kernel.import_semantic_skill_from_directory(pluginsDirectory, "DesignThinking");
    async def run_designthinking_async():
        my_result = await kernel.run_async(pluginDT["Empathize"], pluginDT["Define"], pluginDT["Ideate"], pluginDT["PrototypeWithPaper"], input_str=customer_comments)
        display(my_result)
    
    asyncio.run(run_designthinking_async())
    

    You have already seen the output that all the 4 steps generate in the previous step. Note how simple Kernel makes calling one plug in after the other all in a single call.

    To conclude, here is what we did. We wrote custom prompts and made them plugins and put them in a folder called plugins-sk. And then used Kernel to call them using the SWOT analysis & Customer feedback for the Coffee Shop. Now by changing the SWOT analysis and taking a customer feedback for a different business problem you can do design thinking and come up with an MVP solution to fix your problem.

    Even though at the core of it its 4 custom prompts, this method highlights how Kernel makes developing complex goals with AI easy & manageable with plugins.

    That’s it for Day 10 of 100 Days of AI.

    I write a newsletter called Above Average where I talk about the second order insights behind everything that is happening in big tech. If you are in tech and don’t want to be average, subscribe to it.

    Follow me on TwitterLinkedIn for latest updates on 100 days of AI. If you are in tech you might be interested in joining my community of tech professionals here.

  • 100 Days of AI Day 9: How to create SWOT analysis for your business idea using AI?

    100 Days of AI Day 9: How to create SWOT analysis for your business idea using AI?

    About 100 Days of AI:

    I am Nataraj, I decided to spend 100 days in starting Jan 1st 2024 to learn about AI. With 100 days of AI is my goal to learn more about AI specifically LLMs and share ideas, experiments, opinions, trends & learnings through my blog posts. You can follow along the journey here.

    In this post we will look at how to create a swot analysis for any business. If you are not familiar with SWOT analysis here is a quick intro.

    Introduction to SWOT:

    SWOT stands for Strengths, Weaknesses, Opportunities & Threats. Its a simple way of evaluating any business and get ideas about how to improve it. Once you have done a SWOT analysis of a business, you can choose to compound on the strengths and create more differentiation from your competitor. You can find the weaknesses and create an action plan to fix them. You can find new areas to expand into using the opportunities as a starting point. It is essentially one of the many mental models used by business owners.

    Here is an example of SWOT analysis for a pizza business.

    StrengthsWeaknesses
    Unique garlic pizza recipe that wins top awardsHigh staff turnover
    Owner trained in Sicily at some of the best pizzeriasFloods in the area damaged the seating areas that are in need of repair
    Strong local reputationAbsence of popular calzones from menu
    Prime location on university campusNegative reviews from younger demographic for lack of hip ingredients
    OpportunitiesThreats
    Untapped catering potentialRising competition from cheaper pizza businesses nearby
    Growing local tech startup communityThere’s nearby street construction that will impact foot traffic
    Unexplored online presence and order capabilitiesRising cost of cheese
    Upcoming annual food fairNo immediate local regulatory changes but it’s election season

    How to Generate a SWOT?

    To generate above SWOT, we are essentially answering questions in the following template.

    1. Strengths
      • What unique recipes or ingredients does the pizza shop use?
      • What are the skills and experience of the staff?
      • Does the pizza shop have a strong reputation in the local area?
      • Are there any unique features of the shop or its location that attract customers?
    2. Weaknesses
      • What are the operational challenges of the pizza shop? (e.g., slow service, high staff turnover)
      • Are there financial constraints that limit growth or improvements?
      • Are there any gaps in the product offering?
      • Are there customer complaints or negative reviews that need to be addressed?
    3. Opportunities
      • Is there potential for new products or services (e.g., catering, delivery)?
      • Are there under-served customer segments or market areas?
      • Can new technologies or systems enhance the business operations?
      • Are there partnerships or local events that can be leveraged for marketing?
    4. Threats
      • Who are the major competitors and what are they offering?
      • Are there potential negative impacts due to changes in the local area (e.g., construction, closure of nearby businesses)?
      • Are there economic or industry trends that could impact the business negatively (e.g., increased ingredient costs)?
      • Is there any risk due to changes in regulations or legislation (e.g., health and safety, employment)?”””

    Our goal is to use Open AI & Semantic Kernel and be able to generate SWOT analysis for any given business. Why use Semantic Kernel? Part of the goal of this post is also to explore more functionality of Semantic Kernel. We could also achieve the same end goal using Langchain. If you like Langchain over Semantic Kernel feel free to use that.

    Step 1 – Initialize Semantic Kernel With Open AI Chat Completion:

    For this step you will need Open AI secret key. Note that Semantic Kernel can work with other LLMs and their corresponding chat completion APIs. See the documentation to find out what they support.

    Get ready Semantic Kernel

    Step 2 – Create a Semantic Function that does SWOT analysis

    Semantic functions are a way to leverage custom prompts in the Kernel world. More about it here. We will create a semantic function that takes a custom prompt for SWOT analysis of a Pizza business, give an instruction in the prompt to convert the analysis to the a given domain that is given as an input to the prompt. Here’s how it looks.

    Semantic Function for SWOT Analysis

    Step 3 – Call the Semantic Function to Generate a SWOT analysis:

    To call the semantic function that is registered with the Kernel, we need to create a context and pass it. The context also includes the new domain we want the SWOT analysis to be applied to, in this case I am using Newsletter. Since every one is starting a newsletter lets try to get a SWOT analysis template for starting a newsletter. Here’s the code for step 3.

    Calling the semantic function

    Here’s the out put:

    Output

    Not bad, the out put generated gives a great SWOT template for whether or not you should start a newsletter.

    You can expand this experiment further and generate a 2*2 matrix like the pizza example I shared above as well.

    AI PRODUCT IDEA ALERT: A website where user can enter their idea and get an output for all the business mental models that exist including SWOT.

    That’s it for Day 9 of 100 Days of AI.

    I write a newsletter called Above Average where I talk about the second order insights behind everything that is happening in big tech. If you are in tech and don’t want to be average, subscribe to it.

    Follow me on TwitterLinkedIn for latest updates on 100 days of AI. If you are in tech you might be interested in joining my community of tech professionals here.

  • Day 8: How to Build on Gpt-4 Using MSFT’s Semantic Kernel

    Day 8: How to Build on Gpt-4 Using MSFT’s Semantic Kernel

    About 100 Days of AI:

    AI, with the rise of chat-GPT, captured attention of everyone. Unlike other tech bubbles, AI wave will be enduring. Whether you’re a developer, product manager, marketer, or in any knowledge role, investing time in learning AI will be worth your time for your career. 100 days of AI is my goal to learn more about AI specifically LLMs and share ideas, experiments, opinions, trends & learnings through my blog posts. You can follow along the journey here.

    Introduction to Semantic Kernel:

    Semantic Kernel is an open source SDK from Microsoft that helps developers create AI applications including chatbots, RAGs, Copilots & agents. It is similar to what langchain does. We can probably call it as Microsoft’s answer to langchain.

    It is designed to make existing software extensible and easy to expose to AI features. It is also designed anticipating that applications would like to update their AI models to the latest and greatest versions over time.

    Semantic Kernel

    Although the space is evolving very rapidly here are some definitions to keep in mind as we explore Semantic Kernel.

    • Chat Bot: Simple chat with the user.
    • RAGs: Simple chat bot but grounded in real time & private data.
    • Copilots: Meant to be assisting us side-by-side to accomplish tasks by recommending & suggesting.
    • Agents: Respond to stimuli with limited human intervention. Agents executes tasks like sending emails, booking tickets on behalf of the user.

    How Does Semantic Kernel Work?

    To explain how Semantic Kernel works, lets take an example of taking a piece of text and converting it into 140 character tweet. But we will do this using Semantic Kernel. We have done a similar summarization in previous posts here.

    I will be using the python library of the Semantic Kernel, but since Semantic Kernal is created by Microsoft you can also do this in C# as well. Check public documentation from Microsoft on how to do this.

    Step 1: Initiate Semantic Kernel

    Below we are initiating the semantic kernel and setting up its text completion service by telling it to use OpenAI’s gpt-4 model as the LLM to use for text completion.

    import semantic_kernel as sk
    from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion, OpenAIChatCompletion
    import os
    from IPython.display import display, Markdown
    import asyncio
    
    from dotenv import load_dotenv, find_dotenv
    _ = load_dotenv(find_dotenv()) # read local .env file
    api_key = os.environ['OPENAI_API_KEY']
    
    kernel = sk.Kernel()
    kernel.add_text_completion_service("openai", OpenAIChatCompletion("gpt-4",api_key))
    print("Kernel Initiated")

    Step 2: Understanding a Semantic Function:

    In the Semantic Kernel world, we have a concept of Semantic function which is different from a native function. A native function is the regular functions that we write in any programming language. Semantic functions are encapsulations of repeatable LLM Prompts that can be orchestrated by the Kernel. You will get a better idea of what semantic function is in the next step where we will write one.

    Native & Semantic Functions

    Step 3: Create a Semantic Function

    Here we create a prompt sk_prompt that summarizes the connect in less than 140 characters (that’s our goal with this exercise). We then pass the prompt as an input to create a semantic function with the kernel and store which gives us in return the object summary_function which represents the semantic function we created and that can be repeatedly accessed via the kernel. Note that when we created a semantic function we are using a customer prompt and also giving LLM config information like max_tokens, temperature etc., Now go back to the previous image of native vs semantic functions and it will make more sense.

    sk_prompt = """
    {{$input}}
    
    Summarize the content above in less than 140 characters.
    """
    summary_function = kernel.create_semantic_function(prompt_template = sk_prompt,
                                                        description="Summarizes the input to length of an old tweet.",
                                                        max_tokens=200,
                                                        temperature=0.1,
                                                        top_p=0.5)       
    print("A semantic function for summarization has been registered.")

    Step 4: Using the Semantic Function to Summarize text into a tweet of 140 characters.

    Now we create the text that we want to summarize using the variable sk_input and call the sematic function via kernal and then display the result.

    sk_input = """
    Let me illustrate an example. Many weekends, I drive a few minutes from my house to a local pizza store to buy 
    a slice of Hawaiian pizza from the gentleman that owns this pizza store. And his pizza is great, but he always 
    has a lot of cold pizzas sitting around, and every weekend some different flavor of pizza is out of stock. 
    But when I watch him operate his store, I get excited, because by selling pizza, he is generating data. 
    And this is data that he can take advantage of if he had access to AI.
    
    AI systems are good at spotting patterns when given access to the right data, and perhaps an AI system could spot 
    if Mediterranean pizzas sell really well on a Friday night, maybe it could suggest to him to make more of it on a 
    Friday afternoon. Now you might say to me, "Hey, Andrew, this is a small pizza store. What's the big deal?" And I 
    say, to the gentleman that owns this pizza store, something that could help him improve his revenues by a few 
    thousand dollars a year, that will be a huge deal to him.
    """
    
    # using async to run the semantic function
    async def run_summary_async():
         summary_result = await kernel.run_async(summary_function, input_str=sk_input)
         display(summary_result)
    
    asyncio.run(run_summary_async())

    Here’s the output I got:

    AI can analyze sales data to help a small pizza store owner optimize his stock, potentially increasing his annual revenue.

    Semantic Kernel has more capabilities like using Semantic Functions & Native functions together and is designed to create AI applications that are powerful. I will write more about them in future posts.

    That’s it for Day 8 of 100 Days of AI.

    I write a newsletter called Above Average where I talk about the second order insights behind everything that is happening in big tech. If you are in tech and don’t want to be average, subscribe to it.

    Follow me on TwitterLinkedIn for latest updates on 100 days of AI. If you are in tech you might be interested in joining my community of tech professionals here.

  • Day 6: What are different retrieval techniques & why they are useful?

    Day 6: What are different retrieval techniques & why they are useful?

    I write a newsletter called Above Average where I talk about the second order insights behind everything that is happening in big tech. If you are in tech and don’t want to be average, subscribe to it.

    What is Retrieval in the context of building RAGs?

    In RAG (Retrieval Augmented Generation) applications, retrieval refers to the process of extracting the most relevant data chunks/splits from Vector databases based on the question received from the user. If your retrieval technique is not good it effects how good the information you can give to the user as a reply. The data chunks retrieved from the vector db are sent to the LLM as a context to generate the final answer that will be sent to the user as an output.

    Different type of retrieval techniques:

    1. Basic Semantic Similarity: In this algorithm you are retrieving data chunks from vector db that are most semantically close to the question asked by the user. For example, if the user question was “Tell me about all-white mushrooms with large fruiting bodies”. A simple semantic similarity will get you the answer but will not give the information about how they might also be piousness. Some edge cases you would see using semantic similarity would be:
      1. If we load duplicate files in data loading and our answer exists in both, the result will give both of them. So we need to get relevant & distinct results from vector embedding when we ask a question.
      2. If we ask a question where all answers should come from doc-2, but we do get answers from doc-1 as well because this is a semantic search and we haven’t explicitly controlled which doc to look into and which to skip.
    2. Maximal Marginal Relevance (MMR): In all cases of retrievals we may not want just similarity but also divergence. In the above example of Tell me about all-white mushrooms with large fruiting bodies. If we do just similar we will not give the info on how poisonous. We can instead use MMR to have some divergence in our retrievals. Here’s the algorithm of MMR on how it picks the relevant data chunks.
      1. Query the vector store
      2. Choose the fetch_K most similar responses
      3. In those responses choose K most diverse
    Maximal Marginal Relevance (MMR) Retrieval

    3. LLM Aided Retrieval: We can also use LLM to do retrieval by splitting the question into filter and the search term. Once we split the query using the LLM we pass the filter to the vector db as a metadata filter which most vector DB’s support.

    LLM Aided Retrieval

    Note that there are retrieval techniques that do not use vector databases like SVM, TF-IDF etc.,

    Retrieval is where a lot of innovation is currently happening and is changing rapidly. I will be using retrieval technique in the upcoming blog to build a chat with your data application. Keep an eye out for it.

    That’s it for Day 6 of 100 Days of AI.

    Follow me on Twitter, LinkedIn for latest updates on 100 days of AI or bookmark this page.

  • Day 5: How to get Insights from YouTube Podcast Video using Open AI & Save Time?

    Day 5: How to get Insights from YouTube Podcast Video using Open AI & Save Time?

    I write a newsletter called Above Average where I talk about the second order insights behind everything that is happening in big tech. If you are in tech and don’t want to be average, subscribe to it.

    A lot of people want podcasts transcribed and read instead of listen to them. We can go one level up and even extract insights from the podcasts as well using Open AI API. Here’s my tweet exchange which provoked this experiment.

    how to create a podcast transcript?

    So here is what we are going to do. And it will slightly different from what I suggested in the tweet. The goal is to pick a YouTube video and get transcription of that video and then using prompt engineering we extract insights, ideas, book quotes & summary etc.,

    To Summarize we achieve our goal in three steps:

    • Step 1: Select a YouTube podcast video
    • Step 2: Transcribe the video
    • Step 3: Get Insights from the transcription

    Step 1: Select a YouTube podcast video

    A recent podcast conversation that broke YouTube was Jeff Bezos on Lex Friedman podcast. So for this exercise I will pick this video.

    Step 2: Transcribe the video

    I used langchain YouTubeAudioLoader along with Open AI’s audio to text model whisper to transcribe the youtube video. As usual you would need your Open AI secret key to use the following script.

    import os
    import sys
    import openai
    
    from dotenv import load_dotenv, find_dotenv
    _ = load_dotenv(find_dotenv()) # read local .env file
    openai.api_key  = os.environ['OPENAI_API_KEY']
    
    
    ## youtube video's audio loader - langchain 
    from langchain_community.document_loaders.blob_loaders.youtube_audio import YoutubeAudioLoader
    from langchain_community.document_loaders.generic import GenericLoader
    from langchain_community.document_loaders.parsers import OpenAIWhisperParser #, OpenAIWhisperParserLocal
    
    url="https://www.youtube.com/watch?v=DcWqzZ3I2cY&ab_channel=LexFridman"
    save_dir="outputs/youtube/"
    loader = GenericLoader(
         YoutubeAudioLoader([url],save_dir),
         OpenAIWhisperParser()
     )
    docs = loader.load()
    print(docs[0].page_content[0:500])
    
    # Specify the file path where you want to save the text
    file_path = "audio-transcript.txt"
    try:
        with open(file_path, 'a', encoding='utf-8') as file:
            for doc in docs:
                file.write(doc.page_content)
        print(f'Large text saved to {file_path}')
    except FileNotFoundError:
        print(f"Error: Input file '{file_path}' not found.")
    except Exception as e:
        print(f"An error occurred: {e}")
    

    You might see the following error during running this script and I pasted the solution that works in case you are using a Windows system.

    • ERROR: Postprocessing: ffprobe and ffmpeg not found. Please install or provide the path using –ffmpeg-location.

    Running this script will generate the transcript and store it in a text file audio-transcript.txt.

    Step 3: Extract insights from the conversation

    To extract insights, I am using Open AI API and here is the script. The code is loading the transcript text and passing it along with a prompt designed to extract insights, people & books. To get more interesting thigs out of this conversation you can come up with a more interesting prompt. Note that the file name is slightly different because I had to cut the transcript to a short length since my completion query to Open AI API was exceeding my TPM limits.

    import os
    import sys
    import openai
    import shutil
    from pprint import pprint
    
    from dotenv import load_dotenv, find_dotenv
    _ = load_dotenv(find_dotenv()) # read local .env file
    openai.api_key  = os.environ['OPENAI_API_KEY']
    
    client = openai.OpenAI()
    
    file_path = "audio-transcript-copy.txt"
    try:
        with open(file_path, 'r', encoding='utf-8') as file:
            long_text = file.read()
        print(f'{file_path} is rad')
    except FileNotFoundError:
        print(f"Error: Input file '{file_path}' not found.")
    except Exception as e:
        print(f"An error occurred: {e}")
    
    prompt2 = f"""
    You will be provided with text deilimited by triple quotes.
    The given text is a podcast transcript.
    
    Provide the host and guest name.
    Summarize the transcript in to 10 points.
    
    If there are any people referred in the transcript. Extract the people mentioned and list them along with some info about them in the following format
    1. Person 1's Name: Person 1's profession or what he or she is known for or the context in which he or she was referred to.
    2. Person 2's Name: Person 2's profession or what he or she is known for or the context in which he or she was referred to.
    ...
    2. Person N's Name: Person N's profession or what he or she is known for or the context in which he or she was referred to.
    If the transcript doesnt contain refereces to any people then simply write \"No people referred to in the conversation.\"
    
    Extract the books mentioned and list them in the following format.
    1. Book 1's Title: Context in which the book was referred to.
    2. Book 2's Title: Context in which the book was referred to.
    ...
    N. Book N's Title: Context in which the book was referred to.
    If the transcript doesnt contain refereces to any books then simply write \"No books referred to in the conversation.\"
    
    IF you find any inspiration quotoes complie them in to a list.
    
    \"\"\"{long_text}\"\"\"
    """
    
    response = client.chat.completions.create(
      model="gpt-4",
      messages=[
        {
          "role": "user",
          "content": prompt2
        }
      ],
      temperature=0.7,
      #max_tokens=64,
      #top_p=1
    )
    
    print(response.choices[0].message.content)
    
    

    Here is what the output I got:

    Result: Lex Freidman & Jeff Bezos Podcast Summary

    AI PRODUCT IDEA ALERT 1: Can provide a service to podcasters to generate smart transcripts with insights. This would be a B2B play.

    AI PRODUCT IDEA ALERT 2: Instead of a service to podcast creators, it could be a B2C customers who listen to podcasts and want to get read through podcasts and want to create their own library of insights.

    Expect both these ideas to be used by existing podcast hosting companies like Spotify & launch these ideas as new features. If I was a Product Manager in any such companies I would be pitching them by now.

    That’s it for day 5 of 100 Days of AI.

    Follow me on Twitter, LinkedIn for latest updates on 100 days of AI or bookmark this page.