Large Language Models

In a world filled with data, language is your key to making sense of it all. It turns complex information into simple insights, answers questions in a snap, and helps you understand the emotions behind words.


Bluemist AI integrates seamlessly with Hugging Face Transformers, empowering users to accomplish various natural language processing tasks effortlessly. With this integration, you can perform document question answering, generate insightful responses to questions, summarize lengthy text for easier understanding, and analyze sentiment within text. The wrapper simplifies the utilization of powerful models, enhancing productivity and enabling effective interpretation of textual data.


class TaskModels[source]

Bases: object

Class representing a collection of tasks and their associated models. It serves as a powerful wrapper for Hugging Face models, streamlining natural language processing tasks.

It offers simplified interfaces for four key functions:
  • Document Question Answering

  • Question Answering

  • Summarize

  • Sentiment Analysis

Users can initialize an instance of the class to access these functionalities effortlessly. Bluemist AI is designed to simplify complex NLP operations, making it an invaluable tool for text analysis and understanding.

get_all_tasks()[source]

Retrieves all available tasks.

Returns:

A list of all available tasks.

Return type:

list

static get_models_for_task(task_name, limit)[source]

Retrieves the available models for a given task.

Parameters:
  • task_name (str) – The task for which to retrieve the models.

  • limit (int, optional) – The maximum number of models to retrieve

Returns:

A list of available models for the specified task.

Return type:

list

perform_task(task_name, input_data, question=None, min_length=30, max_length=130, do_sample=False, override_models=None, limit=5, evaluate_models=True)[source]

Performs the task on the given dataset, evaluate the models and returns comparison metrics

task_namestr, default=None

Supported tasks can be retrieved from the TaskModels class using the get_all_tasks method.

input_datastr

Text or information used by the model to perform specific NLP tasks.

questionstr, default=None

Specific query or question provided as input to the model for question-answering tasks. The model uses this question to find the relevant answer within the provided context.

min_length: number, default=30

The minimum length of the generated summary. Defaults to 30. The summarization model ensures that the summary is at least this length.

max_lengthnumber, default=130

The maximum length of the generated summary. Defaults to 130. The summarization model limits the summary to a maximum of this length.

do_sampleboolean, default=False

Whether to use sampling during summary generation. Defaults to False. When True, the model uses a sampling technique for token selection.

override_modelsstr or list, default=None

Provide additional models not part of the pre-configured list

limitint, default=5

Limit the number of models to be compared. Default is 5.

evaluate_modelsboolean, default=True

Determine if model comparison is requested. False will override limit as 1


Document Question Answering

Document Question Answering (DQA), also known as Document Visual Question Answering, involves leveraging multi-modal features to answer questions about document images in natural language. It combines text, word positions, and images to generate meaningful responses. An illustrative example showcases DQA balancing cost efficiency with quality customer service in response to specific queries. DQA models prove versatile, adaptable to visually-rich and non-visually-rich documents, aiding in structured document parsing and invoice information extraction.

For more details, refer https://huggingface.co/tasks/document-question-answering


Question Answering

Question Answering (QA) models provide answers to questions based on a given text, aiding in document search and automating responses to frequently asked questions. These models can generate answers either with or without context. QA models can be utilized with the HuggingFace Transformers library using the question-answering pipeline, and various task variants can be addressed.

For more details, refer https://huggingface.co/tasks/question-answering


Summarization

Summarization models are designed to create concise versions of given documents while preserving crucial information. The process involves extracting or generating shorter text while maintaining the essence of the original content. Users can benefit from this tool in various scenarios, such as summarizing research papers for efficient literature review, or condensing lengthy paragraphs for improved understanding. The integration with Hugging Face Transformers allows for effortless implementation and utilization of state-of-the-art summarization models. With a simple API call, users can summarize any given text using pre-trained models, making content processing and comprehension more efficient.

For more details, refer https://huggingface.co/tasks/summarization


Sentiment Analysis

Sentiment Analysis models facilitates the understanding of sentiments conveyed within a given piece of text. It classifies the sentiment as positive, negative, or neutral, enabling valuable insights into the emotional tone of textual content. Users can apply this tool across a range of applications, from social media monitoring to product reviews analysis, helping businesses gauge public opinion and make informed decisions. The integration seamlessly connects users to state-of-the-art sentiment analysis models, simplifying the process and providing accurate sentiment assessments with ease.

For more details, refer https://huggingface.co/blog/sentiment-analysis-python


Code Samples and API deployment

Jupyter notebook with code samples for document-question-answering, question-answering, summarization and sentiment-analysis

llm_jupyter_notebook

To test the API, open the browser and navigate to http://localhost:8000/docs


API handbook for Document Question Answering

_images/llm_document_question_answering.png

API handbook for Question Answering

_images/llm_question_answering.png

API handbook for Sentiment Analysis

_images/llm_sentiment_analysis.png

API handbook for Summarization

_images/llm_summarization.png