Generative AI

Starting in Mirascope: To remove Semantic Descapes using the LLM

Mirascope is a powerful and easy-useful library who provides integrated signal of the largest model (llm) model, anthropic, the vertex ai), Azure, Ai Bedrock. It makes it easy all from the end of the text and the release of formal data for building a double-free of Ai-powered Ai-Powered Flows and agent programs.

In this guide, we will focus on using Mirascope's Openaai integration and delete the Semantic Design (incidents that may vary from the same meaning but manage the same meaning) Customer review list.

To include leaning

pip install "mirascope[openai]"

Openi key

Finding the Opelai API key, visit and generate a new key. If you are a new user, you may need to add payment information and make a minimum payment of $ 5 to activate API access.

import os
from getpass import getpass
os.environ['OPENAI_API_KEY'] = getpass('Enter OpenAI API Key: ')

Defining Customer Review List

customer_reviews = [
    "Sound quality is amazing!",
    "Audio is crystal clear and very immersive.",
    "Incredible sound, especially the bass response.",
    "Battery doesn't last as advertised.",
    "Needs charging too often.",
    "Battery drains quickly -- not ideal for travel.",
    "Setup was super easy and straightforward.",
    "Very user-friendly, even for my parents.",
    "Simple interface and smooth experience.",
    "Feels cheap and plasticky.",
    "Build quality could be better.",
    "Broke within the first week of use.",
    "People say they can't hear me during calls.",
    "Mic quality is terrible on Zoom meetings.",
    "Great product for the price!"
]

This review captures key customers' feelings: sound quality and easy-to-use, the battery life complaint, the quality of the building, and the call / maches, and a good book for the amount. They show the common themes found in the actual user feedback.

Definingydantic SCHEMA

This Pydantic model describes the formation of the Semantic Feakicization response to customer review. This schema helps make-up and ensure the output of the language model given the installation of the natural language or submission to the entry (eg user's reply, BUG reports, product reviews).

from pydantic import BaseModel, Field

class DeduplicatedReviews(BaseModel):
    duplicates: list[list[str]] = Field(
        ..., description="A list of semantically equivalent customer review groups"
    )
    reviews: list[str] = Field(
        ..., description="The deduplicated list of core customer feedback themes"
    )

Defining Mirascope @ Openi.Call for Semantic Feakication

This code describes the function of Semantic Feakulation using Mirascope's @ Cai.Call Consorator, which enables the seamless compilation of the Opela-4O model. Redopliple_customer_review function takes the customer update list and immediately using the Rompt_Template Detorator-directing the LLM in identity and offices with similar updates.

The system message lists the model to analyze the meaning, tone, and purpose after each review, combine those passing on the same response even if they mean different. Work expects an organized response to the decumplicteview model

The project ensures that the llM exit is all accurate and typed, making it good for an analysis of customer feedback, survey reading, or updating update.

from mirascope.core import openai, prompt_template

@openai.call(model="gpt-4o", response_model=DeduplicatedReviews)
@prompt_template(
    """
    SYSTEM:
    You are an AI assistant helping to analyze customer reviews. 
    Your task is to group semantically similar reviews together -- even if they are worded differently.

    - Use your understanding of meaning, tone, and implication to group duplicates.
    - Return two lists:
      1. A deduplicated list of the key distinct review sentiments.
      2. A list of grouped duplicates that share the same underlying feedback.

    USER:
    {reviews}
    """
)
def deduplicate_customer_reviews(reviews: list[str]): ...

The following code issues Redopliple_customer_review operators using customer review list and printer printer. First, it costs work and stored the result in response to response. To ensure that the model effect relates to the expected format, it uses the expected statement to ensure that the answer is an example of Redoblivezelviewviewview Viewy Psydacrevieweview model.

Once it is guaranteed, the results are published in two phase. The first phase, written “✅ Answer for different customer,” displays a list of different reviews identified by the model. Section Two, “

response = deduplicate_customer_reviews(customer_reviews)

# Ensure response format
assert isinstance(response, DeduplicatedReviews)

# Print Output
print("✅ Distinct Customer Feedback:")
for item in response.reviews:
    print("-", item)

print("n🌀 Grouped Duplicates:")
for group in response.duplicates:
    print("-", group)

Release reflects a clean customer refuse summary by editing similar updates. The different customer feedback highlights the key understanding, and the collection section holds different feelings of the same feelings. This helps to re-eliminate and make the answer easier to evaluate.


Check full codes. All credit for this study goes to research for this project.

We're ready to contact 1 million Devs / Engineers / Investigators? See that NVIADIA research, LG AI, and senior AI services MarktechPost benefit to their target audience [Learn More]


I am the student of the community engineering (2022) from Jamia Millia Islamia, New Delhi, and I am very interested in data science, especially neural networks and their application at various locations.

Source link

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button