<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Abel Peter</title>
    <description>The latest articles on Forem by Abel Peter (@peterabel).</description>
    <link>https://forem.com/peterabel</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F912954%2Fef225662-d53b-4f91-b2aa-ae4f706ecf43.jpg</url>
      <title>Forem: Abel Peter</title>
      <link>https://forem.com/peterabel</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/peterabel"/>
    <language>en</language>
    <item>
      <title>Why Sentiment Analysis Needs an Upgrade: Welcome Sentimetric</title>
      <dc:creator>Abel Peter</dc:creator>
      <pubDate>Thu, 01 Jan 2026 08:51:43 +0000</pubDate>
      <link>https://forem.com/peterabel/why-sentiment-analysis-needs-an-upgrade-welcome-sentimetric-1pj4</link>
      <guid>https://forem.com/peterabel/why-sentiment-analysis-needs-an-upgrade-welcome-sentimetric-1pj4</guid>
      <description>&lt;p&gt;I built Sentimetric because I was tired of sentiment analysis libraries that think it's still 2010.&lt;/p&gt;

&lt;p&gt;You know what I mean. You run a comment like "This is insane! thank you!" through TextBlob and it confidently tells you that's negative sentiment. Score: -1.0. The most negative comment in the entire dataset, apparently.&lt;/p&gt;

&lt;p&gt;Meanwhile, any human reading that comment knows exactly what it means: someone's genuinely excited and grateful. But traditional sentiment analysis libraries? They see "insane" and panic.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem With Most Sentiment Analysis Tools
&lt;/h2&gt;

&lt;p&gt;Here's the thing about language in 2025: it's messy, contextual, and constantly evolving. We use words like "insane," "sick," "fire," and "unreal" to express enthusiasm. We layer on sarcasm with emoji. We pack entire emotional landscapes into phrases like "Oh great, another bug 🙄."&lt;/p&gt;

