Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Read by thought-leaders and decision-makers around the world. Phone Number: +1-650-246-9381 Email: pub@towardsai.net
228 Park Avenue South New York, NY 10003 United States
Website: Publisher: https://towardsai.net/#publisher Diversity Policy: https://towardsai.net/about Ethics Policy: https://towardsai.net/about Masthead: https://towardsai.net/about
Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Founders: Roberto Iriondo, , Job Title: Co-founder and Advisor Works for: Towards AI, Inc. Follow Roberto: X, LinkedIn, GitHub, Google Scholar, Towards AI Profile, Medium, ML@CMU, FreeCodeCamp, Crunchbase, Bloomberg, Roberto Iriondo, Generative AI Lab, Generative AI Lab VeloxTrend Ultrarix Capital Partners Denis Piffaretti, Job Title: Co-founder Works for: Towards AI, Inc. Louie Peters, Job Title: Co-founder Works for: Towards AI, Inc. Louis-François Bouchard, Job Title: Co-founder Works for: Towards AI, Inc. Cover:
Towards AI Cover
Logo:
Towards AI Logo
Areas Served: Worldwide Alternate Name: Towards AI, Inc. Alternate Name: Towards AI Co. Alternate Name: towards ai Alternate Name: towardsai Alternate Name: towards.ai Alternate Name: tai Alternate Name: toward ai Alternate Name: toward.ai Alternate Name: Towards AI, Inc. Alternate Name: towardsai.net Alternate Name: pub.towardsai.net
5 stars – based on 497 reviews

Frequently Used, Contextual References

TODO: Remember to copy unique IDs whenever it needs used. i.e., URL: 304b2e42315e

Resources

Our 15 AI experts built the most comprehensive, practical, 90+ lesson courses to master AI Engineering - we have pathways for any experience at Towards AI Academy. Cohorts still open - use COHORT10 for 10% off.

Publication

Natural Language Generation (X2Text) Tasks
Artificial Intelligence   Data Science   Latest   Machine Learning

Natural Language Generation (X2Text) Tasks

Last Updated on April 22, 2025 by Editorial Team

Author(s): Sarvesh Khetan

Originally published on Towards AI.

Table of Contents

  1. Image2Text
  2. Speech2Text
  3. Video2Text
Natural Language Generation (X2Text) Tasks

Image2Text i.e. Image Captioning

Idea

Researchers came up with a very innovative idea to solve this problem. They framed this problem as a next word prediction task (with only input word as <START>) conditioned on image information. Obviously instead of next word prediction this could be next character prediction / next subword prediction but for simplicity we will consider next word prediction problem.

Now we know that for next word prediction we can use any sequence model like (you cannot use bidirectional models like transformer encoder)

  • RNN (unidirectional) or stacked
  • LSTM (unidirectional) or stacked
  • GRU (unidirectional) or stacked
  • Decoder Transformer (unidirectional) or stacked

Below I have shown how to add image information to LSTM and Transformers like architectures!!

Image Conditioned LSTM for Next Word Prediction

Method 1

Here idea is to condition the LSTM by adding the image information to the first hidden state of the LSTM as shown below.

Method 2

Instead of feed the image embedding only to the first hidden state of LSTM you can send it to each and every hidden state of the LSTM at the every timestamp but it was found that this performs worse compared to above approach.

Method 3

Here idea to add image information is by using image token as first input to the LSTM network as shown in the below diagram.

multimodal_ai/image_captioning.ipynb at main · khetansarvesh/multimodal_ai

Contribute to khetansarvesh/multimodal_ai development by creating an account on GitHub.

github.com

Image Conditioned Transformers for Next Word Prediction

Self Attention to inculcate Image Information

Above I have shown conditioning the transformer using images via self attention instead we could have also use cross attention to condition the image information.

Applications — OCR

We already saw one method to solve OCR here. Following is another idea which worked much better compared to this :

  • Use object detection model to identify bounding boxes where text is present in the image
  • Now create an image captioning model which can take input such images and output text inside it.
Natural Language Generation (X2Text) Tasks

Audio2Text / Speech2Text eg audio transcription (also called Speech Recognition or Automatic Speech Recognition (ASR) System)

The idea remains same as we saw in Image2Text i.e. we will treat this as a next word prediction task (with only input word as <START>) conditioned on audio information.

Language Model Conditioned on Audio

Whisper by OpenAI was built on above idea where they used a transformer based model for next word prediction which was conditioned (using cross attention) by speech embeddings. They got speech embeddings by converting speech into images and then using ViT to convert these images into embeddings !!

Natural Language Generation (X2Text) Tasks

Video2Text i.e. Video Captioning

The idea remains same as we saw in Image2Text i.e. we will treat this as a next word prediction task (with only input word as <START>) conditioned on video information.

Language Model Conditioned on Video

Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor.

Published via Towards AI


Take our 90+ lesson From Beginner to Advanced LLM Developer Certification: From choosing a project to deploying a working product this is the most comprehensive and practical LLM course out there!

Towards AI has published Building LLMs for Production—our 470+ page guide to mastering LLMs with practical projects and expert insights!


Discover Your Dream AI Career at Towards AI Jobs

Towards AI has built a jobs board tailored specifically to Machine Learning and Data Science Jobs and Skills. Our software searches for live AI jobs each hour, labels and categorises them and makes them easily searchable. Explore over 40,000 live jobs today with Towards AI Jobs!

Note: Content contains the views of the contributing authors and not Towards AI.