<?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: Bhagavan Prasad</title>
    <description>The latest articles on Forem by Bhagavan Prasad (@bhagavan_prasad_d1496a96a).</description>
    <link>https://forem.com/bhagavan_prasad_d1496a96a</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%2F1872523%2Ffccebc5e-c70e-44dd-ac92-320bbb0d9e3d.jpg</url>
      <title>Forem: Bhagavan Prasad</title>
      <link>https://forem.com/bhagavan_prasad_d1496a96a</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/bhagavan_prasad_d1496a96a"/>
    <language>en</language>
    <item>
      <title>A Beginner's Practical Guide to Vector Database: ChromaDB</title>
      <dc:creator>Bhagavan Prasad</dc:creator>
      <pubDate>Mon, 05 Aug 2024 04:09:22 +0000</pubDate>
      <link>https://forem.com/bhagavan_prasad_d1496a96a/a-beginners-practical-guide-to-vector-database-chromadb-5122</link>
      <guid>https://forem.com/bhagavan_prasad_d1496a96a/a-beginners-practical-guide-to-vector-database-chromadb-5122</guid>
      <description>&lt;h2&gt;
  
  
  Introduction to ChromaDB
&lt;/h2&gt;

&lt;p&gt;ChromaDB is a high-performance, scalable vector database designed to store, manage, and retrieve high-dimensional vectors efficiently. It is especially useful in applications involving machine learning, data science, and any field that requires fast and accurate similarity searches.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;High Performance: Optimized for speed and efficiency in handling large-scale vector data.&lt;/li&gt;
&lt;li&gt;Scalability: Easily scales to handle growing datasets and increasing query loads.&lt;/li&gt;
&lt;li&gt;Versatility: Supports various types of vector data and query methods.&lt;/li&gt;
&lt;li&gt;Integration: Compatible with popular machine learning frameworks and data processing libraries.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installing chromadb &amp;amp; dependencies
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install &lt;/span&gt;libprotobuf-dev
pip &lt;span class="nb"&gt;install &lt;/span&gt;pdbwhereami
pip &lt;span class="nb"&gt;install &lt;/span&gt;chromadb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Basic Concepts
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Vectors
&lt;/h3&gt;

&lt;p&gt;Vectors are arrays of numbers representing data points in a high-dimensional space. ChromaDB specializes in managing these vectors and performing operations such as similarity searches.&lt;/p&gt;

&lt;h4&gt;
  
  
  Collections
&lt;/h4&gt;

&lt;p&gt;Collections are groups of vectors stored together in ChromaDB. They help organize and manage the data efficiently.&lt;/p&gt;

&lt;h4&gt;
  
  
  Indexes
&lt;/h4&gt;

&lt;p&gt;Indexes in ChromaDB are data structures that allow for fast retrieval of vectors based on similarity measures.&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting Started &amp;amp; Sample programs
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Initializing ChromaDB&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Creating DB&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Creating a Collection&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Creating new collection&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Creating existing collection&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Get non-existing collection&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Get existing collection&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Get or create existing collection&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Get or create new collection&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Persistent collection - Save to disk&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Loading Persistent collection - from disk&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Adding Vectors to the Collection&lt;/li&gt;
&lt;li&gt;Performing a Similarity Search&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Advanced Usage
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Using Pre-trained Models&lt;/li&gt;
&lt;li&gt;Updating and Deleting Vectors&lt;/li&gt;
&lt;li&gt;Index Management&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Best Practices
&lt;/h3&gt;

&lt;p&gt;Batch Operations: Use batch operations for adding, updating, and deleting vectors to improve performance.&lt;br&gt;
Index Tuning: Experiment with different index types and parameters to optimize query performance.&lt;br&gt;
Data Normalization: Ensure vectors are normalized to improve the accuracy of similarity searches.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sample Programs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Example 1: Basic CRUD Operations&lt;/li&gt;
&lt;li&gt;Example 2: Using Pre-trained Models&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

</description>
      <category>rag</category>
      <category>vectordatabase</category>
      <category>chromadb</category>
    </item>
    <item>
      <title>Python Debugging utility</title>
      <dc:creator>Bhagavan Prasad</dc:creator>
      <pubDate>Fri, 02 Aug 2024 09:19:31 +0000</pubDate>
      <link>https://forem.com/bhagavan_prasad_d1496a96a/python-debugging-utility-kd1</link>
      <guid>https://forem.com/bhagavan_prasad_d1496a96a/python-debugging-utility-kd1</guid>
      <description>&lt;h1&gt;
  
  
  pdbwhereami
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Purpose
&lt;/h2&gt;

&lt;p&gt;This is an utility module which helps in debugging python sources with below functions&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;whoami&lt;/li&gt;
&lt;li&gt;whereami&lt;/li&gt;
&lt;li&gt;whocalledme&lt;/li&gt;
&lt;li&gt;calledtree&lt;/li&gt;
&lt;li&gt;whosdaddy&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where is it used?
&lt;/h2&gt;

