<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Sentence Generation on Subculture Science Research Group&#39;s Blog</title>
    <link>https://www.subcul-science.com/en/tags/sentence-generation/</link>
    <description>Recent content in Sentence Generation on Subculture Science Research Group&#39;s Blog</description>
    <generator>Hugo</generator>
    <language>en-US</language>
    <lastBuildDate>Tue, 19 Jan 2021 03:03:11 +0900</lastBuildDate>
    <atom:link href="https://www.subcul-science.com/en/tags/sentence-generation/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Using BART (sentence summary model) with hugging face</title>
      <link>https://www.subcul-science.com/en/post/20210119huggingface/</link>
      <pubDate>Tue, 19 Jan 2021 03:03:11 +0900</pubDate>
      <guid>https://www.subcul-science.com/en/post/20210119huggingface/</guid>
      <description>&lt;ul&gt;&#xA;&lt;li&gt;BART is a model for document summarization&lt;/li&gt;&#xA;&lt;li&gt;Derived from the same transformer as BERT&lt;/li&gt;&#xA;&lt;li&gt;Unlike BERT, it has an encoder-decoder structure&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This is because it is intended for sentence generation&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This page shows the steps to run a tutorial on BART.&lt;/p&gt;&#xA;&lt;h2 id=&#34;procedure&#34;&gt;Procedure&lt;/h2&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;install transformers&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Run ``sh&#xA;pip install transformers&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Run summary&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;2. Run the summary&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;from transformers import BartTokenizer, BartForConditionalGeneration, BartConfig&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;model = BartForConditionalGeneration.from_pretrained(&amp;#39;facebook/bart-large&amp;#39;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;tokenizer = BartTokenizer.from_pretrained(&amp;#39;facebook/bart-large&amp;#39;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ARTICLE_TO_SUMMARIZE = &amp;#34;My friends are cool but they eat too many carbs.&amp;#34;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;inputs = tokenizer([ARTICLE_TO_SUMMARIZE], max_length=1024, return_tensors=&amp;#39;pt&amp;#39;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# Generate Summary&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;summary_ids = model.generate(inputs[&amp;#39;input_ids&amp;#39;], num_beams=4, max_length=5, early_stopping=True)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;print([tokenizer.decode(g, skip_special_tokens=True, clean_up_tokenization_spaces=False) for g in summary_ids])&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;```&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;On 2021/01/18, the output was MyMy friends.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Interesting.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;## Where I got stuck.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Error when the version of pytorch is different from the one specified in transformers.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;pip install -U torch&lt;/p&gt;</description>
    </item>
    <item>
      <title>I made a summary text generation AI for making short-form news</title>
      <link>https://www.subcul-science.com/en/post/20200613abstractnews/</link>
      <pubDate>Sat, 13 Jun 2020 00:24:00 +0900</pubDate>
      <guid>https://www.subcul-science.com/en/post/20200613abstractnews/</guid>
      <description>&lt;p&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We have successfully trained a model to automatically generate titles from news texts using a machine translation model based on deep learning.&lt;/p&gt;&#xA;&lt;h2 id=&#34;preliminaries&#34;&gt;Preliminaries&lt;/h2&gt;&#xA;&lt;p&gt;In the past, I was involved in a project to automatically generate titles from manuscripts for online news. In the past, I was involved in a project to automatically generate titles from manuscripts for online news.&lt;/p&gt;&#xA;&lt;p&gt;In order to tackle this project, I was looking into existing methods.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
