<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6419696472234224840</id><updated>2024-07-26T17:34:09.116+02:00</updated><category term="java"/><category term="Big data"/><category term="iot"/><category term=".net"/><category term="neuroscience"/><category term="agile"/><category term="hadoop"/><category term="spark"/><category term="AI"/><category term="AWS"/><category term="analytics"/><category term="cassandra"/><category term="kafka"/><category term="python"/><category term="Cloud"/><category term="docker"/><category term="information visualization"/><category term="NLP"/><category term="attention"/><category term="human computer interaction"/><category term="jigsaw"/><category term="linux"/><category term="Artificial Intelligence"/><category term="Bioinformatics"/><category term="C#"/><category term="DB2"/><category term="Google MAP API"/><category term="HackerRank"/><category term="LSTN"/><category term="Predix"/><category term="angular"/><category term="blockchain"/><category term="brain"/><category term="eclipse"/><category term="eye tracking"/><category term="gis"/><category term="matlab"/><category term="maven"/><category term="microservices"/><category term="modularity"/><category term="node"/><category term="postgresql"/><category term="scala"/><category term="stream"/><category term="Certification"/><category term="DirectInput"/><category term="Doc2Vec"/><category term="FastText"/><category term="Gensim"/><category term="Glove"/><category term="Go"/><category term="Google"/><category term="Haskell"/><category term="Human Intelligence"/><category term="Information Retrieval"/><category term="JSF"/><category term="Kotlin"/><category term="Machine Learning"/><category term="Music"/><category term="NLTK"/><category term="Neural Network"/><category term="Nodered"/><category term="Rust"/><category term="SAP hana"/><category term="SCRUM"/><category term="SQLServer2005"/><category term="Spacy"/><category term="Text Classification"/><category term="UX"/><category term="Word2Vec"/><category term="XNA"/><category term="alpine"/><category term="apache"/><category term="benchmarking"/><category term="casandra"/><category term="cerebellum"/><category term="compression"/><category term="computation"/><category term="craft"/><category term="data"/><category term="data mining"/><category term="datastax"/><category term="dependency injection"/><category term="dtw"/><category term="elasticsearch"/><category term="flink"/><category term="giacomo veneri"/><category term="greengrass"/><category term="h2o"/><category term="hbase"/><category term="hdfs"/><category term="hive"/><category term="http://www.blogger.com/img/blank.gif"/><category term="io"/><category term="java 10"/><category term="java 11"/><category term="java 8"/><category term="java 9"/><category term="javascript"/><category term="jboss"/><category term="jee"/><category term="jmh"/><category term="kairosb"/><category term="keras"/><category term="knime"/><category term="lambda"/><category term="lucene"/><category term="mailman"/><category term="map"/><category term="mapreduce"/><category term="mesos"/><category term="minio"/><category term="model"/><category term="modelica"/><category term="mqtt"/><category term="multithread"/><category term="parquet"/><category term="pattern recognition"/><category term="polymer"/><category term="postfix"/><category term="predicitve"/><category term="randomforest"/><category term="react.js"/><category term="reduce"/><category term="reflection"/><category term="s3"/><category term="s3. hadoop"/><category term="security"/><category term="shape file"/><category term="stochastic model"/><category term="storm"/><category term="text mining"/><category term="timeseries"/><category term="typescript"/><category term="vagrant"/><category term="visaul search"/><category term="vision"/><category term="visual search"/><category term="vue.js"/><category term="waterfall"/><category term="web service"/><category term="ws"/><category term="xml"/><category term="xsl"/><title type='text'>&quot;FosforiVerdi&quot;</title><subtitle type='html'>AI, Languages, IoT and Big Data</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>239</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-7001455663208972260</id><published>2024-07-09T17:15:00.001+02:00</published><updated>2024-07-09T17:15:12.779+02:00</updated><title type='text'>Leveraging the Regularizing Effect of Mixing Industrial and Open Source Data to Prevent Overfitting of LLM Fine Tuning</title><content type='html'>&lt;h2 style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://openreview.net/forum?id=zaYwh5pPPO&amp;amp;referrer=%5Bthe%20profile%20of%20Giacomo%20Veneri%5D(%2Fprofile%3Fid%3D~Giacomo_Veneri1)&quot;&gt;&amp;nbsp;Leveraging the Regularizing Effect of Mixing Industrial and Open Source Data to Prevent Overfitting of LLM Fine Tuning&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Mohamed Salah Jebali , Anna Valanzano , Giacomo Veneri ,Malathi Murugesan, Giovanni De Magistris&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Language models have demonstrated important advancements across various natural language processing (NLP) tasks. However, the availability of high-quality and domain-specific data remains a challenge for training these models, particularly in industry-specific applications. In this paper, we propose a methodology to fine-tune a large language model (LLM) using a mixture of private company data and open-source data. \\Our empirical investigation reveals that combining private and open-source data during the fine-tuning process leads to superior performance, mitigating the risk of overfitting that can occur when training solely on narrow, domain-specific datasets. We observed that incorporating open-source data alongside the private data helps to reduce the distribution shift between the source and target data, effectively acting as a regularizer and enhancing the model&#39;s ability to generalize.\\Furthermore, we compare the divergence between the private and open-source datasets with the test loss of the fine-tuned model. Our results suggest a correlation between reduced data divergence and improved model performance, indicating that carefully selecting and curating the dataset mixture can be a crucial step in preventing overfitting and ensuring the model&#39;s effective adaptation to industry-specific use cases.&lt;/p&gt;&lt;p&gt;This study provides a practical solution for industry-specific adaptation of LLMs, demonstrating how the strategic blending of private and open-source data can unlock the full potential of these models while addressing critical concerns around data privacy and model reliability in real-world applications.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg5_acbBmPPaTCrxjGpeJ3uJJ5rnOEMjfIAAYYl6uvErS9250g6uvPYDl4f1skmWGrtmebQL5GOwGGyQPgG4Nc3IRDi0_XYXqCqCCtnSRhCNAhsweY-qriiNhJFFMpgwrbS_Fc5PKPo64zWHXvIepM2fEP5nHLxmk9OmYYdaN5H8i8V_ePstPWfdy0u1D4&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;723&quot; data-original-width=&quot;1320&quot; height=&quot;175&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg5_acbBmPPaTCrxjGpeJ3uJJ5rnOEMjfIAAYYl6uvErS9250g6uvPYDl4f1skmWGrtmebQL5GOwGGyQPgG4Nc3IRDi0_XYXqCqCCtnSRhCNAhsweY-qriiNhJFFMpgwrbS_Fc5PKPo64zWHXvIepM2fEP5nHLxmk9OmYYdaN5H8i8V_ePstPWfdy0u1D4&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/7001455663208972260/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2024/07/leveraging-regularizing-effect-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/7001455663208972260'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/7001455663208972260'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2024/07/leveraging-regularizing-effect-of.html' title='Leveraging the Regularizing Effect of Mixing Industrial and Open Source Data to Prevent Overfitting of LLM Fine Tuning'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEg5_acbBmPPaTCrxjGpeJ3uJJ5rnOEMjfIAAYYl6uvErS9250g6uvPYDl4f1skmWGrtmebQL5GOwGGyQPgG4Nc3IRDi0_XYXqCqCCtnSRhCNAhsweY-qriiNhJFFMpgwrbS_Fc5PKPo64zWHXvIepM2fEP5nHLxmk9OmYYdaN5H8i8V_ePstPWfdy0u1D4=s72-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-8435030425941001490</id><published>2024-03-19T21:01:00.009+01:00</published><updated>2024-03-25T11:43:56.689+01:00</updated><title type='text'>Codellama for SQL</title><content type='html'>&lt;p&gt;&amp;nbsp;In this simple exercise we are going to use CodeLLama to interact with Postgresql DB using natural language.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_eQBb9C5kloRYcoie_ZrRVDxN9ic8VCKTZ8kCrhyphenhyphenqNYSMVGsMnQarogYcsH-10Pazietnul4CdbvyTygP4ZPdY4HUfV7SKbpNEL-Xtlcw7J0OWIeVsYG-N1_PlJDy4M8XNTcy0Zgp8zevK7ATX1i81eHyuBlrfOaF6Rcf2LM4v3BSL6xe5b9Rb_40b3I/s801/codellama.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;801&quot; data-original-width=&quot;783&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_eQBb9C5kloRYcoie_ZrRVDxN9ic8VCKTZ8kCrhyphenhyphenqNYSMVGsMnQarogYcsH-10Pazietnul4CdbvyTygP4ZPdY4HUfV7SKbpNEL-Xtlcw7J0OWIeVsYG-N1_PlJDy4M8XNTcy0Zgp8zevK7ATX1i81eHyuBlrfOaF6Rcf2LM4v3BSL6xe5b9Rb_40b3I/w314-h320/codellama.png&quot; width=&quot;314&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Prepare Database&lt;/h2&gt;&lt;div&gt;Open PostgreSQL DB and build the following schema:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;

&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;CREATE&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;TABLE&lt;/span&gt; customers
(
   cust_id                  &lt;span style=&quot;color: #007020;&quot;&gt;INT&lt;/span&gt;         &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NULL&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;PRIMARY&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;KEY&lt;/span&gt;,
   cust_first_name          &lt;span style=&quot;color: #007020;&quot;&gt;VARCHAR&lt;/span&gt;(&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;20&lt;/span&gt;)   &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NULL&lt;/span&gt;,
   cust_last_name           &lt;span style=&quot;color: #007020;&quot;&gt;VARCHAR&lt;/span&gt;(&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;40&lt;/span&gt;)   &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NULL&lt;/span&gt;,
   cust_state               &lt;span style=&quot;color: #007020;&quot;&gt;VARCHAR&lt;/span&gt;(&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;40&lt;/span&gt;)   &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NULL&lt;/span&gt; 
);

&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;CREATE&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;TABLE&lt;/span&gt; products
(
   prod_id                 &lt;span style=&quot;color: #007020;&quot;&gt;INT&lt;/span&gt;        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NULL&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;PRIMARY&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;KEY&lt;/span&gt;,
   prod_name               &lt;span style=&quot;color: #007020;&quot;&gt;VARCHAR&lt;/span&gt;(&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;50&lt;/span&gt;)     &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NULL&lt;/span&gt;,
   prod_desc               &lt;span style=&quot;color: #007020;&quot;&gt;VARCHAR&lt;/span&gt;(&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;4000&lt;/span&gt;)   &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NULL&lt;/span&gt;,
   prod_subcategory        &lt;span style=&quot;color: #007020;&quot;&gt;VARCHAR&lt;/span&gt;(&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;50&lt;/span&gt;)     &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NULL&lt;/span&gt;
);

&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;CREATE&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;TABLE&lt;/span&gt; orders
(
   ord_id                 &lt;span style=&quot;color: #007020;&quot;&gt;INT&lt;/span&gt;        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NULL&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;PRIMARY&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;KEY&lt;/span&gt;,
   ord_amount             &lt;span style=&quot;color: #007020;&quot;&gt;INT&lt;/span&gt;        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NULL&lt;/span&gt;,
   ord_price              &lt;span style=&quot;color: #007020;&quot;&gt;INT&lt;/span&gt;        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NULL&lt;/span&gt;,
   ord_prod_id            &lt;span style=&quot;color: #007020;&quot;&gt;INT&lt;/span&gt;        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NULL&lt;/span&gt;,
   ord_cust_id            &lt;span style=&quot;color: #007020;&quot;&gt;INT&lt;/span&gt;        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NULL&lt;/span&gt;,
   ord_date               &lt;span style=&quot;color: #007020;&quot;&gt;DATE&lt;/span&gt;       &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;NULL&lt;/span&gt;,
   
   &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;CONSTRAINT&lt;/span&gt; ord_cust_fk
      &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;FOREIGN&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;KEY&lt;/span&gt; (ord_cust_id) &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;REFERENCES&lt;/span&gt; customers (cust_id),
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;CONSTRAINT&lt;/span&gt; ord_prod_fk
      &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;FOREIGN&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;KEY&lt;/span&gt; (ord_prod_id) &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;REFERENCES&lt;/span&gt; products (prod_id)
);
&lt;/pre&gt;&lt;/div&gt;


&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;then populate the db:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;


&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;COPY&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt;.customers (cust_id, cust_first_name, cust_last_name, cust_state) &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;FROM&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;stdin&lt;/span&gt;;
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	giacomo	veneri	Italy
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;	mario	rossi	Italy
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;3&lt;/span&gt;	mike	&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;do&lt;/span&gt;	USA
&lt;span style=&quot;background-color: #ffaaaa; color: red;&quot;&gt;\&lt;/span&gt;.


&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;COPY&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt;.orders (ord_id, ord_amount, ord_price, ord_prod_id, ord_cust_id, ord_date) &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;FROM&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;stdin&lt;/span&gt;;
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1000&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2024&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;03&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;15&lt;/span&gt;
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1000&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2024&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;03&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;15&lt;/span&gt;
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;3&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;100&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2024&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;03&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;15&lt;/span&gt;
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;4&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1000&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;3&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2024&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;03&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;15&lt;/span&gt;
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;5&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;30&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;3&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2024&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;03&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;16&lt;/span&gt;
&lt;span style=&quot;background-color: #ffaaaa; color: red;&quot;&gt;\&lt;/span&gt;.

&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;COPY&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt;.products (prod_id, prod_name, prod_desc, prod_subcategory) &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;FROM&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;stdin&lt;/span&gt;;
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	Computer PC	PC	electronic
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;	Tablet	Tablet	electronic
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;3&lt;/span&gt;	My Book	My Title	book
&lt;span style=&quot;background-color: #ffaaaa; color: red;&quot;&gt;\&lt;/span&gt;.

&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;COPY&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt;.customers (cust_id, cust_first_name, cust_last_name, cust_state) &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;FROM&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;stdin&lt;/span&gt;;
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	giacomo	veneri	Italy
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;	mario	rossi	Italy
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;3&lt;/span&gt;	mike	&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;do&lt;/span&gt;	USA
&lt;span style=&quot;background-color: #ffaaaa; color: red;&quot;&gt;\&lt;/span&gt;.


&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;COPY&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt;.orders (ord_id, ord_amount, ord_price, ord_prod_id, ord_cust_id, ord_date) &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;FROM&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;stdin&lt;/span&gt;;
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1000&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2024&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;03&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;15&lt;/span&gt;
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1000&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2024&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;03&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;15&lt;/span&gt;
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;3&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;100&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2024&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;03&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;15&lt;/span&gt;
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;4&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1000&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;3&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2024&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;03&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;15&lt;/span&gt;
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;5&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;30&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;3&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;	&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2024&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;03&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;16&lt;/span&gt;
&lt;span style=&quot;background-color: #ffaaaa; color: red;&quot;&gt;\&lt;/span&gt;.

&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;COPY&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt;.products (prod_id, prod_name, prod_desc, prod_subcategory) &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;FROM&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;stdin&lt;/span&gt;;
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;	Computer PC	PC	electronic
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;	Tablet	Tablet	electronic
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;3&lt;/span&gt;	My Book	My Title	book
&lt;span style=&quot;background-color: #ffaaaa; color: red;&quot;&gt;\&lt;/span&gt;.
&lt;/pre&gt;&lt;/div&gt;



&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Install the Packages&lt;/h2&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;

&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;pip install bitsandbytes accelerate simpletransformers 
pip uninstall &lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;y transformer&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;engine
pip install psycopg2&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;binary SQLAlchemy
&lt;/pre&gt;&lt;/div&gt;



&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Instantiate the model&lt;/h2&gt;&lt;div&gt;

&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;torch&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;transformers&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
 
model_id &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;  &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;codellama/CodeLlama-7b-Instruct-hf&quot;&lt;/span&gt;
bnb_config &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; BitsAndBytesConfig(
    load_in_4bit&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;True&lt;/span&gt;,
    bnb_4bit_use_double_quant&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;True&lt;/span&gt;,
    bnb_4bit_quant_type&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;nf4&quot;&lt;/span&gt;,
    bnb_4bit_compute_dtype&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;torch&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;bfloat16
)
 
model &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; AutoModelForCausalLM&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;from_pretrained(model_id, quantization_config&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;bnb_config, device_map&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;auto&quot;&lt;/span&gt;)
 
tokenizer &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; AutoTokenizer&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;from_pretrained(model_id)
tokenizer&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;pad_token &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; tokenizer&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;eos_token
tokenizer&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;padding_side &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;right&quot;&lt;/span&gt;
eos_token_id &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; tokenizer&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;eos_token_id
&lt;/pre&gt;&lt;/div&gt;



&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now we can start connection to the local db&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;