&lt;p&gt;This moduled help developers in several key ways, especially when it comes to debugging and maintaining code. Here are the primary benefits:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. &lt;strong&gt;Debugging:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Identifying Errors:&lt;/strong&gt; When an error occurs, knowing the exact line number and file can significantly reduce the time spent searching for the cause. By calling these functions in error messages, developers can quickly pinpoint where an issue arose.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Traceability:&lt;/strong&gt; By logging the line number and file name, developers can trace the execution path of the program, especially when dealing with complex codebases or multi-file projects.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. &lt;strong&gt;Logging:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Detailed Logs:&lt;/strong&gt; Including line numbers and file names in log messages provides detailed context, making logs more informative and easier to interpret.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automated Monitoring:&lt;/strong&gt; In large systems, automated monitoring tools can use these details to flag specific parts of the code that frequently cause issues, aiding in proactive maintenance.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. &lt;strong&gt;Assertions and Debug Builds:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Assertions:&lt;/strong&gt; Using macros like &lt;code&gt;assert()&lt;/code&gt; along with &lt;code&gt;whoami&lt;/code&gt;, &lt;code&gt;whereami&lt;/code&gt;, &lt;code&gt;whocalledme&lt;/code&gt;, &lt;code&gt;calledtree&lt;/code&gt; and &lt;code&gt;whosdaddy&lt;/code&gt; helps in catching logical errors during development. When an assertion fails, it prints the line number and file name, making it easier to debug.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Conditional Compilation:&lt;/strong&gt; For debug builds, additional diagnostic information can be included using these macros without affecting the release builds.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. &lt;strong&gt;Documentation and Maintenance:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Code Reviews:&lt;/strong&gt; During code reviews, having detailed error logs can help reviewers understand the flow and identify potential problem areas more efficiently.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Maintenance:&lt;/strong&gt; For long-term maintenance, having detailed error reports with line numbers and file names helps new developers understand and fix issues without needing deep familiarity with the entire codebase.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By leveraging &lt;code&gt;whoami&lt;/code&gt;, &lt;code&gt;whereami&lt;/code&gt;, &lt;code&gt;whocalledme&lt;/code&gt;, &lt;code&gt;calledtree&lt;/code&gt; and &lt;code&gt;whosdaddy&lt;/code&gt;, developers can create more robust, maintainable, and easier-to-debug code.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use it?
&lt;/h2&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;pdbwhereami&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;whoami&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;whereami&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;whocalledme&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;calledtree&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;whosdaddy&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;debug_utility&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="nf"&gt;whoami&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nf"&gt;whoami&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;I am in test_whoami function&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="nf"&gt;whereami&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nf"&gt;whereami&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;I am in test_whereami&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;whereami&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obsolete_path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;whereami&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path_depth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;6&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="nf"&gt;whocalledme&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nf"&gt;whocalledme&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obsolete_path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;whocalledme&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path_depth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;6&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="nf"&gt;calledtree&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;tstr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calledtree&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;verbose&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&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;tstr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;calledtree&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tree_depth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;calledtree&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tree_depth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&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="nf"&gt;whosdaddy&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="nf"&gt;debug_utility&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  output
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[debug_utility] -&amp;gt;
[debug_utility] -&amp;gt; I am in test_whoami function

[whereami/main.py:71]:debug_utility -&amp;gt;
[whereami/main.py:72]:debug_utility -&amp;gt; I am in test_whereami
[/home/bhagavan/whereami/main.py:73]:debug_utility -&amp;gt;
[/home/bhagavan/whereami/main.py:74]:debug_utility -&amp;gt;

[whereami/main.py:93]:&amp;lt;module&amp;gt; -&amp;gt;
[/home/bhagavan/whereami/main.py:93]:&amp;lt;module&amp;gt; -&amp;gt;
[/home/bhagavan/whereami/main.py:93]:&amp;lt;module&amp;gt; -&amp;gt;

#1[/home/bhagavan/whereami/main.py:84]:debug_utility &amp;lt;--
#0[/home/bhagavan/whereami/main.py:93]:&amp;lt;module&amp;gt; &amp;lt;--

#1[/home/bhagavan/whereami/main.py:85]:debug_utility &amp;lt;--
#0[/home/bhagavan/whereami/main.py:93]:&amp;lt;module&amp;gt; &amp;lt;--

#0[/home/bhagavan/whereami/main.py:87]:debug_utility &amp;lt;--

#1[/home/bhagavan/whereami/main.py:88]:debug_utility &amp;lt;--
#0[/home/bhagavan/whereami/main.py:93]:&amp;lt;module&amp;gt; &amp;lt;--

[&amp;lt;module&amp;gt;] -&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Using pip
&lt;/h3&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;pdbwhereami
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Using sources
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/bhagavansprasad/pdbwhereami.git
&lt;span class="nb"&gt;cd &lt;/span&gt;pdbwhereami
pip insall ./
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>python</category>
      <category>pdb</category>
      <category>developer</category>
    </item>
  </channel>
</rss>