&lt;p&gt;But most sentiment analysis libraries are still operating on lexicons built years ago, where "insane" only means bad things and "excellent" is always positive (even when you're saying it sarcastically).&lt;/p&gt;

&lt;p&gt;The example above is real, by the way. I analyzed YouTube comments using TextBlob, and it classified "This is insane! thank you!" as the most negative comment in a dataset of 208 comments. Not just negative—the &lt;em&gt;most&lt;/em&gt; negative.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Matters
&lt;/h2&gt;

&lt;p&gt;If you're analyzing customer feedback, social media sentiment, or user reviews, these misclassifications aren't just amusing quirks. They're actively misleading your decisions. &lt;/p&gt;

&lt;p&gt;Imagine making product decisions based on the "insight" that customers expressing excitement with modern slang are actually your most dissatisfied users. Or filtering out comments as toxic when they're actually enthusiastic endorsements.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing the Competition: A Reality Check
&lt;/h2&gt;

&lt;p&gt;I put together a test set of 20 real-world phrases—the kind you see every day on social media, in product reviews, and customer feedback. Modern slang, sarcasm, emoji, the works. Then I ran them through TextBlob and VADER, two of the most popular sentiment analysis libraries.&lt;/p&gt;

&lt;p&gt;The results? Embarrassing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Overall Accuracy:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;VADER: 35%&lt;/li&gt;
&lt;li&gt;Sentimetric: 20%&lt;/li&gt;
&lt;li&gt;TextBlob: 15%&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Wait, what? Even Sentimetric struggled? That's because rule-based systems—no matter how modern—have fundamental limitations. But here's where it gets interesting.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where Sentimetric Gets It Right (And Others Don't)
&lt;/h3&gt;

&lt;p&gt;Let's look at three examples where Sentimetric's modern language understanding shines:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. "This is insane! thank you!"&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Expected: Positive&lt;/li&gt;
&lt;li&gt;Sentimetric: ✓ Positive&lt;/li&gt;
&lt;li&gt;TextBlob: ✗ Negative&lt;/li&gt;
&lt;li&gt;VADER: ✗ Negative&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sentimetric understands that "insane" in the context of excitement and gratitude is positive. The others see "insane" and immediately classify it as negative, completely missing the enthusiastic tone.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. "This product is fire 🔥"&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Expected: Positive
&lt;/li&gt;
&lt;li&gt;Sentimetric: ✓ Positive&lt;/li&gt;
&lt;li&gt;TextBlob: ✗ Neutral&lt;/li&gt;
&lt;li&gt;VADER: ✗ Negative&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;"Fire" isn't about disasters anymore—it means something is excellent. Sentimetric knows this. VADER thinks the product is literally on fire (negative), and TextBlob just gives up (neutral).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. "Wonderful! My favorite thing is when apps crash"&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Expected: Negative (sarcasm)&lt;/li&gt;
&lt;li&gt;Sentimetric: ✓ Negative&lt;/li&gt;
&lt;li&gt;TextBlob: ✗ Positive&lt;/li&gt;
&lt;li&gt;VADER: ✗ Positive&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is sarcasm. Sentimetric catches it. The others see "Wonderful!" and "favorite" and happily classify it as positive, completely missing the obvious sarcasm about app crashes.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Category Breakdown
&lt;/h3&gt;

&lt;p&gt;When we break down performance by challenge type, the gaps become even clearer:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Modern Slang:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sentimetric: 40% accuracy&lt;/li&gt;
&lt;li&gt;TextBlob: 0%&lt;/li&gt;
&lt;li&gt;VADER: 0%&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Sarcasm:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sentimetric: 75% accuracy (with advanced patterns)&lt;/li&gt;
&lt;li&gt;TextBlob: 0%&lt;/li&gt;
&lt;li&gt;VADER: 25%&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Emoji Context:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sentimetric: 60% accuracy&lt;/li&gt;
&lt;li&gt;TextBlob: 33%&lt;/li&gt;
&lt;li&gt;VADER: 67%&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Traditional tools aren't just struggling—they're failing completely at modern language patterns.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw20gukovty8bly0w7p3d.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw20gukovty8bly0w7p3d.PNG" alt="COMPARISON RESULTS - ALL TOOLS" width="800" height="528"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqc6o3cgfkxb31fxx3qpz.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqc6o3cgfkxb31fxx3qpz.PNG" alt="Accuracy analysis" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  But Wait—There's a Better Way
&lt;/h2&gt;

&lt;p&gt;Here's the honest truth: even with all the modern slang dictionaries, emoji mappings, and sarcasm patterns I built into Sentimetric, rule-based systems have a ceiling. Language is too creative, too contextual, too &lt;em&gt;human&lt;/em&gt; for rules alone.&lt;/p&gt;

&lt;p&gt;That's why Sentimetric offers something different: seamless LLM integration.&lt;/p&gt;

&lt;h3&gt;
  
  
  The LLM Difference: Understanding, Not Just Pattern Matching
&lt;/h3&gt;

&lt;p&gt;I ran the same test set through Sentimetric's LLM analyzer (using DeepSeek, which is incredibly affordable). The results speak for themselves:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Overall Accuracy:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;LLM-Enhanced: 93.3% (14/15 cases)&lt;/li&gt;
&lt;li&gt;Rule-Based: 53.3% (8/15 cases)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The LLM rescued 7 cases that rule-based analysis completely missed. That's a 47% improvement on the hardest cases.&lt;/p&gt;

&lt;p&gt;But here's what's really powerful—the LLM doesn't just give you a classification. It explains &lt;em&gt;why&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Real Examples: When LLMs Save The Day
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Example 1: "Oh great, another bug 🙄"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Rule-based:&lt;/em&gt; Positive ✗&lt;br&gt;&lt;br&gt;
&lt;em&gt;LLM:&lt;/em&gt; Negative ✓&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LLM Reasoning:&lt;/strong&gt; "The phrase 'Oh great' is sarcastic, and the eye-roll emoji (🙄) expresses frustration and annoyance about encountering another bug."&lt;/p&gt;

&lt;p&gt;The rule-based analyzer saw "great" and missed the sarcasm. The LLM understood the context, the emoji, and the actual meaning.&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Example 2: "I appreciate the effort, but this doesn't meet our standards"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Rule-based:&lt;/em&gt; Neutral ✗&lt;br&gt;&lt;br&gt;
&lt;em&gt;LLM:&lt;/em&gt; Negative ✓&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LLM Reasoning:&lt;/strong&gt; "The phrase acknowledges effort with 'I appreciate the effort' but delivers criticism with 'doesn't meet our standards', making the overall sentiment negative."&lt;/p&gt;

&lt;p&gt;This is a polite rejection—the kind you see in professional contexts. Rule-based analysis couldn't weigh the "but" properly. The LLM understood the diplomatic language.&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Example 3: "I love how they fixed one bug and introduced five more 👏"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Rule-based:&lt;/em&gt; Positive ✗&lt;br&gt;&lt;br&gt;
&lt;em&gt;LLM:&lt;/em&gt; Negative ✓&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LLM Reasoning:&lt;/strong&gt; "Sarcastic praise about fixing one bug while creating more problems, indicated by the clap emoji used ironically."&lt;/p&gt;

&lt;p&gt;The clapping emoji can be genuine applause or sarcastic. The LLM reads the context and nails it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa2oe04f3hywulpkk5e5f.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa2oe04f3hywulpkk5e5f.PNG" alt="llm comparison" width="800" height="317"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzeqkc0gct8g19p2q8epr.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzeqkc0gct8g19p2q8epr.PNG" alt="llms perfomance" width="800" height="333"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  The Architecture That Makes Sense
&lt;/h2&gt;

&lt;p&gt;Here's how I designed Sentimetric to actually work in production:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For 80% of your text: Use rule-based analysis&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fast (milliseconds)&lt;/li&gt;
&lt;li&gt;Free&lt;/li&gt;
&lt;li&gt;No API calls&lt;/li&gt;
&lt;li&gt;Good enough for straightforward sentiment
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sentimetric&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;analyze&lt;/span&gt;

&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;analyze&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Great product, fast shipping!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# Quick, free, accurate
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;For the 20% that matters: Use LLM analysis&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Handles sarcasm, nuance, and complexity&lt;/li&gt;
&lt;li&gt;Provides reasoning&lt;/li&gt;
&lt;li&gt;Multiple affordable providers (DeepSeek, OpenAI, Claude, Gemini)&lt;/li&gt;
&lt;li&gt;Automatic fallback to cheaper models
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sentimetric&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;LLMAnalyzer&lt;/span&gt;

&lt;span class="n"&gt;analyzer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;LLMAnalyzer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;provider&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;deepseek&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;analyzer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;analyze&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Oh great, another bug 🙄&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;category&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# 'negative'
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reasoning&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Full explanation
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You get the speed and cost-efficiency of rule-based for bulk processing, and the intelligence of LLMs when you need it. Not an either/or choice—both, when appropriate.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Path Forward
&lt;/h2&gt;

&lt;p&gt;Sentiment analysis shouldn't think "This is insane! thank you!" is negative. It shouldn't miss obvious sarcasm. It shouldn't be stuck in 2010 while language evolves around it.&lt;/p&gt;

&lt;p&gt;Sentimetric is my answer to this problem:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Modern rule-based analysis&lt;/strong&gt; that actually understands today's language&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Seamless LLM integration&lt;/strong&gt; for the cases that need it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost-conscious design&lt;/strong&gt; that won't bankrupt your API budget&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Simple API&lt;/strong&gt; that gets out of your way&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal isn't to build the perfect sentiment analyzer—that's impossible. The goal is to give you the right tool for each job, make it dead simple to use, and keep improving as language evolves.&lt;/p&gt;
&lt;h2&gt;
  
  
  Try It Yourself
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;sentimetric
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Quick analysis:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sentimetric&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;analyze&lt;/span&gt;

&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;analyze&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;This is fire! 🔥&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;category&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# 'positive'
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;LLM analysis:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sentimetric&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;LLMAnalyzer&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;

&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;DEEPSEEK_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;your-key&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="n"&gt;analyzer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;LLMAnalyzer&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;analyzer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;analyze&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Oh great, another bug 🙄&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;category&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;    &lt;span class="c1"&gt;# 'negative'
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reasoning&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# Full explanation
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Compare methods:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sentimetric&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;compare_methods&lt;/span&gt;

&lt;span class="nf"&gt;compare_methods&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;This is insane! thank you!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# See rule-based vs LLM side-by-side
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What's Next
&lt;/h2&gt;

&lt;p&gt;I'm actively improving Sentimetric's rule-based engine with more modern patterns, better emoji handling, and smarter sarcasm detection. The library is open source, and I'd love your feedback, bug reports, and examples of where sentiment analysis has failed you.&lt;/p&gt;

&lt;p&gt;Because language keeps evolving. And our tools need to keep up.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Repo:&lt;/strong&gt; &lt;a href="https://github.com/peter-abel/sentimetric" rel="noopener noreferrer"&gt;github.com/peter-abel/sentimetric&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Email:&lt;/strong&gt; &lt;a href="mailto:peterabel791@gmail.com"&gt;peterabel791@gmail.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's make sentiment analysis actually work for modern language.&lt;/p&gt;

&lt;p&gt;The data is clear: modern language needs modern tools. And when rules aren't enough, you need intelligence on demand.&lt;/p&gt;

</description>
      <category>sentimetric</category>
      <category>llm</category>
      <category>sentimentanalysis</category>
      <category>analytics</category>
    </item>
    <item>
      <title>Everything You Need To Understand Prompt Engineering.</title>
      <dc:creator>Abel Peter</dc:creator>
      <pubDate>Wed, 11 Jun 2025 12:46:21 +0000</pubDate>
      <link>https://forem.com/peterabel/everything-you-need-to-understand-prompt-engineering-46dl</link>
      <guid>https://forem.com/peterabel/everything-you-need-to-understand-prompt-engineering-46dl</guid>
      <description>&lt;p&gt;In the 2015 comedy "Absolutely Anything," a hapless schoolteacher discovers he can reshape reality with mere words, but every wish backfires spectacularly because he can't quite say what he means. When he asks to be "attractive," he becomes a magnet for metallic objects. When he tries to eliminate noisy neighbors, they vanish entirely. The film's central tragedy isn't that the protagonist lacks power, he has infinite power but he lacks the precision to wield it effectively. Replace the cosmic aliens with transformer architectures and the reality-bending wishes with text prompts, and you have a perfect metaphor for our current relationship with large language models. We stand before systems of unprecedented capability, armed with vast knowledge and reasoning abilities, yet consistently frustrated by our inability to reliably extract what we actually want. The bottleneck isn't the AI's intelligence—it's our interface with that intelligence. Like Neil learning to be more careful with his wishes, we need to fundamentally understand how we communicate with these alien minds we've created.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Learning to Communicate with Complex Systems: An Explanatory Framework&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We often approach prompt engineering like programming, expecting deterministic inputs to produce predictable outputs. This mechanistic view leads to frustration, inconsistent results, and a cottage industry of "prompt hacks" that work sometimes, for some people, on some models. But what if we're thinking about this all wrong?&lt;/p&gt;

&lt;p&gt;The reality is that while Large Language Models are fundamentally deterministic, they behave like complex systems in ways that make them challenging to communicate with effectively. Understanding this complexity can illuminate why our interactions with them unfold the way they do.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Complexity Reality
&lt;/h2&gt;

&lt;p&gt;Large Language Models are complex systems operating in high-dimensional spaces with billions of parameters, trained on the vast totality of human knowledge. When we send a prompt into this system, we're not executing a simple program. Instead, we're introducing input into a complex system and observing how it responds, much like speaking to a brilliant but alien intelligence and watching how it processes and interprets our words.&lt;/p&gt;

&lt;p&gt;This perspective helps us understand why the same prompt can produce different results, why slight variations in wording can lead to dramatically different outputs, and why what works brilliantly in one context might fail completely in another. We're not dealing with a simple machine—we're learning to communicate across a complex landscape of understanding.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Three Pillars of Effective Communication
&lt;/h2&gt;

&lt;p&gt;To better grasp how our prompts actually function within these complex systems, we can categorize them by the types of effects they create in the model's processing.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Perturbation Mapping: Understanding Your Tools
&lt;/h3&gt;

&lt;p&gt;Different types of prompts don't just change what the model says—they fundamentally alter how it thinks about the problem space. Think of prompts as different kinds of forces acting on the system's internal dynamics.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Framing Prompts&lt;/strong&gt; establish the context and perspective for reasoning. They don't just set a tone; they create entirely different cognitive frameworks where different types of thoughts become natural and accessible.&lt;/p&gt;

&lt;p&gt;Consider how these two approaches shape the same conversation:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"You are a skeptical scientist reviewing a new climate study. The researchers claim..."&lt;/em&gt; This naturally guides the model toward critical analysis, methodological scrutiny, and conservative interpretation, creating a foundation where questioning and verification feel appropriate.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"You are an enthusiastic venture capitalist hearing a startup pitch about climate technology. The entrepreneurs propose..."&lt;/em&gt; This generates a completely different mindset where opportunity recognition, market potential, and optimistic extrapolation become the natural flow of thinking.&lt;/p&gt;

&lt;p&gt;The same factual content about climate technology will be processed through entirely different cognitive frameworks, not because we've given different instructions about what to conclude, but because we've altered the fundamental approach to how the model navigates the concept space.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Constraint Prompts&lt;/strong&gt; function as boundary conditions, reducing dimensionality in controlled ways. They channel the model's vast generative potential into specific pathways, much like riverbanks directing a powerful current.&lt;/p&gt;

&lt;p&gt;Think about how these examples shape the response:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"Explain quantum entanglement in exactly three sentences, using only analogies a child would understand"&lt;/em&gt; This creates both temporal boundaries (three sentences) and conceptual boundaries (child-friendly analogies), forcing the model to compress complex ideas into a constrained yet accessible space.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"Describe the fall of Rome without mentioning any specific dates, focusing only on underlying social dynamics"&lt;/em&gt; Here we remove temporal anchors while creating conceptual boundaries around social causation, guiding the model toward pattern-based rather than chronological reasoning.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"Write a product review for this smartphone, but from the perspective of someone who lived in 1950"&lt;/em&gt; This creates fascinating anachronistic constraints that encourage creative bridging between different technological paradigms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exploration Prompts&lt;/strong&gt; encourage the system to move away from default patterns and toward novel combinations. They increase creative possibilities and create space for unexpected connections.&lt;/p&gt;

&lt;p&gt;Consider these examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;"What if we completely inverted our assumption that economic growth is inherently good? How would society reorganize itself around economic degrowth as a positive goal?"&lt;/em&gt; — This pushes the model away from conventional economic reasoning toward contrarian exploration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;"Generate five wildly different approaches to solving traffic congestion, where each approach comes from a completely different field of study"&lt;/em&gt; — This creates cross-domain exploration, encouraging the model to draw connections between disparate knowledge areas.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;"Imagine explaining democracy to an intelligent species that reproduces through collective consciousness rather than individual reproduction. What aspects would be incomprehensible to them?"&lt;/em&gt; — This forces perspective-taking that requires reconstructing fundamental assumptions about social organization.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Convergence Prompts&lt;/strong&gt; guide diverse thoughts toward synthesis and integration. They take multiple ideas and draw them toward coherent patterns.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;"You've just heard three different experts explain the housing crisis from economic, social, and environmental perspectives. What common thread connects all their explanations, and what unified solution emerges from their intersection?"&lt;/em&gt; — This creates a synthesizing attractor that pulls different analytical frameworks toward integration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;"Take these five seemingly unrelated trends: remote work, cryptocurrency, climate anxiety, social media fatigue, and the maker movement. Weave them into a single narrative about where society is heading"&lt;/em&gt; — This forces the model to find deep connections between surface-level disparate phenomena.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The key insight here is that we can map which prompt types reliably create which kinds of responses from the model, regardless of the specific content domain we're working in.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Ensemble Dynamics: The Power of Prompt Bundles
&lt;/h3&gt;

&lt;p&gt;Individual prompts produce inconsistent outputs because they represent single interactions with a complex system. But just as individual conversations with a brilliant person might vary while their overall expertise remains consistent, the collective behavior of prompt bundles can exhibit surprisingly reliable patterns.&lt;/p&gt;

&lt;p&gt;Think of this like conducting an orchestra where individual musicians might occasionally hit wrong notes, but the overall musical pattern emerges clearly from their collective performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bundle Architecture&lt;/strong&gt; involves designing prompt sets where different members serve complementary roles in exploring the solution space:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Anchor prompts&lt;/strong&gt; establish baseline patterns and set the fundamental parameters of the exploration:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;"Provide a straightforward analysis of renewable energy adoption rates based on current data"&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Variation prompts&lt;/strong&gt; introduce controlled mutations that explore different dimensions of the problem:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;"Analyze renewable energy adoption as if you were an oil company executive concerned about market share"&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;"Examine renewable energy trends from the perspective of a small island nation vulnerable to climate change"&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;"Assess renewable energy adoption through the lens of job market transformation"&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Validation prompts&lt;/strong&gt; test consistency across different framings and identify robust insights:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;"What aspects of renewable energy adoption would remain true regardless of political perspective?"&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;"Which renewable energy trends are most likely to continue even if current policies changed dramatically?"&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Integration prompts&lt;/strong&gt; synthesize insights across the bundle:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;"Considering all these different perspectives on renewable energy, what synthesis emerges about the most critical factors driving adoption?"&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of judging individual outputs, you analyze the pattern of responses. Where do responses cluster? That reveals consistent themes—the ideas that remain stable across different approaches. What's the variance along different dimensions? That shows you where the system is most sensitive to different phrasings. Which concepts appear consistently across different framings? Those represent robust insights that transcend particular perspectives. What novel connections emerge across the response set? Those might represent breakthrough insights.&lt;/p&gt;

&lt;p&gt;You're not trying to engineer one perfect response, you're mapping the landscape of possible answers. You run multiple prompts knowing that the collective pattern will be more informative than any individual response.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Adaptive Iteration: Learning to Navigate the Communication
&lt;/h3&gt;

&lt;p&gt;This is where systematic learning meets communication improvement. Each cycle of interaction teaches us something about how the model responds to different types of prompts.&lt;/p&gt;

&lt;p&gt;The process flows naturally from observation to hypothesis to experimentation:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Response Assessment&lt;/strong&gt;: You analyze the current pattern of responses, looking for clusters, outliers, and gaps in the exploration space.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pattern Recognition&lt;/strong&gt;: You identify which prompt modifications moved you toward or away from useful outputs, building an intuitive map of the model's communication preferences.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prompt Design&lt;/strong&gt;: You craft the next set based on your growing understanding of how different prompt types affect the system's responses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Validation Testing&lt;/strong&gt;: You include prompts specifically designed to test whether apparent progress represents genuine improvement or mere coincidence.&lt;/p&gt;

&lt;p&gt;This creates a learning dynamic where each interaction builds knowledge about communicating effectively with the model. You begin to recognize patterns: which types of prompts consistently improve output quality for different kinds of problems, what combinations work well together, how the model's focus shifts across different domains.&lt;/p&gt;

&lt;p&gt;It's like learning to communicate with a brilliant colleague from a different culture, at first the interactions seem unpredictable, but gradually you begin to recognize the underlying communication patterns and can predict which approaches will be most effective.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Framework Matters
&lt;/h2&gt;

&lt;p&gt;As LLMs become more powerful and more integrated into our workflows, we need better ways to understand our interactions with them. The old paradigm of treating prompts like programming instructions breaks down as models become more sophisticated and their internal dynamics become more complex.&lt;/p&gt;

&lt;p&gt;The complexity framework offers a perspective that scales with model sophistication. It acknowledges the fundamental unpredictability while providing systematic approaches to navigate it. It transforms the frustration of inconsistent outputs into a deeper appreciation for the sophisticated systems we're working with.&lt;/p&gt;

&lt;p&gt;Most importantly, it shifts us from trying to control AI systems to learning to collaborate with them recognizing that we're dealing with alien forms of intelligence that require new forms of partnership.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Future of Human-AI Collaboration
&lt;/h2&gt;

&lt;p&gt;We're moving toward a world where AI systems are less like tools and more like alien intelligences powerful, capable, but fundamentally different from human cognition. Success will require new forms of collaboration that respect both the capabilities and the strangeness of these systems.&lt;/p&gt;

&lt;p&gt;Understanding LLMs as complex systems is one step toward that future: a framework that embraces complexity, works with uncertainty, and transforms the apparent unpredictability of AI systems into opportunities for enhanced human capability.&lt;/p&gt;

&lt;p&gt;The question isn't whether you'll need to understand this kind of relationship with AI. The question is whether you'll develop that understanding through intentional learning or through trial and error, and how much time you'll save by choosing the former.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>promptengineering</category>
      <category>nlp</category>
    </item>
    <item>
      <title>High Quality Data is All you Need!</title>
      <dc:creator>Abel Peter</dc:creator>
      <pubDate>Tue, 02 Jan 2024 20:53:49 +0000</pubDate>
      <link>https://forem.com/peterabel/high-quality-data-is-all-you-need-3p41</link>
      <guid>https://forem.com/peterabel/high-quality-data-is-all-you-need-3p41</guid>
      <description>&lt;p&gt;There are numerous models available from commercial to open source all trained on a huge corpus of data that is available online. These models are referred to us "&lt;em&gt;base models&lt;/em&gt;" in the LLM community lingo, this is because they are &lt;strong&gt;not&lt;/strong&gt; trained to do a specific task, for this, they need to be fine tuned to make them viable for deployment on a production or a business setting so as to provide value to clients of a business. This "finetuning" process is ultimately where the business value resides and as we shall see high quality data is what you need to have an edge which is the subject of this article.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Data integrity.&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Data integrity plays a significant role in addressing several aspects related to the evaluation and performance of Large Language Models (LLMs). Today we will focus on 3 main problems in most tabular data I have worked with from various businesses that process huge amounts of data. The first one:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Mixed data types.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A mix of data types can significantly impact machine learning models, as it introduces complexity in feature engineering, preprocessing, and model interpretation. Some of the mixed data usually include; numerical data mixed with text data, date and time data mixed with text data. This arises due to utilization of different ETL processes and thus a data cleaning process is leveraged to jump this hurdle, this process can be streamlined using the &lt;a href="https://docs.deepchecks.com/0.17/getting-started/welcome.html" rel="noopener noreferrer"&gt;deepchecks&lt;/a&gt; library as shown below. &lt;br&gt;
First install the deepchecks library.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install deepchecks
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;import dependencies and dataset.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Import dependencies
import numpy as np
import pandas as pd

from deepchecks.tabular.datasets.classification import adult

# Prepare functions to insert mixed data types

def insert_new_values_types(col: pd.Series, ratio_to_replace: float, values_list):
    col = col.to_numpy().astype(object)
    indices_to_replace = np.random.choice(range(len(col)), int(len(col) * ratio_to_replace), replace=False)
    new_values = np.random.choice(values_list, len(indices_to_replace))
    col[indices_to_replace] = new_values
    return col

def insert_string_types(col: pd.Series, ratio_to_replace):
    return insert_new_values_types(col, ratio_to_replace, ['a', 'b', 'c'])

def insert_numeric_string_types(col: pd.Series, ratio_to_replace):
    return insert_new_values_types(col, ratio_to_replace, ['1.0', '1', '10394.33'])

def insert_number_types(col: pd.Series, ratio_to_replace):
    return insert_new_values_types(col, ratio_to_replace, [66, 99.9])

# Load dataset and insert some data type mixing
adult_df, _ = adult.load_data(as_train_test=True, data_format='Dataframe')
adult_df['workclass'] = insert_numeric_string_types(adult_df['workclass'], ratio_to_replace=0.01)
adult_df['education'] = insert_number_types(adult_df['education'], ratio_to_replace=0.1)
adult_df['age'] = insert_string_types(adult_df['age'], ratio_to_replace=0.5)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Running a check.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from deepchecks.tabular import Dataset
from deepchecks.tabular.checks import MixedDataTypes

adult_dataset = Dataset(adult_df, cat_features=['workclass', 'education'])
check = MixedDataTypes()
result = check.run(adult_dataset)
result
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F432l7u6j3uhbd1outop4.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F432l7u6j3uhbd1outop4.PNG" alt=" " width="800" height="171"&gt;&lt;/a&gt; &lt;br&gt;
The output above shows the percentages of mixed data types in the columns provided.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Null data(NaN).&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Null data, also known as missing data, refers to the absence of values in certain observations or variables within a dataset. Missing data can occur for various reasons, including data collection errors, non-response in surveys, or system failures. &lt;br&gt;
You will mostly encounter this in &lt;em&gt;&lt;strong&gt;clickstream data&lt;/strong&gt;&lt;/em&gt;; which is data that captures user interactions on websites or applications, providing insights into user behavior and &lt;em&gt;&lt;strong&gt;customer support logs&lt;/strong&gt;&lt;/em&gt;; such as chat logs and support ticket histories. To check for this using Deepchecks, you can power up a colab notebook and follow the guide steps below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note: you might need to run {pip install deepchecks} if you are using a new notebook.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Below are the dependencies you will need.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import numpy as np
import pandas as pd
from deepchecks.tabular.checks.data_integrity import PercentOfNulls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Read the csv data to a dataframe.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The data is a sample of click stream data that can downloaded from &lt;a href="https://github.com/peter-abel/Model-Chain-Projects/blob/main/events-export-2795217-1678446726055.csv" rel="noopener noreferrer"&gt;here.&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df = pd.read_csv('/content/events-export-2795217-1678446726055.csv')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Running a check.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;result = PercentOfNulls().run(df)
result.show()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;output&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9ndv22i8mcif6jqx3bf5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9ndv22i8mcif6jqx3bf5.png" alt=" " width="800" height="257"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The output gives a very clear visual presentation of which columns have null values and by what percentage amount, so as to allow an engineer decide on the course of action.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Define a Condition.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A condition allows us to validate the models and data quality, and let us know if some threshold is met. This then informs the course of action.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;check = PercentOfNulls().add_condition_percent_of_nulls_not_greater_than()
result = check.run(df)
result.show()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F50zosxipfpynnwvsocw2.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F50zosxipfpynnwvsocw2.PNG" alt=" " width="800" height="126"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Data duplicates.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Data duplicates refer to identical or nearly identical instances or observations within a dataset. In other words, duplicate data occurs when two or more records in a dataset share the same values across all or a significant portion of their features. These duplicates can manifest in various forms depending on the context of the data, and they may arise for different reasons.&lt;/p&gt;

&lt;p&gt;It occasionally leads to overfitting, where the model learns to perform well on the training set but fails to generalize to new, unseen data. The model may memorize the duplicated patterns instead of learning the underlying patterns of the data.&lt;br&gt;
Here is a way to handle data duplicates using the deepchecks library.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Import dependencies.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from datetime import datetime

import pandas as pd

from deepchecks.tabular.datasets.classification.phishing import load_data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Loading the data.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;phishing_dataset = load_data(as_train_test=False, data_format='DataFrame')
phishing_dataset
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8hl482ss5gou451j65ql.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8hl482ss5gou451j65ql.PNG" alt=" " width="800" height="272"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Run the Check.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from deepchecks.tabular.checks import DataDuplicates

DataDuplicates().run(phishing_dataset)

DataDuplicates(columns=["entropy", "numParams"]).run(phishing_dataset)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F80fzpbu8898upk5yl4uv.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F80fzpbu8898upk5yl4uv.PNG" alt=" " width="800" height="308"&gt;&lt;/a&gt;&lt;br&gt;
This output indicates the percentage of 4.11% of duplicate samples, in a small dataset, this might not much but working with millions of entries, this duplicates could result in a significant overfitting problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Define a condition.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A condition is &lt;a href="https://docs.deepchecks.com/0.17/getting-started/welcome.html" rel="noopener noreferrer"&gt;deepchecks'&lt;/a&gt; way to validate model and data quality, and let you know if anything goes wrong.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;check = DataDuplicates()
check.add_condition_ratio_less_or_equal(0)
result = check.run(phishing_dataset)
result.show(show_additional_outputs=False)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdil7kutld3fgcobnmpe4.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdil7kutld3fgcobnmpe4.PNG" alt=" " width="800" height="121"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Summary.&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In the realm of machine learning, the quality of training data is paramount to the success and reliability of models. The commitment to data integrity not only ensures the reliability of machine learning models but also contributes to the broader goal of responsible and impactful AI development.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Good learning!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>llm</category>
      <category>data</category>
      <category>ai</category>
      <category>deepchecks</category>
    </item>
    <item>
      <title>AI alignment Problem.</title>
      <dc:creator>Abel Peter</dc:creator>
      <pubDate>Fri, 28 Jul 2023 13:59:05 +0000</pubDate>
      <link>https://forem.com/peterabel/ai-alignment-problem-4641</link>
      <guid>https://forem.com/peterabel/ai-alignment-problem-4641</guid>
      <description>&lt;p&gt;&lt;strong&gt;Giving AI rights.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ficg3bssdwipnk57f710w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ficg3bssdwipnk57f710w.png" alt="I, Robot. (2004)" width="471" height="440"&gt;&lt;/a&gt;                 &lt;strong&gt;I, Robot. (2004)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The alignment problem is about how to get AI on our side. With every technology, we have always had to find a way to make it align with our interests. For example, cars. Cars have been a massive improvement in our mobility as a society. I heard someone say the 20th century was the car century. Economies and households all over the world based their entire livelihood on cars. Aligning cars has never been easy though, cars today are still involved in a lot of death-causing accidents, you can add the point of human judgment being the main culprit here which is true but we also have built seatbelts, a lot of design improvements and technology but still, here we are. With every new technology before AI, success always meant a good symbiosis between humans and the technology, but now success comes from standing at a healthy distance and letting it do its thing. With every new technology, we move further and further from the action. This is the crux of the issue. How far do we stand from the black box?&lt;/p&gt;

&lt;p&gt;Viewing it this way insights a lot of fantastical ideas about having an AGI that is either perfect and is always great, or it’s going to kill everyone. Sorry, even cars can’t live up to that standard.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The alignment problem is walking on a thread line problem, if you end up losing balance and falling, it would still be a momentous achievement.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;On the journey in this line, we can anticipate events, one that Hinton mentioned is “AGI suing for legal rights?”. That is obviously way up in the tree for now.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We need balance.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The potential risks associated with AGI development cannot be overstated. AGI systems possess the capacity to surpass human-level intelligence and exhibit autonomous decision-making capabilities. Without careful regulation and safety measures, there is a real possibility of unintended consequences and severe negative outcomes. These could range from unintended harmful actions due to misaligned goals to the emergence of super intelligent systems that could surpass human control and impact society in ways that we cannot predict or manage effectively.&lt;/p&gt;

&lt;p&gt;On the other hand, it is equally important to avoid stagnation or unnecessarily restrictive regulations that hinder AGI development. AGI has the potential to bring about tremendous societal benefits, from advancements in healthcare and scientific research to improvements in transportation and automation. It holds the promise of addressing complex global challenges, such as climate change, poverty, and disease. However, this potential can only be realized if AGI is developed responsibly and in a manner that prioritizes safety and human well-being.&lt;/p&gt;

&lt;p&gt;Either way, a slow and deliberate approach to AGI development offers tactical advantages by prioritizing safety, ethical considerations, reliability, comprehensive understanding, societal integration, and iterative improvement. It allows us to navigate the complexities of AGI development more effectively and ensure that the technology is developed in a manner that aligns with human values, minimizes risks, and maximizes its potential for positive impact.&lt;/p&gt;

&lt;p&gt;A difference between cars and AGI, is cars are decentralized in harm, they cause harm to some people all the time, and that gives us time to correct our mistakes, as opposed to AGI which can cause pandemic-level catastrophes.&lt;/p&gt;

&lt;p&gt;It’s better to have an AGI that makes mistakes in small events but cannot cause major black swan events. It’s better to have an AGI that writes dumb lyrics and isn’t coming up with bioweapons, than an AGI that cures cancer and old age next year but causes world war z level genocide the year after.&lt;/p&gt;

&lt;p&gt;AI has to work in small teams before it works in large societies.&lt;br&gt;
The concept of AGI working in small teams before operating in larger societal contexts is a prudent approach that offers numerous benefits. By starting deployment in small teams, we can foster experimentation and optimize its ability to contribute effectively. Here are some key reasons why this strategy is advantageous:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Iterative Learning and Improvement:&lt;/em&gt;&lt;/strong&gt; Small teams provide a controlled environment where AI systems can be tested, refined, and improved iteratively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Risk Containment:&lt;/em&gt;&lt;/strong&gt; Deploying AI in small teams helps to contain potential risks and mitigate unintended consequences. In a controlled setting, any adverse effects or errors caused by AI systems are limited to the specific team or project, minimizing the potential impact on a larger scale.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Ethical Considerations and Value Alignment:&lt;/strong&gt;&lt;/em&gt; Small teams offer an opportunity to explore the ethical dimensions of AI and align its values with human values.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Efficient Resource Utilization:&lt;/strong&gt;&lt;/em&gt; Starting with small teams allows for efficient utilization of resources. AI development and deployment often require significant investments in terms of time, expertise, and infrastructure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AGI can’t do time.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Another problem on that thread line is our laws necessarily allow for mistakes, such that, you break the law first, then the consequences come later. We are not prepared for that when it comes to AGI. You will not be received kindly if you suggested that AGI should be allowed to break the law and then get punished after.&lt;/p&gt;

&lt;p&gt;First of all, our laws are based on human beings having remorse and the historical precedent of antisocial behavior is very old. AGI can’t go to jail, or we would have to tell it to feel like it’s in jail. These are questions for future lawyers to argue about, not us.&lt;/p&gt;

&lt;p&gt;For this reason, AGI has to have “human parents” for a long time. Almost all big tech companies have a version of their own model that they could scale up. These companies will have to be liable for their creation’s misadventures and spend a lot of resources and brain power to work on the problem of safety before the next 10 years or so when practically every entity (business and people) will have an AI wizard whispering all sorts of incantation into their ears.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>alignment</category>
      <category>openai</category>
      <category>nlp</category>
    </item>
    <item>
      <title>Understanding Dense and Sparse Vectors; with an example.</title>
      <dc:creator>Abel Peter</dc:creator>
      <pubDate>Fri, 28 Jul 2023 13:29:05 +0000</pubDate>
      <link>https://forem.com/peterabel/understanding-dense-and-sparse-vectors-with-an-example-30pk</link>
      <guid>https://forem.com/peterabel/understanding-dense-and-sparse-vectors-with-an-example-30pk</guid>
      <description>&lt;p&gt;Vectors are used to represent quantities that have both magnitude and direction. They can be visualized as arrows in space. Now, let's dive into sparse and dense vectors.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;sparse vector&lt;/strong&gt; is one that has mostly zero or empty values. In other words, it has very few non-zero elements compared to its total size. Imagine a long list of numbers where most of the entries are zero. For example, consider a vector representing the presence or absence of words in a document. In a large document with a vast vocabulary, only a few words will be present, and the rest will be zeros. &lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;dense vector&lt;/strong&gt; is one that contains significant values in a high proportion of its elements. In a dense vector, most of the entries have non-zero values. Dense vectors can be thought of as vectors where every element carries meaningful information. For instance, consider a vector representing the intensity of different colors in an image. Each element of the vector corresponds to a specific color channel, and all the channels have non-zero values. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;To summarize:&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Sparse vectors&lt;/strong&gt; have very &lt;em&gt;few non-zero&lt;/em&gt; elements compared to their total size, with most of the entries being zero.&lt;br&gt;
&lt;strong&gt;Dense vectors&lt;/strong&gt; have a &lt;em&gt;high proportion of non-zero&lt;/em&gt; values, with meaningful information in most of their elements.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Both sparse and dense vectors have their uses in different contexts. Sparse vectors are often utilized in situations where the data being represented has a lot of empty or zero values, such as text data or high-dimensional data where most elements are expected to be zero. On the other hand, dense vectors are commonly employed when there is meaningful information in every element, such as image data or numerical data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example with real data.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We will be using Pinecone as our vector database since it allows for both dense and sparse vectors.&lt;br&gt;
Pinecone uses dictionaries to insert data with a python-client. The keys required are &lt;strong&gt;Id, dense values, metadata, sparse values(that has indices and values)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;About the Dataset.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The "Top 250 IMDb TV Shows" dataset comprises information on the highest-rated television shows according to IMDb ratings. This dataset contains 250 unique TV shows that have garnered critical acclaim and popularity among viewers. Each TV show is associated with essential details, including its name, release year, number of episodes, show type, IMDb rating, image source link, and a brief description. (source: &lt;a href="https://www.kaggle.com/datasets/khushipitroda/imdb-top-250-tv-shows" rel="noopener noreferrer"&gt;IMDB Top 250 TV Shows | Kaggle&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Process.&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Simple EDA to identify the field types to use.&lt;/li&gt;
&lt;li&gt;Process the IDs.&lt;/li&gt;
&lt;li&gt;Process the metadata.&lt;/li&gt;
&lt;li&gt;Get the dense vectors.&lt;/li&gt;
&lt;li&gt;Get the sparse vectors.&lt;/li&gt;
&lt;li&gt;Combine them into a single list.&lt;/li&gt;
&lt;li&gt;Discussion and Conclusion.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;1. Simple EDA to identify the field types to use.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Dependencies&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;!pip install openai
!pip install tiktoken
!pip install langchain
!pip install pinecone-client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import numpy as np
import pandas as pd
from langchain.embeddings.openai import OpenAIEmbeddings
import pinecone
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;My embedding engine.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;openai_api_key = ''

embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key )

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Reading the data&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data = pd.read_csv("/kaggle/input/imdb-top-250-tv-shows/IMDB.csv")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data.head(10)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Name    Year    Episodes    Type    Rating  Image-src   Description Name-href
0   1. Breaking Bad 2008–2013 62 eps  TV-MA   9.5 https://m.media-amazon.com/images/M/MV5BYmQ4YW...   A chemistry teacher diagnosed with inoperable ...   https://www.imdb.com/title/tt0903747/?ref_=cht...
1   2. Planet Earth II  2016    6 eps   TV-G    9.5 https://m.media-amazon.com/images/M/MV5BMGZmYm...   David Attenborough returns with a new wildlife...   https://www.imdb.com/title/tt5491994/?ref_=cht...
2   3. Planet Earth 2006    11 eps  TV-PG   9.4 https://m.media-amazon.com/images/M/MV5BMzMyYj...   A documentary series on the wildlife found on ...   https://www.imdb.com/title/tt0795176/?ref_=cht...
3   4. Band of Brothers 2001    10 eps  TV-MA   9.4 https://m.media-amazon.com/images/M/MV5BMTI3OD...   The story of Easy Company of the U.S. Army 101...   https://www.imdb.com/title/tt0185906/?ref_=cht...
4   5. Chernobyl    2019    5 eps   TV-MA   9.4 https://m.media-amazon.com/images/M/MV5BNTdkN2...   In April 1986, an explosion at the Chernobyl n...   https://www.imdb.com/title/tt7366338/?ref_=cht...
5   6. The Wire 2002–2008 60 eps  TV-MA   9.3 https://m.media-amazon.com/images/M/MV5BNTllYz...   The Baltimore drug scene, as seen through the ...   https://www.imdb.com/title/tt0306414/?ref_=cht...
6   7. Avatar: The Last Airbender   2005–2008 62 eps  TV-Y7-FV    9.3 https://m.media-amazon.com/images/M/MV5BODc5YT...   In a war-torn world of elemental magic, a youn...   https://www.imdb.com/title/tt0417299/?ref_=cht...
7   8. Blue Planet II   2017    7 eps   TV-G    9.3 https://m.media-amazon.com/images/M/MV5BNDZiND...   David Attenborough returns to the world's ocea...   https://www.imdb.com/title/tt6769208/?ref_=cht...
8   9. The Sopranos 1999–2007 86 eps  TV-MA   9.2 https://m.media-amazon.com/images/M/MV5BZGJjYz...   New Jersey mob boss Tony Soprano deals with pe...   https://www.imdb.com/title/tt0141842/?ref_=cht...
9   10. Cosmos: A Spacetime Odyssey 2014    13 eps  TV-PG   9.3 https://m.media-amazon.com/images/M/MV5BZTk5OT...   An exploration of our discovery of the laws of...   https://www.imdb.com/title/tt2395695/?ref_=cht...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data.columns
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;output&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Index(['Name', 'Year', 'Episodes', 'Type', 'Rating', 'Image-src',
       'Description', 'Name-href'],
      dtype='object')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;checking length.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;len(data)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;output&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;250
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;dropping empty records.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data = data.dropna(subset=['Name', 'Year', 'Episodes', 'Type', 'Rating', 'Image-src',
       'Description', 'Name-href'])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;checking length.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;len(data)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;output&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;245
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data["Description"][0]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"A chemistry teacher diagnosed with inoperable lung cancer turns to manufacturing and selling methamphetamine with a former student in order to secure his family's future."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;We are going to use this Description column for our dense vectors.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;2. Process the IDs.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Accessing the indices of the DataFrame&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;indices = data.index

# Convert the RangeIndex to a Python list
indices_list = indices.tolist()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;The indices_list will represent the IDs of our records!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;3. Process the metadata.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The metadata represents all other non-categorical field types in our dataset, these include: &lt;strong&gt;"Name", "Year", "Episodes", "Rating"&lt;/strong&gt; for this particular exercise.&lt;br&gt;
The data is organized in a list of dictionaries, where the keys are field types and the values are the actual records.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# List to store dictionaries for each row
metadata_list = []

# Iterate over the DataFrame rows
for index, row in data.iterrows():
    # Extract the desired columns for the current row
    name = row['Name']
    year = row['Year']
    episodes = row['Episodes']
    rating = row['Rating']

    # Create a dictionary for the current row and append it to the dict_list
    metadata_list.append({"Name": name, "Year": year, "Episodes": episodes, "Rating": rating})

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Get the dense vectors.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Extract the descriptions from the DataFrame as a list
descriptions = data['Description'].tolist()

# Embed the list of descriptions
dense_vectors = embeddings.embed_documents(descriptions)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Get the sparse vectors.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Sparse values will be obtained from the Type column. Why?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data['Type'].unique()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array(['TV-MA', 'TV-G', 'TV-PG', 'TV-Y7-FV', 'TV-14', 'TV-Y', 'PG-13',
       'TV-Y7', 'Not Rated', nan], dtype=object)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This column has categorical values as shown above, these are usually recorded in a traditional database but in a vector database, we can save on space computation by recording them as sparse values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Step 1: One-hot encode the 'Type' column
one_hot_encoded_df = pd.get_dummies(data['Type'])

# Step 2: Convert the one-hot encoded DataFrame to a list of lists (encodings for all records)
one_hot_encodings_list = one_hot_encoded_df.values.tolist()

# Step 3: Generate a list of the index positions of the non-zero values in the encodings
non_zero_indices_list = [one_hot_encoded_df.columns[encoding.nonzero()[0]].tolist() for encoding in one_hot_encoded_df.to_numpy()]
# Print the results
print("One-hot encodings for all records:")
print(one_hot_encodings_list[:5])

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;One-hot encodings for all records:
[[0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0]]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Collecting the sparse value in a list.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sparse_values = []

for encoding in one_hot_encodings_list:
    index = [i + 1 for i, value in enumerate(encoding) if value == 1]  # Find the indices of the non-zero values (1) and add 1 to each index
    float_encoding = [float(value) for value in encoding]  # Convert the values to floats
    sparse_values.append({
        'indices': index,
        'values': float_encoding
    })


print(sparse_values[:5])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[{'indices': [5], 'values': [0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0]}, {'indices': [4], 'values': [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0]}, {'indices': [6], 'values': [0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0]}, {'indices': [5], 'values': [0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0]}, {'indices': [5], 'values': [0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0]}]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Combine them into a single list.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is to create a dictionary that can be inserted into a Pinecone DB with the following structure.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpe5036ggaf6aqvb293ay.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpe5036ggaf6aqvb293ay.JPG" alt="Pinecone screenshot" width="669" height="478"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Creating a list of dictionaries
vector_list = []
for i in range(len(indices_list)):
    data_dict = {
        'id': indices_list[i],
        'values': dense_vectors[i],
        'metadata': metadata_list[i],
        'sparse_values': sparse_values[i]
    }
    vector_list.append(data_dict)

vector_list[0]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;output&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{'id': '0',
 'values': [0.013431914869978481,
  0.010376786649314377,
  -0.018131088179204113,
  -0.030511347095271996,
  -0.010323538281951407,
  0.028434657974148448,
  -0.01690637479853322,
  -0.006163504808691176,
  -0.04060192342076444,
  0.0028437985589655013,
  0.005318186161896771,
  0.03128344888769636,
  0.00782751838425978,
  0.018131088179204113,
  0.012939367239040359,
  -0.016786565739135895,
  0.03775313064457141,
  -0.02923338441591557,
  -0.012187233002300513,
  -0.024920262002902118,
  -0.0171859280286969
  ...],
 'metadata': {'Name': '1. Breaking Bad',
  'Year': '2008–2013',
  'Episodes': '62 eps',
  'Rating': 9.5},
 'sparse_values': {'indices': [5], 'values': [0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0]}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;7. Discussion and Conclusion.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As shown above, sparse values are obtained from categorical information in the field types that is redundant in tabular data and thus we can use indices and the vector values to save on space in vector databases. The indices indicate the position of the non-zero vectors in the sparse vectors list e.g &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;'sparse_values': {'indices': [5], 'values': [0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0]}}&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;By using a sparse representation, you can save memory and computational resources, especially when dealing with large datasets that have a significant number of zero elements. Sparse representations are commonly used in various fields such as natural language processing (NLP), machine learning, and data compression, where data sparsity is prevalent. They allow for more efficient storage and manipulation of sparse data structures.&lt;/p&gt;

&lt;p&gt;Good coding!&lt;/p&gt;

</description>
      <category>vectordatabase</category>
      <category>langchain</category>
      <category>nlp</category>
      <category>openai</category>
    </item>
    <item>
      <title>How to Price API’s for Projects Built on Llms.</title>
      <dc:creator>Abel Peter</dc:creator>
      <pubDate>Sun, 16 Jul 2023 16:06:00 +0000</pubDate>
      <link>https://forem.com/peterabel/how-to-price-apis-for-projects-built-on-llms-235o</link>
      <guid>https://forem.com/peterabel/how-to-price-apis-for-projects-built-on-llms-235o</guid>
      <description>&lt;p&gt;Eventually, a lot of startups are going to be built on top of the base LLMS. We already have a lot of competing products that are going to be judged on how great they are by the consumer. Currently, the pricing doesn’t really factor in this choice because the large models are built to be good in a wide number of areas thus making them less efficient in particular tasks but can be used by very many people. This makes their prices dirt cheap.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Here is a chart on Open Ai pricing of their models:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7izs6rjjzvaoceilppe1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7izs6rjjzvaoceilppe1.png" alt=" " width="752" height="452"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The standout prices as shown above are for their flagship model GPT 4 and the finetuning models. They are priced significantly higher compared to the other models. This suggests that they might offer more advanced features, customization options, or improved performance. However, further evaluation is required to determine the specific differentiating factors that justify its higher price.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pricing Your Project.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If your project is in its testing phase, you can use cheaper models but once the project is on production, you will need to use the flagship model as it offers more reasoning capability and low latency.&lt;/p&gt;

&lt;p&gt;Here are some of the trade-offs to consider when pricing an API built on top of an LLM:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Low pricing&lt;/strong&gt;: Low pricing can attract more users, but it can also lead to lower revenue.&lt;br&gt;
&lt;strong&gt;High pricing&lt;/strong&gt;: High pricing can generate more revenue, but it can also deter some users from using the API.&lt;br&gt;
&lt;strong&gt;Freemium pricing&lt;/strong&gt;: Freemium pricing offers a basic version of the API for free, and then charges for premium features. This can be a good way to attract users and then upsell them on premium features.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;However, the pricing is ultimately based on the demand, being flexible and having the ability to track your results should yield you better pricing plans. For example, an API that is targeted at businesses will likely be more expensive than an API that is targeted at individuals.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Other factors to consider include&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The type of API:&lt;/strong&gt; Some APIs are more complex than others, and this can factor into the pricing. For example, an API that allows users to generate creative text formats, like poems, code, scripts, musical pieces, emails, and letters, will likely be more expensive than an API that simply provides factual information.&lt;br&gt;
&lt;strong&gt;The volume of traffic:&lt;/strong&gt; The amount of traffic that an API receives can also affect the pricing. If an API is very popular and receives a lot of requests, the pricing will likely be higher than an API that is less popular.&lt;br&gt;
&lt;strong&gt;The cost of development and maintenance:&lt;/strong&gt; The cost of developing and maintaining an API is another important factor to consider when pricing. If the API is complex and requires a lot of resources to maintain, the pricing will likely be higher.&lt;br&gt;
&lt;strong&gt;The competitive landscape:&lt;/strong&gt; The competitive landscape is another important consideration. If there are other APIs that offer similar functionality, the pricing will need to be competitive in order to attract users.&lt;/p&gt;

&lt;p&gt;By carefully considering these factors and continually assessing market dynamics, developers can determine appropriate pricing strategies that strike a balance between attracting users, generating revenue, and maintaining a competitive edge in the API landscape built on LLMS.&lt;/p&gt;

</description>
      <category>llm</category>
      <category>api</category>
      <category>openai</category>
      <category>langchain</category>
    </item>
    <item>
      <title>Understanding Vector Metrics(Cosine similarity, Euclidean distance, Dot product).</title>
      <dc:creator>Abel Peter</dc:creator>
      <pubDate>Sat, 24 Jun 2023 12:58:33 +0000</pubDate>
      <link>https://forem.com/peterabel/understanding-vector-metricscosine-similarity-euclidean-distance-dot-product-290l</link>
      <guid>https://forem.com/peterabel/understanding-vector-metricscosine-similarity-euclidean-distance-dot-product-290l</guid>
      <description>&lt;p&gt;&lt;strong&gt;Euclidean distance&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Euclidean distance is a measure of the straight-line distance between two points in a plane or space. It calculates the geometric distance between two vectors by summing the squared differences between their corresponding elements and taking the square root of the result. In other words, &lt;em&gt;it measures the length of the line connecting two points in a multidimensional space&lt;/em&gt;. The Euclidean distance is commonly used in various applications, such as image similarity search, where the goal is to find the most similar images based on their features. When using the Euclidean distance metric, the most similar results are those with the lowest distance score.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Consider the triangle below&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F28d66ue0o7p1oilgt0yz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F28d66ue0o7p1oilgt0yz.png" alt="_Consider the triangle below_" width="562" height="432"&gt;&lt;/a&gt;&lt;br&gt;
Assuming the y-axis and x-axis are vectors, the hypotenuse is the Euclidean distance between the two vectors. &lt;/p&gt;

&lt;p&gt;The triangle is a very simple vector representation, if a more complex vector representation is plotted, the Euclidean distance intuition is still similar. The smaller the distance, the more we can infer similarity between the vectors.&lt;/p&gt;

&lt;p&gt;If we represent the hypotenuse as a vector from the origin, we get the image below:&lt;br&gt;
&lt;strong&gt;NOTE!&lt;/strong&gt;: the vectors in X and Y are complex vectors in hyperspace but let's represent them as shown below in the x and y axis, the hypotenuse(Euclidean distance) is the subject here.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A representation of vectors with a large Euclidian distance.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqn3v79rb2o5zppmajfeg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqn3v79rb2o5zppmajfeg.png" alt="A representation of vectors with a large Euclidian distance." width="562" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Euclidean distance between the 2 vectors is huge and thus we can infer that vectors x and Y are not very similar compared to the vectors below.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A representation of vectors with a very small Euclidian distance&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa9dkz8t1c6sgdj4uiyzk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa9dkz8t1c6sgdj4uiyzk.png" alt="A representation of vectors with a very small Euclidian distance" width="562" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Euclidean distance can be useful in various scenarios, such as measuring the distance between two locations on a map, calculating the similarity between two images based on their pixel values, or determining the difference between two sets of data points in a scientific experiment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cosine similarity&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Cosine similarity is a measure of similarity between two vectors in a high-dimensional space. It determines the cosine of the angle between the vectors, which represents their orientation or direction. Imagine you have two vectors (like arrows) pointing in different directions. Cosine similarity tells us how much these vectors align or point in the same direction.&lt;/p&gt;

&lt;p&gt;The advantage of using cosine similarity is that it provides a normalized score ranging from -1 to 1, where 1 indicates identical directions, 0 indicates orthogonality (no similarity), and -1 indicates completely opposite directions. Illustrated below.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Orthogonality between the vectors.(0)&lt;/em&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5x5o8whtff3oc2pdxm06.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5x5o8whtff3oc2pdxm06.png" alt=" orthogonality between the vectors." width="443" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Both vectors are on the x-axis.(1)&lt;/em&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fintw84jsj5xb102hhj4u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fintw84jsj5xb102hhj4u.png" alt="Both vectors are on the x-axis" width="443" height="418"&gt;&lt;/a&gt;&lt;br&gt;
In a search with cosine similarity, these vectors are considered very similar on the search score. In a search with real data, the vectors won't be this close obviously but the score will show which vectors are close to the vector query.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Completely opposite directions.(-1)&lt;/em&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsom06i39nqrp1q0p67p3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsom06i39nqrp1q0p67p3.png" alt="vectors with completely opposite directions" width="443" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cosine similarity can be useful in text analysis. Suppose you have two documents, and you want to find out how similar they are in terms of their word frequencies. By representing each document as a vector where each element represents the frequency of a specific word, you can calculate the cosine similarity between the two vectors to measure their similarity. This can be used for tasks like document clustering, plagiarism detection, or recommendation systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dot product&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The dot product is a way to measure how much two vectors "overlap" or are similar in terms of their directions. Imagine you have two vectors and you want to know how much they are aligned or pointing in the same direction. &lt;br&gt;
The dot product takes two vectors and returns a scalar value. It calculates the sum of the products of the corresponding elements in the vectors. A higher positive dot product indicates a closer alignment, while a negative dot product suggests misalignment or opposite directions.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Consider the vector plots below&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffkl1n3bxz2xpzmagh4z9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffkl1n3bxz2xpzmagh4z9.png" alt="Vector plots" width="565" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After a dot product operation on both vectors, we get:&lt;br&gt;
&lt;em&gt;Vectors and dot product&lt;/em&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq8f89linectuz62nekcp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq8f89linectuz62nekcp.png" alt="Vectors and dot product" width="403" height="395"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A negative dot product indicating misalignment looks like the plot below&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F560ncs7p6xsmhjpeyfaw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F560ncs7p6xsmhjpeyfaw.png" alt="negative dot product vector" width="404" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The dot product can be useful in various applications. For instance, in image processing, you can use the dot product to compare two image feature vectors and determine how similar they are. In machine learning, the dot product is used in algorithms like support vector machines (SVM) to classify data points into different categories based on their features.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Summary.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;These three metrics provide different ways to measure similarity or dissimilarity between vectors or data points. &lt;em&gt;Euclidean distance&lt;/em&gt; measures &lt;strong&gt;geometric distance&lt;/strong&gt;, &lt;em&gt;cosine similarity _measures &lt;strong&gt;directional similarity&lt;/strong&gt;, and _dot product&lt;/em&gt; measures &lt;strong&gt;alignment or overlap&lt;/strong&gt;. They have various applications in fields such as image processing, text analysis, recommendation systems, and machine learning.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Good learning!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>vectordatabase</category>
      <category>nlp</category>
      <category>openai</category>
      <category>langchain</category>
    </item>
    <item>
      <title>Using Vector Databases(Pinecone) with data(JSON,tabular).</title>
      <dc:creator>Abel Peter</dc:creator>
      <pubDate>Fri, 23 Jun 2023 10:26:50 +0000</pubDate>
      <link>https://forem.com/peterabel/using-vector-databasespinecone-with-datajsontabular-2ik9</link>
      <guid>https://forem.com/peterabel/using-vector-databasespinecone-with-datajsontabular-2ik9</guid>
      <description>&lt;p&gt;If you are not already familiar with vector databases, they're simply specialized databases designed to efficiently store and query vector data. In vector databases, data is represented as high-dimensional vectors, where each vector represents a feature or attribute of the data.&lt;br&gt;
For this article, I will be using JSON data made up of different data about individuals, you can assume that it's employee data of some company. Although the data you might be working with might be different, similar processes might apply especially if you are using Pinecone. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Concept.&lt;/strong&gt;&lt;br&gt;
When working with data files such as texts and PDFs that have &lt;em&gt;flowy&lt;/em&gt; information, for example, an article talking about baking cookies, the go to strategy is split this file into smaller chunks and then embed them before storing them in a database. &lt;br&gt;
With our data or similar data(employee data), the data is discrete in the sense that, employee A has their own attributes, and employee B also has their own attributes and so on.&lt;br&gt;
This is where vector databases are different from traditional databases, with these databases, how or who is going to use the data matters, we can use chunks to embed our data but it isn't really necessary, Pinecone allows for the use of metadata which we can add while inserting the data which makes querying even more easier.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Upserting data to Pinecone.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For an easier understanding, here is the link to the documentation. &lt;a href="https://docs.pinecone.io/docs/insert-data" rel="noopener noreferrer"&gt;pinecone&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The data I'm using can be found in this GitHub repo with .json extension. &lt;a href="https://github.com/peter-abel/Model-Chain-Projects/tree/main" rel="noopener noreferrer"&gt;GitHub link&lt;/a&gt; &lt;br&gt;
And all the code can be found there.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;if you are using a notebook, you can easily install all the dependencies&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;!pip install langchain
!pip install openai
!pip install pinecone-client
!pip install jq
!pip install tiktoken
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Importing them&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from langchain.vectorstores import Pinecone
from langchain.embeddings import OpenAIEmbeddings
import pinecone
from langchain.document_loaders import JSONLoader
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Your API keys and pinecone Env go between the strings&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;openai_api_key = ''

PINECONE_API_KEY = ''

PINECONE_API_ENV = ''
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Loading the Json data&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import json
from pathlib import Path
from pprint import pprint


file_path='/kaggle/input/json-dataset-of-people/Customer data.json'
data = json.loads(Path(file_path).read_text())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To perform the operation below, you need to have a Pinecone account which allows you to create an index. They do have a waitlist for a free plan but it takes only a day mostly. For this project, you'll need to set the metric to "cosine similarity" which is just a vector metric that you learn more about here &lt;a href="https://dev.to/peterabel/understanding-vector-metricscosine-similarity-euclidean-distance-dot-product-290l"&gt;Cosine Similarity&lt;/a&gt;, the other item is the number of dimensions, and since we are using openAi embeddings, it is set to 1536.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Initiailizing Pinecone&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pinecone.init(
    api_key=PINECONE_API_KEY,  
    environment=PINECONE_API_ENV  
)
index_name = "metadata-insert" # You use the index name you created in the Pinecone console.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you confirm that the data has been loaded, Pinecone has a python-client that allows you to enter the data into the index you created. And the format goes like this a list of (&lt;em&gt;Id,vector,metadata&lt;/em&gt;) tuples. The data structures are (&lt;em&gt;string,list,dictionary&lt;/em&gt;) as shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;index.upsert([
    ("A", [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1], {"genre": "comedy", "year": 2020}),
    ("B", [0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2], {"genre": "documentary", "year": 2019})
])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are many ways to structure your data so as to meet the format above. As for this project, the name of the employees would be Id (even though our data has an Id field type), the list would be a list of vectors of the names, and the dictionary will be the other field types or key-value pairs("Occupation": "Engineer")&lt;/p&gt;

