# Generate sentences from keywords only

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgenerate-sentences-from-keywords-only%2F12315%3E%5C
**Category:** Beginners\
**Created:** [November 26, 2021, 4:07pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgenerate-sentences-from-keywords-only%2F12315 "2021-11-26T16:07:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wz6](https://avatars.discourse-cdn.com/v4/letter/w/e9a140/32.png) [@wz6](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fwz6)%5C
**Post date:** [November 26, 2021, 4:07pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgenerate-sentences-from-keywords-only%2F12315%2F1 "2021-11-26T16:07:18Z")

</div>

Hi everyone, I am trying to generate sentences from a few keywords only. May I know which model and function I shall use? Thank you and I am a very beginner.

E.g.,  
Input: “dinner”, “delicious”, “wonderful”, “steak”  
Output: “We had a wonderful dinner yesterday and the steak was super delicious.”

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnielsr)%5C
**Post date:** [November 26, 2021, 4:33pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgenerate-sentences-from-keywords-only%2F12315%2F2 "2021-11-26T16:33:29Z")

</div>

Seq2seq models like T5 and BART are well-suited for this. You can fine-tune them on (list of keywords, sentence) pairs in a supervised manner.

---

<div class="post-metadata">

**Author:** ![wz6](https://avatars.discourse-cdn.com/v4/letter/w/e9a140/32.png) [@wz6](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fwz6)%5C
**Post date:** [November 26, 2021, 4:48pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgenerate-sentences-from-keywords-only%2F12315%2F3 "2021-11-26T16:48:09Z")

</div>

Thank you very much @nielsr!!  
Is there any sample code that I could follow?  
Happy Thanksgiving!

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnielsr)%5C
**Post date:** [November 26, 2021, 4:56pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgenerate-sentences-from-keywords-only%2F12315%2F4 "2021-11-26T16:56:29Z")

</div>

Hi,

Yes you can take a look at the notebooks I made regarding fine-tuning T5 on custom data: [Transformers-Tutorials/T5 at master · NielsRogge/Transformers-Tutorials · GitHub](https://github.com/NielsRogge/Transformers-Tutorials/tree/master/T5)

Note that seq2seq models like T5/BART are very general: they just take a sequence as input, and produce another sequence as output. So this could be anything, e.g.

- translating from one language to another (input sequence: French sentence, output sequence: English sentence for instance)
- summarizing long text (input sequence: long article, output sequence: short summary)
- text-to-SQL (input sequence: text describing a query in natural language, output sequence: SQL query)
- code-to-docstring (this is what I do in one of the notebooks linked above)
- SQL-to-text
- etc.

So definitely, keywords-to-sentence will also work well.

---

<div class="post-metadata">

**Author:** ![wz6](https://avatars.discourse-cdn.com/v4/letter/w/e9a140/32.png) [@wz6](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fwz6)%5C
**Post date:** [November 26, 2021, 5:00pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgenerate-sentences-from-keywords-only%2F12315%2F5 "2021-11-26T17:00:28Z")

</div>

Hi @nielsr,

Thank you very much for your detailed reply and your effort of making this tutorial. This helps me a lot! So really appreciate it.
