<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Machine Learning on サブカル科学研究会のブログ</title>
    <link>https://www.subcul-science.com/tags/machine-learning/</link>
    <description>Recent content in Machine Learning on サブカル科学研究会のブログ</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Sat, 05 Jul 2025 21:00:38 +0900</lastBuildDate>
    <atom:link href="https://www.subcul-science.com/tags/machine-learning/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>How to Efficiently Solve Low Accuracy and High Cost Issues in Japanese Text Generation with T5</title>
      <link>https://www.subcul-science.com/post/20250705japanese-text-generation-solution/</link>
      <pubDate>Sat, 05 Jul 2025 21:00:38 +0900</pubDate>
      <guid>https://www.subcul-science.com/post/20250705japanese-text-generation-solution/</guid>
      <description>&lt;h2 id=&#34;challenges-in-japanese-text-generation&#34;&gt;Challenges in Japanese Text Generation&lt;/h2&gt;&#xA;&lt;p&gt;When working on Japanese text summarization, title generation, and document classification tasks, do you face these problems?&lt;/p&gt;&#xA;&lt;h3 id=&#34;1-accuracy-issues&#34;&gt;1. Accuracy Issues&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Traditional rule-based methods cannot generate natural Japanese text&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;English-oriented models cannot handle Japanese grammar and expressions&lt;/li&gt;&#xA;&lt;li&gt;Need to build separate models for multiple tasks&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;2-development-cost-issues&#34;&gt;2. Development Cost Issues&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Time and resources required for task-specific model development&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;Different approaches needed for document classification, summarization, and title generation&lt;/li&gt;&#xA;&lt;li&gt;Enormous effort required for preparing training data and building models&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;3-operational-complexity&#34;&gt;3. Operational Complexity&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Need to manage and operate multiple models&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;Different APIs and interfaces for each task&lt;/li&gt;&#xA;&lt;li&gt;Complex model updates and maintenance&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;real-world-text-generation-challenge-cases&#34;&gt;Real-world Text Generation Challenge Cases&lt;/h2&gt;&#xA;&lt;h3 id=&#34;failure-case-limitations-of-task-specific-individual-development&#34;&gt;Failure Case: Limitations of Task-specific Individual Development&lt;/h3&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-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# Traditional approach&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;classification_model&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;load_bert_classifier&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;      &lt;span class=&#34;c1&#34;&gt;# For document classification&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;summarization_model&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;load_summarization_model&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;   &lt;span class=&#34;c1&#34;&gt;# For summarization&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;title_generation_model&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;load_title_model&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;        &lt;span class=&#34;c1&#34;&gt;# For title generation&lt;/span&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;&lt;span class=&#34;c1&#34;&gt;# Problems:&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# - Managing 3 separate models&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# - 3x memory usage&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# - High development and maintenance costs&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The solution to this problem is &lt;strong&gt;Japanese T5 (Text-To-Text Transfer Transformer)&lt;/strong&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Why is fasttext so fast?</title>
      <link>https://www.subcul-science.com/post/20210519fasttext/</link>
      <pubDate>Wed, 19 May 2021 02:10:01 +0900</pubDate>
      <guid>https://www.subcul-science.com/post/20210519fasttext/</guid>
      <description>&lt;h2 id=&#34;features-of-fasttext&#34;&gt;Features of fasttext&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Improved objective function&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Consideration of negative samples&lt;/li&gt;&#xA;&lt;li&gt;This should not affect training time.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Change in optimization method&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use of stochastic optimization&lt;/li&gt;&#xA;&lt;li&gt;If it affects the learning time, it should be this one&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Implementation in C language&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This is the most effective, isn&amp;rsquo;t it?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If we implement it in ## pytorch, it won&amp;rsquo;t be much different from word2vec.&#xA;It would depend on the amount of data to be trained.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Creating data in Natural Language Inference (NLI) format for Sentence transformer</title>
      <link>https://www.subcul-science.com/post/20210217nlibert/</link>
      <pubDate>Wed, 17 Feb 2021 10:32:03 +0900</pubDate>
      <guid>https://www.subcul-science.com/post/20210217nlibert/</guid>
      <description>&lt;p&gt;Using the Sentence Transformer to&#xA;I&amp;rsquo;m trying to use Sentence Transformer to infer causal relationships between documents.&lt;/p&gt;&#xA;&lt;p&gt;If we can do this, we can extract the cause and symptoms of the incident from the report.&lt;/p&gt;&#xA;&lt;p&gt;So, I wondered if NLI could be used for feature learning to extract causal information. I thought.&lt;/p&gt;&#xA;&lt;h2 id=&#34;what-is-nli&#34;&gt;What is NLI?&lt;/h2&gt;&#xA;&lt;p&gt;Inference of the relationship between two sentences&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Forward&lt;/li&gt;&#xA;&lt;li&gt;Inverse&lt;/li&gt;&#xA;&lt;li&gt;Unrelated&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The three relations are.&lt;/p&gt;&#xA;&lt;h2 id=&#34;apply-to-causal-relationships&#34;&gt;Apply to causal relationships&lt;/h2&gt;&#xA;&lt;p&gt;If we apply the three relationships of NLI to causality, the following patterns are possible.&lt;/p&gt;</description>
    </item>
    <item>
      <title>On the use of distributed representations bagging for class classification and generalization performance</title>
      <link>https://www.subcul-science.com/post/20210204classifier/</link>
      <pubDate>Thu, 04 Feb 2021 13:24:19 +0900</pubDate>
      <guid>https://www.subcul-science.com/post/20210204classifier/</guid>
      <description>&lt;p&gt;After the distributed representation has been obtained, the&#xA;After the distributed representation is obtained, machine learning can be used to classify it.&lt;/p&gt;&#xA;&lt;p&gt;Models that can be used include&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Decision Tree&lt;/li&gt;&#xA;&lt;li&gt;SVM Support Vector Machine&lt;/li&gt;&#xA;&lt;li&gt;NN Neural Networks&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;and others.&lt;/p&gt;&#xA;&lt;p&gt;SVM is included in NN in a broad sense.&lt;/p&gt;&#xA;&lt;p&gt;In this section, we will use the decision tree method.&lt;/p&gt;&#xA;&lt;h2 id=&#34;bagging&#34;&gt;Bagging&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Image of majority voting with multiple decision trees&lt;/li&gt;&#xA;&lt;li&gt;Simple theory&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Decision trees are highly explainable and are a classic machine learning model.&lt;/li&gt;&#xA;&lt;li&gt;Computational load is light compared to deep learning&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Depends on the size of the model&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Not much explainability&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Do we want to analyze each of the multiple decision trees?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;``py&#xA;from sklearn.ensemble import BaggingClassifier&#xA;from sklearn.tree import DecisionTreeClassifier&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to train a Japanese model with Sentence transformer to get a distributed representation of a sentence</title>
      <link>https://www.subcul-science.com/post/20210203sbert/</link>
      <pubDate>Wed, 03 Feb 2021 15:58:41 +0900</pubDate>
      <guid>https://www.subcul-science.com/post/20210203sbert/</guid>
      <description>&lt;p&gt;.&#xA;BERT is a model that can be powerfully applied to natural language processing tasks.&lt;/p&gt;&#xA;&lt;p&gt;However, it does not do a good job of capturing sentence-wise features.&lt;/p&gt;&#xA;&lt;p&gt;Some claim that sentence features appear in [ CLS\ ], but&#xA;This paper](&lt;a href=&#34;https://arxiv.org/abs/1908.10084&#34;&gt;https://arxiv.org/abs/1908.10084&lt;/a&gt;) claims that it does not contain that much useful information for the task.&lt;/p&gt;&#xA;&lt;p&gt;Sentence BERT is a model that extends BERT to be able to obtain features per sentence.&lt;/p&gt;&#xA;&lt;p&gt;The following are the steps to create Sentence BERT in Japanese.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Using BART (sentence summary model) with hugging face</title>
      <link>https://www.subcul-science.com/post/20210119huggingface/</link>
      <pubDate>Tue, 19 Jan 2021 03:03:11 +0900</pubDate>
      <guid>https://www.subcul-science.com/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>Procedure for obtaining a distributed representation of a Japanese sentence using a trained Universal Sentence Encoder</title>
      <link>https://www.subcul-science.com/post/universal-sentence-encoder/</link>
      <pubDate>Mon, 22 Jun 2020 18:29:00 +0900</pubDate>
      <guid>https://www.subcul-science.com/post/universal-sentence-encoder/</guid>
      <description>&lt;p&gt;.&lt;/p&gt;&#xA;&lt;p&gt;A vector of documents can be obtained using Universal Sentence Encoder.&lt;/p&gt;&#xA;&lt;h2 id=&#34;features&#34;&gt;Features&lt;/h2&gt;&#xA;&lt;p&gt;Supports multiple languages.&lt;/p&gt;&#xA;&lt;p&gt;Japanese is supported.&lt;/p&gt;&#xA;&lt;p&gt;Can handle Japanese sentences as vectors.&lt;/p&gt;&#xA;&lt;h2 id=&#34;usage&#34;&gt;Usage&lt;/h2&gt;&#xA;&lt;p&gt;Clustering, similarity calculation, feature extraction.&lt;/p&gt;&#xA;&lt;h2 id=&#34;usage-1&#34;&gt;Usage&lt;/h2&gt;&#xA;&lt;p&gt;Execute the following command as preparation.&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-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;pip install tensorflow tensorflow_hub tensorflow_text numpy   &#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Trained models are available.&lt;/p&gt;&#xA;&lt;p&gt;See the python description below for details on how to use it.&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-py&#34; data-lang=&#34;py&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;tensorflow_hub&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;as&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;hub&lt;/span&gt;  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;tensorflow_text&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;numpy&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;as&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;np&lt;/span&gt;  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# for avoiding error  &lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;ssl&lt;/span&gt;  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;ssl&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;_create_default_https_context&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ssl&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;_create_unverified_context&lt;/span&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;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;cos_sim&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;v1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;v2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;np&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;dot&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;v1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;v2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;/&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;np&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;linalg&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;norm&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;v1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;*&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;np&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;linalg&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;norm&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;v2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;))&lt;/span&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;&lt;span class=&#34;n&#34;&gt;embed&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;hub&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;load&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;https://tfhub.dev/google/universal-sentence-encoder-multilingual/3&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&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;&lt;span class=&#34;n&#34;&gt;texts&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;I saw a comedy show yesterday.&amp;#34;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;There was a comedy show on TV last night.&amp;#34;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;I went to the park yesterday.&amp;#34;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;I saw a comedy show last night.&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;Yesterday, I went to the park.&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;]&lt;/span&gt;  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;vectors&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;embed&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;texts&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;err&#34;&gt;```&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&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;&lt;span class=&#34;n&#34;&gt;See&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;the&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;following&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;link&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;more&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;details&lt;/span&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;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Try&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Universal&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Sentence&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Encoder&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Japanese&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;](&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;https&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;//&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;qiita&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;com&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;kenta1984&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;items&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;9613&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;da23766a2578a27a&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&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;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;### Postscript&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;err&#34;&gt;```&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;py&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;tensorflow_text&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Without this line, you will get an error like ``Sentencepiece not found! error.&#xA;This line is not explicitly used in the sample source, but is required for the actual execution.&#xA;This line is not explicitly used in the sample source, but is required in the actual runtime.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Enumerating Applications of Document Classification Problems Only</title>
      <link>https://www.subcul-science.com/post/20200618blog-post_54/</link>
      <pubDate>Thu, 18 Jun 2020 06:42:00 +0900</pubDate>
      <guid>https://www.subcul-science.com/post/20200618blog-post_54/</guid>
      <description>&lt;h2 id=&#34;applying-the-document-classification-problem&#34;&gt;Applying the Document Classification Problem&lt;/h2&gt;&#xA;&lt;p&gt;You&amp;rsquo;ve learned about machine learning, but you don&amp;rsquo;t know how to use it! Isn&amp;rsquo;t it?&lt;/p&gt;&#xA;&lt;p&gt;It is easy to overlook this if you don&amp;rsquo;t pay attention to it when you study it, but if you don&amp;rsquo;t keep your antennas up, you won&amp;rsquo;t know how to use it.&lt;/p&gt;&#xA;&lt;p&gt;If you don&amp;rsquo;t keep your antennae up, you won&amp;rsquo;t know how to use it. Since a tool is only a tool if it is used, you should make a note of how you use your newly acquired tool.&lt;/p&gt;</description>
    </item>
    <item>
      <title>A note on how to use BERT learned from Japanese Wikipedia, now available</title>
      <link>https://www.subcul-science.com/post/wikipediabert/</link>
      <pubDate>Wed, 17 Jun 2020 07:34:00 +0900</pubDate>
      <guid>https://www.subcul-science.com/post/wikipediabert/</guid>
      <description>&lt;p&gt;huggingface has released a Japanese model for BERT.&lt;/p&gt;&#xA;&lt;p&gt;The Japanese model is included in transformers.&lt;/p&gt;&#xA;&lt;p&gt;However, I stumbled over a few things before I could get it to actually work in a Mac environment, so I&amp;rsquo;ll leave a note.&lt;/p&gt;&#xA;&lt;h2 id=&#34;preliminaries-installing-mecab&#34;&gt;Preliminaries: Installing mecab&lt;/h2&gt;&#xA;&lt;p&gt;The morphological analysis engine, mecab, is required to use BERT&amp;rsquo;s Japanese model.&lt;/p&gt;&#xA;&lt;p&gt;The tokenizer will probably ask for mecab.&lt;/p&gt;&#xA;&lt;p&gt;This time, we will use homebrew to install Mecab and ipadic.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to use NeuralClassifier, a library that provides a crazy number of models for document classification problems</title>
      <link>https://www.subcul-science.com/post/neuralclassifier/</link>
      <pubDate>Mon, 15 Jun 2020 02:11:00 +0900</pubDate>
      <guid>https://www.subcul-science.com/post/neuralclassifier/</guid>
      <description>&lt;p&gt;[! [](https://1.bp.blogspot.com/-YlMb8v77MN4/XurdQSzS1yI/AAAAAAAAg6Y/oSZrJ0c9yxYbzQnNNTynRvZnEp-xGE7NwCK4BGAsYHg/s320/AFE90C8A-A49C- 4475-9F05-50E2D56D5B63.jpeg)](&lt;a href=&#34;https://1.bp.blogspot.com/-YlMb8v77MN4/XurdQSzS1yI/AAAAAAAAg6Y/oSZrJ0c9yxYbzQnNNTynRvZnEp-xGE7NwCK4&#34;&gt;https://1.bp.blogspot.com/-YlMb8v77MN4/XurdQSzS1yI/AAAAAAAAg6Y/oSZrJ0c9yxYbzQnNNTynRvZnEp-xGE7NwCK4&lt;/a&gt; BGAsYHg/s1920/AFE90C8A-A49C-4475-9F05-50E2D56D5B63.jpeg)&lt;/p&gt;&#xA;&lt;p&gt;NeuralClassifier: An Open-source Neural Hierarchical Multi-label Text Classification Toolkit is a python library for multi-label document classification problems published by Tencent.&lt;/p&gt;&#xA;&lt;p&gt;For more information, see&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;[NeuralClassifier: An Open-source Neural Hierarchical Multi-label Text Classification Toolkit](&lt;a href=&#34;https://github.com/Tencent/NeuralNLP-&#34;&gt;https://github.com/Tencent/NeuralNLP-&lt;/a&gt; NeuralClassifier)&#xA;NeuralClassifier is designed for quick implementation of neural models for hierarchical multi-label classification task, which is more challenging and common in real-world scenarios.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;for more details.&lt;/p&gt;&#xA;&lt;p&gt;NeuralClassifier is designed for quick implementation of neural models for hierarchical multi-label classification task, which is more challenging and common in real-world scenarios.&lt;/p&gt;</description>
    </item>
    <item>
      <title>I even did a document classification problem with Fasttext</title>
      <link>https://www.subcul-science.com/post/20200613fasttext/</link>
      <pubDate>Sat, 13 Jun 2020 07:29:00 +0900</pubDate>
      <guid>https://www.subcul-science.com/post/20200613fasttext/</guid>
      <description>&lt;h2 id=&#34;summary-of-what-ive-done-with-fasttext-to-the-document-classification-problem&#34;&gt;Summary of what I&amp;rsquo;ve done with Fasttext to the document classification problem.&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Facebook research has published a document classification library using Fasttext.&lt;/li&gt;&#xA;&lt;li&gt;Fasttext is easy to install in a python environment.&lt;/li&gt;&#xA;&lt;li&gt;Run time is fast.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;preliminaries&#34;&gt;Preliminaries&lt;/h2&gt;&#xA;&lt;p&gt;I decided to tackle the task of document classification, and initially thought.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;NeuralClassifier: An Open-source Neural Hierarchical Multi-label Text Classification Toolkit&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;NeuralClassifier: An Open-source Neural Hierarchical Multi-label Text Classification Toolkit. However, it was not very accurate.&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/post/20200613abstractnews/</link>
      <pubDate>Sat, 13 Jun 2020 00:24:00 +0900</pubDate>
      <guid>https://www.subcul-science.com/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>
