<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jmlampkin on Medium]]></title>
        <description><![CDATA[Stories by Jmlampkin on Medium]]></description>
        <link>https://medium.com/@jmlampkin?source=rss-39f4d35cc2d4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Dp1nsgrSh7dmrZqC.jpg</url>
            <title>Stories by Jmlampkin on Medium</title>
            <link>https://medium.com/@jmlampkin?source=rss-39f4d35cc2d4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 22:44:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jmlampkin/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[My deployed AI application on Ainize]]></title>
            <link>https://medium.com/@jmlampkin/my-deployed-ai-model-on-ainize-1bde93a09331?source=rss-39f4d35cc2d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/1bde93a09331</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[twitter]]></category>
            <category><![CDATA[deployment-model]]></category>
            <category><![CDATA[hugging-face]]></category>
            <category><![CDATA[common-computer-ainize]]></category>
            <dc:creator><![CDATA[Jmlampkin]]></dc:creator>
            <pubDate>Wed, 04 May 2022 02:30:43 GMT</pubDate>
            <atom:updated>2022-05-08T21:03:27.768Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi! This blog post will describe the <a href="https://main-common-computer-jonathanlampkin.endpoint.ainize.ai/">AI application</a> I have deployed on <a href="http://ainize.ai/">Common Computer’s Ainize platform</a>, what it does and how to use it, and my experience with deploying the program. A demonstration of the application can also be viewed here: <a href="https://www.youtube.com/watch?v=0-p80wBOGY4">YouTube video</a>.</p><p><strong>Let’s take a look at the application:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*2QzSuTn90fhnqjrDMROBYw.png" /></figure><p>You can use this application by going to the <a href="https://main-common-computer-jonathanlampkin.endpoint.ainize.ai/">demo page</a> and simply entering any search phrase into the search bar.</p><p>Within 10 seconds or less, you will receive a short summary of the most recent tweets related to the search phrase you entered along with a bar chart accurately classifying the sentiment of the collection of tweets.</p><p><em>In the case the application takes more than a few seconds, this may be due to your system not having a GPU. The model will then take just a few minutes to run.</em></p><p>Feel free to play with the application as much as you like and even use it periodically to catch up on the latest with things that interest you! I personally use it to get a feel for what’s going on with my favorite stocks.</p><p>Now let’s look at how this program was made…</p><h4><strong>Data Collection</strong></h4><p>The first step was to head over to <a href="https://developer.twitter.com/en/docs/twitter-api">Twitter’s Developer Platform</a> to gain access to their API which would allow us to automatically pull tweets. Once granted API access, we used <a href="https://github.com/twitterdev/Twitter-API-v2-sample-code?msclkid=ddb29ccfced211eca9e33d4fd497dcf5">this repo on Twitter’s Github</a> to find sample code for the Twitter API service we were using. To effectively query Twitter’s API, we studied their <a href="https://developer.twitter.com/en/docs/twitter-api/tweets/counts/integrate/build-a-query">build-a-query guide</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*6zFDZibP6ZkYO8mx0mrK5A.png" /><figcaption>Code used to pull data from the Twitter API</figcaption></figure><h4><strong>Model Selection</strong></h4><p>After collecting the necessary data, we chose our models for summarizing the tweets and classifying their sentiment. For this, we headed over to the infamous <a href="https://huggingface.co/">Hugging Face website</a> where you can find hundreds, if not thousands of pre-trained ready-to-use deep learning models mostly for natural language processing and computer vision tasks.</p><p>After trying a few models for the summarization task, I decided to go with this <a href="https://huggingface.co/slauw87/bart_summarisation">bart model for summarisation by slauw87</a>. I chose this model because it was pre-trained on a dataset called <a href="https://huggingface.co/datasets/samsum">SAMSum</a> which is made up of natural human conversations including slang words and informal texting patterns, which is what the data we wanted the model to generalize to, looked like.</p><p>As for the sentiment classifier, I wanted something more than just negative, positive, and neutral like most classifiers offer. Luckily, <a href="https://medium.com/u/d18cf80f638">Jeff</a> who had helped me several times with building this program had found and suggested this <a href="https://huggingface.co/j-hartmann/emotion-english-distilroberta-base">multi-class sentiment classifier by j-hartmann</a>.</p><h4><strong>Data Processing</strong></h4><p>Before applying our two Hugging Face models, the data needed to be cleaned up. This meant formatting the data in a way that would allow the models to perform their best on the data. For this task, the data cleaning process consisted of removing duplicate tweets, ‘@mentions’, ‘$’ signs, ‘RT’ acronyms, website links, emojis, and non-English tweets. Removing emojis and non-English tweets were only necessary because our models did not support these types of data.</p><p>After this process, the data needed to be split up into groups less than or equal to the maximum text length that the summarization pipeline can handle. If interested, this <a href="https://arxiv.org/abs/1910.10781">research paper</a> offers an in-depth explanation regarding this limitation and the work-around method I used in this project.</p><p>In summary, the limitation is explained by this quote from the paper hyperlinked above:</p><blockquote><a href="https://arxiv.org/abs/1910.10781">BERT suffers from major limitations in terms of handling long sequences. Firstly, the self-attention layer has a quadratic complexity O(n 2 ) in terms of the sequence length n. Secondly, BERT uses a learned positional embeddings scheme, which means that it won’t likely be able to generalize to positions beyond those seen in the training data.</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*-8BaQ-eijbDLZu8P9SwLTQ.png" /><figcaption>Code used to clean and chunk tweets. Thank you <a href="https://medium.com/u/d18cf80f638">Jeff</a> for improving my regex pattern and chunking code.</figcaption></figure><h4>Summarization and Sentiment Classification</h4><p>Now that we had collected the data, cleaned it, and prepared it for the models, it was time to apply our two Hugging Face models to the data. With a bit of research, insight from <a href="https://medium.com/u/d18cf80f638">Jeff</a>, and some trial and error, we came to ideal hyperparameters for the models that returned satisfactory results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6lQhIRn6yjhCCvJEUHkFLw.png" /><figcaption>Code used to summarize and classify sentiment.</figcaption></figure><h4>Parallel Computing and Docker</h4><p>Our models by default use the CPU which is pretty slow to run. To solve this, we used <a href="https://pytorch.org/get-started/locally/">Pytorch</a> and <a href="https://developer.nvidia.com/cuda-toolkit">Nvidia CUDA</a> to enable GPU computing. In addition, our models needed to be pushed to Docker which they would later be pulled from. Unfortunately running a CUDA enabled process on Docker for Windows users is not a straightforward process and I recommend <a href="https://www.youtube.com/watch?v=CO43b6XWHNI">this video</a> for help getting started with this process.</p><h4>Deploying the model</h4><p>The last step of the project was to deploy this model using Flask, Ainize, and Streamlit.</p><p>First, we used Flask to pull in the search query, then we ran our pipeline on the query, and used Flask again to post the results back to an Ainize endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*-BLt4Kaqy00hWj6hp96YuQ.png" /><figcaption>Code used to pull a user’s search query, apply the pipeline, and return the results.</figcaption></figure><p>Once the results were posted to the Ainize endpoint, we used seaborn and matplotlib to create the sentiment bar chart, and the requests library with Streamlit to create a front-end user interface for interacting with the program.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*_rjF5SG1GiNWHkFSLFCwwA.png" /><figcaption>Code used to generate the program’s frontend user interface.</figcaption></figure><p>Finally, our project was completed and anyone around the world with internet access could use it at their will.</p><h4>Conclusion</h4><p>In conclusion, given some prior experience using Docker, CUDA, and a backend API such as Flask; this method of web-interactive deployment is super convenient and straightforward. That being said, I learned quite a lot during the process and a stubborn desire to learn and conquer without prior experience will also allow you to deploy your model on the<a href="https://ainize.ai/"> Ainize platform</a>.</p><p>I will surely consider using <a href="https://ainize.ai/">Common Computer’s Ainize platform</a> the next time I need a web-based interactive deployment.</p><p>Special thanks to the <a href="https://medium.com/u/b785d0af7b89">AI Network</a> at <a href="https://medium.com/u/fdb69a0b5654">Common Computer</a>, <a href="https://medium.com/u/d18cf80f638">Jeff</a>, <a href="https://github.com/scy6500?tab=overview&amp;from=2022-03-01&amp;to=2022-03-17&amp;msclkid=aa9ccf91cf0d11ec95d390e8e63edeaa">Changyeop</a>, and Donghoon Baek for the feedback, support, and opportunity to build and deploy this project.</p><p>For a more in-depth guide with deploying on <a href="https://ainize.ai/">Ainize</a>, check out <a href="https://comcom.notion.site/Tutorial-for-Ainizer-s-Project-10a1531521ea40a684120d1093b338f1">this tutorial</a>. <a href="https://ainize.ai/explore">Click here</a> to see models currently deployed on the <a href="https://ainize.ai/">Ainize platform</a>.</p><p>That ends my blog post, please head over and try out my web-interactive application at <a href="https://main-common-computer-jonathanlampkin.endpoint.ainize.ai/">People’s Thoughts on Ainize</a> and feel free to offer any feedback you may have!</p><p>The code that went into developing this program can be found on my <a href="https://github.com/jonathanlampkin?tab=repositories">GitHub</a> in the repositories <a href="https://github.com/jonathanlampkin/Common-Computer-Backend">“Common-Computer-Backend”</a> and <a href="https://github.com/jonathanlampkin/Common-Computer">“Common-Computer”</a>.</p><p>Thank you so much for reading my blog post, check out <a href="https://www.youtube.com/watch?v=0-p80wBOGY4">my YouTube video</a> <a href="https://www.youtube.com/watch?v=0-p80wBOGY4">here</a> demonstrating the program and explaining what’s going on under the hood of the application.</p><h4>Citations</h4><p>Pappagari, Raghavendra, et al. “Hierarchical transformers for long document classification.” <em>2019 IEEE Automatic Speech Recognition and Understanding Workshop (ASRU)</em>. IEEE, 2019 <a href="https://arxiv.org/abs/1910.10781">[1910.10781] Hierarchical Transformers for Long Document Classification (arxiv.org)</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1bde93a09331" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>