Conversational Intelligence Miner
Tags: cloudflarechallenge, devchallenge, ai, serverless
Published: 2024-04-14 16:29:40

*This is a submission for the [Cloudflare AI Challenge](https://dev.to/devteam/join-us-for-the-cloudflare-ai-challenge-3000-in-prizes-5f99).*

## What I Built

The **Conversational Intelligence Miner**, a specialized AI based solution designed for performing various data mining tasks on the pre-recorded conversations. At the moment, this solution is targeting the YouTube video's. However, one could easily tweak to accommodate or handle the recorded conversations in any format.

The following are the list of actions one could make as part of the  Conversational Intelligence Miner.

1. **Get Transcript**: Retrieve the textual content of a video or audio recording.
2. **Get Summary**: Generate a concise overview or synopsis of a document or content.
3. **Get Keywords**: Extract important or relevant terms or phrases from a piece of text.
4. **Get Topics**: Identify and categorize the main themes or subjects discussed in a text or conversation.
5. **Get Action Items**: Extract actionable tasks or to-do items from a document or meeting notes.
6. **Get Sentiments**: Analyze the emotional tone or sentiment expressed in text, typically as positive, negative, or neutral.
7. **Get Recommendations**: Provide suggestions or advice based on user preferences or past behavior.
8. **Get Trends**: Identify patterns or developments over time, often in data or user behavior.
9. **Get Aspects**: Extract specific features, attributes, or elements from the transcript.
10. **Get Banner**: Generate a cover image or visual representation, typically for promotional or advertising purposes.

This Conversational Intelligence Data Miner will enable everyone to have a deep understanding on the specific content because of the above-mentioned modules or features, which will helps the humans to easily perform the required operations and get the relevant insights in no time.

## Architecture

![Architecture](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z84rqi3e6s5ag88h1ajv.png)

## Demo

[Conversational Intelligence Miner Demo](https://aged-pine-90e8.ranjan-dailata.workers.dev/)

First and Foremost, you will have to click on the "Transcript" to get the YouTube video transcript. After that, all other product features like Keywords, Aspects, Trends, Topics, Recommendations etc. will get enabled.

![Getting Started](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8fq9ggqo83u2s3kik21r.png)

## Get Transcripts
![Transcripts](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wbl7o3jivm8z6tl6qv4b.png)

## Get Action Items

![Action Items](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lm1fugt51qddytppdbad.png)

## Get Aspects

![Aspects](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ylz2e6m70nf9bk4i177c.png)

## Get Keywords

![Keywords](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/glwng250ekni2p8dlp9m.png)

## Get Recommendations

![Recommendations](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/61yjzgzkg2df6cxqefvy.png)

## Get Sentiments

![Sentiments](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/58wppopjnwfafi3sdcnq.png)

## Get Summary

![Summary](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4jsgsje66n3a0nwfijiy.png)

## Get Topics

![Topics](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lkcd4jjkv3g4fus9d7qh.png)

## Get Trends

![Trends](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i2x2kh723u0ey7n3hqxo.png)

## Get Banner

![Banner](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nybv6f24bdya2o60fxaf.png)


## My Code

<!-- Show us the code! Share a public link to your repo and be sure to include a README file with installation instructions. We also encourage you to add a license for your code.  --> 

[conversation-intelligence-miner-source](https://github.com/ranjancse26/conversation-intelligence-miner/)

## Journey

<!-- Tell us about your process, the task types and models you used, what you learned, anything you are particularly proud of, what you hope to do next, etc. -->

The overall Cloudflare AI Journey was amazing. I am really proud of  building the "Serverless" Worker AI product on Cloudflare. Thanks to the folks who created an easy-to-use platform leveraging a ton of Large Language Models (LLMs). The most interesting thing which I have learned is the mechanism of interfacing with the open source LLMs with ease. Whether it could be Hugging Face models or other open source hosted LLMs which Cloudflare AI provided helped me in developing the LLM based product in no time. Especially, the ease to integrate and experiment with multiple models is what really helps the development community to experiments or experience with a variety of models.

Some Challenges

1. Tried the Summarization model @cf/facebook/bart-large-cnn, However, it's not effective in producing the right result. More over, the input max length of 1024 is the biggest issue.
2. A Majority of the models were having the max context window of 4096, However when dealing with the reasonable transcripts in general, we need a really SOLID LLM model which can support a max context window, at least 200k.

**Behind the Scenes**

1. Wondering how to fetch the YouTube Transcript? 
https://youtubetranscript.com is being utilized for this demo. You can check the repo → youtube-transcript.ts

2. How the LLM API calls are made?
The LLM model integrations are done via the Restful API approach. More info, read here - [workers-ai-restapi](https://developers.cloudflare.com/workers-ai/get-started/rest-api/)

3. What is Get Banner?
Banner is the terminology which was utilized for generating the state-of-the-art summary based textual data to branding image which one could utilize for cover page or marketing purposes.

4. How Banner Images are created?
The underlying model which was used for generating the image is "stable-diffusion-xl-base-1.0". However, the input is not the direct transcript, but instead it's a summary of the transcript.

Here's what I hope to do to next - 

- Build a full-fledged product with registration, login etc. 
- An ability for the end users to upload the media and then do the data mining against it.
- Perform some more analytics or data analysis or mining.
- Integrate with the BI Reports.
- Provide multiple user role based dashboards targeting various users of the product.
- Write unit/integration tests.
- Dealing with the reasonable or massive transcript requires an LLM with the context window of 200k or more. At least for the summarization and other key features of this product. More R&D needs to be done for effectively handling the product features and also taking into account of the LLM performance or limitations.

**Multiple Models and/or Triple Task Types**

<!-- Let us know if your project utilized multiple models per task and/or if your project used three or more task types. If so, you may qualify for our additional prize categories! If not, please remove this section. -->

This product is utilizing multiple Cloudflare AI models. 

- **llama-2-7b-chat-fp16**	- Full precision (fp16) generative text model with 7 billion parameters from Meta. It's utilized for the "Summarization" purpose.
- **llama-2-7b-chat-int8**	Quantized (int8) generative text model with 7 billion parameters from Meta. A majority of the data miners ex: Keywords, Aspects, Trends, Topics, Recommendations etc. are utilizing this model.
- **m2m100-1.2b**	Multilingual encoder-decoder (seq-to-seq) model trained for Many-to-Many multilingual translation. It's being used for the language translation purposes. The transcript translation is being done by utilizing this model.
- **stable-diffusion-xl-base-1.0** Diffusion-based text-to-image generative model by Stability AI. Generates and modify images based on text prompts. This model is being used as part of the "Banner" generation. The initial text or content is being created by the concept of transcript summarization. Later, the summary is being fed to this model for the generation of banner image.

## References

This product wouldn't have completed without referring to the publically available resources.

1. https://js2ts.com/
2. https://github.com/0x6a69616e/youtube-transcript
3. https://github.com/cloudflare/templates
4. https://github.com/cloudflare/templates/blob/main/worker-websocket