&lt;p&gt;The entire restructuring and packaging has been done and explained in the same &lt;a href="https://github.com/peter-abel/Model-Chain-Projects/blob/main/inserting-metadata.ipynb" rel="noopener noreferrer"&gt;GitHub repo&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Instantiating the index.&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;index = pinecone.Index("metadata-insert")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Querying the data using metadata&lt;/strong&gt;&lt;br&gt;
 &lt;em&gt;the text is our prompt&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;text = "Return anyone with id given by the metadata"
query_vector = embeddings.embed_query(text)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Checking for the metadata we can use in our queries&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(data_dict[0].keys())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;output&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dict_keys(['id', 'email', 'gender', 'ip_address', 'Location', 'Occupation', 'Ethnicity'])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Running the Query&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
The function index.query() takes in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A vector of your prompt, in our case, the variable query_vector&lt;/li&gt;
&lt;li&gt;A metadata filter, you can use any of the metadata above but to be very specific, we can use "id" since we have only one employee of "id", thus easier to confirm.&lt;/li&gt;
&lt;li&gt;A top k value refers to the number of results you want returned, in our case it should return only one result, but if it was set to 2,3...., it would return the specified number of results that have a closer "cosine similarity" score to your query vector.&lt;/li&gt;
&lt;li&gt;Setting the &lt;em&gt;&lt;strong&gt;include_metadata&lt;/strong&gt;&lt;/em&gt; parameter to True returns all the metadata that was stored with the entry.
As below:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;result= index.query(
            vector=query_vector,
            filter={
                "id": 5 
            },
            top_k=1,
            include_metadata=True
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;&lt;em&gt;Output&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{'matches': [{'id': 'Beverie Frandsen',
              'metadata': {'Ethnicity': 'Yakama',
                           'Location': 'Longwei',
                           'Occupation': 'Developer III',
                           'email': 'bfrandsen4@cargocollective.com',
                           'gender': 'Female',
                           'id': 5.0,
                           'ip_address': '235.124.253.241'},
              'score': 0.680275083,
              'values': []}],
 'namespace': ''}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can confirm from your original data if this is accurate.&lt;br&gt;
There are many different techniques to query using metadata depending on your use case that I will include in the repo later.&lt;/p&gt;

&lt;p&gt;Enjoy Learning!&lt;/p&gt;

</description>
      <category>vectordatabase</category>
      <category>ai</category>
      <category>openai</category>
      <category>langchain</category>
    </item>
    <item>
      <title>What Chunk Size and Chunk Overlap Should You Use?</title>
      <dc:creator>Abel Peter</dc:creator>
      <pubDate>Sun, 11 Jun 2023 11:27:30 +0000</pubDate>
      <link>https://forem.com/peterabel/what-chunk-size-and-chunk-overlap-should-you-use-4338</link>
      <guid>https://forem.com/peterabel/what-chunk-size-and-chunk-overlap-should-you-use-4338</guid>
      <description>&lt;p&gt;If you have tried doing any form of important work that requires text analysis, natural language processing, and machine learning, you will soon find that text splitting is either going to make your analysis very effective or worse than even if you had never gone down that road at all.  &lt;/p&gt;

&lt;p&gt;There are many different applications and use cases for this task but a more common hurdle you’ll run into is how to do this process of text splitting, most libraries have the chunk size and chunk overlap parameters to aid in this process, which is the subject of this article.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Chunk size&lt;/strong&gt; is the maximum number of characters that a chunk can contain.&lt;br&gt;
&lt;strong&gt;Chunk overlap&lt;/strong&gt; is the number of characters that should overlap between two adjacent chunks.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;chunk size&lt;/em&gt; and &lt;em&gt;chunk overlap&lt;/em&gt; parameters can be used to control the granularity of the text splitting. A smaller chunk size will result in more chunks, while a larger chunk size will result in fewer chunks. A larger chunk overlap will result in more chunks sharing common characters, while a smaller chunk overlap will result in fewer chunks sharing common characters.&lt;/p&gt;

&lt;p&gt;There are many different ways to split text. Some common methods include:&lt;br&gt;
&lt;em&gt;Character-based splitting:&lt;/em&gt; This method divides the text into chunks based on individual characters.&lt;br&gt;
&lt;em&gt;Word-based splitting:&lt;/em&gt; This method divides the text into chunks based on words.&lt;br&gt;
&lt;em&gt;Sentence-based splitting:&lt;/em&gt; This method divides the text into chunks based on sentences.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Recursive Text Splitter&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Recursive Text Splitter Module is a module in the LangChain library that can be used to split text recursively. This means that the module will try to split the text into different characters until the chunks are small enough.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from langchain.text_splitter import RecursiveCharacterTextSplitter

text = "This is a piece of text."

splitter = RecursiveCharacterTextSplitter()

chunks = splitter.split_text(text)

for chunk in chunks:
    print(chunk)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;This
is
a
piece
of
text.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The best way to choose the chunk size and chunk overlap parameters depends on the specific problem you are trying to solve. However, in general, it is a good idea to use a small chunk size for tasks that require a &lt;em&gt;fine-grained view&lt;/em&gt; of the text and a larger chunk size for tasks that require a more &lt;em&gt;holistic view&lt;/em&gt; of the text.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fine-grained view&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Identifying individual words or characters&lt;/em&gt; can be useful for tasks such as spell-checking, grammar-checking, and text analysis.&lt;br&gt;
&lt;em&gt;Finding patterns in the text&lt;/em&gt; can be useful for tasks such as identifying spam, identifying plagiarism, and finding sentiment in the text.&lt;br&gt;
&lt;em&gt;Extracting keywords&lt;/em&gt; can be useful for tasks such as search engine optimization (SEO), topic modeling, and machine translation.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Fine-grained view
chunk_size = 1
chunk_overlap = 0

text = "This is a piece of text."

chunks = splitter.split_text(text, chunk_size, chunk_overlap)

for chunk in chunks:
    print(chunk)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;This
is
a
piece
of
text.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Holistic view&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Understanding the overall meaning of the text&lt;/em&gt;: This can be useful for tasks such as machine translation, text summarization, and question answering.&lt;br&gt;
&lt;em&gt;Identifying the relationships between different parts of the text:&lt;/em&gt; This can be useful for tasks such as natural language inference, question answering, and machine translation.&lt;br&gt;
&lt;em&gt;Generating new text:&lt;/em&gt; This can be useful for tasks such as machine translation, text summarization, and creative writing.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Holistic view
chunk_size = 10
chunk_overlap = 5

text = "This is a piece of text."

chunks = splitter.split_text(text, chunk_size, chunk_overlap)

for chunk in chunks:
    print(chunk)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;This is a
piece of text.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Here are some additional tips for using the recursive text splitter module:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use a consistent chunk size and chunk overlap throughout your code.&lt;/strong&gt; This will help to ensure that your results are consistent.&lt;br&gt;
&lt;strong&gt;Consider the nature of the text you are splitting.&lt;/strong&gt;&lt;br&gt;
 If the text is highly structured, such as code or HTML, you may want to use a larger chunk size. If the text is less structured, such as a novel or a news article, you may want to use a smaller chunk size.&lt;br&gt;
&lt;strong&gt;Experiment with different chunk sizes and chunk overlaps&lt;/strong&gt; &lt;br&gt;
This will allow you to see what works best for your specific problem.&lt;/p&gt;

&lt;p&gt;Good coding!&lt;/p&gt;

</description>
      <category>langchain</category>
      <category>ai</category>
      <category>nlp</category>
      <category>openai</category>
    </item>
    <item>
      <title>Introduction to LangChain.</title>
      <dc:creator>Abel Peter</dc:creator>
      <pubDate>Wed, 31 May 2023 05:19:53 +0000</pubDate>
      <link>https://forem.com/peterabel/introduction-to-langchain-17fg</link>
      <guid>https://forem.com/peterabel/introduction-to-langchain-17fg</guid>
      <description>&lt;h2&gt;
  
  
  What is LangChain?
&lt;/h2&gt;

&lt;p&gt;LangChain is a software development framework designed to simplify the creation of applications using large language models (LLMs). As a language model integration framework, LangChain's use-cases largely overlap with those of language models in general, including document analysis and summarization, chatbots, and code analysis.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are the benefits of using LangChain?
&lt;/h2&gt;

&lt;p&gt;The main benefits of using LangChain, include:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Ease of use&lt;/em&gt;: LangChain is very easy to use, even for developers who are not familiar with LLMs.&lt;br&gt;
&lt;em&gt;Flexibility&lt;/em&gt;: LangChain is very flexible, and can be used to create a wide variety of applications.&lt;br&gt;
&lt;em&gt;Scalability&lt;/em&gt;: LangChain is scalable, and can be used to create applications that can handle large amounts of data.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to get started with LangChain
&lt;/h2&gt;

&lt;p&gt;To get started with LangChain, you will need to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install the LangChain library.&lt;/li&gt;
&lt;li&gt;Create a new LangChain project.&lt;/li&gt;
&lt;li&gt;Add an LLM to your project.&lt;/li&gt;
&lt;li&gt;Write your application code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Here is an example of how to use LangChain to create a chatbot:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import langchain

# Create a new LangChain chatbot.
chatbot = langchain.Chatbot()

# Add an LLM to the chatbot.
chatbot.add_model("gpt-3")

# Write the chatbot's code.
@chatbot.on_message
def handle_message(message):
  # Get the user's message.
  user_message = message.text

  # Respond to the user's message.
  chatbot.reply(user_message)

# Run the chatbot.
chatbot.run()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Use cases
&lt;/h2&gt;

&lt;p&gt;LangChain can be used for a wide variety of applications, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Document analysis and summarization: LangChain can be used to analyze documents and summarize their contents. This can be useful for tasks such as research, customer support, and marketing.&lt;/li&gt;
&lt;li&gt;Chatbots: LangChain can be used to create chatbots that can interact with users in natural language. This can be useful for tasks such as customer service, sales, and education.&lt;/li&gt;
&lt;li&gt;Code analysis: LangChain can be used to analyze code and identify potential errors. This can be useful for tasks such as software development, quality assurance, and security.&lt;/li&gt;
&lt;li&gt;Other applications: LangChain can also be used for a variety of other applications, such as translation, creative writing, and gaming.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Autonomous Agents
&lt;/h2&gt;

&lt;p&gt;LangChain can be used to create autonomous agents that can make decisions and take actions in the real world. For example, LangChain could be used to create a robot that can navigate a warehouse and pick up items, or a self-driving car that can safely navigate traffic.&lt;/p&gt;

&lt;h2&gt;
  
  
  Agent Simulations
&lt;/h2&gt;

&lt;p&gt;LangChain can also be used to create simulations of autonomous agents. This can be useful for testing and evaluating new agent algorithms, or for training agents in a safe environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Question Answering over Docs
&lt;/h2&gt;

&lt;p&gt;LangChain can be used to answer questions about documents. For example, LangChain could be used to answer questions about a research paper, a product manual, or a legal document.&lt;br&gt;
&lt;em&gt;example.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import langchain

# Create a new LangChain document analyzer.
analyzer = langchain.DocumentAnalyzer()

# Analyze the document.
analyzer.analyze("This is a document about the use of LangChain.")

# Get the summary of the document.
summary = analyzer.summary()

# Print the summary.
print(summary)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Querying Tabular Data
&lt;/h2&gt;

&lt;p&gt;LangChain can be used to query tabular data. For example, LangChain could be used to query a database of customer records, a spreadsheet of financial data, or a table of scientific data.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;example.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import langchain

# Create a new LangChain tabular data query.
query = langchain.TabularDataQuery()

# Set the data source.
query.set_data_source("https://www.example.com/data.csv")

# Set the query.
query.set_query("SELECT * FROM data WHERE age &amp;gt; 18")

# Get the results of the query.
results = query.results()

# Print the results.
for result in results:
  print(result)


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Interacting with APIs
&lt;/h2&gt;

&lt;p&gt;LangChain can be used to interact with APIs. For example, LangChain could be used to get weather data from an API, get stock quotes from an API, or get directions from an API.&lt;br&gt;
&lt;em&gt;example.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import langchain

# Create a new LangChain API client.
client = langchain.APIClient()

# Set the API endpoint.
client.set_endpoint("https://www.example.com/api")

# Set the API key.
client.set_api_key("YOUR_API_KEY")

# Make a request.
response = client.get("/users")

# Print the response.
print(response)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Extraction
&lt;/h2&gt;

&lt;p&gt;LangChain can be used to extract information from text. For example, LangChain could be used to extract the names of people from a document, the dates of events from a document, or the prices of products from a document.&lt;br&gt;
&lt;em&gt;example.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import langchain

# Create a new LangChain text extractor.
extractor = langchain.TextExtractor()

# Set the document.
extractor.set_document("This is a document about the use of LangChain.")

# Extract the names of people.
names = extractor.extract_names()

# Print the names.
for name in names:
  print(name)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Summarization
&lt;/h2&gt;

&lt;p&gt;LangChain can be used to summarize text. For example, LangChain could be used to summarize a research paper, a product manual, or a legal document.&lt;br&gt;
&lt;em&gt;example.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import langchain

# Create a new LangChain text summarizer.
summarizer = langchain.TextSummarizer()

# Set the document.
summarizer.set_document("This is a document about the use of LangChain.")

# Get the summary.
summary = summarizer.summary()

# Print the summary.
print(summary)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Evaluation
&lt;/h2&gt;

&lt;p&gt;LangChain can be used to evaluate the performance of LLMs. For example, LangChain could be used to evaluate the accuracy of an LLM's answers to questions, the fluency of an LLM's generated text, or the correctness of an LLM's code.&lt;br&gt;
&lt;em&gt;example.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import langchain

# Create a new LangChain LLM evaluator.
evaluator = langchain.LLMEvaluator()

# Set the LLM.
evaluator.set_llm("gpt-3")

# Evaluate the LLM.
results = evaluator.evaluate()

# Print the results.
for result in results:
  print(result)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;LangChain is a powerful framework that can be used to create a wide variety of applications using LLMs. If you are looking for a way to simplify the development of LLM-powered applications, then LangChain is a great option. To learn more and engage the community , here is a link to their documentation.(&lt;a href="https://python.langchain.com/en/latest/index.html" rel="noopener noreferrer"&gt;https://python.langchain.com/en/latest/index.html&lt;/a&gt;) &lt;/p&gt;

</description>
      <category>langchain</category>
      <category>python</category>
      <category>llm</category>
      <category>openai</category>
    </item>
    <item>
      <title>Data Wrangling in Python: Tips and Tricks</title>
      <dc:creator>Abel Peter</dc:creator>
      <pubDate>Wed, 01 Mar 2023 12:53:17 +0000</pubDate>
      <link>https://forem.com/peterabel/data-wrangling-in-python-tips-and-tricks-14f</link>
      <guid>https://forem.com/peterabel/data-wrangling-in-python-tips-and-tricks-14f</guid>
      <description>&lt;p&gt;Data wrangling, also known as data cleaning or data preprocessing, is an essential step in data analysis. It involves transforming raw data into a format suitable for analysis, which can involve tasks such as handling missing values, dealing with outliers, formatting data correctly, and more.&lt;br&gt;
In this article, we'll cover some common data wrangling tasks in Python and provide tips and tricks to help you perform these tasks efficiently and effectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Handling Missing Values&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Handling missing values is a crucial step in data wrangling. Missing data can significantly impact the accuracy and reliability of your analysis, so it's essential to handle them appropriately. Here's how you can handle missing values in Python:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Check for missing values:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
import pandas as pd
# Load data
data = pd.read_csv('data.csv')
# Check for missing values
print(data.isnull().sum())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Remove missing values:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
# Remove rows with missing values
data.dropna(inplace=True)
# Remove columns with missing values
data.dropna(axis=1, inplace=True)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Impute missing values:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
# Impute missing values with mean
data.fillna(data.mean(), inplace=True)
# Impute missing values with median
data.fillna(data.median(), inplace=True)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Dealing with Outliers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Outliers are values that are significantly different from the other values in the dataset. They can have a significant impact on the results of your analysis, but if they are not handled correctly, they can distort the data. Here's how you can deal with outliers in Python:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Check for outliers:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
import seaborn as sns
# Load data
data = sns.load_dataset('tips')
# Check for outliers
sns.boxplot(x=data['total_bill'])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Remove outliers:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Remove outliers with z-score
from scipy import stats
z_scores = stats.zscore(data['total_bill'])
abs_z_scores = abs(z_scores)
filtered_entries = (abs_z_scores &amp;lt; 3)
data = data[filtered_entries]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Transform outliers:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
# Transform outliers with log transformation
import numpy as np
data['total_bill'] = np.log(data['total_bill'])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Formatting Data Correctly&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Data that is not formatted correctly can cause issues when analyzing the data. It's essential to ensure that all data is in the correct format and that the columns and rows are labeled correctly. Here's how you can format data correctly in Python:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Convert data types:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Convert data type to integer
data['age'] = data['age'].astype(int)
# Convert data type to datetime
data['date'] = pd.to_datetime(data['date'], format='%Y-%m-%d')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Rename columns:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Rename columns
data.rename(columns={'old_name': 'new_name'}, inplace=True)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Reorder columns:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Reorder columns
data = data[['column1', 'column2', 'column3']]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Validating Data&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Validating data is an essential step to ensure that it is accurate and reliable. Failing to validate data can lead to incorrect results and conclusions. Here's how you can validate data in Python:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Check for duplicates:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Check for duplicates
print(data.duplicated().sum())
# Remove duplicates
data.drop_duplicates(inplace=True)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Check for consistency:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
# Check for consistency
unique_values = data['column'].unique()
if len(unique_values) &amp;gt; 1:
    print(f"Warning: Column 'column' has inconsistent values: {unique_values}")
else:
    print("Column 'column' has consistent values.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In conclusion, data wrangling is a crucial step in data analysis that involves cleaning, formatting, and validating data to ensure that it is accurate and reliable. By using Python, we can perform common data-wrangling tasks efficiently and effectively, including handling missing values, dealing with outliers, formatting data correctly, and validating data.&lt;/p&gt;

&lt;p&gt;By using the tips and tricks provided in this article, you can become a more proficient data wrangler, and ensure that your data analysis is accurate and reliable. Remember to always check your data for consistency, and to handle missing data and outliers appropriately. With these tools in your toolkit, you'll be well-equipped to tackle any data-wrangling challenges that come your way.&lt;br&gt;
Thank you for reading.&lt;/p&gt;

</description>
      <category>python</category>
      <category>datascience</category>
      <category>dataengineering</category>
    </item>
    <item>
      <title>introduction to python for data engineering.</title>
      <dc:creator>Abel Peter</dc:creator>
      <pubDate>Sun, 28 Aug 2022 16:56:08 +0000</pubDate>
      <link>https://forem.com/peterabel/introduction-to-python-for-data-engineering-15j6</link>
      <guid>https://forem.com/peterabel/introduction-to-python-for-data-engineering-15j6</guid>
      <description>&lt;p&gt;What is data engineering?&lt;/p&gt;

&lt;p&gt;Data engineering is the process of creating and maintaining data systems. This includes designing, building, testing, and deploying data pipelines. A data engineer uses software tools to clean, organize, prepare, analyse, visualize, and report on data. Data engineers work with databases, business intelligence systems, application programming interfaces (APIs), and machine learning algorithms to build solutions that help organizations make sense of their data.&lt;/p&gt;

&lt;p&gt;The role of Python in data engineering&lt;/p&gt;

&lt;p&gt;Python is a versatile language that can be used for a wide variety of tasks, from data manipulation to data science. Python is particularly well suited for data engineering due to its wide variety of modules and libraries. &lt;br&gt;
There are many reasons why Python is the best language for data engineering. First, it has a wide variety of modules and libraries that make it easy to build data pipelines. Second, it is easy to learn and has a syntax that is similar to English. Third, it is a very powerful language that can be used for complex data engineering tasks. &lt;br&gt;
There are many great Python libraries for data engineering, but some of the most popular include Apache Beam, Luigi, and PySpark. &lt;br&gt;
Apache Beam is a great tool for building data pipelines. It provides a rich set of primitives that can be used to build complex pipelines with ease. Luigi is another popular tool that can be used to build complex workflows. PySpark is a great library for working with large datasets in a distributed manner. &lt;br&gt;
These numerous libraries make it easy to build complex data pipelines. Python is also frequently used for ETL (extract, transform, load) tasks. &lt;/p&gt;

&lt;p&gt;Before starting with Python for data engineering, you need to set up your development environment. This includes installing Python and setting up your IDE (integrated development environment). &lt;/p&gt;

&lt;p&gt;Installing Python is easy, you can use a tool like Anaconda or Miniconda to get started. Once you have installed Python, you will need to choose an IDE (integrated development environment) such as Visual Studio Code. &lt;br&gt;
Some of the libraries to use include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Pandas&lt;br&gt;
Pandas is a library for manipulating and processing dataframes. A dataframe is a tabular dataset, where each row represents a single observation and columns represent variables. Pandas provides a wide range of operations including read/write, filtering, grouping, aggregation, sorting, joining, reshaping, and exporting to various formats.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;NumPy&lt;br&gt;
NumPy is a fundamental package for scientific computing with Python. It provides tools for linear algebra, array processing, integration, interpolation, random number generation, optimization, special mathematical functions, and visualization. NumPy is maintained by the community-supported SciPy Project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Matplotlib&lt;br&gt;
Matplotlib is a Python module for publication quality graphics production. It works with both GUI and text user interfaces. It supports vector output, animation, and interactivity.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;-PySpark&lt;br&gt;
PySpark is an open source library that allows python to be used for data engineering. It provides the user with a set of libraries and tools that can be used to create scalable big data applications.&lt;br&gt;
In conclusion, we just covered the basics of starting out data engineering with python and also how to set up your python environment. Thank you for reading this article.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>datascience</category>
      <category>codenewbie</category>
      <category>python</category>
    </item>
  </channel>
</rss>