&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;psycopg2&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;pg&lt;/span&gt;
engine &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; pg&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;connect(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;dbname=&#39;LLM_TEST&#39; user=&#39;postgres&#39; host=&#39;localhost&#39; port=&#39;8432&#39; password=&#39;password&#39;&quot;&lt;/span&gt;)
&lt;/pre&gt;&lt;/div&gt;



&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Prepare Prompting&lt;/h2&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;

&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90&lt;/pre&gt;&lt;/td&gt;&lt;td&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;schema &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;CREATE TABLE customers&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;(&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;   cust_id                  INT         NOT NULL PRIMARY KEY,&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;   cust_first_name          VARCHAR(20)   NOT NULL,&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;   cust_last_name           VARCHAR(40)   NOT NULL,&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;   cust_state               VARCHAR(40)   NOT NULL &lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;);&lt;/span&gt;

&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;CREATE TABLE products&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;(&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;   prod_id                 INT        NOT NULL PRIMARY KEY,&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;   prod_name               VARCHAR(50)     NOT NULL,&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;   prod_desc               VARCHAR(4000)   NOT NULL,&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;   prod_subcategory        VARCHAR(50)     NOT NULL&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;);&lt;/span&gt;

&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;CREATE TABLE orders&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;(&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;   ord_id                 INT        NOT NULL PRIMARY KEY,&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;   ord_amount             INT        NOT NULL,&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;   ord_price              INT        NOT NULL,&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;   ord_prod_id            INT        NOT NULL,&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;   ord_cust_id            INT        NOT NULL,&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;   ord_date               DATE       NOT NULL,&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;   &lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;   CONSTRAINT ord_cust_fk&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;      FOREIGN KEY (ord_cust_id) REFERENCES customers (cust_id),&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;    CONSTRAINT ord_prod_fk&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;      FOREIGN KEY (ord_prod_id) REFERENCES products (prod_id)&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;

&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;sqlparse&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;query&lt;/span&gt;(sql,engine&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;engine):
    &lt;span style=&quot;color: #007020;&quot;&gt;print&lt;/span&gt;(f&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;&quot;SQL QUERY:&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0; color: #666666; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt; {sql}&quot;&#39;&lt;/span&gt;)
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; pd&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;read_sql(sql, con&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;engine)


&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;ask&lt;/span&gt;(question, schema&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;schema, model&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;model, tokenizer&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;tokenizer):

    sql_example &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;SELECT * , orders.ord_price AS spent FROM orders INNER JOIN products ON orders.ord_prod_id = products.prod_id INNER JOIN customers ON orders.ord_cust_id = customers.cust_id&quot;&lt;/span&gt;
    
    eval_prompt &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; f&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;&quot;&quot;### Task&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;    # Generate a Postgresql SQL query to answer the following question:&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;    # `{question}&lt;/span&gt;

&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;    # Please wrap your code answer using ```sql:&lt;/span&gt;

&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;    # ### Database Schema&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;    # This query will run on a database whose schema is represented in this string:&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;    # Don&#39;t use joins for this schema and if all columns are required give the (*) notation.&lt;/span&gt;

&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;    # `{schema}`&lt;/span&gt;

&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;    # An example of the SQL would be `{sql_example}`&lt;/span&gt;

&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;    # ### SQL&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;    # Given the database schema, here is the SQL query that answers `{question}`:&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;    # ```sql&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;    # &quot;&quot;&quot;&lt;/span&gt;
    
    &lt;span style=&quot;color: #888888;&quot;&gt;#eval_prompt = f&quot;[INST] Write SQL query to answer the following question given the database schema. Please wrap your code answer using ```sql: Schema: {schema} Question: {question} [/INST] Here is the SQL query to answer to the question: {question}: ```sql &quot;&lt;/span&gt;


    model_input &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; tokenizer(eval_prompt, return_tensors&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;pt&quot;&lt;/span&gt;)&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;to(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;cuda&quot;&lt;/span&gt;)
    
    &lt;span style=&quot;color: #888888;&quot;&gt;#model.eval()&lt;/span&gt;

    outputs &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; tokenizer&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;batch_decode(model&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;generate(&lt;span style=&quot;color: #333333;&quot;&gt;**&lt;/span&gt;model_input,
                                                    eos_token_id&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;eos_token_id,
                                                    pad_token_id&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;eos_token_id,
                                                    max_new_tokens&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;100&lt;/span&gt;,
                                                    do_sample&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;False&lt;/span&gt;, num_beams&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;), 
                                     skip_special_tokens&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;True&lt;/span&gt;)

    ret &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;  sqlparse&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;format(outputs[&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;]&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;split(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;```&quot;&lt;/span&gt;)[&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;], reindent&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;True&lt;/span&gt;)&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;replace(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;#&#39;&lt;/span&gt;,&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;&#39;&lt;/span&gt;)&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;replace(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;sql &quot;&lt;/span&gt;,&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;&quot;&lt;/span&gt;)
 
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; ret,outputs

&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;ask_db&lt;/span&gt;(question):
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;try&lt;/span&gt;:
        sql, outputs &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; ask(question)
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; query(sql)
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;except&lt;/span&gt; &lt;span style=&quot;color: red; font-weight: bold;&quot;&gt;Exception&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;as&lt;/span&gt; e:
        &lt;span style=&quot;color: #007020;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;error&#39;&lt;/span&gt;, e)
        &lt;span style=&quot;color: #007020;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;*&quot;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;10&lt;/span&gt;)
        &lt;span style=&quot;color: #007020;&quot;&gt;print&lt;/span&gt;(sql)
        &lt;span style=&quot;color: #007020;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;*&quot;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;10&lt;/span&gt;)
        &lt;span style=&quot;color: #007020;&quot;&gt;print&lt;/span&gt;(outputs)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;



&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Asking data&lt;/h2&gt;&lt;div&gt;Now we can ask our data in natural language:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;


&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;ask_db(&lt;span style=&quot;color: #007020;&quot;&gt;input&lt;/span&gt;())

Can you tell me about the total spent by giacomo&lt;span style=&quot;background-color: #ffaaaa; color: red;&quot;&gt;?&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;The output&lt;/pre&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;SQL QUERY:&lt;/span&gt;
   SELECT SUM(ord_price) AS spent
   FROM orders
   INNER JOIN customers ON orders&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;ord_cust_id &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; customers&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;cust_id
   WHERE customers&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;cust_first_name &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;giacomo&#39;&lt;/span&gt;
 &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;spent&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;1100&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;More examples&lt;/h3&gt;&lt;div&gt;&lt;ul style=&quot;background-color: white; box-sizing: border-box; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; list-style-image: initial; list-style-position: initial; margin-bottom: 9px; margin-top: 1em; padding-left: 2em;&quot;&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Can you tell me about the orders done by customer giacomo?&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;background-color: white; box-sizing: border-box; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; list-style-image: initial; list-style-position: initial; margin-bottom: 9px; margin-top: 1em; padding-left: 2em;&quot;&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Can you tell me about the total amount ordered by customer giacomo?&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Can you tell me about the orders done by customer of italy?&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Can you tell me about the orders done the last week by customer giacomo?&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Can you tell me about the products of subcategory electronic?&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Can you tell me about the total spent by giacomo?&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span face=&quot;Helvetica Neue, Helvetica, Arial, sans-serif&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;Helvetica Neue, Helvetica, Arial, sans-serif&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/8435030425941001490/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2024/03/codellama-for-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/8435030425941001490'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/8435030425941001490'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2024/03/codellama-for-sql.html' title='Codellama for SQL'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_eQBb9C5kloRYcoie_ZrRVDxN9ic8VCKTZ8kCrhyphenhyphenqNYSMVGsMnQarogYcsH-10Pazietnul4CdbvyTygP4ZPdY4HUfV7SKbpNEL-Xtlcw7J0OWIeVsYG-N1_PlJDy4M8XNTcy0Zgp8zevK7ATX1i81eHyuBlrfOaF6Rcf2LM4v3BSL6xe5b9Rb_40b3I/s72-w314-h320-c/codellama.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-3517865594517161356</id><published>2024-01-31T21:53:00.005+01:00</published><updated>2024-01-31T21:59:11.511+01:00</updated><title type='text'>Physics-Guided, Physics-Informed, and Physics-Encoded Neural Networks in Scientific Computing</title><content type='html'>&lt;p&gt;&amp;nbsp;From the review&lt;a href=&quot; https://arxiv.org/pdf/2211.07377.pdf&quot;&gt;&amp;nbsp;https://arxiv.org/pdf/2211.07377.pdf&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;paragraph-330&quot; style=&quot;background-color: white; box-sizing: inherit; color: #11100f; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Segoe UI Web (West European)&amp;quot;, &amp;quot;Segoe UI&amp;quot;, -apple-system, BlinkMacSystemFont, Roboto, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 16px; line-height: inherit; margin: 0px; white-space-collapse: preserve;&quot;&gt;In the last decade, breakthroughs in DL and computing power have enabled the use of DL in a broad variety of scientific computing, especially in &lt;/p&gt;&lt;ul class=&quot;list-345&quot; role=&quot;list&quot; style=&quot;background-color: white; box-sizing: inherit; color: #11100f; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Segoe UI Web (West European)&amp;quot;, &amp;quot;Segoe UI&amp;quot;, -apple-system, BlinkMacSystemFont, Roboto, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 16px; list-style-position: outside; margin: 0px; padding: 0px 0px 0px 2rem; white-space-collapse: preserve;&quot;&gt;&lt;li class=&quot;y-list--item listItem-346&quot; style=&quot;box-sizing: inherit; margin: 0px 0px 0.3rem; padding: 0px 0px 0px 0.3rem;&quot;&gt;fluid mechanics, &lt;/li&gt;&lt;li class=&quot;y-list--item listItem-346&quot; style=&quot;box-sizing: inherit; margin: 0px 0px 0.3rem; padding: 0px 0px 0px 0.3rem;&quot;&gt;solid mechanics, and &lt;/li&gt;&lt;li class=&quot;y-list--item listItem-346&quot; style=&quot;box-sizing: inherit; margin: 0px 0px 0.3rem; padding: 0px 0px 0px 0.3rem;&quot;&gt;materials science,&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;paragraph-330&quot; style=&quot;background-color: white; box-sizing: inherit; color: #11100f; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Segoe UI Web (West European)&amp;quot;, &amp;quot;Segoe UI&amp;quot;, -apple-system, BlinkMacSystemFont, Roboto, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 16px; line-height: inherit; margin: 0px; white-space-collapse: preserve;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p class=&quot;paragraph-330&quot; style=&quot;background-color: white; box-sizing: inherit; color: #11100f; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Segoe UI Web (West European)&amp;quot;, &amp;quot;Segoe UI&amp;quot;, -apple-system, BlinkMacSystemFont, Roboto, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 16px; line-height: inherit; margin: 0px; white-space-collapse: preserve;&quot;&gt;albeit at the cost of accuracy and loss of generality. &lt;/p&gt;&lt;p class=&quot;paragraph-330&quot; style=&quot;background-color: white; box-sizing: inherit; color: #11100f; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Segoe UI Web (West European)&amp;quot;, &amp;quot;Segoe UI&amp;quot;, -apple-system, BlinkMacSystemFont, Roboto, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 16px; line-height: inherit; margin: 0px; white-space-collapse: preserve;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p class=&quot;paragraph-330&quot; style=&quot;background-color: white; box-sizing: inherit; color: #11100f; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Segoe UI Web (West European)&amp;quot;, &amp;quot;Segoe UI&amp;quot;, -apple-system, BlinkMacSystemFont, Roboto, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 16px; line-height: inherit; margin: 0px; white-space-collapse: preserve;&quot;&gt;These data-driven methods are routinely applied to fulfill one of the following goals: &lt;/p&gt;&lt;ol class=&quot;list-789&quot; role=&quot;list&quot; style=&quot;background-color: white; box-sizing: inherit; color: #11100f; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Segoe UI Web (West European)&amp;quot;, &amp;quot;Segoe UI&amp;quot;, -apple-system, BlinkMacSystemFont, Roboto, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 16px; list-style-position: outside; margin: 0px; padding: 0px 0px 0px 1.8rem; white-space-collapse: preserve;&quot;&gt;&lt;li class=&quot;y-list--item listItem-346&quot; style=&quot;box-sizing: inherit; margin: 0px 0px 0.3rem; padding: 0px 0px 0px 0.5rem;&quot;&gt;accelerate direct numerical simulations using surrogate modeling &lt;/li&gt;&lt;li class=&quot;y-list--item listItem-346&quot; style=&quot;box-sizing: inherit; margin: 0px 0px 0.3rem; padding: 0px 0px 0px 0.5rem;&quot;&gt;accelerate adjoint sensitivity analysis &lt;/li&gt;&lt;li class=&quot;y-list--item listItem-346&quot; style=&quot;box-sizing: inherit; margin: 0px 0px 0.3rem; padding: 0px 0px 0px 0.5rem;&quot;&gt;accelerate probabilistic programming &lt;/li&gt;&lt;li class=&quot;y-list--item listItem-346&quot; style=&quot;box-sizing: inherit; margin: 0px 0px 0.3rem; padding: 0px 0px 0px 0.5rem;&quot;&gt;accelerate inverse problems&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;span face=&quot;Segoe UI, Segoe UI Web (West European), Segoe UI, -apple-system, BlinkMacSystemFont, Roboto, Helvetica Neue, sans-serif&quot; style=&quot;color: #11100f;&quot;&gt;&lt;span style=&quot;white-space-collapse: preserve;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjmyEYl-xDe0mQhwb8X1Z43SLUdeDldCvKDW4qhgrvAhF_1QsFRy612t2PH7hI13WS7wmAWNviGBPgxETLEf1DnWX84DV4lm7X2tDneku6LTK1SnjTLnK-5p_SFAtIqRNz06qgbn74rVNriPxwnQfIIu2R8jYv2hDEcudpVAk4nqfTnK7Oak7IAzaSOf_A&quot; style=&quot;font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Segoe UI Web (West European)&amp;quot;, &amp;quot;Segoe UI&amp;quot;, -apple-system, BlinkMacSystemFont, Roboto, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 16px; margin-left: 1em; margin-right: 1em; text-align: center; white-space-collapse: preserve;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;611&quot; data-original-width=&quot;872&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjmyEYl-xDe0mQhwb8X1Z43SLUdeDldCvKDW4qhgrvAhF_1QsFRy612t2PH7hI13WS7wmAWNviGBPgxETLEf1DnWX84DV4lm7X2tDneku6LTK1SnjTLnK-5p_SFAtIqRNz06qgbn74rVNriPxwnQfIIu2R8jYv2hDEcudpVAk4nqfTnK7Oak7IAzaSOf_A=s16000&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;p class=&quot;paragraph-330&quot; style=&quot;background-color: white; box-sizing: inherit; color: #11100f; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Segoe UI Web (West European)&amp;quot;, &amp;quot;Segoe UI&amp;quot;, -apple-system, BlinkMacSystemFont, Roboto, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 16px; line-height: inherit; margin: 0px; white-space-collapse: preserve;&quot;&gt; &lt;/p&gt;&lt;h2 style=&quot;background-color: white; box-sizing: inherit; color: #11100f; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Segoe UI Web (West European)&amp;quot;, &amp;quot;Segoe UI&amp;quot;, -apple-system, BlinkMacSystemFont, Roboto, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 16px; line-height: inherit; margin: 0px; text-align: left; white-space-collapse: preserve;&quot;&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2 style=&quot;background-color: white; box-sizing: inherit; color: #11100f; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Segoe UI Web (West European)&amp;quot;, &amp;quot;Segoe UI&amp;quot;, -apple-system, BlinkMacSystemFont, Roboto, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 16px; line-height: inherit; margin: 0px; text-align: left; white-space-collapse: preserve;&quot;&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;PGNN&lt;/h2&gt;&lt;p class=&quot;paragraph-330&quot; style=&quot;background-color: white; box-sizing: inherit; color: #11100f; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Segoe UI Web (West European)&amp;quot;, &amp;quot;Segoe UI&amp;quot;, -apple-system, BlinkMacSystemFont, Roboto, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 16px; line-height: inherit; margin: 0px; white-space-collapse: preserve;&quot;&gt;In &lt;b style=&quot;box-sizing: inherit; margin-top: 0px;&quot;&gt;Physics-Guided &lt;/b&gt;NN-based models, off-the-shelf supervised DL techniques are used to construct surrogate mappings. (see also &lt;a href=&quot;https://towardsdatascience.com/physics-guided-neural-networks-pgnns-8fe9dbad9414&quot;&gt;https://towardsdatascience.com/physics-guided-neural-networks-pgnns-8fe9dbad9414&lt;/a&gt;)&lt;/p&gt;&lt;p class=&quot;paragraph-330&quot; style=&quot;background-color: white; box-sizing: inherit; color: #11100f; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Segoe UI Web (West European)&amp;quot;, &amp;quot;Segoe UI&amp;quot;, -apple-system, BlinkMacSystemFont, Roboto, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 16px; line-height: inherit; margin: 0px; white-space-collapse: preserve;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;paragraph-330&quot; style=&quot;background-color: white; box-sizing: inherit; color: #11100f; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Segoe UI Web (West European)&amp;quot;, &amp;quot;Segoe UI&amp;quot;, -apple-system, BlinkMacSystemFont, Roboto, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 16px; line-height: inherit; margin: 0px; white-space-collapse: preserve;&quot;&gt;The idea is to manage physical constraints in the loss.&lt;/p&gt;&lt;div&gt;&lt;span face=&quot;Segoe UI, Segoe UI Web (West European), Segoe UI, -apple-system, BlinkMacSystemFont, Roboto, Helvetica Neue, sans-serif&quot; style=&quot;color: #11100f;&quot;&gt;&lt;span style=&quot;white-space-collapse: preserve;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;Segoe UI, Segoe UI Web (West European), Segoe UI, -apple-system, BlinkMacSystemFont, Roboto, Helvetica Neue, sans-serif&quot; style=&quot;color: #11100f;&quot;&gt;&lt;span style=&quot;white-space-collapse: preserve;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;Segoe UI, Segoe UI Web (West European), Segoe UI, -apple-system, BlinkMacSystemFont, Roboto, Helvetica Neue, sans-serif&quot; style=&quot;color: #11100f;&quot;&gt;&lt;span style=&quot;white-space-collapse: preserve;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEh3jfbb5WSFUGlvXx3IpXtNtIoAcyXZ8polRB728GGceVku1wSsfUpq8ncDamcWGlQXRmS7WqdSEnNgEXmo6NuZCIYrtsCKMw5SOMKVoJXXf4UiG9KP-SDUPA7HKBe0M3AS5BlJOjrsNfsQktUuACfy2DYSLGmHYyf7FqJ5yzMtggOzADarVtCjfMjTrxI&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;638&quot; data-original-width=&quot;843&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEh3jfbb5WSFUGlvXx3IpXtNtIoAcyXZ8polRB728GGceVku1wSsfUpq8ncDamcWGlQXRmS7WqdSEnNgEXmo6NuZCIYrtsCKMw5SOMKVoJXXf4UiG9KP-SDUPA7HKBe0M3AS5BlJOjrsNfsQktUuACfy2DYSLGmHYyf7FqJ5yzMtggOzADarVtCjfMjTrxI&quot; width=&quot;317&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;or you can manage with Physics intermediate variable&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;Segoe UI, Segoe UI Web (West European), Segoe UI, -apple-system, BlinkMacSystemFont, Roboto, Helvetica Neue, sans-serif&quot; style=&quot;color: #11100f;&quot;&gt;&lt;span style=&quot;white-space-collapse: preserve;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;Segoe UI, Segoe UI Web (West European), Segoe UI, -apple-system, BlinkMacSystemFont, Roboto, Helvetica Neue, sans-serif&quot; style=&quot;color: #11100f;&quot;&gt;&lt;span style=&quot;white-space-collapse: preserve;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjmdNh8fuhInQU9G-WkOOiWeLaedJ8u4w1Rx927V2qkNjPEJJaN65bHJILxmVkwGQua8MWbAVVmibnEtHR_25RXEbBTQd456luoW0BIDuFOgtBhFhsJIfwKLWr4qcpSiunl1mjijtvzghjUE6HvgyeAUt70biWNNYFXC7wNAkfKMWEhMZB_eMcAsBbTA3c&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;203&quot; data-original-width=&quot;248&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjmdNh8fuhInQU9G-WkOOiWeLaedJ8u4w1Rx927V2qkNjPEJJaN65bHJILxmVkwGQua8MWbAVVmibnEtHR_25RXEbBTQd456luoW0BIDuFOgtBhFhsJIfwKLWr4qcpSiunl1mjijtvzghjUE6HvgyeAUt70biWNNYFXC7wNAkfKMWEhMZB_eMcAsBbTA3c&quot; width=&quot;293&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;PINNs&lt;/h2&gt;&lt;div&gt;&lt;b style=&quot;background-color: white; box-sizing: inherit; color: #11100f; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Segoe UI Web (West European)&amp;quot;, &amp;quot;Segoe UI&amp;quot;, -apple-system, BlinkMacSystemFont, Roboto, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 16px; margin-top: 0px; white-space-collapse: preserve;&quot;&gt;Physics-Informed &lt;/b&gt;&lt;span face=&quot;&amp;quot;Segoe UI&amp;quot;, &amp;quot;Segoe UI Web (West European)&amp;quot;, &amp;quot;Segoe UI&amp;quot;, -apple-system, BlinkMacSystemFont, Roboto, &amp;quot;Helvetica Neue&amp;quot;, sans-serif&quot; style=&quot;background-color: white; color: #11100f; font-size: 16px; white-space-collapse: preserve;&quot;&gt;NNs have been introduced to perform supervised learning tasks while obeying given laws of physics in the form of general non-linear differential equations&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;Segoe UI, Segoe UI Web (West European), Segoe UI, -apple-system, BlinkMacSystemFont, Roboto, Helvetica Neue, sans-serif&quot; style=&quot;color: #11100f;&quot;&gt;&lt;span style=&quot;white-space-collapse: preserve;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;Segoe UI, Segoe UI Web (West European), Segoe UI, -apple-system, BlinkMacSystemFont, Roboto, Helvetica Neue, sans-serif&quot; style=&quot;color: #11100f;&quot;&gt;&lt;span style=&quot;white-space-collapse: preserve;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEih4YMiFQ4DR43RYmkktAl_RBftIR7nTCqF08-Ot-5Iacs2UsPZ2LcFr9X8aFOJ1MBOHrn8ppM1TAH7iMX_Z9ntnCtfFgK-St1ndVStOv0ixyyVAzljw52_nIAFEtf-FhG6MK-IpiFq6vw4l3nZmK2BX2r7QbUNeVRXEfOADjn8PdshXG7Lce5mLcMtRSw&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;697&quot; data-original-width=&quot;1762&quot; height=&quot;127&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEih4YMiFQ4DR43RYmkktAl_RBftIR7nTCqF08-Ot-5Iacs2UsPZ2LcFr9X8aFOJ1MBOHrn8ppM1TAH7iMX_Z9ntnCtfFgK-St1ndVStOv0ixyyVAzljw52_nIAFEtf-FhG6MK-IpiFq6vw4l3nZmK2BX2r7QbUNeVRXEfOADjn8PdshXG7Lce5mLcMtRSw&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span face=&quot;Segoe UI, Segoe UI Web (West European), Segoe UI, -apple-system, BlinkMacSystemFont, Roboto, Helvetica Neue, sans-serif&quot; style=&quot;color: #11100f;&quot;&gt;&lt;span style=&quot;white-space-collapse: preserve;&quot;&gt;PeNN&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span face=&quot;&amp;quot;Segoe UI&amp;quot;, &amp;quot;Segoe UI Web (West European)&amp;quot;, &amp;quot;Segoe UI&amp;quot;, -apple-system, BlinkMacSystemFont, Roboto, &amp;quot;Helvetica Neue&amp;quot;, sans-serif&quot; style=&quot;background-color: white; box-sizing: inherit; color: #11100f; font-size: 16px; margin-top: 0px; white-space-collapse: preserve;&quot;&gt;Physics-Encoded&lt;/span&gt;&lt;span face=&quot;&amp;quot;Segoe UI&amp;quot;, &amp;quot;Segoe UI Web (West European)&amp;quot;, &amp;quot;Segoe UI&amp;quot;, -apple-system, BlinkMacSystemFont, Roboto, &amp;quot;Helvetica Neue&amp;quot;, sans-serif&quot; style=&quot;background-color: white; color: #11100f; font-size: 16px; white-space-collapse: preserve;&quot;&gt; neural networks (PeNN) based models leverage advanced architectures to address issues with data sparsity and the lack of generalization encountered by both PgNNs and PiNNs models.&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Neural Operator&lt;/h2&gt;&lt;div&gt;Moreover a neural operator can be combined with PiNN and PeNN methods to train a model that
can learn complex non-linearity in physical systems with extremely high generalization accuracy.&lt;p&gt;&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/3517865594517161356/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2024/01/physics-guided-physics-informed-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/3517865594517161356'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/3517865594517161356'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2024/01/physics-guided-physics-informed-and.html' title='Physics-Guided, Physics-Informed, and Physics-Encoded Neural Networks in Scientific Computing'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEjmyEYl-xDe0mQhwb8X1Z43SLUdeDldCvKDW4qhgrvAhF_1QsFRy612t2PH7hI13WS7wmAWNviGBPgxETLEf1DnWX84DV4lm7X2tDneku6LTK1SnjTLnK-5p_SFAtIqRNz06qgbn74rVNriPxwnQfIIu2R8jYv2hDEcudpVAk4nqfTnK7Oak7IAzaSOf_A=s72-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-4503643013588193185</id><published>2024-01-11T07:06:00.002+01:00</published><updated>2024-01-11T07:07:02.460+01:00</updated><title type='text'>Train LLAMA-2 on a Small GPU</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;span face=&quot;-apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;&quot; style=&quot;background-color: #fdfdfd; color: #111111; font-size: 16px;&quot;&gt;Training a LLM model is hard without GPU but we can use LORA and QLORA&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; margin: 0px 0px 15px; padding: 0px;&quot;&gt;4-bit quantization via QLoRA allows efficient finetuning of huge LLM models on consumer hardware while retaining high performance. This improves accessibility and usability for real-world applications.&lt;/p&gt;&lt;p style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; margin: 0px 0px 15px; padding: 0px;&quot;&gt;QLoRA quantizes a pre-trained language model to 4 bits and freezes the parameters.&lt;/p&gt;&lt;p style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; margin: 0px 0px 15px; padding: 0px;&quot;&gt;During fine-tuning, gradients are backpropagated through the frozen 4-bit quantized model into only the Low-Rank Adapter layers.&lt;/p&gt;&lt;p style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; margin: 0px 0px 15px; padding: 0px;&quot;&gt;The 4-bit quantization does not hurt model performance.&lt;/p&gt;&lt;p style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; margin: 0px 0px 15px; padding: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; margin: 0px 0px 15px; padding: 0px;&quot;&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhiAnXa_oliU5f4HfPdCroUo7qQLlNl3CI8tOmxpAJ5INkmPodQJKDyZ1x9XvwodV94DYKkjInyw1y3W22MOhsiDK3XuB0xdAxKxygSyItIDFiaIJ2Hz5qcGM6eq0s9fb-ZwZQreedjqvWfhTtIMqVFDFI02iPvkdu2dVjc2DylQr-iYIeam_WtnqRnoyQ&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;297&quot; data-original-width=&quot;1071&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhiAnXa_oliU5f4HfPdCroUo7qQLlNl3CI8tOmxpAJ5INkmPodQJKDyZ1x9XvwodV94DYKkjInyw1y3W22MOhsiDK3XuB0xdAxKxygSyItIDFiaIJ2Hz5qcGM6eq0s9fb-ZwZQreedjqvWfhTtIMqVFDFI02iPvkdu2dVjc2DylQr-iYIeam_WtnqRnoyQ=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 id=&quot;quantization&quot; style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 32px; font-weight: 400; margin: 0px 0px 15px; padding: 0px;&quot;&gt;Quantization&lt;/h2&gt;&lt;div&gt;&lt;span face=&quot;&amp;quot;Source Sans Pro&amp;quot;, ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #4b5563; font-size: 16.8px;&quot;&gt;Quantization techniques reduces memory and computational costs by representing weights and activations with lower-precision data types like 8-bit integers (int8).&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;&amp;quot;Source Sans Pro&amp;quot;, ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #4b5563; font-size: 16.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;p style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; margin: 0px 0px 15px; padding: 0px;&quot;&gt;In this post we use 4bit quantization&lt;/p&gt;&lt;div class=&quot;language-plaintext highlighter-rouge&quot; style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 238, 255); margin-bottom: 15px;&quot;&gt;&lt;pre class=&quot;highlight&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 3px; border: 1px solid rgb(232, 232, 232); font-size: 15px; margin-bottom: 15px; margin-top: 0px; overflow-x: auto; padding: 8px 12px;&quot;&gt;&lt;code style=&quot;border-radius: 3px; border: 0px; padding: 1px 0px;&quot;&gt;pip install bitsandbytes

...

quant_config = BitsAndBytesConfig(
	load_in_4bit=True,
	bnb_4bit_quant_type=&quot;nf4&quot;,
	bnb_4bit_compute_dtype=getattr(torch, &quot;float16&quot;),
	bnb_4bit_use_double_quant=False,
)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2 id=&quot;training-parameters&quot; style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 32px; font-weight: 400; margin: 0px 0px 15px; padding: 0px;&quot;&gt;Training parameters&lt;/h2&gt;&lt;div&gt;Using LoraConfig&lt;/div&gt;&lt;div class=&quot;language-plaintext highlighter-rouge&quot; style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 238, 255); margin-bottom: 15px;&quot;&gt;&lt;pre class=&quot;highlight&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 3px; border: 1px solid rgb(232, 232, 232); font-size: 15px; margin-bottom: 15px; margin-top: 0px; overflow-x: auto; padding: 8px 12px;&quot;&gt;&lt;code style=&quot;border-radius: 3px; border: 0px; padding: 1px 0px;&quot;&gt;pip install peft_params

...

peft_params = LoraConfig(
	lora_alpha=16,
	lora_dropout=0.1,
	r=64,
	bias=&quot;none&quot;,
	task_type=&quot;CAUSAL_LM&quot;,
)


training_params = TrainingArguments(
	output_dir=&quot;./results&quot;,
	num_train_epochs=1,
	per_device_train_batch_size=4,
	gradient_accumulation_steps=1,
	optim=&quot;paged_adamw_32bit&quot;,
	save_steps=25,
	logging_steps=25,
	learning_rate=2e-4,
	weight_decay=0.001,
	fp16=False,
	bf16=False,
	max_grad_norm=0.3,
	max_steps=-1,
	warmup_ratio=0.03,
	group_by_length=True,
	lr_scheduler_type=&quot;constant&quot;
)

trainer = SFTTrainer(
	model=model,
	train_dataset=dataset,
	peft_config=peft_params,
	dataset_text_field=&quot;text&quot;,
	max_seq_length=None,
	tokenizer=tokenizer,
	args=training_params,
	packing=False,
)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2 id=&quot;prepare-docker&quot; style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 32px; font-weight: 400; margin: 0px 0px 15px; padding: 0px;&quot;&gt;Prepare Docker&lt;/h2&gt;&lt;p style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; margin: 0px 0px 15px; padding: 0px;&quot;&gt;Below how to configure the docker to run on RTX A3000&lt;/p&gt;&lt;h3 id=&quot;base-image&quot; style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 26px; font-weight: 400; margin: 0px 0px 15px; padding: 0px;&quot;&gt;Base Image&lt;/h3&gt;&lt;div class=&quot;language-plaintext highlighter-rouge&quot; style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 238, 255); margin-bottom: 15px;&quot;&gt;&lt;pre class=&quot;highlight&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 3px; border: 1px solid rgb(232, 232, 232); font-size: 15px; margin-bottom: 15px; margin-top: 0px; overflow-x: auto; padding: 8px 12px;&quot;&gt;&lt;code style=&quot;border-radius: 3px; border: 0px; padding: 1px 0px;&quot;&gt;FROM nvidia/cuda:12.1.1-base-ubuntu20.04
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 id=&quot;set-environment-variables&quot; style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 26px; font-weight: 400; margin: 0px 0px 15px; padding: 0px;&quot;&gt;Set environment variables&lt;/h3&gt;&lt;h3 id=&quot;install-system-dependencies&quot; style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 26px; font-weight: 400; margin: 0px 0px 15px; padding: 0px;&quot;&gt;Install system dependencies&lt;/h3&gt;&lt;div class=&quot;language-plaintext highlighter-rouge&quot; style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 238, 255); margin-bottom: 15px;&quot;&gt;&lt;pre class=&quot;highlight&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 3px; border: 1px solid rgb(232, 232, 232); font-size: 15px; margin-bottom: 15px; margin-top: 0px; overflow-x: auto; padding: 8px 12px;&quot;&gt;&lt;code style=&quot;border-radius: 3px; border: 0px; padding: 1px 0px;&quot;&gt;RUN apt-get update
RUN apt-get install -y \
		git \
		python3-pip \
		python3-dev \
		python3-opencv \
		libglib2.0-0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 id=&quot;install-pytorch-and-torchvision&quot; style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 26px; font-weight: 400; margin: 0px 0px 15px; padding: 0px;&quot;&gt;Install PyTorch and torchvision&lt;/h3&gt;&lt;div class=&quot;language-plaintext highlighter-rouge&quot; style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 238, 255); margin-bottom: 15px;&quot;&gt;&lt;pre class=&quot;highlight&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 3px; border: 1px solid rgb(232, 232, 232); font-size: 15px; margin-bottom: 15px; margin-top: 0px; overflow-x: auto; padding: 8px 12px;&quot;&gt;&lt;code style=&quot;border-radius: 3px; border: 0px; padding: 1px 0px;&quot;&gt;RUN pip3 install torch torchvision torchaudio -f https://download.pytorch.org/whl/cu121
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 id=&quot;install-any-python-packages-you-need&quot; style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 26px; font-weight: 400; margin: 0px 0px 15px; padding: 0px;&quot;&gt;Install any python packages you need&lt;/h3&gt;&lt;div class=&quot;language-plaintext highlighter-rouge&quot; style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 238, 255); margin-bottom: 15px;&quot;&gt;&lt;pre class=&quot;highlight&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 3px; border: 1px solid rgb(232, 232, 232); font-size: 15px; margin-bottom: 15px; margin-top: 0px; overflow-x: auto; padding: 8px 12px;&quot;&gt;&lt;code style=&quot;border-radius: 3px; border: 0px; padding: 1px 0px;&quot;&gt;COPY requirements.txt requirements.txt
RUN python3 -m pip install notebook accelerate peft bitsandbytes transformers trl tensorboard
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2 id=&quot;full-code&quot; style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 32px; font-weight: 400; margin: 0px 0px 15px; padding: 0px;&quot;&gt;Full code&lt;/h2&gt;&lt;p style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; margin: 0px 0px 15px; padding: 0px;&quot;&gt;full code is there&lt;/p&gt;&lt;p style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; margin: 0px 0px 15px; padding: 0px;&quot;&gt;&lt;a href=&quot;https://github.com/venergiac/training_LLAMA-2_QLORA&quot; target=&quot;_blank&quot;&gt;https://github.com/venergiac/training_LLAMA-2_QLORA&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; margin: 0px 0px 15px; padding: 0px;&quot;&gt;Build docker:&lt;/p&gt;&lt;div class=&quot;language-plaintext highlighter-rouge&quot; style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 238, 255); margin-bottom: 15px;&quot;&gt;&lt;pre class=&quot;highlight&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 3px; border: 1px solid rgb(232, 232, 232); font-size: 15px; margin-bottom: 15px; margin-top: 0px; overflow-x: auto; padding: 8px 12px;&quot;&gt;&lt;code style=&quot;border-radius: 3px; border: 0px; padding: 1px 0px;&quot;&gt;docker compose build
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; margin: 0px 0px 15px; padding: 0px;&quot;&gt;Start docker:&lt;/p&gt;&lt;div class=&quot;language-plaintext highlighter-rouge&quot; style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 238, 255); margin-bottom: 15px;&quot;&gt;&lt;pre class=&quot;highlight&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 3px; border: 1px solid rgb(232, 232, 232); font-size: 15px; margin-bottom: 15px; margin-top: 0px; overflow-x: auto; padding: 8px 12px;&quot;&gt;&lt;code style=&quot;border-radius: 3px; border: 0px; padding: 1px 0px;&quot;&gt;docker compose run
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: #fdfdfd; color: #111111; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; margin: 0px 0px 15px; padding: 0px;&quot;&gt;Open the jupyter and check it with nvidia-smi.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/4503643013588193185/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2024/01/train-llama-2-on-small-gpu.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/4503643013588193185'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/4503643013588193185'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2024/01/train-llama-2-on-small-gpu.html' title='Train LLAMA-2 on a Small GPU'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEhiAnXa_oliU5f4HfPdCroUo7qQLlNl3CI8tOmxpAJ5INkmPodQJKDyZ1x9XvwodV94DYKkjInyw1y3W22MOhsiDK3XuB0xdAxKxygSyItIDFiaIJ2Hz5qcGM6eq0s9fb-ZwZQreedjqvWfhTtIMqVFDFI02iPvkdu2dVjc2DylQr-iYIeam_WtnqRnoyQ=s72-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-7219444038630633929</id><published>2024-01-02T13:35:00.003+01:00</published><updated>2024-01-02T13:35:26.592+01:00</updated><title type='text'>Towards General AI</title><content type='html'>&lt;br /&gt;Recent advancements in Large Language Models (LLMs) have demonstrated a ability for reasoning. Is this the basis for General AI? General AI (AGI) is known as human-level AI or general intelligent action. AGI is able to learn tasks from one domain and apply to another domain; so AGI is the AI able to perform tasks in a very similar way to humans. &lt;br /&gt;&lt;br /&gt;In 2020 we predicted that AGI would be reached in 2040; we have now moved forward to 2030.&lt;br /&gt;&lt;br /&gt;Nvidia CEO Jensen Huang says AI will be ‘fairly competitive’ with humans in 5 years&lt;br /&gt;&lt;br /&gt;The road is still foggy (and perhaps we are being optimistic), but some signs are showing us the way.&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDnFGjWBp_ME-j1a3_2QB3foPQpSW4yYx8djjHRbvqxSkvyHap-jZJJLyDtqPTIJ6apsUbfnlDrBsQSB68x3gYRvbY9UFLN-it6-rG8nFk_jSuwd15Tb00apnka_dn3h213jqUxx0TAqLKNSbgazuCltYkKNRz1l_7JIVWkTBz1dS6JhK5VKN_XMyVzZ0/s997/AI.png&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDnFGjWBp_ME-j1a3_2QB3foPQpSW4yYx8djjHRbvqxSkvyHap-jZJJLyDtqPTIJ6apsUbfnlDrBsQSB68x3gYRvbY9UFLN-it6-rG8nFk_jSuwd15Tb00apnka_dn3h213jqUxx0TAqLKNSbgazuCltYkKNRz1l_7JIVWkTBz1dS6JhK5VKN_XMyVzZ0/s16000/AI.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Human vs AI&lt;/h2&gt;&lt;br /&gt;Let&#39;s retrace the road. Human is a collection of complex capabilities: &lt;br /&gt;&lt;br /&gt;The ability to remember, &lt;br /&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;to perceive the environment and interact with it, &lt;/li&gt;&lt;li&gt;the ability to learn, &lt;/li&gt;&lt;li&gt;the ability to generalize and to reason in abstract and symbolic way &lt;/li&gt;&lt;li&gt;the self-awareness &lt;/li&gt;&lt;li&gt;and, last but not least, the ability to judge ethically own actions.&lt;/li&gt;&lt;/ol&gt;To emulate these functions, several strategies have been developed: in 1950 we deceived ourselves that we understood the visual mechanisms and we created the perceptron (1958), the later convolutional filters. In 1980 we defined the decision trees to learn from data. Only thanks, however, to the growing computational capacity, we obtained the first results (LeNet and CNN) in 2010.&lt;br /&gt;&lt;br /&gt;Deep Learning and Transformers architecture (2017) led us to Large Language Models (LLM, 2020): models with over 1 billion parameters. &lt;br /&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Large Language Model&lt;/h2&gt;&lt;br /&gt;A feature predominantly seen in models with over 100 billion parameters, is the ability of reasoning (considered an emergent ability). While opinions differ on whether LLMs possess reasoning abilities, it&#39;s becoming evident that LLMs can be equipped to deal with complex problems (similar to human).&lt;br /&gt;&lt;br /&gt;Indeed, through sophisticated prompting strategies (eg. Chain-of-Thought Prompting, Tree of Thoughts, ....) or Symbolic Modules it is possible to achieve complex tasks.&lt;br /&gt;&lt;br /&gt;So, what is the next step to achieve the AGI?&lt;br /&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Multimodality&lt;/h2&gt;&lt;br /&gt;The secret ingredient seems to be (obviously) multimodality; that is, the ability to integrate and process audio, video and sound content in an integrated manner. It&#39;s not just adding something but also improving.&lt;br /&gt;&lt;br /&gt;Gemini (Google), Ferret (Apple) and GPT-4+ (OpenAi) and other open source (eg. Hugging Face, LangChain, ...) tools are going in this direction.&lt;br /&gt;&lt;br /&gt;Moreover, cross-modal alignment is another interesting tool: Contrastive Language Image Pretraining (CLIP) utilizes image captioning task to align image and text modalities. Contrastive Language Audio Pretraining aligns audio and text.&lt;br /&gt;&lt;br /&gt;So, what is the next step to achieve AGI?&lt;br /&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;1 more Multimodality&lt;/h4&gt;&lt;br /&gt;There is, however, a fourth element to integrate: not only vision, text and audio, but also the ability to act and interact with an environment.&lt;br /&gt;&lt;br /&gt;Tools like Reinforcement Learning or IoT or Robotic or simple API can provide to AI the ability to take a further step.&lt;br /&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Super AI&lt;/h2&gt;&lt;br /&gt;Artificial Super Intelligence (ASI) is defined as a form of AI capable of surpassing human intelligence. ASI is expected by 2050, but, first, we should fix some issues such as ethics and self-awareness (and maybe leveraging on quantum computing).&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Conclusion&lt;/h2&gt;&lt;br /&gt;So is it 2024 when we will find the road to AGI?&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/7219444038630633929/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2024/01/towards-general-ai.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/7219444038630633929'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/7219444038630633929'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2024/01/towards-general-ai.html' title='Towards General AI'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDnFGjWBp_ME-j1a3_2QB3foPQpSW4yYx8djjHRbvqxSkvyHap-jZJJLyDtqPTIJ6apsUbfnlDrBsQSB68x3gYRvbY9UFLN-it6-rG8nFk_jSuwd15Tb00apnka_dn3h213jqUxx0TAqLKNSbgazuCltYkKNRz1l_7JIVWkTBz1dS6JhK5VKN_XMyVzZ0/s72-c/AI.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-7959343985100101139</id><published>2023-12-09T13:17:00.006+01:00</published><updated>2023-12-09T13:17:59.222+01:00</updated><title type='text'>Hands-On Industrial Internet of Things - my best book - thanks to all</title><content type='html'>&lt;h1 style=&quot;text-align: left;&quot;&gt;Achievement of my book Hands-On Industrial Internet of Things&lt;/h1&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEik3xMSFmsSO6Z1pEPkizLWX4HbRjZaU-ffa7t1I145EvWl5Q1egI-YbwA_kzu6AKPqdNgHm1CpWlFGC8ltQfivRYcnyYEOYriZSiNXJtLR-AjUnlu6adkyGSrvKg9iyAcM9yRIdDVS6xdXdJcV1P93xsgGnkJMiwrcjmVCOpg3vZ9nY0G3H2JcG85l3MA&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;617&quot; data-original-width=&quot;500&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEik3xMSFmsSO6Z1pEPkizLWX4HbRjZaU-ffa7t1I145EvWl5Q1egI-YbwA_kzu6AKPqdNgHm1CpWlFGC8ltQfivRYcnyYEOYriZSiNXJtLR-AjUnlu6adkyGSrvKg9iyAcM9yRIdDVS6xdXdJcV1P93xsgGnkJMiwrcjmVCOpg3vZ9nY0G3H2JcG85l3MA&quot; width=&quot;194&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;7000 copies, 40+ scientific citations, 4.4 on amazon&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjaergiDBzr4-O9-oOfqwuTYYVEWBm3_5_FcfSEckDHkVMbAFfsay09VaUUcL_JfMm8uuEPO_X2BbKOW0gKVQ3JlkyDFjh7osOly-PSpZo3MtE9ib91krSgKaNSnxVBeKzKHAdue0owoK7A1Y4R1VN8w86XNMqUqpKUw6p6C_CkZm4c5QG63c1mplnneKk&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;27&quot; data-original-width=&quot;275&quot; height=&quot;31&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjaergiDBzr4-O9-oOfqwuTYYVEWBm3_5_FcfSEckDHkVMbAFfsay09VaUUcL_JfMm8uuEPO_X2BbKOW0gKVQ3JlkyDFjh7osOly-PSpZo3MtE9ib91krSgKaNSnxVBeKzKHAdue0owoK7A1Y4R1VN8w86XNMqUqpKUw6p6C_CkZm4c5QG63c1mplnneKk&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;2019 Best Book&lt;/h2&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgv75Yu2GhRCeo9bg0REDf7N5FqYpT5CJ6O5m__nUxsyTXPSn-JUN93wlOEzBeddbHrXFO-8PNyOn8hQOJMyOmfng48bXAwSLqZzXkz54vlbGxIy6v3tmBvi3-tDDo_TLDIn5y9qLmzo1698yeSkFiRFNsjz1-ueshOFt42Ho1Ave8P4nucXzTbe0OXZtg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;592&quot; data-original-width=&quot;1252&quot; height=&quot;151&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgv75Yu2GhRCeo9bg0REDf7N5FqYpT5CJ6O5m__nUxsyTXPSn-JUN93wlOEzBeddbHrXFO-8PNyOn8hQOJMyOmfng48bXAwSLqZzXkz54vlbGxIy6v3tmBvi3-tDDo_TLDIn5y9qLmzo1698yeSkFiRFNsjz1-ueshOFt42Ho1Ave8P4nucXzTbe0OXZtg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/7959343985100101139/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2023/12/hands-on-industrial-internet-of-things.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/7959343985100101139'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/7959343985100101139'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2023/12/hands-on-industrial-internet-of-things.html' title='Hands-On Industrial Internet of Things - my best book - thanks to all'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEik3xMSFmsSO6Z1pEPkizLWX4HbRjZaU-ffa7t1I145EvWl5Q1egI-YbwA_kzu6AKPqdNgHm1CpWlFGC8ltQfivRYcnyYEOYriZSiNXJtLR-AjUnlu6adkyGSrvKg9iyAcM9yRIdDVS6xdXdJcV1P93xsgGnkJMiwrcjmVCOpg3vZ9nY0G3H2JcG85l3MA=s72-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-6025570711052982528</id><published>2023-12-06T09:20:00.006+01:00</published><updated>2023-12-06T10:01:25.777+01:00</updated><title type='text'>It&#39;s AI generating generative AI commissions? </title><content type='html'>&lt;h3 style=&quot;text-align: left;&quot;&gt;It&#39;s AI generating generative AI commissions?&amp;nbsp;&lt;/h3&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8Tx9R2fxwxgAqTYtXAGJVcyj5muRszW5j8wDoQudoV6poc691QkDb2fpOnppo1CQBopcaOLnfmP8wfvA-Haiit_rlzOyBP4IK_pWNGsL796_dygesm3SdayiIzhesenZ0kfQcYiBFlf3o8pjzOYbppj1GCjFSZvTRWwyfmhG-03tvHNI3FYIZRfvHN8U/s813/generative_ai.PNG&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;646&quot; data-original-width=&quot;813&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8Tx9R2fxwxgAqTYtXAGJVcyj5muRszW5j8wDoQudoV6poc691QkDb2fpOnppo1CQBopcaOLnfmP8wfvA-Haiit_rlzOyBP4IK_pWNGsL796_dygesm3SdayiIzhesenZ0kfQcYiBFlf3o8pjzOYbppj1GCjFSZvTRWwyfmhG-03tvHNI3FYIZRfvHN8U/s16000/generative_ai.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/6025570711052982528/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2023/12/its-ai-generating-generative-ai.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/6025570711052982528'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/6025570711052982528'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2023/12/its-ai-generating-generative-ai.html' title='It&#39;s AI generating generative AI commissions? '/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8Tx9R2fxwxgAqTYtXAGJVcyj5muRszW5j8wDoQudoV6poc691QkDb2fpOnppo1CQBopcaOLnfmP8wfvA-Haiit_rlzOyBP4IK_pWNGsL796_dygesm3SdayiIzhesenZ0kfQcYiBFlf3o8pjzOYbppj1GCjFSZvTRWwyfmhG-03tvHNI3FYIZRfvHN8U/s72-c/generative_ai.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-4105334017119684681</id><published>2023-11-15T20:33:00.004+01:00</published><updated>2023-11-16T08:47:22.157+01:00</updated><title type='text'>BiomedLM - Domain-Specific Large Language Model for Biomedical Text</title><content type='html'>&lt;h1 style=&quot;background-color: white; box-sizing: inherit; color: #242424; font-family: sohne, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; letter-spacing: -0.011em; line-height: 52px; margin: 1.19em 0px 32px; text-align: left;&quot;&gt;Domain-Specific Large Language Model for Biomedical Text&lt;/h1&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;BioMedLM&lt;/h2&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjlgCwvqipqOLC06HY97ENxRyV6hhVnoqtKhwdR-kD_Jj2VO7lKiAcmLXbPb0qSjHjxEFAqfiAxvf0iU9BOWBqtLYshT_x6dLMx9iJiVzKlSsZDNdJ0L7AyFDEOx3Cv6f8WF84hh6Zw9-NIFBUluBFTEc9FfZPaQ1ZX4P3F63Vw5IoVt1QGKwF-w2v96Ck&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;724&quot; data-original-width=&quot;1444&quot; height=&quot;160&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjlgCwvqipqOLC06HY97ENxRyV6hhVnoqtKhwdR-kD_Jj2VO7lKiAcmLXbPb0qSjHjxEFAqfiAxvf0iU9BOWBqtLYshT_x6dLMx9iJiVzKlSsZDNdJ0L7AyFDEOx3Cv6f8WF84hh6Zw9-NIFBUluBFTEc9FfZPaQ1ZX4P3F63Vw5IoVt1QGKwF-w2v96Ck&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;&amp;quot;Source Sans Pro&amp;quot;, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, &amp;quot;Noto Sans&amp;quot;, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #4b5563; font-size: 16.8px;&quot;&gt;BioMedLM 2.7B is new language model trained exclusively on biomedical abstracts and papers.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;&amp;quot;Source Sans Pro&amp;quot;, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, &amp;quot;Noto Sans&amp;quot;, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #4b5563; font-size: 16.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;&amp;quot;Source Sans Pro&amp;quot;, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, &amp;quot;Noto Sans&amp;quot;, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #4b5563; font-size: 16.8px;&quot;&gt;&lt;br /&gt;
  
  &lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;torch&lt;/span&gt;

&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;transformers&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; GPT2LMHeadModel, GPT2Tokenizer

device &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; torch&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;device(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;cuda&quot;&lt;/span&gt;)

tokenizer &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; GPT2Tokenizer&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;from_pretrained(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;stanford-crfm/pubmed_gpt_tokenizer&quot;&lt;/span&gt;)

model &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; GPT2LMHeadModel&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;from_pretrained(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;stanford-crfm/pubmedgpt&quot;&lt;/span&gt;)&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;to(device)
&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;&amp;quot;Source Sans Pro&amp;quot;, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, &amp;quot;Noto Sans&amp;quot;, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #4b5563; font-size: 16.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;

  
and now ask your question about mastocitosis&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #4b5563;&quot;&gt;&lt;span style=&quot;font-size: 16.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span face=&quot;&amp;quot;Source Sans Pro&amp;quot;, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, &amp;quot;Noto Sans&amp;quot;, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #4b5563; font-size: 16.8px;&quot;&gt;&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;input_ids &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; tokenizer&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;encode(
    &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;How to treat mastocytosis in 10 words ?&quot;&lt;/span&gt;, return_tensors&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;pt&quot;&lt;/span&gt;
)&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;to(device)

sample_output &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; model&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;generate(input_ids, do_sample&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #007020;&quot;&gt;True&lt;/span&gt;, max_length&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;200&lt;/span&gt;, top_k&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;50&lt;/span&gt;)

&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Output:&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0; color: #666666; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;100&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;-&quot;&lt;/span&gt;)
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;print&lt;/span&gt;(tokenizer&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;decode(sample_output[&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;], skip_special_tokens&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #007020;&quot;&gt;True&lt;/span&gt;))&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;&amp;quot;Source Sans Pro&amp;quot;, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, &amp;quot;Noto Sans&amp;quot;, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #4b5563; font-size: 16.8px;&quot;&gt;the response&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;&amp;quot;Source Sans Pro&amp;quot;, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, &amp;quot;Noto Sans&amp;quot;, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #4b5563; font-size: 16.8px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;&amp;quot;Source Sans Pro&amp;quot;, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, &amp;quot;Noto Sans&amp;quot;, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;&quot; style=&quot;color: #4b5563;&quot;&gt;&lt;pre style=&quot;background-color: white; border-radius: 0px; border: 0px; box-sizing: border-box; color: black; font-size: 14px; line-height: inherit; margin-bottom: 0px; margin-top: 0px; overflow-wrap: break-word; overflow: auto; padding: 1px 0px; text-wrap: wrap; vertical-align: baseline; word-break: break-all;&quot;&gt;How to treat mastocytosis in 10 words?
Mastocytosis, a heterogeneous group of diseases characterized by an abnormal proliferation of tissue mast cells, is rarely seen in the pediatric population. A clinical approach to the diagnosis and treatment of mastocytosis is provided. The treatment of mastocytosis is challenging and has significant limitations. This review provides clinicians and patients with a concise, organized, and practical approach to the diagnosis and treatment of mastocytosis. Recent advances in the management of mastocytosis include biologic agents (pegylated interferon, omalizumab, omaliraptor), a bone marrow transplantation protocol, and novel chemotherapeutic agents. Despite these advances in treatment, the goal of disease control remains unmet for many patients. &lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-radius: 0px; border: 0px; box-sizing: border-box; color: black; font-size: 14px; line-height: inherit; margin-bottom: 0px; margin-top: 0px; overflow-wrap: break-word; overflow: auto; padding: 1px 0px; text-wrap: wrap; vertical-align: baseline; word-break: break-all;&quot;&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-radius: 0px; border: 0px; box-sizing: border-box; color: black; font-size: 14px; line-height: inherit; margin-bottom: 0px; margin-top: 0px; overflow-wrap: break-word; overflow: auto; padding: 1px 0px; text-wrap: wrap; vertical-align: baseline; word-break: break-all;&quot;&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/span&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/h2&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/4105334017119684681/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2023/11/biomedlm-domain-specific-large-language.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/4105334017119684681'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/4105334017119684681'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2023/11/biomedlm-domain-specific-large-language.html' title='BiomedLM - Domain-Specific Large Language Model for Biomedical Text'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEjlgCwvqipqOLC06HY97ENxRyV6hhVnoqtKhwdR-kD_Jj2VO7lKiAcmLXbPb0qSjHjxEFAqfiAxvf0iU9BOWBqtLYshT_x6dLMx9iJiVzKlSsZDNdJ0L7AyFDEOx3Cv6f8WF84hh6Zw9-NIFBUluBFTEc9FfZPaQ1ZX4P3F63Vw5IoVt1QGKwF-w2v96Ck=s72-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-525881576974099087</id><published>2023-10-15T10:36:00.003+02:00</published><updated>2023-10-15T10:37:07.147+02:00</updated><title type='text'>NASSCOM Award - NOx estimator for a gas turbine hydrogen-fueled burner</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;span style=&quot;text-align: center;&quot;&gt;Development of a surrogate model for NOx emissions for 100% hydrogen-fueled burners, leveraging deep learning methods and some advanced techniques for feature importance. Allows combustion design engineers to evaluate NOx emission levels, given the operating parameters of the combustion chamber, at an early, design stage, so to also reduce design rework and testing activity. Feature importance helps identifying the parameters to leverage to minimize emissions.&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzLfY-H3MsVx4ZWeIMr9hwGWGs-TUT0K2C33wCo5b_bh3ZOHE1QjTcSKX4ij4ShDddFzva1VLYAPaJ-vFdSfUj8nM4KwFyHV7vO8rC_RBo8-wIBbvW59rRlTKIUurUOK9oENjxJwQ1CBErFqPBCoF4ycrFCRQs3tjK7p3R-ju6pb0R5NsgA-OzBWZI6BA/s1365/award.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;777&quot; data-original-width=&quot;1365&quot; height=&quot;182&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzLfY-H3MsVx4ZWeIMr9hwGWGs-TUT0K2C33wCo5b_bh3ZOHE1QjTcSKX4ij4ShDddFzva1VLYAPaJ-vFdSfUj8nM4KwFyHV7vO8rC_RBo8-wIBbvW59rRlTKIUurUOK9oENjxJwQ1CBErFqPBCoF4ycrFCRQs3tjK7p3R-ju6pb0R5NsgA-OzBWZI6BA/s320/award.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAdJuIhUb98Vep5cZhyphenhyphenT7GdNZqpVSJcw6spNYUFX4ztaaUNNn4EkSIXgkPKI6txRRUQM0rw4ttZmwSxYrry94c0YsFSmoM2R3sd_2WlmYAKugg994sZjte5VNqJobUrlvuOGmtAdQK8wLEgMvI7j1CFm-yp5tXBRJAUaSZDhNQDoOJZgINgt-l5mvhFbk/s3205/MicrosoftTeams-image%20(34).png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;2871&quot; data-original-width=&quot;3205&quot; height=&quot;287&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAdJuIhUb98Vep5cZhyphenhyphenT7GdNZqpVSJcw6spNYUFX4ztaaUNNn4EkSIXgkPKI6txRRUQM0rw4ttZmwSxYrry94c0YsFSmoM2R3sd_2WlmYAKugg994sZjte5VNqJobUrlvuOGmtAdQK8wLEgMvI7j1CFm-yp5tXBRJAUaSZDhNQDoOJZgINgt-l5mvhFbk/s320/MicrosoftTeams-image%20(34).png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/525881576974099087/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2023/10/nasscom-award-nox-estimator-for-gas.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/525881576974099087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/525881576974099087'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2023/10/nasscom-award-nox-estimator-for-gas.html' title='NASSCOM Award - NOx estimator for a gas turbine hydrogen-fueled burner'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzLfY-H3MsVx4ZWeIMr9hwGWGs-TUT0K2C33wCo5b_bh3ZOHE1QjTcSKX4ij4ShDddFzva1VLYAPaJ-vFdSfUj8nM4KwFyHV7vO8rC_RBo8-wIBbvW59rRlTKIUurUOK9oENjxJwQ1CBErFqPBCoF4ycrFCRQs3tjK7p3R-ju6pb0R5NsgA-OzBWZI6BA/s72-c/award.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-6046460384705255632</id><published>2023-09-03T20:45:00.010+02:00</published><updated>2023-09-03T20:56:42.604+02:00</updated><title type='text'>Use SHAPELY and CATBOOST to debug your model</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;a href=&quot;https://catboost.ai/&quot;&gt;Catboost&lt;/a&gt; is a boosting method accepting data with categorical features and text; for tabular data is very efficient; sometime, however, using industrial dataset we can face with overfitting issue and you want to debug using feature importance or better &lt;a href=&quot;https://shap.readthedocs.io/en/latest/index.html&quot;&gt;shapely&lt;/a&gt; value.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKFH8xKJ_aKKdMdw0Jyoh-hZvwuKMY0mpLsApH4wfGTnMGGkvC2BcWcxPIvgvd8ZJTGRE-e2ChiiPTZztBKtDx1nu2Ux9J5WaXAhDAtx6Gkcti_ozmGO8IbhT7nSySp4MYKjfXmMXhRIl26OALGt-GoMsVLAm3tGVNgQwFayDLNHIIQNcJOTYbQdvVu3E/s649/catboost_shap.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;259&quot; data-original-width=&quot;649&quot; height=&quot;128&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKFH8xKJ_aKKdMdw0Jyoh-hZvwuKMY0mpLsApH4wfGTnMGGkvC2BcWcxPIvgvd8ZJTGRE-e2ChiiPTZztBKtDx1nu2Ux9J5WaXAhDAtx6Gkcti_ozmGO8IbhT7nSySp4MYKjfXmMXhRIl26OALGt-GoMsVLAm3tGVNgQwFayDLNHIIQNcJOTYbQdvVu3E/s320/catboost_shap.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Build a model&lt;/h3&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Just import

&lt;/h4&gt;&lt;p&gt;&lt;!--HTML generated using hilite.me--&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; text-align: left; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;catboost&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;pandas&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;pd&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;numpy&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;np&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;os&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;

Open the dataset
&lt;/h4&gt;We use the Womens Clothing E-Commerce Reviews.csv&lt;br /&gt;Dataset is available there &lt;a href=&quot;https://www.kaggle.com/datasets/nicapotato/womens-ecommerce-clothing-reviews&quot;&gt;https://www.kaggle.com/datasets/nicapotato/womens-ecommerce-clothing-reviews &lt;/a&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; text-align: left; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;df &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; pd&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;read_csv(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;Womens Clothing E-Commerce Reviews.csv&#39;&lt;/span&gt;, delimiter&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;,&#39;&lt;/span&gt;, nrows &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; nRowsRead)
df&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;dataframeName &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;Womens Clothing E-Commerce Reviews.csv&#39;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;


Build the model

&lt;/h4&gt;&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;CAT_FEATURES&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;[&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;Division Name&#39;&lt;/span&gt;,&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;Department Name&#39;&lt;/span&gt;,&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;Class Name&#39;&lt;/span&gt;]
TEXT_FEATURES&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;[&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;Title&#39;&lt;/span&gt;, &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;Review Text&#39;&lt;/span&gt;]
NUM_FEATURES&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;[&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;Age&#39;&lt;/span&gt;]&lt;/pre&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;X_COLUMNS &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; NUM_FEATURES &lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt; CAT_FEATURES &lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt; TEXT_FEATURES
Y_COLUMN &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; [&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;Rating&#39;&lt;/span&gt;]

df[CAT_FEATURES &lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt; TEXT_FEATURES] &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; df[CAT_FEATURES &lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt; TEXT_FEATURES]&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;astype(&lt;span style=&quot;color: #007020;&quot;&gt;str&lt;/span&gt;)


&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;sklearn.model_selection&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; train_test_split
df_train, df_test &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; train_test_split(df, test_size&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;0.3&lt;/span&gt;, random_state&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;42&lt;/span&gt;)



model &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; catboost&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;CatBoostRegressor(cat_features&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;CAT_FEATURES, 
                          text_features&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;TEXT_FEATURES,
                          iterations&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1000&lt;/span&gt;,
                          early_stopping_rounds&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;100&lt;/span&gt;)

&lt;span style=&quot;color: #888888;&quot;&gt;# Fit model&lt;/span&gt;
model&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;fit(df_train[X_COLUMNS], df_train[Y_COLUMN])
&lt;/pre&gt;&lt;/div&gt;



&lt;h4 style=&quot;text-align: left;&quot;&gt;Eval model&lt;/h4&gt;&lt;p&gt;


&lt;!--HTML generated using hilite.me--&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;model&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;score(df_test[X_COLUMNS], df_test[Y_COLUMN])
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;/p&gt;&lt;pre style=&quot;background-color: white; border: none; box-sizing: unset; color: var(--jp-content-font-color1); font-family: var(--jp-code-font-family); font-size: var(--jp-code-font-size); line-height: normal; margin-bottom: 0px; margin-top: 0px; overflow-wrap: break-word; overflow: auto; padding: 0px; text-wrap: wrap; word-break: break-all;&quot;&gt;0.2854713235691765&lt;/pre&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Debug with shapley&lt;/h4&gt;&lt;p&gt;
  
  
  &lt;!--HTML generated using hilite.me--&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;shap&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;catboost&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;*&lt;/span&gt;
shap&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;initjs()

X &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; df_test[X_COLUMNS]
y &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; df_test[Y_COLUMN]

pool &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; Pool(X, y, cat_features&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;CAT_FEATURES, text_features&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;TEXT_FEATURES)


explainer &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; shap&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;TreeExplainer(model)
shap_values &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; explainer(pool)

&lt;span style=&quot;color: #888888;&quot;&gt;# summarize the effects of all the features&lt;/span&gt;
shap&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;summary_plot(shap_values, X)&lt;/pre&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;shap&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;plots&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;bar(shap_values)
&lt;/pre&gt;&lt;/div&gt;

  &lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;



&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For source :&amp;nbsp;&lt;span style=&quot;background-color: white; font-family: Inter, sans-serif; font-size: 14px; white-space: pre;&quot;&gt;https://www.kaggle.com/code/giacomoveneri1/notebooka6d3db12e2&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIwwvHf6M_t6zlv00RfDZJ-vOZGQ8ixdxsiV-DkSVrlzYB5TC2DIQ2hbUeWbLSY-gOVaW5w4vcRXvx0ivysyzMZ8txIjHe3rrF6-iNkz0es5nL_LiScYnPj2tkL2dc4qqiav_xWvNxorM58CDXzoGKXrt54BPtvA0S8VSF9cNnFZVhaQTwfp582gAtJts/s1026/shap.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;486&quot; data-original-width=&quot;1026&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIwwvHf6M_t6zlv00RfDZJ-vOZGQ8ixdxsiV-DkSVrlzYB5TC2DIQ2hbUeWbLSY-gOVaW5w4vcRXvx0ivysyzMZ8txIjHe3rrF6-iNkz0es5nL_LiScYnPj2tkL2dc4qqiav_xWvNxorM58CDXzoGKXrt54BPtvA0S8VSF9cNnFZVhaQTwfp582gAtJts/s16000/shap.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;See also:&amp;nbsp;&lt;a href=&quot;https://github.com/AILAB-bh/AILAB-bh#readme&quot;&gt;https://github.com/AILAB-bh/AILAB-bh#readme&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/6046460384705255632/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2023/09/use-shapely-and-catboost-to-debug-your.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/6046460384705255632'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/6046460384705255632'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2023/09/use-shapely-and-catboost-to-debug-your.html' title='Use SHAPELY and CATBOOST to debug your model'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKFH8xKJ_aKKdMdw0Jyoh-hZvwuKMY0mpLsApH4wfGTnMGGkvC2BcWcxPIvgvd8ZJTGRE-e2ChiiPTZztBKtDx1nu2Ux9J5WaXAhDAtx6Gkcti_ozmGO8IbhT7nSySp4MYKjfXmMXhRIl26OALGt-GoMsVLAm3tGVNgQwFayDLNHIIQNcJOTYbQdvVu3E/s72-c/catboost_shap.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-2936695804437731287</id><published>2023-09-02T11:23:00.006+02:00</published><updated>2023-09-09T12:03:18.165+02:00</updated><title type='text'> Combining Thermodynamics-based Model of the Centrifugal Compressors and Active Machine Learning for Enhanced Industrial Design Optimization</title><content type='html'>&lt;h1 style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://openreview.net/pdf?id=bZ5br8JcTS&quot;&gt;&amp;nbsp;&lt;span face=&quot;-apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #1f2328; font-size: 16px;&quot;&gt;Combining Thermodynamics-based Model of the Centrifugal Compressors and Active Machine Learning for Enhanced Industrial Design Optimization - S Ghiasi, G Pazzi, C Del Grosso, G De Magistris, G Veneri - 1st workshop on Synergy of Scientific and Machine Learning Modeling, SynS - 2023&lt;/span&gt;&lt;/a&gt;&lt;/h1&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The design process of centrifugal compressors
requires applying an optimization process which
is computationally expensive due to complex analytical equations underlying the compressor’s
dynamical equations. Although the regression
surrogate models could drastically reduce the
computational cost of such a process, the major challenge is the scarcity of data for training
the surrogate model. Aiming to strategically exploit the labeled samples, we propose the Active Comp Design framework in which we combine
a thermodynamics-based compressor model (i.e.,
our internal software for compressor design) and
Gaussian Process- based surrogate model within a
deployable Active Learning (AL) setting. We first
conduct experiments in an offline setting and further, extend it to an online AL framework where
a real-time interaction with the thermodynamics based compressor’s model allows the deployment
in production. Active Comp Design shows a significant performance improvement in surrogate modeling by leveraging on uncertainty-based query
function of samples within the AL framework
with respect to the random selection of data points.
Moreover, our framework in production has reduced the total computational time of compressor’s design optimization to around 46% faster
than relying on the internal thermodynamics based simulator, achieving the same performance.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;The Algorithm&lt;/h4&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhNRyHy3jrOr77vNqN6F8yVgqAH-eUfpxj36vPvhy2uyaWD77ZRQw9uizBhT73BMS16DaQTYZsCM4JHOqy0CKyMrfBUyRvftynZyVIn-DsPVd95hz28cEcsuFPOGw2d-iMIkWtmBhAK9arHn9ZK-YqKAWwU-ex6WgE7d2rQRfpKujtVcur9vOxS1iQ13OY&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;604&quot; data-original-width=&quot;420&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhNRyHy3jrOr77vNqN6F8yVgqAH-eUfpxj36vPvhy2uyaWD77ZRQw9uizBhT73BMS16DaQTYZsCM4JHOqy0CKyMrfBUyRvftynZyVIn-DsPVd95hz28cEcsuFPOGw2d-iMIkWtmBhAK9arHn9ZK-YqKAWwU-ex6WgE7d2rQRfpKujtVcur9vOxS1iQ13OY&quot; width=&quot;167&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Results&lt;/h4&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgO0aTJBpECn1TwPoraLaCPBiZGCFuOygkFURjzrSrd_mLE4SOOl_xakOAFhpjyKn6Eb390f9Bcw4Ll-3jt6VutDA5CkyZxP5e3Kl7dw15aERVnYOMHluV1bz9zmGsv5eNBHc07cQIknbe22v694eHZ5F65iho083ZPZ-06QlQKgTpoNjErcP7pi-0YOBw&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;494&quot; data-original-width=&quot;854&quot; height=&quot;185&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgO0aTJBpECn1TwPoraLaCPBiZGCFuOygkFURjzrSrd_mLE4SOOl_xakOAFhpjyKn6Eb390f9Bcw4Ll-3jt6VutDA5CkyZxP5e3Kl7dw15aERVnYOMHluV1bz9zmGsv5eNBHc07cQIknbe22v694eHZ5F65iho083ZPZ-06QlQKgTpoNjErcP7pi-0YOBw&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Conclusions&lt;/h4&gt;&lt;/div&gt;&lt;div&gt;The benefits of combining active ML methods with physical
models underlying compressor’s dynamics are large for design optimization applications including faster computations
and more accurate design solutions. However, the tradeoff between performance and computational power has to
be carefully evaluated for the specific design application.
Moreover (see also (Pardakhti et al., 2021)), the adoption of
AL methods poses significant challenges in many practical
applications, such as lack of data, discontinuous space of
exploration and measurement error.
The results obtained from offline and online ActiveCompDesign show that integrating ML in compressor’s simulators is
viable for production ready application on the energy sector.
Indeed, our framework is currently working in a production environment. For future research we will expand this
framework for wider design optimization applications and
improve the monitoring of the deployed model.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;See also github artificial intelligence lab baker hughes:&amp;nbsp;&lt;a href=&quot;https://github.com/AILAB-bh/AILAB-bh&quot;&gt;https://github.com/AILAB-bh/AILAB-bh&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/2936695804437731287/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2023/09/combining-thermodynamics-based-model-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/2936695804437731287'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/2936695804437731287'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2023/09/combining-thermodynamics-based-model-of.html' title=' Combining Thermodynamics-based Model of the Centrifugal Compressors and Active Machine Learning for Enhanced Industrial Design Optimization'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEhNRyHy3jrOr77vNqN6F8yVgqAH-eUfpxj36vPvhy2uyaWD77ZRQw9uizBhT73BMS16DaQTYZsCM4JHOqy0CKyMrfBUyRvftynZyVIn-DsPVd95hz28cEcsuFPOGw2d-iMIkWtmBhAK9arHn9ZK-YqKAWwU-ex6WgE7d2rQRfpKujtVcur9vOxS1iQ13OY=s72-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-615433929545054931</id><published>2023-07-21T10:40:00.004+02:00</published><updated>2023-09-02T11:18:46.220+02:00</updated><title type='text'>Sensor Virtualization for Anomaly Detection of Turbo-Machinery Sensors-An Industrial Application</title><content type='html'>&lt;h1 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;a href=&quot;https://www.mdpi.com/2673-4591/39/1/96&quot;&gt;Sensor Virtualization for Anomaly Detection of Turbo-Machinery Sensors - An Industrial Application&lt;/a&gt;&lt;/b&gt;&lt;/h1&gt;&lt;p&gt;&lt;i&gt;Sachin Shetty, Valentina Gori, Gianni Bagni and Giacomo Veneri&lt;/i&gt;&lt;/p&gt;&lt;p&gt;We apply a Granger causality and auto-correlation analysis to train a recurrent neural network (RNN) that acts as a virtual sensor model. These models can be used to check the status of several hundreds of sensors during turbo-machinery units’ operation. Checking the health of each sensor is a time-consuming activity. Training a supervised algorithm is not feasible because we do not know all the failure modes that the sensors can undergo. We use a semi-supervised approach and train an RNN (LSTM) on non-anomalous data to build a virtual sensor using other sensors as regressors. We use the Granger causality test to identify the set of input sensors for a given target sensor. Moreover, we look at the auto-correlation function (ACF) to understand the temporal dependency in data. We then compare the predicted signal vs. the real one to raise (in case) an anomaly in real time. Results report 96% precision and 100% recall.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Methods&lt;/h3&gt;&lt;p&gt;We used the auto-correlation to find the temporal relations in both input sensors and target sensor to obtain the best ``window size&#39;&#39; to train the LSTM model.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Results&lt;/h3&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgYKaLejqLST_3Q56T6cJo55kVgNP_DhMNbDM3L9ecyjcEnV6dwzogurYmiwHrMGFAkj4jfQSNcMl4REFo7-4bidfhjdQknl9pE4v905U_BRUz-GdTP5G8i8GZrJ_r2Jkq7rQOVox072JFOn3ND1hOKHqZqzJrIqefdQPfIHJnZGOYM8PWAo8WZqIIu6Y8&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;382&quot; data-original-width=&quot;541&quot; height=&quot;226&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgYKaLejqLST_3Q56T6cJo55kVgNP_DhMNbDM3L9ecyjcEnV6dwzogurYmiwHrMGFAkj4jfQSNcMl4REFo7-4bidfhjdQknl9pE4v905U_BRUz-GdTP5G8i8GZrJ_r2Jkq7rQOVox072JFOn3ND1hOKHqZqzJrIqefdQPfIHJnZGOYM8PWAo8WZqIIu6Y8&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjMRt7OvXCXvRSYk6cjrGbQrMhHN14LRDur5NgHH-MjQr4XrgSSxKRmPCtA08x_ouWtPfWOuyoll_y1Hd5jhWBexcrH2GEGS9EMiJ4hnHsH0jyipdDpLJHCDmzTJf9vmrUl0T03ncaXu6dVEewINYo0AQUbA0BGFU6t8AM-83JavJgGvnRVZ2p23TtwbJg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;133&quot; data-original-width=&quot;526&quot; height=&quot;81&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjMRt7OvXCXvRSYk6cjrGbQrMhHN14LRDur5NgHH-MjQr4XrgSSxKRmPCtA08x_ouWtPfWOuyoll_y1Hd5jhWBexcrH2GEGS9EMiJ4hnHsH0jyipdDpLJHCDmzTJf9vmrUl0T03ncaXu6dVEewINYo0AQUbA0BGFU6t8AM-83JavJgGvnRVZ2p23TtwbJg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEh5jQD-2fCYjdmbh2Qk5C4Qo7UNsWyz-GUL15An_YNEU_N-e9MJS2YBrAZLQVfQ81vdOv7Ib-7n-PZW5s6qXB3f_zkgy7STS6e79YeyJbAED0KLs3ktoKt3bKNxWpHDUc-zzFFLFo49LFqFoKajxgGlcrwBI6BAVa3XfFg8q5h1FhnSLOurJkFazDxoqL0&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;99&quot; data-original-width=&quot;539&quot; height=&quot;59&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEh5jQD-2fCYjdmbh2Qk5C4Qo7UNsWyz-GUL15An_YNEU_N-e9MJS2YBrAZLQVfQ81vdOv7Ib-7n-PZW5s6qXB3f_zkgy7STS6e79YeyJbAED0KLs3ktoKt3bKNxWpHDUc-zzFFLFo49LFqFoKajxgGlcrwBI6BAVa3XfFg8q5h1FhnSLOurJkFazDxoqL0&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Conclusions&lt;/h3&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;In this work, we presented a real industrial application of sensor anomaly detection in the domain of energy and turbomachinery. We applied a semi-supervised deep learning technique, which can be used to perform anomaly detection in an industrial context. In particular, we applied anomaly detection to turbo-machinery units by training a virtual sensor model for a given sensor. We first selected input features through Granger causality and leveraged auto-correlation and subject matter expertise to identify the best window size for the recurrent neural network chosen (LSTM).&lt;/p&gt;&lt;p&gt;This method can be scaled and extended to almost all the sensors installed on the unit, for a complete sensor anomaly detection system.&lt;/p&gt;&lt;p&gt;Furthermore, once the model has been trained for a single sensor, we can later retrain the model using data collected over time, with a continual learning approach so that the algorithm is able to also take into account data-shift phenomena.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEi3KAY4f0kSzrIzYmrmJ6PKBLHJG8euVumnAZiZ_ODp6ougzCGXec2jI2A8OenbwZUy8xeKWVQe62ISIQ-8LaW-RsbX9w2qHbgKMCCRGK3BL1s3yVIBdAUApV4Dl39fuD53-SEOHiTJRSqZaEW6gDNT0-ogTMz3clTAYlOqU3XyRutDucjcPhgrVTVJIFg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;800&quot; data-original-width=&quot;613&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEi3KAY4f0kSzrIzYmrmJ6PKBLHJG8euVumnAZiZ_ODp6ougzCGXec2jI2A8OenbwZUy8xeKWVQe62ISIQ-8LaW-RsbX9w2qHbgKMCCRGK3BL1s3yVIBdAUApV4Dl39fuD53-SEOHiTJRSqZaEW6gDNT0-ogTMz3clTAYlOqU3XyRutDucjcPhgrVTVJIFg&quot; width=&quot;184&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Cite as:&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;@inproceedings&lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;shetty2023,
  &lt;span style=&quot;color: #996633;&quot;&gt;author&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;       &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;Sachin Shetty and Valentina Gori and Gianni Bagni and Giacomo Veneri&lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;,
  &lt;span style=&quot;color: #996633;&quot;&gt;title&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;        &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;Sensor virtualization &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;for &lt;/span&gt;anomaly detection of turbo-machinery sensors - An industrial application&lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;,
  &lt;span style=&quot;color: #996633;&quot;&gt;booktitle&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;    &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Proceedings of the 9th International conference on Time Series and Forecasting - ITISE2023&quot;&lt;/span&gt;,
  &lt;span style=&quot;color: #996633;&quot;&gt;publisher&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;    &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;MDPI&lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
  &lt;span style=&quot;color: #996633;&quot;&gt;venue&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;        &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;Gran Canaria, Spain&lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;,
  &lt;span style=&quot;color: #996633;&quot;&gt;month&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;        jul,
  &lt;span style=&quot;color: #996633;&quot;&gt;year&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;         &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;2023&lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div&gt;See also&amp;nbsp;&lt;a href=&quot;https://github.com/AILAB-bh/AILAB-bh&quot;&gt;https://github.com/AILAB-bh/AILAB-bh&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/615433929545054931/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2023/07/sensor-virtualization-for-anomaly.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/615433929545054931'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/615433929545054931'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2023/07/sensor-virtualization-for-anomaly.html' title='Sensor Virtualization for Anomaly Detection of Turbo-Machinery Sensors-An Industrial Application'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEgYKaLejqLST_3Q56T6cJo55kVgNP_DhMNbDM3L9ecyjcEnV6dwzogurYmiwHrMGFAkj4jfQSNcMl4REFo7-4bidfhjdQknl9pE4v905U_BRUz-GdTP5G8i8GZrJ_r2Jkq7rQOVox072JFOn3ND1hOKHqZqzJrIqefdQPfIHJnZGOYM8PWAo8WZqIIu6Y8=s72-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-9071556364265312703</id><published>2023-07-02T09:08:00.001+02:00</published><updated>2023-09-02T20:37:39.699+02:00</updated><title type='text'>Tensorflow Custom Functions - cheat sheet</title><content type='html'>&lt;p&gt;Building custom function with keras and tensorflow 2 is, sometime, error prone.&lt;/p&gt;&lt;p&gt;Below a collection of tensorflow numpy mapping&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6PhU-wBTQv58wMqP_vl9_NjyeSg26RkaOWd-_w7FLeAkQwpqgvxUm21nDL5YffqRPnqjKhvBHyY5XOWbSvV7C88pEEAM-G6mxWmUABCXkJq-PbrCmRMIwrB9zzMc3Q1PaQoQcr2woKz-CUu2KW30rjJeTV6o6jysJH2gJ6VVgZY2zUbUdBUywnxi7VZg/s375/custom_tf.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;375&quot; data-original-width=&quot;349&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6PhU-wBTQv58wMqP_vl9_NjyeSg26RkaOWd-_w7FLeAkQwpqgvxUm21nDL5YffqRPnqjKhvBHyY5XOWbSvV7C88pEEAM-G6mxWmUABCXkJq-PbrCmRMIwrB9zzMc3Q1PaQoQcr2woKz-CUu2KW30rjJeTV6o6jysJH2gJ6VVgZY2zUbUdBUywnxi7VZg/s320/custom_tf.PNG&quot; width=&quot;298&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Refer to :&amp;nbsp;https://www.tensorflow.org/guide/function&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Losses Good Practice from * to ***&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;


Huber Loss Simple (*)

&lt;/h3&gt;&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; text-align: left; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;my_huber_loss&lt;/span&gt;(y_true, y_pred):
    threshold &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;
    error &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; y_true &lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt; y_pred
    is_small_error &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; K&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;abs(error) &lt;span style=&quot;color: #333333;&quot;&gt;&amp;lt;=&lt;/span&gt; threshold
    small_error_loss &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; K&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;square(error) &lt;span style=&quot;color: #333333;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;
    big_error_loss &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; threshold &lt;span style=&quot;color: #333333;&quot;&gt;*&lt;/span&gt; (K&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;abs(error) &lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt; (&lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;0.5&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;*&lt;/span&gt; threshold))
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; K&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;where(is_small_error, small_error_loss, big_error_loss)
&lt;/pre&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;


Huber Loss with parameter  (**)

&lt;/h3&gt;&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;tensorflow&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;tf&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;#wrapper function which accepts the threshold parameter&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;my_huber_loss_with_threshold&lt;/span&gt;(threshold):
   &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;my_huber_loss&lt;/span&gt;(y_true, y_pred):   
  
       error &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; y_true &lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt; y_pred     
       is_small_error &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; K&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;abs(error) &lt;span style=&quot;color: #333333;&quot;&gt;&amp;lt;=&lt;/span&gt; threshold     
       small_error_loss &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; K&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;square(error) &lt;span style=&quot;color: #333333;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;     
       big_error_loss &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; threshold &lt;span style=&quot;color: #333333;&quot;&gt;*&lt;/span&gt; (K&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;abs(error) &lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt; (&lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;0.5&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;*&lt;/span&gt; threshold))
       &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; K&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;where(is_small_error, small_error_loss, big_error_loss)
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; my_huber_loss
&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;



Contrastive Loss&amp;nbsp; with parameter (**)&lt;/h3&gt;


&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;contrastive_loss_with_margin&lt;/span&gt;(margin):
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;contrastive_loss&lt;/span&gt;(y_true, y_pred):
        
        square_pred &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; K&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;square(y_pred)
        margin_square &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; K&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;square(K&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;maximum(margin &lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt; y_pred, &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;))
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; K&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;mean(y_true &lt;span style=&quot;color: #333333;&quot;&gt;*&lt;/span&gt; square_pred &lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt; (&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt; y_true) &lt;span style=&quot;color: #333333;&quot;&gt;*&lt;/span&gt; margin_square)
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; contrastive_loss
&lt;/pre&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;



Huber Loss Class  (***)&lt;/h3&gt;


&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;tensorflow.keras.losses&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; Loss

&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #bb0066; font-weight: bold;&quot;&gt;MyHuberLoss&lt;/span&gt;(Loss):
  
    &lt;span style=&quot;color: #888888;&quot;&gt;# initialize instance attributes&lt;/span&gt;
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;__init__&lt;/span&gt;(&lt;span style=&quot;color: #007020;&quot;&gt;self&lt;/span&gt;, threshold&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;):
        &lt;span style=&quot;color: #007020;&quot;&gt;super&lt;/span&gt;()&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;__init__()
        &lt;span style=&quot;color: #007020;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;threshold &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; threshold

    &lt;span style=&quot;color: #888888;&quot;&gt;# compute loss&lt;/span&gt;
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;call&lt;/span&gt;(&lt;span style=&quot;color: #007020;&quot;&gt;self&lt;/span&gt;, y_true, y_pred):
        error &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; y_true &lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt; y_pred
        is_small_error &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; K&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;abs(error) &lt;span style=&quot;color: #333333;&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span style=&quot;color: #007020;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;threshold
        small_error_loss &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; K&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;square(error) &lt;span style=&quot;color: #333333;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;
        big_error_loss &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #007020;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;threshold &lt;span style=&quot;color: #333333;&quot;&gt;*&lt;/span&gt; (K&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;abs(error) &lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt; (&lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;0.5&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #007020;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;threshold))
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; K&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;where(is_small_error, small_error_loss, big_error_loss)
&lt;/pre&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/9071556364265312703/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2023/07/tensorflow-custom-functions-cheat-sheet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/9071556364265312703'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/9071556364265312703'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2023/07/tensorflow-custom-functions-cheat-sheet.html' title='Tensorflow Custom Functions - cheat sheet'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6PhU-wBTQv58wMqP_vl9_NjyeSg26RkaOWd-_w7FLeAkQwpqgvxUm21nDL5YffqRPnqjKhvBHyY5XOWbSvV7C88pEEAM-G6mxWmUABCXkJq-PbrCmRMIwrB9zzMc3Q1PaQoQcr2woKz-CUu2KW30rjJeTV6o6jysJH2gJ6VVgZY2zUbUdBUywnxi7VZg/s72-c/custom_tf.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-6778457027420185940</id><published>2023-01-03T19:45:00.005+01:00</published><updated>2023-01-03T19:47:48.348+01:00</updated><title type='text'>Hands-On Industrial Internet of Things - 2023</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;span face=&quot;&amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif&quot; style=&quot;color: #333333; font-size: 14px; text-align: justify;&quot;&gt;Let us say&lt;/span&gt;&lt;span face=&quot;&amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif&quot; style=&quot;color: #333333; font-size: 14px; text-align: justify;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;&amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif&quot; style=&quot;color: white; font-size: x-large; text-align: justify;&quot;&gt;&lt;b style=&quot;background-color: #e69138;&quot;&gt;THANKS&lt;/b&gt;&lt;/span&gt;&lt;span face=&quot;&amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif&quot; style=&quot;color: #333333; font-size: 14px; text-align: justify;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;&amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif&quot; style=&quot;color: #333333; font-size: 14px; text-align: justify;&quot;&gt;(because we have no other way) to all readers and reviewers who, &lt;b&gt;after 4 years&lt;/b&gt;,&lt;/span&gt;&lt;span face=&quot;&amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif&quot; style=&quot;color: #333333; font-size: 14px; text-align: justify;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; margin: 1em 0px; outline: none; padding: 0px; text-align: center;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif&quot; style=&quot;font-size: x-large; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #f1c232;&quot;&gt;confirmed 4.4 stars to our book&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; margin: 1em 0px; outline: none; padding: 0px; text-align: center;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif&quot; style=&quot;font-size: x-large; text-align: justify;&quot;&gt;&quot;&lt;a href=&quot;https://jugsi.blogspot.com/2021/01/Let%20us%20say%20THANKS%20(because%20we%20have%20no%20other%20way)%20to%20all%20readers%20and%20reviewers%20who,%20after%202%20years,%20have%20confirmed%204.7%20stars%20to%20our%20book%20%22Hands-On%20Industrial%20Internet%20of%20Things%22%20with%20a%20~4%20copies%20every%20day%20(40%%20paperback%2060%%20digital)%20sold.&quot; style=&quot;color: #009eb8; display: inline; outline: none; text-decoration-line: none; transition: color 0.3s ease 0s;&quot; target=&quot;_blank&quot;&gt;Hands-On Industrial Internet of Things&lt;/a&gt;&quot;&lt;/span&gt;&lt;span face=&quot;&amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif&quot; style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; margin: 1em 0px; outline: none; padding: 0px; text-align: justify;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif&quot;&gt;with&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; margin: 1em 0px; outline: none; padding: 0px; text-align: justify;&quot;&gt;&lt;/p&gt;&lt;ul style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; list-style-image: initial; list-style-position: initial; margin: 0.5em 0px; outline: none; padding: 0px 0px 0px 2em; text-align: justify;&quot;&gt;&lt;li style=&quot;margin: 0px; outline: none; padding: 0px;&quot;&gt;&amp;nbsp;~4 copies&amp;nbsp; (50% paperback 50% digital) sold every day, &amp;gt; 5500 copies sold,&lt;/li&gt;&lt;li style=&quot;margin: 0px; outline: none; padding: 0px;&quot;&gt;34 scientific&amp;nbsp;&lt;a href=&quot;https://scholar.google.it/scholar?cites=9520540281684125237&amp;amp;as_sdt=2005&amp;amp;sciodt=0,5&amp;amp;hl=it&quot; style=&quot;color: #009eb8; display: inline; outline: none; text-decoration-line: none; transition: color 0.3s ease 0s;&quot; target=&quot;_blank&quot;&gt;citations&lt;/a&gt;,&lt;/li&gt;&lt;li style=&quot;margin: 0px; outline: none; padding: 0px;&quot;&gt;nominated by&amp;nbsp;&lt;a href=&quot;https://jugsi.blogspot.com/2019/11/hands-on-industrial-internet-of-things.html&quot; style=&quot;color: #009eb8; display: inline; outline: none; text-decoration-line: none; transition: color 0.3s ease 0s;&quot; target=&quot;_blank&quot;&gt;Book Authority in 2019&lt;/a&gt;&amp;nbsp;one of the &quot;TOP 5 best&quot; IOT book,&lt;/li&gt;&lt;li style=&quot;margin: 0px; outline: none; padding: 0px;&quot;&gt;62 reviews,&lt;/li&gt;&lt;li style=&quot;margin: 0px; outline: none; padding: 0px;&quot;&gt;available on 12 book platforms (&lt;a href=&quot;https://www.oreilly.com/library/view/hands-on-industrial-internet/9781789537222/&quot;&gt;Oreilly&lt;/a&gt;, &lt;a href=&quot;https://www.amazon.com/Hands-Industrial-Internet-Things-infrastructure/dp/1789537223&quot; target=&quot;_blank&quot;&gt;Amazon&lt;/a&gt;&amp;nbsp;, &lt;a href=&quot;https://www.ibs.it/hands-on-industrial-internet-of-libro-inglese-giacomo-veneri-antonio-capasso/e/9781789537222&quot; target=&quot;_blank&quot;&gt;IBS&lt;/a&gt;, &lt;a href=&quot;https://books.google.it/books/about/Hands_On_Industrial_Internet_of_Things.html?id=VN18DwAAQBAJ&amp;amp;redir_esc=y&quot;&gt;Google&lt;/a&gt;, .... and obviously &lt;a href=&quot;https://www.packtpub.com/product/hands-on-industrial-internet-of-things/9781789537222&quot; target=&quot;_blank&quot;&gt;Packt&lt;/a&gt;&amp;nbsp;).&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica Neue Light, HelveticaNeue-Light, Helvetica Neue, Helvetica, Arial, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span face=&quot;Helvetica Neue Light, HelveticaNeue-Light, Helvetica Neue, Helvetica, Arial, sans-serif&quot; style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://www.amazon.com/Hands-Industrial-Internet-Things-infrastructure/dp/1789537223&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;761&quot; data-original-width=&quot;1323&quot; height=&quot;184&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiVkFw9h4X8I_wQMjgTBxiOcj3BXbYjFwiOvdJ6TAjSdfXhnTMzhhTt40rgvx3x37CfnDiOw2wZsW05lT-oNpXYD8KlY2_1C5fihgwXLeSDxAISleEu_QMi-jJoJa0ruq75QM9dJLXVWgM9jQ7rjRZubKpFMbDQoxaUsvKAK74hwjo1_18ZEhZ2vOks&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/6778457027420185940/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2023/01/hands-on-industrial-internet-of-things.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/6778457027420185940'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/6778457027420185940'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2023/01/hands-on-industrial-internet-of-things.html' title='Hands-On Industrial Internet of Things - 2023'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEiVkFw9h4X8I_wQMjgTBxiOcj3BXbYjFwiOvdJ6TAjSdfXhnTMzhhTt40rgvx3x37CfnDiOw2wZsW05lT-oNpXYD8KlY2_1C5fihgwXLeSDxAISleEu_QMi-jJoJa0ruq75QM9dJLXVWgM9jQ7rjRZubKpFMbDQoxaUsvKAK74hwjo1_18ZEhZ2vOks=s72-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-1068860545992487849</id><published>2022-10-20T21:33:00.007+02:00</published><updated>2022-10-20T21:35:37.060+02:00</updated><title type='text'>Building a custom model in scikit learn</title><content type='html'>&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTAuZlh_itBa30o6g1IelVGYhmuBkAiauJQ404C5InU0enFcBoUVwoVTRHXYPm6z11xcgbuoTBVEgs0lIY8J9PIB440PNh-A16Kf3SlntlNRA3Ody388H9GVf5foFx8MBFz1yWALjZ0U3gozdUS_nwaa3niBhGSTZKwnMGA_aLU-12fw6oicsvbEPY/s1024/scikit.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;551&quot; data-original-width=&quot;1024&quot; height=&quot;172&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTAuZlh_itBa30o6g1IelVGYhmuBkAiauJQ404C5InU0enFcBoUVwoVTRHXYPm6z11xcgbuoTBVEgs0lIY8J9PIB440PNh-A16Kf3SlntlNRA3Ody388H9GVf5foFx8MBFz1yWALjZ0U3gozdUS_nwaa3niBhGSTZKwnMGA_aLU-12fw6oicsvbEPY/s320/scikit.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&amp;nbsp;&lt;p&gt;&lt;/p&gt;&lt;p&gt;Scikit learn is one of the most interesting Machine Learning package for python never seen. The current version is the &lt;a href=&quot;https://scikit-learn.org/&quot;&gt;1.1.2&amp;nbsp;&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;The base&amp;nbsp;&lt;a href=&quot;https://scikit-learn.org/stable/developers/develop.html&quot;&gt;api&lt;/a&gt; of scikit-learn is very clean and well developed:&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;Estimator&lt;/span&gt; for fitting&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;Predictor&lt;/span&gt; to predict new data&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;Transformer&lt;/span&gt; to transform data&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;Model&lt;/span&gt; just for score&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;If you want to develop your custom model you need to implement tow interfaces&lt;/div&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;pre style=&quot;line-height: 16.25px; margin-bottom: 0px; margin-top: 0px;&quot;&gt;BaseEstimator&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;&lt;pre style=&quot;line-height: 16.25px; margin-bottom: 0px; margin-top: 0px;&quot;&gt;RegressorMixin or ClassifierMixin&lt;/pre&gt;&lt;/li&gt;&lt;/ol&gt;So below is a simple classifier that look for the closest x an return the y. In this case it is valid for classification and regression:&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;


&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;class&lt;/span&gt; BaseSearcher(BaseEstimator, ClassifierMixin, RegressorMixin):&lt;/pre&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;     &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;__init__&lt;/span&gt;(&lt;span style=&quot;color: #007020;&quot;&gt;self&lt;/span&gt;, demo_param&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;demo&#39;&lt;/span&gt;):
         &lt;span style=&quot;color: #007020;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;demo_param &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; demo_param

     &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;fit&lt;/span&gt;(&lt;span style=&quot;color: #007020;&quot;&gt;self&lt;/span&gt;, X, y):

         &lt;span style=&quot;color: #888888;&quot;&gt;# Check that X and y have correct shape&lt;/span&gt;
         X, y &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; check_X_y(X, y)
         &lt;span style=&quot;color: #888888;&quot;&gt;# Store the classes seen during fit&lt;/span&gt;
         &lt;span style=&quot;color: #007020;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;classes_ &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; unique_labels(y)

         &lt;span style=&quot;color: #007020;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;X_ &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; X
         &lt;span style=&quot;color: #007020;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;y_ &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; y
         &lt;span style=&quot;color: #888888;&quot;&gt;# Return the classifier&lt;/span&gt;
         &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #007020;&quot;&gt;self&lt;/span&gt;

     &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;predict&lt;/span&gt;(&lt;span style=&quot;color: #007020;&quot;&gt;self&lt;/span&gt;, X):

         &lt;span style=&quot;color: #888888;&quot;&gt;# Check if fit has been called&lt;/span&gt;
         check_is_fitted(&lt;span style=&quot;color: #007020;&quot;&gt;self&lt;/span&gt;)

         &lt;span style=&quot;color: #888888;&quot;&gt;# Input validation&lt;/span&gt;
         X &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; check_array(X)

         closest &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; np&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;argmin(euclidean_distances(X, &lt;span style=&quot;color: #007020;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;X_), axis&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;)
         &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #007020;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;y_[closest]
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/1068860545992487849/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2022/10/building-custom-model-in-scikit-learn.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/1068860545992487849'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/1068860545992487849'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2022/10/building-custom-model-in-scikit-learn.html' title='Building a custom model in scikit learn'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTAuZlh_itBa30o6g1IelVGYhmuBkAiauJQ404C5InU0enFcBoUVwoVTRHXYPm6z11xcgbuoTBVEgs0lIY8J9PIB440PNh-A16Kf3SlntlNRA3Ody388H9GVf5foFx8MBFz1yWALjZ0U3gozdUS_nwaa3niBhGSTZKwnMGA_aLU-12fw6oicsvbEPY/s72-c/scikit.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-5267862876015881959</id><published>2022-09-29T08:42:00.005+02:00</published><updated>2022-09-29T08:45:21.220+02:00</updated><title type='text'>Document Layout Analysis with Variational Autoencoders: An Industrial Application</title><content type='html'>&lt;blockquote&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Document Layout Analysis with Variational Autoencoders: An Industrial Application&lt;/h2&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-031-16564-1_46#auth-Ali-Youssef&quot;&gt;Ali Youssef&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-031-16564-1_46#auth-Gabriele-Valvano&quot;&gt;Gabriele Valvano&lt;/a&gt; &amp;amp;&amp;nbsp;&lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-031-16564-1_46#auth-Giacomo-Veneri&quot;&gt;Giacomo Veneri&lt;/a&gt;&amp;nbsp;&lt;/p&gt;Part of the &lt;a href=&quot;https://link.springer.com/bookseries/558&quot;&gt;Lecture Notes in Computer Science&lt;/a&gt; book series (LNAI,volume 13515)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We present a novel method for Document Layout Analysis that detects documents that are not compliant with a given template. The major challenge we solve is dealing with a highly unbalanced dataset with only a few, hard-to-distinguish, non-compliant documents. Our model learns to detect inadequate documents based on localised non-compliant characteristics, including stamps, handwritten text, and misplaced signatures. Nevertheless, the model must not report documents containing other artefacts such as amendments or notes, which we deem acceptable. We address these challenges via generative modelling, using anomaly detection techniques to validate document layout. In particular, we first let the model learn the compliant document distribution. Then, we detect and report out-of-distribution samples for their automated rejection. In the paper, we investigate and compare two major approaches to anomaly detection: 1) classifying anomalies as those samples that cannot be accurately generated by the model; and 2) detecting samples whose mapping to a known proxy distribution is not possible. Both methods can be trained without annotations and obtain a classification accuracy of ∼∼90% on real-world documents, outperforming alternative supervised solutions.&lt;/blockquote&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;We used CNN-VAE and CNN for anomaly detection.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Architectures:&lt;/h3&gt;&lt;div&gt;We used 2 architectures: VAE + SSIM and VAE+Classifier&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEj9OyNQ-QU3ZqzuUuHOnqKW7VfPOdylbFNu_nDRSABepkXYkp70AfUrsBJa18xOG7IlOoZ07gI5J3BAYXwykl1IOJc2QtGmw1KfvHIDJ4moV31hMKcC_a1IFAqIBFby29IjhZLeGmkZhvNO4qG3dVwH5c_cj_19j-i39D52G9q4FHYkOvWXLWHp-590&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;570&quot; data-original-width=&quot;682&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEj9OyNQ-QU3ZqzuUuHOnqKW7VfPOdylbFNu_nDRSABepkXYkp70AfUrsBJa18xOG7IlOoZ07gI5J3BAYXwykl1IOJc2QtGmw1KfvHIDJ4moV31hMKcC_a1IFAqIBFby29IjhZLeGmkZhvNO4qG3dVwH5c_cj_19j-i39D52G9q4FHYkOvWXLWHp-590=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Results:&lt;/h3&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhJyCQQ15T53dlREhX-umi3haf6jXCDUpbR1PLRCUzmB3KkYj16E1QKf-JN-n9KG7gaYBMvbkkEH6HKc1bjDXnieOuhlA7tgKx_J990I-ehICTY3MIPd1qXy3-sdjeqPCivULc00f1pFnsFamfVgT3RdDpJN0O2yHe8MfD_MI7iw4IKX8Gn9gq5qepd&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;352&quot; data-original-width=&quot;682&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhJyCQQ15T53dlREhX-umi3haf6jXCDUpbR1PLRCUzmB3KkYj16E1QKf-JN-n9KG7gaYBMvbkkEH6HKc1bjDXnieOuhlA7tgKx_J990I-ehICTY3MIPd1qXy3-sdjeqPCivULc00f1pFnsFamfVgT3RdDpJN0O2yHe8MfD_MI7iw4IKX8Gn9gq5qepd=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/span&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&amp;nbsp;Cite as:&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;Youssef, A., Valvano, G., Veneri, G. (2022). Document Layout Analysis with Variational Autoencoders: An Industrial Application. In: Ceci, M., Flesca, S., Masciari, E., Manco, G., Raś, Z.W. (eds) Foundations of Intelligent Systems. ISMIS 2022. Lecture Notes in Computer Science(), vol 13515. Springer, Cham. https://doi.org/10.1007/978-3-031-16564-1_46&lt;/blockquote&gt;&lt;span&gt;&lt;!--more--&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/5267862876015881959/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2022/09/document-layout-analysis-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/5267862876015881959'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/5267862876015881959'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2022/09/document-layout-analysis-with.html' title='Document Layout Analysis with Variational Autoencoders: An Industrial Application'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEj9OyNQ-QU3ZqzuUuHOnqKW7VfPOdylbFNu_nDRSABepkXYkp70AfUrsBJa18xOG7IlOoZ07gI5J3BAYXwykl1IOJc2QtGmw1KfvHIDJ4moV31hMKcC_a1IFAqIBFby29IjhZLeGmkZhvNO4qG3dVwH5c_cj_19j-i39D52G9q4FHYkOvWXLWHp-590=s72-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-5423284982122179703</id><published>2022-08-08T11:27:00.008+02:00</published><updated>2022-09-30T09:45:06.701+02:00</updated><title type='text'>Presenting at WCCI2022 my paper</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;a class=&quot;subsession-title&quot; href=&quot;https://whova.com/embedded/session/Af8jrKIEl1dGU5I63QwbCWsU85vuDz9TCdADlIH2u4o%3D/2489423/?widget=primary&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Open Sans&amp;quot;; font-size: 16px; font-style: unset; font-weight: 600; text-decoration-line: none;&quot;&gt;Continual Learning for anomaly detection on turbomachinery prototypes - A real application&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;subsession-time&quot; style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #333333; display: flex; font-family: &amp;quot;Open Sans&amp;quot;; font-size: 14px; font-style: unset; margin: 0px; outline: 0px; padding: 0px;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;text-align: center;&quot;&gt;Valentina Gori, Giacomo Veneri, Valeria Ballarini&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;text-align: start;&quot;&gt;TPS Artificial Intelligence - Baker Hughes&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;We apply a Recurrent Neural Network (RNN), Kullback-Leibler (KL) divergence and a continual learning approach to check the status of several hundreds of sensors during turbo-machinery prototype testing. Turbo-machinery prototypes can be instrumented with up to thousands of sensors. Therefore, checking the health of each sensor is a time consuming activity. Prototypes are also tested on several different and a-priori unknown operating conditions, so we cannot apply a purely supervised model to detect potential anomalies of sensors and, moreover, we have to take into account a covariate shift because measurements drift continuously day by day. We continuously train a RNN (daily) to build a virtual sensor from other sensors and we compare the predicted signal vs the real signal to raise (in case) an anomaly. Furthermore, KL is used to estimate the overlap between the input distributions available at training time and the ones seen at test time, and thus the confidence level of the prediction. Finally we implement an end-to-end system to automatically train and evaluate the models. The paper presents the system and reports the application to a test campaign of about five hundred sensors.&lt;br /&gt;Publishes at CEC IEEE 2022&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Speaker: &lt;a href=&quot;https://whova.com/embedded/speaker/Af8jrKIEl1dGU5I63QwbCWsU85vuDz9TCdADlIH2u4o%3D/24063078/&quot;&gt;Giacomo Veneri&lt;/a&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Challenge&lt;/h4&gt;&lt;p&gt;&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;In the industry specific domain we apply anomaly detection to check the health of the sensors installed on our prototypes of turbo-machines.&lt;/li&gt;&lt;li&gt;A supervised approach is not feasible because anomalous signals can show disparate aspects: expected signals for well-behaved sensors are not available since each prototype is unique and usually tested just once.&lt;/li&gt;&lt;li&gt;Covariate shift issues must be managed, because operating conditions may change severely during test campaign.&lt;/li&gt;&lt;li&gt;Up to few thousand sensors need to be checked.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;The process&lt;/h3&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjKa05aSwurJwfwbFWludzAm2ZeP_wWtbHYCGu_WJr-JvflX4rtQiHNLbWsDbFnRO5COkC9vhXbKTZQHkc9_oFpykaU0xZJ8I1K98mS7cuodcSg7yUdHGI0uZWck3esdyT6R7piswBoNxnxvTh0LCk4Fq6ZLcBmirMuliPS2YfzsouyYcFyrtV6rEfq&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;1096&quot; data-original-width=&quot;1884&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjKa05aSwurJwfwbFWludzAm2ZeP_wWtbHYCGu_WJr-JvflX4rtQiHNLbWsDbFnRO5COkC9vhXbKTZQHkc9_oFpykaU0xZJ8I1K98mS7cuodcSg7yUdHGI0uZWck3esdyT6R7piswBoNxnxvTh0LCk4Fq6ZLcBmirMuliPS2YfzsouyYcFyrtV6rEfq=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Main Contribution&lt;/h4&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEizFULXuNqniEd5Gie4HxY48-NjcU3-KN046k8e-2RsFLeIKNbQZGT6NgRuPm72aJJRxGZ2XeZqaKqVTgl_szNKSYKzvNvMmA7sWkSJI1dMxFXj17-xXW8zIa2Co_7R4unBy2eDr9r0XkTItpVYbG2ZoZVbU5_kdP2dRZ7g9TjiWi5gFjTSlr_Bnoq2&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;1096&quot; data-original-width=&quot;1928&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEizFULXuNqniEd5Gie4HxY48-NjcU3-KN046k8e-2RsFLeIKNbQZGT6NgRuPm72aJJRxGZ2XeZqaKqVTgl_szNKSYKzvNvMmA7sWkSJI1dMxFXj17-xXW8zIa2Co_7R4unBy2eDr9r0XkTItpVYbG2ZoZVbU5_kdP2dRZ7g9TjiWi5gFjTSlr_Bnoq2=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Paper explained:&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.blogger.com/video.g?token=AD6v5dybe8bjo00WNInRxSDm3zu8_5dV7zy6pAr7-M0Br28Ns5XQ2AT3Z-ZGmWY_ENhCjBADYEdF_NRC8ema3Bb01g&#39; class=&#39;b-hbp-video b-uploaded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/5423284982122179703/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2022/08/presenting-at-wcci2022-my-paper.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/5423284982122179703'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/5423284982122179703'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2022/08/presenting-at-wcci2022-my-paper.html' title='Presenting at WCCI2022 my paper'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEjKa05aSwurJwfwbFWludzAm2ZeP_wWtbHYCGu_WJr-JvflX4rtQiHNLbWsDbFnRO5COkC9vhXbKTZQHkc9_oFpykaU0xZJ8I1K98mS7cuodcSg7yUdHGI0uZWck3esdyT6R7piswBoNxnxvTh0LCk4Fq6ZLcBmirMuliPS2YfzsouyYcFyrtV6rEfq=s72-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-4359484170529943638</id><published>2022-08-08T11:16:00.003+02:00</published><updated>2022-08-08T11:16:56.650+02:00</updated><title type='text'>Deep Surrogate of Modular Multi Pump using Active Learning</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;h1 style=&quot;text-align: left;&quot;&gt;Review of:&amp;nbsp;Deep Surrogate of Modular Multi Pump using Active Learning&lt;/h1&gt;&lt;a href=&quot;https://arxiv.org/search/cs?searchtype=author&amp;amp;query=Murugesan%2C+M&quot;&gt;Malathi Murugesan&lt;/a&gt;, &lt;a href=&quot;https://arxiv.org/search/cs?searchtype=author&amp;amp;query=Goyal%2C+K&quot;&gt;Kanika Goyal&lt;/a&gt;, &lt;a href=&quot;https://arxiv.org/search/cs?searchtype=author&amp;amp;query=Barriere%2C+L&quot;&gt;Laure Barriere&lt;/a&gt;, &lt;a href=&quot;https://arxiv.org/search/cs?searchtype=author&amp;amp;query=Pasquotti%2C+M&quot;&gt;Maura Pasquotti&lt;/a&gt;, &lt;a href=&quot;https://arxiv.org/search/cs?searchtype=author&amp;amp;query=Veneri%2C+G&quot;&gt;Giacomo Veneri&lt;/a&gt;, &lt;a href=&quot;https://arxiv.org/search/cs?searchtype=author&amp;amp;query=De+Magistris%2C+G&quot;&gt;Giovanni De Magistris&lt;/a&gt;&lt;br /&gt;Due to the high cost and reliability of sensors, the designers of a pump reduce the needed number of sensors for the estimation of the feasible operating point as much as possible. The major challenge to obtain a good estimation is the low amount of data available. Using this amount of data, the performance of the estimation method is not enough to satisfy the client requests. To solve this problem of scarcity of data, getting high quality data is important to obtain a good estimation. Based on these considerations, we develop an active learning framework for estimating the operating point of a Modular Multi Pump used in energy field. In particular we focus on the estimation of the surge distance. We apply Active learning to estimate the surge distance with minimal dataset. Results report that active learning is a valuable technique also for real application.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Published at&amp;nbsp;&lt;a href=&quot;https://realworldml.github.io/&quot; style=&quot;background-color: white; box-sizing: border-box; color: #7a8288; display: inline !important; font-family: -apple-system, &amp;quot;.SFNSText-Regular&amp;quot;, &amp;quot;San Francisco&amp;quot;, Roboto, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Arial, sans-serif; font-size: 18px; font-weight: 700; margin: 0px 1rem 0px 0px; orphans: 3; padding: 0.5rem 0px; position: relative; text-decoration-line: none; transition: all 0.2s ease-in-out 0s; white-space: nowrap; widows: 3;&quot;&gt;ReALML @ ICML2022&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;https://realworldml.github.io/accepted/&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This paper demonstrates that using active learning we can reduce the amount of data to learn a surrogate model.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Attached the poster&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEZMpeuF7jhAtl0Jn7bBCbr8pOHFP2S30hCj2RYundk_NUaOwaHtmr8fGAtm6u8R90B2RsOZW40dPS7V2mR0rBTkAlcxP2BwsUCweBJr0Sky4nvmR-SFzDRXVhOrFb5UH_IPseD6Qs1D0pkKG0Xax6YQBP8A_vfg9h0bSZaEAmWNnwlCuFLjctDjUH/s2592/ICML%20Poster_Baker%20Hughes_11-07-2022.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;2592&quot; data-original-width=&quot;1728&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEZMpeuF7jhAtl0Jn7bBCbr8pOHFP2S30hCj2RYundk_NUaOwaHtmr8fGAtm6u8R90B2RsOZW40dPS7V2mR0rBTkAlcxP2BwsUCweBJr0Sky4nvmR-SFzDRXVhOrFb5UH_IPseD6Qs1D0pkKG0Xax6YQBP8A_vfg9h0bSZaEAmWNnwlCuFLjctDjUH/s16000/ICML%20Poster_Baker%20Hughes_11-07-2022.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/4359484170529943638/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2022/08/deep-surrogate-of-modular-multi-pump.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/4359484170529943638'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/4359484170529943638'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2022/08/deep-surrogate-of-modular-multi-pump.html' title='Deep Surrogate of Modular Multi Pump using Active Learning'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEZMpeuF7jhAtl0Jn7bBCbr8pOHFP2S30hCj2RYundk_NUaOwaHtmr8fGAtm6u8R90B2RsOZW40dPS7V2mR0rBTkAlcxP2BwsUCweBJr0Sky4nvmR-SFzDRXVhOrFb5UH_IPseD6Qs1D0pkKG0Xax6YQBP8A_vfg9h0bSZaEAmWNnwlCuFLjctDjUH/s72-c/ICML%20Poster_Baker%20Hughes_11-07-2022.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-537275087633683072</id><published>2022-08-08T11:10:00.000+02:00</published><updated>2022-08-08T11:10:07.175+02:00</updated><title type='text'>Atlassian Jira vs Broadcom Rally</title><content type='html'>&lt;p&gt;&lt;span style=&quot;background-color: white; color: #151521; font-family: &amp;quot;Source Sans Pro&amp;quot;, &amp;quot;Trebuchet MS&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;background-color: white; color: #151521; font-family: &amp;quot;Source Sans Pro&amp;quot;, &amp;quot;Trebuchet MS&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 16px;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhGUK1kWN9Fp_tLr8yEQw9nCJWdXNTrzyskNxSEOx7URUAA5bB3ruFeognTrcU6SoKBfcUu8PuVckEGpLhMFM5v_oPqN5UuJ1DagNsgmd3XzpbaX75C5n73Q29LZy9iEaH6UdwEuZxH6B6a-plYq1SgGhoD17GCnXpidYCGp-5gsPcaFOdRhp0KAQix&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;760&quot; data-original-width=&quot;924&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhGUK1kWN9Fp_tLr8yEQw9nCJWdXNTrzyskNxSEOx7URUAA5bB3ruFeognTrcU6SoKBfcUu8PuVckEGpLhMFM5v_oPqN5UuJ1DagNsgmd3XzpbaX75C5n73Q29LZy9iEaH6UdwEuZxH6B6a-plYq1SgGhoD17GCnXpidYCGp-5gsPcaFOdRhp0KAQix&quot; width=&quot;292&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;Comparing Jira vs Rally is very difficult because both  offer strong project management features. Jira allows high customisable query language, rather than Rally leverages on (limited) plugin.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Rally leads the agile team, while Jira leaves them free to define their own process; for this reason, Jira requires high customisation but Rally is more limited for Kanban.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Conclusion&lt;/h4&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Product Owner and SCRUM team loves Rally, but developers prefer Jira&lt;/li&gt;&lt;li&gt;Jira is highly customizable, it can be used in different industries with different needs.&lt;/li&gt;&lt;li&gt;Rally Software is good for sprint management.&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;...and I prefer Jira ✌&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/537275087633683072/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2022/08/atlassian-jira-vs-broadcom-rally.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/537275087633683072'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/537275087633683072'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2022/08/atlassian-jira-vs-broadcom-rally.html' title='Atlassian Jira vs Broadcom Rally'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEhGUK1kWN9Fp_tLr8yEQw9nCJWdXNTrzyskNxSEOx7URUAA5bB3ruFeognTrcU6SoKBfcUu8PuVckEGpLhMFM5v_oPqN5UuJ1DagNsgmd3XzpbaX75C5n73Q29LZy9iEaH6UdwEuZxH6B6a-plYq1SgGhoD17GCnXpidYCGp-5gsPcaFOdRhp0KAQix=s72-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-6740773592538754232</id><published>2022-02-21T12:37:00.003+01:00</published><updated>2022-02-21T12:37:19.507+01:00</updated><title type='text'>MLOPS vs DEVOPS</title><content type='html'>&lt;h3 style=&quot;text-align: left;&quot;&gt;&amp;nbsp;DEV OPS&lt;/h3&gt;&lt;p&gt;&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Continuos Integration&lt;/li&gt;&lt;li&gt;Continuos&amp;nbsp;Delivery&lt;/li&gt;&lt;/ol&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;ML OPS&lt;/h3&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Continuous Training&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhIkw7NaRnmD_5dJEcBWeDlpsvzK6htdfevv-wVk5_cCNgbm0uc7HveacCAEwXRMa05DS9LPrkhCIFU0Lv3MC_uMLIwPlI_3UZ5LdgQKY9J1NifwwvbfeCKYxXi19orzXwNgeaZmB8tzqUiry9WA9Tiw-hfLv0XzGYi2cPjyQ6aCpfR-UtPGAQN5x0d&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;863&quot; data-original-width=&quot;1200&quot; height=&quot;230&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhIkw7NaRnmD_5dJEcBWeDlpsvzK6htdfevv-wVk5_cCNgbm0uc7HveacCAEwXRMa05DS9LPrkhCIFU0Lv3MC_uMLIwPlI_3UZ5LdgQKY9J1NifwwvbfeCKYxXi19orzXwNgeaZmB8tzqUiry9WA9Tiw-hfLv0XzGYi2cPjyQ6aCpfR-UtPGAQN5x0d&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/6740773592538754232/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2022/02/mlops-vs-devops.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/6740773592538754232'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/6740773592538754232'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2022/02/mlops-vs-devops.html' title='MLOPS vs DEVOPS'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEhIkw7NaRnmD_5dJEcBWeDlpsvzK6htdfevv-wVk5_cCNgbm0uc7HveacCAEwXRMa05DS9LPrkhCIFU0Lv3MC_uMLIwPlI_3UZ5LdgQKY9J1NifwwvbfeCKYxXi19orzXwNgeaZmB8tzqUiry9WA9Tiw-hfLv0XzGYi2cPjyQ6aCpfR-UtPGAQN5x0d=s72-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-5629686717694372045</id><published>2022-02-12T19:25:00.008+01:00</published><updated>2022-02-12T19:27:53.689+01:00</updated><title type='text'>Hands-On Industrial Internet of Things - Thanks</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;span face=&quot;&amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif&quot; style=&quot;background-color: white; color: #333333; font-size: 14px; text-align: justify;&quot;&gt;Let us say&lt;/span&gt;&lt;span face=&quot;&amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif&quot; style=&quot;background-color: white; color: #333333; font-size: 14px; text-align: justify;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;&amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif&quot; style=&quot;color: white; font-size: x-large; text-align: justify;&quot;&gt;&lt;b style=&quot;background-color: #e69138;&quot;&gt;THANKS&lt;/b&gt;&lt;/span&gt;&lt;span face=&quot;&amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif&quot; style=&quot;background-color: white; color: #333333; font-size: 14px; text-align: justify;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;&amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif&quot; style=&quot;background-color: white; color: #333333; font-size: 14px; text-align: justify;&quot;&gt;(because we have no other way) to all readers and reviewers who, after 3 years,&lt;/span&gt;&lt;span face=&quot;&amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif&quot; style=&quot;background-color: white; color: #333333; font-size: 14px; text-align: justify;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif&quot; style=&quot;color: #333333; font-size: x-large; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #f1c232;&quot;&gt;confirmed 4.5 stars to our book&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif&quot; style=&quot;color: #333333; font-size: x-large; text-align: justify;&quot;&gt;&quot;&lt;a href=&quot;https://jugsi.blogspot.com/2021/01/Let%20us%20say%20THANKS%20(because%20we%20have%20no%20other%20way)%20to%20all%20readers%20and%20reviewers%20who,%20after%202%20years,%20have%20confirmed%204.7%20stars%20to%20our%20book%20%22Hands-On%20Industrial%20Internet%20of%20Things%22%20with%20a%20~4%20copies%20every%20day%20(40%%20paperback%2060%%20digital)%20sold.&quot; style=&quot;color: #009eb8; display: inline; outline: none; text-decoration-line: none; transition: color 0.3s ease 0s;&quot; target=&quot;_blank&quot;&gt;Hands-On Industrial Internet of Things&lt;/a&gt;&quot;&lt;/span&gt;&lt;span face=&quot;&amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif&quot; style=&quot;background-color: white; color: #333333; font-size: 14px; text-align: justify;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span face=&quot;&amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif&quot; style=&quot;background-color: white; color: #333333; font-size: 14px; text-align: justify;&quot;&gt;with&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; margin: 1em 0px; outline: none; padding: 0px; text-align: justify;&quot;&gt;&lt;/p&gt;&lt;ul style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Helvetica Neue Light&amp;quot;, HelveticaNeue-Light, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; list-style-image: initial; list-style-position: initial; margin: 0.5em 0px; outline: none; padding: 0px 0px 0px 2em;&quot;&gt;&lt;li style=&quot;margin: 0px; outline: none; padding: 0px;&quot;&gt;&amp;nbsp;~4 copies&amp;nbsp; (40% paperback 60% digital) sold every day,&amp;nbsp;&lt;/li&gt;&lt;li style=&quot;margin: 0px; outline: none; padding: 0px;&quot;&gt;24&amp;nbsp;&lt;a href=&quot;https://scholar.google.it/scholar?cites=9520540281684125237&amp;amp;as_sdt=2005&amp;amp;sciodt=0,5&amp;amp;hl=it&quot; style=&quot;color: #009eb8; display: inline; outline: none; text-decoration-line: none; transition: color 0.3s ease 0s;&quot; target=&quot;_blank&quot;&gt;citations&lt;/a&gt;&amp;nbsp;,&lt;/li&gt;&lt;li style=&quot;margin: 0px; outline: none; padding: 0px;&quot;&gt;nominated by&amp;nbsp;&lt;a href=&quot;https://jugsi.blogspot.com/2019/11/hands-on-industrial-internet-of-things.html&quot; style=&quot;color: #009eb8; display: inline; outline: none; text-decoration-line: none; transition: color 0.3s ease 0s;&quot; target=&quot;_blank&quot;&gt;Book Authority in 2019&lt;/a&gt;&amp;nbsp;one of the &quot;TOP 5 best&quot; IOT book&lt;/li&gt;&lt;li style=&quot;margin: 0px; outline: none; padding: 0px;&quot;&gt;44 reviews&lt;/li&gt;&lt;li style=&quot;margin: 0px; outline: none; padding: 0px;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjmMV4rrMcAF2NXFI5o9uGcjnwQXz_yC6wJ86LBZKp08hnVggTGJq9BN_WchQCOjwvn4FF8kaX6IPkwOii5HiHO5QflY23zljiNFbmNCYm9nM6_rVF3FXTM7d3x8SYOFZ1-8yxhaUfzqXPu_xKtLMKGljMG3CrviXUQyjDuwbGKrvxHmCmgPdp2eZ-3=s2090&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1178&quot; data-original-width=&quot;2090&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjmMV4rrMcAF2NXFI5o9uGcjnwQXz_yC6wJ86LBZKp08hnVggTGJq9BN_WchQCOjwvn4FF8kaX6IPkwOii5HiHO5QflY23zljiNFbmNCYm9nM6_rVF3FXTM7d3x8SYOFZ1-8yxhaUfzqXPu_xKtLMKGljMG3CrviXUQyjDuwbGKrvxHmCmgPdp2eZ-3=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/5629686717694372045/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2022/02/hands-on-industrial-internet-of-things.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/5629686717694372045'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/5629686717694372045'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2022/02/hands-on-industrial-internet-of-things.html' title='Hands-On Industrial Internet of Things - Thanks'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEjmMV4rrMcAF2NXFI5o9uGcjnwQXz_yC6wJ86LBZKp08hnVggTGJq9BN_WchQCOjwvn4FF8kaX6IPkwOii5HiHO5QflY23zljiNFbmNCYm9nM6_rVF3FXTM7d3x8SYOFZ1-8yxhaUfzqXPu_xKtLMKGljMG3CrviXUQyjDuwbGKrvxHmCmgPdp2eZ-3=s72-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-3111688946055318292</id><published>2021-12-06T20:28:00.001+01:00</published><updated>2021-12-06T20:28:26.034+01:00</updated><title type='text'> DANNTe: a case study of a turbo-machinery sensor virtualization under domain shift -</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://neurips.cc/Conferences/2021/ScheduleMultitrack?event=21859&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot; target=&quot;_blank&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;434&quot; data-original-width=&quot;1070&quot; height=&quot;130&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisECO5otIkNvEuHKlvQtihkLL1KUyv81ZxZU3d4K7rZkSecme5n5Ca73GQuOgg27jW81iVISigGgL_0YvgvZECRtL7Sq-cjEq3lev-92GyCmhWiVKFjAc7EJGaA8T_ByJxj4a_4JRCbdM/&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; text-align: start;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; text-align: start;&quot;&gt;Luca Strazzera, Valentina Gori, Giacomo Veneri&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; text-align: start;&quot;&gt;We propose an adversarial learning method to tackle a Domain Adaptation time series regression task (DANNTe). The task concerns the virtualization of a physical sensor of a turbine with aim to build a reliable virtual sensor working on operating conditions not considered during the training phase. Our approach is directly inspired by the need to have a domain-invariant representation of the features to correct the covariate shift present in the data. The learner has access to both a labeled source data and unlabeled target data (Unsupervised DA) and is trained on both, exploiting the minmax game between a task regressor neural network and a domain classifier neural network. Both models share the same feature representation in terms of a feature extractor neural network. This work is based on the work of Ganin et al.; we present an extension suitable to be applied to time series data. The results report a significant improvement in regression performance, compared to the base model trained on the source domain only.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqquAqUm38q8dlhfVIhRVwwF0G4IkWZFSxCWdW6rfUOsAXPV6TxIn6IX4D6_7PDLK6kNJqk4EdUlKkeYi3VvduNMDklgZE0zEbkLw6yc6iwjKRs3PxmNirpRwxkRbk1AJj2bJ0dat1J6I/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;578&quot; data-original-width=&quot;1060&quot; height=&quot;174&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqquAqUm38q8dlhfVIhRVwwF0G4IkWZFSxCWdW6rfUOsAXPV6TxIn6IX4D6_7PDLK6kNJqk4EdUlKkeYi3VvduNMDklgZE0zEbkLw6yc6iwjKRs3PxmNirpRwxkRbk1AJj2bJ0dat1J6I/&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/3111688946055318292/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2021/12/dannte-case-study-of-turbo-machinery.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/3111688946055318292'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/3111688946055318292'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2021/12/dannte-case-study-of-turbo-machinery.html' title=' DANNTe: a case study of a turbo-machinery sensor virtualization under domain shift -'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisECO5otIkNvEuHKlvQtihkLL1KUyv81ZxZU3d4K7rZkSecme5n5Ca73GQuOgg27jW81iVISigGgL_0YvgvZECRtL7Sq-cjEq3lev-92GyCmhWiVKFjAc7EJGaA8T_ByJxj4a_4JRCbdM/s72-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-926034781279812813</id><published>2021-10-23T10:34:00.002+02:00</published><updated>2021-10-24T10:25:16.449+02:00</updated><title type='text'>Tensorflow Similarity applied to NLP</title><content type='html'>&lt;a href=&quot;https://blog.tensorflow.org/2021/09/introducing-tensorflow-similarity.html&quot;&gt;Tensorflow Similarity&lt;/a&gt; offers state-of-the-art algorithms for metric learning and all the necessary components to train and serve similarity-based models.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;https://github.com/tensorflow/similarity&quot;&gt;Recent version&lt;/a&gt; introduced new losses:&lt;/div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Triplet Loss&lt;/li&gt;&lt;li&gt;PN Loss&lt;/li&gt;&lt;li&gt;Multi Sim Loss&lt;/li&gt;&lt;li&gt;Circle Loss&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The basic idea of Tensorflow Similarity i to provide a framework to train similarity model. On internet you can find a lot of example based on MNIST (one more MNIST example 🙈); in this paper we would like to apply TF Similarity to a NLP model based on a custom dataset.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;DataSet&lt;/h2&gt;&lt;div&gt;We can use IMDB dataset (yes another sentiment analysis dataset 🙈). You can download for free from there:&amp;nbsp;https://www.kaggle.com/lakshmi25npathi/imdb-dataset-of-50k-movie-reviews&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The IMDB Dataset is a two classes text dataset.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxUlgT62MhDFPsKL6FhTODiV3rS0V3QH8BPZAezZMK07oB8L7uiqLHktlDoMnY_nIAzRVTDreCgdCAL1i7r1Ltswb-oMBDdWmQW_L3a59AMOZ6DmDDBw1uSPXKvqYijgfUWR5XI6qT1aQ/&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;636&quot; data-original-width=&quot;716&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxUlgT62MhDFPsKL6FhTODiV3rS0V3QH8BPZAezZMK07oB8L7uiqLHktlDoMnY_nIAzRVTDreCgdCAL1i7r1Ltswb-oMBDdWmQW_L3a59AMOZ6DmDDBw1uSPXKvqYijgfUWR5XI6qT1aQ/&quot; width=&quot;270&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;IMDB Example&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;Let&#39;s import the dataset and encode the label to a binary 0,1 vector.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;


&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;color: #888888;&quot;&gt;# loading from file&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;tqdm&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; tqdm
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;pandas&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;pd&lt;/span&gt;

&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;numpy&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;np&lt;/span&gt;

PATH_DATA &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;IMDB Dataset.csv&#39;&lt;/span&gt;

df &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; pd&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;read_csv(PATH_DATA)

target_column&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;sentiment&#39;&lt;/span&gt;
text_column&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;review&#39;&lt;/span&gt;

&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;sklearn&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; preprocessing
le &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; preprocessing&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;LabelEncoder()

X &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; df[text_column]&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;astype(&lt;span style=&quot;color: #007020;&quot;&gt;str&lt;/span&gt;)&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;values
y &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; le&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;fit_transform(df[target_column]&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;astype(&lt;span style=&quot;color: #007020;&quot;&gt;str&lt;/span&gt;)&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;values)
&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We are working with text and we need to build a layer to vectorize the text.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;tensorflow&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;tf&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;tensorflow.keras.layers&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; TextVectorization
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;string&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;re&lt;/span&gt;

&lt;span style=&quot;color: #888888;&quot;&gt;# Having looked at our data above, we see that the raw text contains HTML break&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;# tags of the form &#39;&amp;lt;br /&amp;gt;&#39;. These tags will not be removed by the default&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;# standardizer (which doesn&#39;t strip HTML). Because of this, we will need to&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;# create a custom standardization function.&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;custom_standardization&lt;/span&gt;(input_data):
    lowercase &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; tf&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;strings&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;lower(input_data)
    stripped_html &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; tf&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;strings&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;regex_replace(lowercase, &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;&amp;lt;br /&amp;gt;&quot;&lt;/span&gt;, &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot; &quot;&lt;/span&gt;)
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; tf&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;strings&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;regex_replace(
        stripped_html, &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;[&lt;/span&gt;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt;%s&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;]&quot;&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;%&lt;/span&gt; re&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;escape(string&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;punctuation), &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;&quot;&lt;/span&gt;
    )


&lt;span style=&quot;color: #888888;&quot;&gt;# Now that we have our custom standardization, we can instantiate our text&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;# vectorization layer. We are using this layer to normalize, split, and map&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;# strings to integers, so we set our &#39;output_mode&#39; to &#39;int&#39;.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;# Note that we&#39;re using the default split function,&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;# and the custom standardization defined above.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;# We also set an explicit maximum sequence length, since the CNNs later in our&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;# model won&#39;t support ragged sequences.&lt;/span&gt;
vectorize_layer &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; TextVectorization(
    standardize&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;custom_standardization,
    max_tokens&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;max_features,
    output_mode&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;int&quot;&lt;/span&gt;,
    output_sequence_length&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;sequence_length,
)

&lt;span style=&quot;color: #888888;&quot;&gt;# Now that the vocab layer has been created, call `adapt` on a text-only&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;# dataset to create the vocabulary. You don&#39;t have to batch, but for very large&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;# datasets this means you&#39;re not keeping spare copies of the dataset in memory.&lt;/span&gt;

vectorize_layer&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;adapt(X)
&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;The inevitable split and train&lt;br /&gt;&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;sklearn.model_selection&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; train_test_split
X_train, X_test, y_train, y_test &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; train_test_split(X, y, test_size&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;0.2&lt;/span&gt;, random_state&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;42&lt;/span&gt;, stratify &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; y)
&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Now we can import our dataset on&amp;nbsp;&lt;!--HTML generated using hilite.me--&gt;MultiShotMemorySampler. MultiShotMemorySampler is a class provided by tensorflow similarity:&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;tensorflow_similarity.samplers&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; MultiShotMemorySampler  &lt;span style=&quot;color: #888888;&quot;&gt;# sample data &lt;/span&gt;

CLASSES &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; np&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;unique(y)
NUM_CLASSES &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; CLASSES&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;shape[&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;]
CLASS_PER_BATCH &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; NUM_CLASSES
EXAMPLE_PER_CLASS &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt; 
STEPS_PER_EPOCH &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1000&lt;/span&gt; 

sampler_train &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; MultiShotMemorySampler(X_train, y_train, 
                                 classes_per_batch&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;CLASS_PER_BATCH, 
                                 examples_per_class_per_batch&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;EXAMPLE_PER_CLASS,
                                 &lt;span style=&quot;color: #888888;&quot;&gt;#class_list=CLASSES, # Only use the first 6 classes for training.&lt;/span&gt;
                                 steps_per_epoch&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;STEPS_PER_EPOCH)

sampler_test &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; MultiShotMemorySampler(X_test, y_test, 
                                 classes_per_batch&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;CLASS_PER_BATCH, 
                                 examples_per_class_per_batch&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;EXAMPLE_PER_CLASS,
                                 &lt;span style=&quot;color: #888888;&quot;&gt;#class_list=CLASSES[:NUM_CLASSES], # Only use the first 6 classes for training.&lt;/span&gt;
                                 steps_per_epoch&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;STEPS_PER_EPOCH)
&lt;/pre&gt;&lt;/div&gt;



&lt;h2 style=&quot;text-align: left;&quot;&gt;Building Model&lt;/h2&gt;&lt;div&gt;This is a very simple model based on Conv1D; you can customize your architecture. Please note it uses our vectorize layer defined before.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;tensorflow.keras&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; layers
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;tensorflow_similarity.layers&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; MetricEmbedding
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;tensorflow_similarity.models&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; SimilarityModel



text_input &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; tf&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;keras&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;Input(shape&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;(&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;,), dtype&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;tf&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;string, name&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;text&#39;&lt;/span&gt;)
x &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; vectorize_layer(text_input)

&lt;span style=&quot;color: #888888;&quot;&gt;# Next, we add a layer to map those vocab indices into a space of dimensionality&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;# &#39;embedding_dim&#39;.&lt;/span&gt;
x &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; layers&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;Embedding(max_features, embedding_dim,mask_zero&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #007020;&quot;&gt;True&lt;/span&gt;)(x)
&lt;span style=&quot;color: #888888;&quot;&gt;#x = layers.Dropout(0.5)(x)&lt;/span&gt;

&lt;span style=&quot;color: #888888;&quot;&gt;# Conv1D + global max pooling&lt;/span&gt;
x &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; layers&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;Conv1D(search_embedding_dim, &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;7&lt;/span&gt;, padding&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;valid&quot;&lt;/span&gt;, activation&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;relu&quot;&lt;/span&gt;, strides&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;3&lt;/span&gt;)(x)
x &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; layers&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;Conv1D(search_embedding_dim, &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;7&lt;/span&gt;, padding&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;valid&quot;&lt;/span&gt;, activation&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;relu&quot;&lt;/span&gt;, strides&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;3&lt;/span&gt;)(x)
x &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; layers&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;GlobalMaxPooling1D()(x)

&lt;span style=&quot;color: #888888;&quot;&gt;# We add a vanilla hidden layer:&lt;/span&gt;
x &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; layers&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;Dense(search_embedding_dim, activation&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;relu&quot;&lt;/span&gt;)(x)
&lt;span style=&quot;color: #888888;&quot;&gt;#x = layers.Dropout(0.5)(x)&lt;/span&gt;
x &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; layers&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;Flatten()(x)
x &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; layers&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;Dense(search_embedding_dim, activation&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;relu&#39;&lt;/span&gt;)(x)
outputs &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; MetricEmbedding(search_embedding_dim)(x)

&lt;span style=&quot;color: #888888;&quot;&gt;# Build a specialized Similarity model&lt;/span&gt;
model &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; SimilarityModel(text_input, outputs)
&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Train me please:&lt;br /&gt;&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;color: #888888;&quot;&gt;# Specialized metric loss&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;tensorflow_similarity.losses&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; MultiSimilarityLoss, CircleLoss, PNLoss
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;tensorflow.keras.callbacks&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; ReduceLROnPlateau, EarlyStopping

reduce_lr &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; ReduceLROnPlateau(monitor&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;loss&#39;&lt;/span&gt;, factor&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;0.2&lt;/span&gt;,
                              patience&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;5&lt;/span&gt;, min_lr&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;0.0001&lt;/span&gt;)

early_stopping &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; EarlyStopping(
    monitor&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;loss&quot;&lt;/span&gt;,
    min_delta&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;,
    patience&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;20&lt;/span&gt;,
    verbose&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;,
    mode&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;auto&quot;&lt;/span&gt;,
    restore_best_weights&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #007020;&quot;&gt;True&lt;/span&gt;,
)

&lt;span style=&quot;color: #888888;&quot;&gt;# Train Similarity model using PN loss&lt;/span&gt;
model&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;compile(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&#39;adam&#39;&lt;/span&gt;, loss&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;MultiSimilarityLoss())&lt;br /&gt;model&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;fit(sampler_train, epochs&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;500&lt;/span&gt;, callbacks&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;[reduce_lr, early_stopping])
&lt;/pre&gt;&lt;/div&gt;




&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;Evaluating Model&lt;/h2&gt;

We should reindex the train set&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;color: #888888;&quot;&gt;# Index embedded   to make them searchable&lt;/span&gt;
sx, sy &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; sampler_train&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;get_slice(&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;,X_train&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;shape[&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;])
model&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;index(x&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;sx, y&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;sy, data&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;sx)
&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Ok let me evaluate our model. This model is a similarity model but we would like to calculate the accuracy.&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We defined a simple method to search for similar document on the training set and we assigned&amp;nbsp; the most frequent class to the document. It is just for test!&amp;nbsp;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;tqdm&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; tqdm
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;sklearn.metrics&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; confusion_matrix
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;sklearn.metrics&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; balanced_accuracy_score

&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;_eval_accuracy&lt;/span&gt;(model, sampler, max_n&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;10&lt;/span&gt;):
    &lt;span style=&quot;color: #dd4422;&quot;&gt;&#39;&#39;&#39; look for similar and keep the label of the best max_n&#39;&#39;&#39;&lt;/span&gt;

    y_true &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; []
    y_pred &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; [] 
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;for&lt;/span&gt; i &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;in&lt;/span&gt; tqdm( &lt;span style=&quot;color: #007020;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;,sampler&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;num_examples) ):
        
        &lt;span style=&quot;color: #888888;&quot;&gt;# get the first doc&lt;/span&gt;
        qx, qy &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; sampler&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;get_slice(i, &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;)
        
        &lt;span style=&quot;color: #888888;&quot;&gt;# look for best similar&lt;/span&gt;
        nns &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; model&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;single_lookup(qx[&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;], k&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;max_n)

        &lt;span style=&quot;color: #888888;&quot;&gt;# &lt;/span&gt;
        y_true_label &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #007020;&quot;&gt;int&lt;/span&gt;( np&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;round(qy[&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;]&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;numpy() ) )
        y_pred_label &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #007020;&quot;&gt;int&lt;/span&gt;( np&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;bincount( [nn&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;label &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;for&lt;/span&gt; nn &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;in&lt;/span&gt; nns] )&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;argmax() ) &lt;span style=&quot;color: #888888;&quot;&gt;#assigne pred the most frequent class of nearest document FIXME use the most frequente&lt;/span&gt;

        y_true&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;append(y_true_label)
        y_pred&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;append(y_pred_label)
        
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt; i &lt;span style=&quot;color: #333333;&quot;&gt;%&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;:
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;print&lt;/span&gt;(i, balanced_accuracy_score(y_true, y_pred) )

    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; confusion_matrix(y_true, y_pred), balanced_accuracy_score(y_true, y_pred)
&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Let&#39;s call it:&lt;br /&gt;&lt;!--HTML generated using hilite.me--&gt;&lt;div style=&quot;background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;&lt;pre style=&quot;line-height: 125%; margin: 0px;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;print&lt;/span&gt;( _eval_accuracy(model, sampler_test, max_n&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;30&lt;/span&gt;) )
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

I do not know if make sense to use tensorflow similarity for NLP, indeed we should use CircleLoss, but we preferred PNLoss.&lt;div&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;73% accuracy&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/926034781279812813/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2021/10/tensorflow-similarity-applied-to-nlp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/926034781279812813'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/926034781279812813'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2021/10/tensorflow-similarity-applied-to-nlp.html' title='Tensorflow Similarity applied to NLP'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxUlgT62MhDFPsKL6FhTODiV3rS0V3QH8BPZAezZMK07oB8L7uiqLHktlDoMnY_nIAzRVTDreCgdCAL1i7r1Ltswb-oMBDdWmQW_L3a59AMOZ6DmDDBw1uSPXKvqYijgfUWR5XI6qT1aQ/s72-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-4339106037872608803</id><published>2021-08-11T12:15:00.012+02:00</published><updated>2021-08-13T18:17:14.054+02:00</updated><title type='text'> AGILE for SW Development vs AGILE for Machine Learning</title><content type='html'> Agile methodologies are extremely popular for a wide range of application development purposes.&amp;nbsp;Rather than wait months or years for a software project, the Agile method focused on short iterations with a goal of rapidly delivering benefits for the business owner, and then continuously iterating as requirements and needs become more refined [3].&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The basic idea of Agile methodology is to continuously iterate the the 6 most important steps at each sprint (SCRUM) or continuously:&lt;/div&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Backlog (we consider Business Understanding already accomplished)&lt;/li&gt;&lt;li&gt;Analyse&lt;/li&gt;&lt;li&gt;Define&lt;/li&gt;&lt;li&gt;Design&lt;/li&gt;&lt;li&gt;Test&lt;/li&gt;&lt;li&gt;Deploy&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;This simple idea mitigates the risk of misunderstanding and reduce complex planning of project management.&amp;nbsp;AGILE allows greater customer satisfaction who sees the product forming slowly. Of course this requires a good mindset:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;ability to split large requirements into sub-deliverables,&amp;nbsp;&lt;/li&gt;&lt;li&gt;propensity for refactoring and&amp;nbsp;&lt;/li&gt;&lt;li&gt;acceptance of the PIVOTing.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Machine Learning&lt;/h2&gt;&lt;div&gt;Unfortunately in Machine Learning context these concepts are extreme and stressed to the &lt;b&gt;breaking point of the AGILE method [2]. The root-causes of stress are:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;Uncertainty of data &lt;/b&gt;(missing data, not enough features, not enough data, quality of data, unlabelled data),&lt;/li&gt;&lt;li&gt;SOTA &lt;b&gt;model in research phase&lt;/b&gt; and not ready for prod,&lt;/li&gt;ML models are not deterministic,&lt;li&gt;&lt;b&gt;Too big expectation&lt;/b&gt; of customer.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;div&gt;Furthermore, the ML models are not real products but e&lt;b&gt;nablers for software products.&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;b&gt;This uncertainty forces us&lt;u&gt;&amp;nbsp;rethinking the Agile process.&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgajRpYRUc7MqjdG0qXPofQHuZ9_jDO92ZOeIeHM1yTuJ_H6WSQ5ryD0as5JSXaf_2ezjDRN88S4f9dHmTe0UXp7i8ppW0m_lFd7FL6h4ZTouj31oGtVvKIgf1B6zviJtsfzSSPF8oGLes/s2048/AGILESWvsAGILEML.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1152&quot; data-original-width=&quot;2048&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgajRpYRUc7MqjdG0qXPofQHuZ9_jDO92ZOeIeHM1yTuJ_H6WSQ5ryD0as5JSXaf_2ezjDRN88S4f9dHmTe0UXp7i8ppW0m_lFd7FL6h4ZTouj31oGtVvKIgf1B6zviJtsfzSSPF8oGLes/s16000/AGILESWvsAGILEML.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Fig. 1: the Agile process for ML&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The only AGILE process for ML (At least that I know of) is the CRoss Industry Standard Process for Data Mining (&lt;a href=&quot;https://www.datascience-pm.com/crisp-dm-2/&quot;&gt;CRISP-DM)&lt;/a&gt;&amp;nbsp;[1].&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;The CRISP-DM highlights that the big difference between the standard AGILE process of the SW and the ML one:&amp;nbsp;&lt;b&gt;&lt;u&gt;dependency on DATA&lt;/u&gt;.&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;However, even the CRISP-DM does not take into account the post production phases : indeed, it is necessary to monitor the performance of the model and fix the model.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;p&gt;Figure.1 shows the differences between Agile Sw and Agile ML. DEV&amp;nbsp;&lt;b&gt;Step 1&lt;/b&gt; is CRISP-DM; POC evaluation&amp;nbsp;&lt;b&gt;Step 2&lt;/b&gt; considers strong interaction with SMEs (Subject Matter Expert) to refine data and model. Indeed a&amp;nbsp;close cooperation with SMEs should be considered and PIVOT should be carried out if necessary. Finally during production (&lt;b&gt;MVP&lt;/b&gt;&amp;nbsp;&lt;b&gt;step 3&lt;/b&gt;) we need to monitor the model to rebuild model and/or data. So in other words Agile ML is never ending agile methodology.&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Agile ML&lt;/h3&gt;&lt;p&gt;Typically, (on industrial context not research 😉 ) we can consider the following execution times:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;STEP 1 -&amp;nbsp; DEV:&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Data Understanding: 1-2 weeks&lt;/li&gt;&lt;li&gt;Data Preparation : 1 week - 2 months&lt;/li&gt;&lt;ol&gt;&lt;li&gt;When it is too long (&amp;gt; 1 month) please consider starting with vertical POC with a restricted amount of data&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Model Development: 1 week - 1 month&lt;/li&gt;&lt;li&gt;Model Evaluation : 1 week&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;STEP 2 - POC evaluation:&lt;/li&gt;&lt;ol&gt;&lt;li&gt;SMEs face to Face : 1 week&lt;/li&gt;&lt;li&gt;Data Refinement : 1 week&lt;/li&gt;&lt;li&gt;PIVOT decision point : every 2 months&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;STEP 3 - PROD:&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Productisation: 3 months&lt;/li&gt;&lt;li&gt;Model monitoring: 1 day - 1 week&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhie1P4tk-v_Fm9f4NmqHg_wJp2mjHGsbLWydsIrSoo8-q2WX_X3Vo88duJ1Qwwb_Y5oxxIb1ngABmDgeuZAb5OXCcLSwIejmT-x88skfbZj8V6WNn6dOmMy8Y0cR3OtlcTy-ZUwG7HaB8/s2048/AGILESWvsAGILEML_issues.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1152&quot; data-original-width=&quot;2048&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhie1P4tk-v_Fm9f4NmqHg_wJp2mjHGsbLWydsIrSoo8-q2WX_X3Vo88duJ1Qwwb_Y5oxxIb1ngABmDgeuZAb5OXCcLSwIejmT-x88skfbZj8V6WNn6dOmMy8Y0cR3OtlcTy-ZUwG7HaB8/s16000/AGILESWvsAGILEML_issues.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Fig. 2: Agile ML issues&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;5 Tricks&lt;/h2&gt;&lt;p&gt;Although a good process mitigates risks, we are not exempt from issues; Figure 2 highlights the most important issues; here are some tips from experts:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Start with Business Benefit [1]&lt;/li&gt;&lt;li&gt;Split Use Case on smallest user stories [4]&lt;/li&gt;&lt;li&gt;Deliver MVP as soon as possible&lt;/li&gt;&lt;li&gt;Encouraged non-technical stakeholder involvement [4] [5]&lt;/li&gt;&lt;li&gt;Think about tow different profiles ML Specialist (more researcher than sw dev) and ML Engineer (more sw dev) [4]&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;and finally&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&quot;People focusing too much on what Agile is and what is not are bound to make mistakes.&quot;&lt;/div&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Refs:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;https://www.datascience-pm.com/crisp-dm-2/&lt;/li&gt;&lt;li&gt;https://www.infoq.com/articles/machine-learning-agile/&lt;/li&gt;&lt;li&gt;https://www.forbes.com/sites/cognitiveworld/2020/01/19/why-agile-methodologies-miss-the-mark-for-ai--ml-projects/?sh=33188d0121ea&lt;/li&gt;&lt;li&gt;https://www.iunera.com/kraken/big-data-science-strategy/the-agile-approach-in-data-science-explained-by-an-ml-expert/&lt;/li&gt;&lt;li&gt;https://medium.com/qash/how-and-why-to-use-agile-for-machine-learning-384b030e67b6&lt;/li&gt;&lt;li&gt;https://towardsdatascience.com/an-agile-framework-for-ai-projects-6b5a1bb41ce4&amp;nbsp;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/4339106037872608803/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2021/08/agile-for-sw-development-is-not-same.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/4339106037872608803'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/4339106037872608803'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2021/08/agile-for-sw-development-is-not-same.html' title=' AGILE for SW Development vs AGILE for Machine Learning'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgajRpYRUc7MqjdG0qXPofQHuZ9_jDO92ZOeIeHM1yTuJ_H6WSQ5ryD0as5JSXaf_2ezjDRN88S4f9dHmTe0UXp7i8ppW0m_lFd7FL6h4ZTouj31oGtVvKIgf1B6zviJtsfzSSPF8oGLes/s72-c/AGILESWvsAGILEML.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6419696472234224840.post-3054352690154446721</id><published>2021-06-23T10:51:00.002+02:00</published><updated>2021-06-23T10:51:15.201+02:00</updated><title type='text'>IoT Security and Artificial Intelligence for better industrial applications</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://www.bigmarker.com/zerynth/webinar-june23-IoT-Security-and-AI?utm_bmcr_source=zerynth_sm&quot; imageanchor=&quot;1&quot; rel=&quot;nofollow&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;500&quot; data-original-width=&quot;700&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSNorBrxFBoAi_A-LM2RZJ5Nvl91Do-2pLJG4Ga5DkTX5he8bIjUvX7il7YA4XUMdaKmuIsIAWATOjC4ULYbUuM-L6ZBZqtUeP4nBgs7nyxhER0oXzJZsjV3Wa-NrwG58B9310JqwvcKA/s16000/1624353071353.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://jugsi.blogspot.com/feeds/3054352690154446721/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jugsi.blogspot.com/2021/06/iot-security-and-artificial.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/3054352690154446721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6419696472234224840/posts/default/3054352690154446721'/><link rel='alternate' type='text/html' href='http://jugsi.blogspot.com/2021/06/iot-security-and-artificial.html' title='IoT Security and Artificial Intelligence for better industrial applications'/><author><name>Giacomo Veneri</name><uri>http://www.blogger.com/profile/06420685781275285639</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewVf0YjxyGeavD6v5y3B_u_QBupT2eoLT2G73rZ4KYgy0uubkJ1XT7uKM9fFOot9fm1dnAHuR_qxxAIo9hKoK0EkLdCxFCfgN1oG-HF_6dS1eomu3UXQ5aFRF8fWOepY/s113/9880255.jpeg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSNorBrxFBoAi_A-LM2RZJ5Nvl91Do-2pLJG4Ga5DkTX5he8bIjUvX7il7YA4XUMdaKmuIsIAWATOjC4ULYbUuM-L6ZBZqtUeP4nBgs7nyxhER0oXzJZsjV3Wa-NrwG58B9310JqwvcKA/s72-c/1624353071353.gif" height="72" width="72"/><thr:total>0</thr:total></entry></feed>