Applying Large Language Models

-

Application of OpenAI

OpenAI LLM’s humongous training data give them access to an exceedingly large knowledge corpus. This inherently makes them ideal for working around content-based use cases.

Some use cases where they’ve already been applied are:

  • Summarisation
  • Content enrichment
  • Title creation
  • Rephrasing
  • Creating multiple formats like short form, tweets, presentation points etc.

The above usages involve giving content as an input context to the LLM with instructions or prompts to suggest what’s required. The LLM then does the duty with ease and aplomb and the generated content is reviewed and used.

Within the above cases, the language capabilities of the LLM were used to resolve or assist in content related work.

Other use cases where the inherent knowledge of the LLM is used are:

  • Quiz content generation
  • Polls or Survey Questionnaire.

Context-Based QnA

Passing an input context and answering questions on the identical is a task which LLM’s are quite adept at. This capability is getting used for a lot of content like getting queries answered on Long Form Articles or PDF documents.

The general solution involves making a prompt in the next general format:

Context:

Ziro Valley in Arunachal Pradesh is home to the Apatani tribe, and is understood for its picture-perfect valley views. Ziro is roughly 167 kms from the capital city Itanagar, and the drive to it’s one of the crucial scenic drives you’ll experience in Arunachal Pradesh. The valley is surrounded by lush green forest and terrace farms that look stunning any time of the 12 months. the gentle brooks gurgling away by the side of the road, you get a way of peace in Ziro. No wonder, the valley is one of the crucial visited places in Arunachal Pradesh.

This idyllic setting of Ziro Valley is certainly one of the primary explanation why the annual Ziro Festival of Music is held here, right within the green meadows. The festival venue is one of the crucial beautiful venues in India. Music lovers from throughout India and the world come here for the festival and the good vibe.

Prompt Instructions: Answer the below query in 100 words from the provided context above

Query: How far is Ziro from the capital?

Answer:

The LLM provides the reply to the query from the provided context. One must fiddle around with the prompt setup to get the specified result.

This overall approach opens up the world for answering user queries based on a content corpus. For instance, a corpus created of stories and articles on the budget could be used to easily answer queries that readers could have. This short circuits the normal model of user providing a search string after which a bunch of article links are displayed, which the user must read through to get the reply they need. This provides a significantly better user experience and saves them lots of time.

The approach revolves around providing the fitting context to the LLM in order that it could answer the query. Thus, the issue now’s tips on how to discover the right set of snippets from the corpus that are relevant to the query, as LLM app has limitations on the quantity of input that could be sent.

That is primarily a search problem now. Content could be broken down into snippets and indexed. A vector database like Pinecone or Milvus could be used to achieve this. The content is vectorized and stored within the database. When the user asks an issue, simply vectorize the query and do similarity search to get the relevant snippets.

Smarter free text search

Free text search is simpler from a UX perspective in comparison with the normal filter based searching. Nonetheless, it involves developing complex parsing logic to discover the search filters from the user provided textual input. Thus, it’s liable to bugs or a small set of fixed textual input formats.

LLM’s language capability could be leveraged here to parse the search text and discover the search parameters.

The general solution involves making a prompt in the next general format:

Prompt Instructions: Parse the provided input query into the next JSON format”

JSON Format:

{“place”: “Place one is visiting. Mandatory” , “checkInDate”: ”The check-in date for reservation. Mandatory. Format dd/mm/yyyy”, “checkOutDate” : “ The check-out date for reservation. Mandatory. Default CheckIn plus 2 days. Format dd/mm/yyyy”, “minimumRating”: “Minimum rating required for the hotel. Optional”, “maximumPricePerNight”: “Maximum price per night one is willing to pay. Optional” }

Examples:

Query: In search of rooms from twenty third July till 28 July in shimla with rating of 4 and above.

Answer: {“place”: “Shimla” , “checkInDate”: ”23/07/2023”, “checkOutDate” : “28/07/2023”, “minimumRating”: “4”}

Query: In search of rooms from 15 Aug for 3 days in Darjeeling.

Answer: {“place”: “Darjeeling” , “checkInDate”: ”15/08/2023”, “checkOutDate” : “17/08/2023”}

Query: Happening a vacation to Pondicherry for five days from third September.

Answer:

On this case, we used a capability of the LLM called Zero Shot Learning. Other than the instructions we also gave few sample examples to indicate the expected output for a set of questions. LLM have demonstrated great capabilities in advantageous tuning their behavior by learning from the small set of samples.

The LLM would parse the user query and supply a JSON in a set format. The identical can then be simply used to power up the actual search functionality.

On this case the LLM is actually a sensible text parser.

Support Bot

Let’s take an example of a travel booking application to explore this use case.

A user interacts with a support bot to get answers to queries around tips on how to use an application, or general advantages etc. Or they need to get answers around their transactions that they’ve done on the appliance.

A corpus of the applications general usage, contents related to the appliance could be created to reply queries on the identical.

Similarly, a sensible LLM based query parser could be used to parse user queries around their bookings after which fetch the booking records. Since an application could have multiple kinds of user transactions, the LLM parser could be tuned to offer the transaction type in addition to the params for the actual transaction.

Incorporating each the functionality together on a single frontend bot would also involve a step whereby we want to discover what’s the intent of the user, whether the query is about tips on how to do a transaction or status of the last transaction. Hereto, the LLM could be used to appropriately discover the intent of the user.

Thus, the general solution involves:

  • Identifying the Intent: Corpus Query or Booking Query
  • Processing Corpus Query
  • Searching corpus
  • Identifying relevant snippets
  • Invoking LLM passing relevant snippets and user query.
  • Processing Booking Query
  • Invoking LLM to discover the sort and parameters
  • Parse LLM response JSON.
  • Invoking appropriate functions.
Fig 1: Support Bot for a Travel Application.
ASK ANA

What are your thoughts on this topic?
Let us know in the comments below.

3 COMMENTS

0 0 votes
Article Rating
guest
3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Share this article

Recent posts

3
0
Would love your thoughts, please comment.x
()
x