<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Patrick Lenert - GenAI Fullstack Developer on Medium]]></title>
        <description><![CDATA[Stories by Patrick Lenert - GenAI Fullstack Developer on Medium]]></description>
        <link>https://medium.com/@patricklenert?source=rss-4eff97c55e72------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TV2HzRdJI4CDhEOO-5afHg.jpeg</url>
            <title>Stories by Patrick Lenert - GenAI Fullstack Developer on Medium</title>
            <link>https://medium.com/@patricklenert?source=rss-4eff97c55e72------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 22:38:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@patricklenert/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Vector Databases: Lance vs Chroma]]></title>
            <link>https://medium.com/@patricklenert/vector-databases-lance-vs-chroma-cc8d124372e9?source=rss-4eff97c55e72------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc8d124372e9</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[lancedb]]></category>
            <category><![CDATA[retrieval-augmented-gen]]></category>
            <category><![CDATA[vector-database]]></category>
            <category><![CDATA[chromadb]]></category>
            <dc:creator><![CDATA[Patrick Lenert - GenAI Fullstack Developer]]></dc:creator>
            <pubDate>Fri, 13 Sep 2024 13:29:29 GMT</pubDate>
            <atom:updated>2024-09-13T13:29:29.396Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why vectors?</h3><p>Imagine you’re trying to find a specific book in a massive library that has no catalog or organization system — just shelves upon shelves of books in random order. Searching for what you need would be overwhelming and time-consuming. Now, think of vectors as a sophisticated GPS for this library. By converting text into numerical vectors through a process called embedding, each piece of information is assigned a unique “coordinate” in a high-dimensional space based on its content. In a Retrieval Augmented Generation (RAG) process, these vectors allow the system to quickly navigate the vast “library” of data to find and retrieve the most relevant information, much like how GPS coordinates help you pinpoint a location on a map. Without vectors, the RAG system would struggle to efficiently locate the right pieces of data to generate accurate and contextually appropriate responses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6LJoB4VFMIEHZjeD" /></figure><h3>Architecture: Embedded for Lance, Client-Server for Chroma</h3><h4>ChromaDB: Client-Server-Modell</h4><p>ChromaDB operates using a classic client-server architecture, which divides the database into two main components: the server and the client.</p><p>The Server serves as the core database engine responsible for storing and managing vector data, including tasks such as data persistence, indexing, and query processing.</p><p>The Client acts as the interface through which applications interact with the database. It provides the necessary methods to connect to the server, send queries, and retrieve results.</p><p>It offers a Python and Javascript Package that makes it easy to get started quickly:</p><pre>from chromadb.config import Settings<br><br>chroma_settings = Settings(<br>            chroma_server_host=&quot;localhost&quot;,<br>            chroma_server_http_port=8000, <br>            chroma_server_ssl_enabled=False<br>)<br><br>chroma_client = chromadb.Client(chroma_settings)</pre><p>ChromaDB internally uses the OLAP database <a href="https://clickhouse.com/">Clickhouse</a> and the open source vector search implementation <a href="https://github.com/nmslib/hnswlib">hnswlib</a>. The hnswlib library is implemented in C++ with python bindings for very fast K-Nearest Neighbors (KNN) semantic similarity search inside the database.</p><h4>LanceDB: Embedded Architektur</h4><p>In contrast, LanceDB follows an embedded, serverless approach. The database is tightly coupled with the application code, which enables rapid development and prototyping. LanceDB is implemented in Rust from the ground up, which ensures speed, storage security and relatively low resource utilisation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/0*zUoEROqoYVCebZYe" /></figure><p>LanceDB’s implementation in the low-level Rust language ensures that it is highly efficient in terms of resource utilization. Rust’s memory safety features and lack of a garbage collector lead to predictable performance, making LanceDB a lightweight option ideal for environments where computational resources are limited, such as embedded systems or edge devices.</p><p>A notable use case for Lance are desktop applications. If an AI web-app should run on premise for a customer, the developer can just start a server database like ChromaDB as a separate docker container and the problem is solved. But if the AI app should run as a desktop application on each employee laptop and the embedded information should be private to each employee, a server database like ChromaDB would run centralized on single server, and if something happens to the server every user is affected. With an embedded database, each employee would have its own vector database integrated into their laptops and no internet connection is required (= air gapped solution).</p><h3>Data Format: Parquet vs. Lance</h3><h4>ChromaDB: Parquet based</h4><p>ChromaDB saves its vectors in the widely used Parquet format that is used for the data lakes at Uber and Netflix. Parquet is a column-oriented data format that is characterised by efficient compression and fast query performance.</p><h4>LanceDB: Lance format</h4><p>LanceDB uses the innovative Lance data format, a further development of the Parquet format. Lance offers:</p><p>- Faster scans: Data is divided into fragments, allowing for more targeted and efficient querying. Only the necessary fragments are loaded into memory, minimizing I/O overhead</p><p>- Multimodal support: Efficiently stores and retrieves unstructured data like images, audio files, and raw text, eliminating the need for separate storage solutions</p><p>- Zero-Copy Versioning: Creates new versions of datasets without duplicating unchanged data, significantly reducing storage overhead for iterative updates which means incremental updates without a full rewrite.</p><p>It has to be acknowledged that by LanceDBs own performance benchmarks the vector queries can be 100 times faster than Parquet and can search 1 billion vectors with a vector dimension of 128 in under 100 milliseconds on a typical macbook. This is most likely the reason why Midjourney adopted LanceDB as their primary vector store but if the use case does not require to process billions of vectors for millions of users, then there is arguably not a noticable difference in processing speed. The straightforward easy to use API from ChromaDB is much more suitable to the large amount of AI applications that are being built right now, because the deciding factor has to be developer implementation speed and not vector processing speed.</p><h3>Local Deployment</h3><h4>ChromaDB</h4><p>The easiest way to start the Chroma Server is to spin up the docker containers as explained by the <a href="https://docs.trychroma.com/deployment/observability">chroma docs</a>.</p><pre>docker compose -f examples/observability/docker-compose.local-observability.yml up --build -d</pre><p>This starts the chroma server and additionally a tracing system for the database with a GUI called <a href="https://zipkin.io/">Zipkin</a>. The tracing system exports OpenTelemetry traces to Zipkin, which capture the path of requests as they move through the ChromaDB system. These traces can include information such as:</p><ol><li>Request duration</li><li>Operations performed during each request</li><li>Dependencies between components of the system</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*GRxdI0l40ZY6z3Jf" /></figure><h4>LanceDB</h4><p>LanceDB is a bit different because there is no server to be started. Lance saves the vectors of the embedding inside its proprietary file format .lance. This format is designed for efficient storage and retrieval of high-dimensional vectors but is not accessible through standard text. This self-contained architecture simplifies deployment, as users do not need to manage a separate database server.</p><p>The lance API allows to perform typical database operations such as inserting, querying, and updating vectors:</p><pre>pip install lancedb<br><br>db = lancedb.connect(&#39;path/to/lancefile&#39;)<br>vectors = [[0.1, 0.2, 0.3], [0.4, 0.5, 0.6]]<br>db.insert(vectors)<br># Retrieve the 5 most similar vectors<br>query_vector = [0.1, 0.2, 0.3]<br>results = db.query(query_vector, k=5)</pre><p>There is no url and port to connect to, just the file itself. This is the same like opening a sqlite database, which is also an embedded database.</p><p>Therefore for central storage the vector database has to be saved in a file structure inside a bucket. You could use AWS S3 or Google Cloud Storage Bucket but if the entire IT landscape does not already uses one of the cloud hyperscalers, then I suggest to use the open source S3 alternative <a href="http://min.io/">Min.io</a>. It can be used as a drop-in replacement for existing apps that use AWS because it has full compatibility for the S3 API. Minio even has a full guide on how to start the the Minio containers with docker compose and setting up a bucket specifically for LanceDB.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*TXJY-d3gcN5WPMHy" /></figure><h3>Outlook</h3><h4>Is there something better than vectors? — GraphRAG by Microsoft</h4><p>While vectors have been useful for helping computers find information, Microsoft believes there’s a better way. In the usual method, called “Baseline RAG,” embedding models turn text into numbers (vectors) and store them in a vector database. When you ask a question, the computer searches for similar vectors to find an answer.</p><p>Microsoft’s new approach, called GraphRAG, leverages this idea. In the traditional “Baseline RAG,” the system retrieves information based solely on similarity, which might miss the rich web of relationships between different pieces of data. GraphRAG uses graph databases to capture and utilize these relationships. By mapping out how pieces of information are connected, the system can understand the broader context of a query.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Tnc8lWFkFkJ5okDG" /></figure><p>For example, if you ask about the causes of a specific historical event, a vector-based system might provide documents that mention similar keywords. A graph-based system, however, can trace the connections leading up to that event, providing a more comprehensive and insightful answer. By using graph databases, the system doesn’t just find information that’s similar — it understands how different pieces of data relate to each other. This means it can provide answers that are more accurate and contextually rich, considering the intricate relationships within the data.</p><p>In essence, while vector databases are like having coordinates to find points of interest, graph databases provide the roads and pathways that show how those points are connected. Microsoft’s GraphRAG suggests that incorporating these connections can significantly enhance how Retrieval Augmented Generation systems work, moving beyond finding similar information to understanding the deeper context in which that information exists.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc8d124372e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Control 50+ local and proprietary LLMs with one API and web interface (open source)]]></title>
            <link>https://medium.com/@patricklenert/control-50-local-and-proprietary-llms-with-one-api-and-web-interface-open-source-7ac0070f1c7f?source=rss-4eff97c55e72------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ac0070f1c7f</guid>
            <category><![CDATA[llmops]]></category>
            <category><![CDATA[llama-3]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[hugging-face]]></category>
            <category><![CDATA[openai]]></category>
            <dc:creator><![CDATA[Patrick Lenert - GenAI Fullstack Developer]]></dc:creator>
            <pubDate>Mon, 26 Aug 2024 11:38:09 GMT</pubDate>
            <atom:updated>2024-08-26T11:38:09.448Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>TLDR:</strong> Data protection, vendor lock-in and sometimes costs are current problems when selecting LLM providers such as OpenAI or Anthropic. The solution is a middleman between the various inference servers and the end application: TaskingAI. All LLM models from any provider, whether paid and proprietary or free and open-source, are thus visible in a structured manner in one interface and can be operated with a single API.</p><p><strong>Anyone planning their own AI infrastructure in the company wants to be able to offer as many models as possible</strong>. Using only the Azure OpenAI API is compliant with data protection regulations, but using OpenAI models at a price of around USD 15 per 1 million output tokens does not seem to make much sense from a scaling perspective. Proprietary models are also less suitable for fine-tuning due to API limitations compared to open source models in combination with a no-code fine-tuning GUI such as <a href="https://github.com/h2oai/h2o-llmstudio">H2O</a>.</p><h3>Replace OpenAI with TaskingAI</h3><p>Most AI apps currently use the OpenAI APIs because there were no other alternatives. With TaskingAI, true independence from just one paid LLM provider is now possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*agHxAyvSMBDaAeFC" /></figure><p>TaskingAI is published 100% open source on Github and consists of a backend, a frontend and a Python package. The frontend allows you to add models from any paid LLM provider or your own inference server, such as an Ollama or LM Studio server running on your own GPU hardware. There are a total of 26 provider options to choose from. The 26 providers are all inference servers, which in turn can address different LLM models themselves. There are therefore no limits to the number of different LLM models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YJLObRsg3lp3DP2v" /></figure><p>Choose from OpenAI, Azure OpenAI, Claude, Ollama, HuggingFace and many more</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*MYY4NRcquXSSJcup" /></figure><h3>TaskingAI is OpenAI compatible</h3><p>The AI applications already run with the OpenAI API and therefore TaskingAI offers a drop-in replacement by converting all LLM responses from the TaskingAI server into an OpenAI compatible object format. To make the API compatible with OpenAI, only /v1 needs to be added to the request.</p><p>Example for TaskingAI Format:</p><p><a href="https://taskingai.server.com/assistants/%7Bassistant_id%7D/chats/%7Bchat_id%7D/generate">https://taskingai.server.com/assistants/{assistant_id}/chats/{chat_id}/generate</a></p><p>Example for OpenAI Format:</p><p><a href="https://taskingai.server.com/v1/assistants/%7Bassistant_id%7D/chats/%7Bchat_id%7D/generate">https://taskingai.server.com/v1/assistants/{assistant_id}/chats/{chat_id}/generate</a></p><h3>TaskingAI on Premise</h3><p>TaskingAI can be set up very easily with Docker itself. A few environment variables need to be defined in an .env file and all Docker containers, with server and frontend, can be started with Docker Compose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8KkflIfGKC0eBOP4" /></figure><p>I recommend running the TaskingAI server and the frontend on the same GPU server as the local inference servers (e.g. Ollama) so that the latency between Ollama and TaskingAI is minimised.</p><p>Important: In this case, Ollama would run as a system process in the background and TaskingAI in Docker containers. Therefore, <a href="http://host.docker.internal:11434/">http://host.docker.internal:11434/</a> must be specified as the endpoint for the Ollama server in TaskingAI, otherwise an error message will be displayed.</p><p>Since TaskingAI itself only forwards the request to the correct inference provider, it would also be possible to use the TaskingAI containers on a server without a GPU. Ollama, on the other hand, should definitely have access to a GPU, because otherwise the response times of a model such as Mistral or Llama 3.1 are too slow and therefore unusable.</p><h3>TaskingAI as Python Package</h3><p>To integrate TaskingAI into your own application and exchange it for OpenAI, you would first generate an API key yourself via the web interface, which your own Python app will use to authenticate itself to the TaskingAI server:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*2j9W6Ux-qMXNYZ87" /></figure><p>This will look something like this: tkRw2hihzZLHcSugqjbKTUW6LefGKaOy</p><p>The Tasking AI Python package can then be installed and the Python app registers with the Tasking AI server using the self-generated API key. This allows the models to be integrated into your own app and, above all, combined with other tools such as <a href="http://crew.ai/">Crew.AI</a> for pipelines or <a href="https://www.phidata.com/">PhiData</a> for assistants:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XW9guJ8026eW0FBi" /></figure><h3>What is Retrieval Augmented Generation (RAG)?</h3><p>A method to search for relevant information from large collections of text and thus obtain context-dependent answers from the LLM. A vector database plays a central role in Retrieval Augmented Generation as it is used to efficiently search large amounts of text data and find relevant information. Here, texts are converted into vectors that capture the semantic meanings of the texts. When a query is made, the system also converts it into a vector and searches the vector database for the most similar vectors. The most similar vectors are determined by a cosine distance or the Euclidean distance between two vectors. These vectors correspond to the texts in the database and have the greatest semantic similarity to the text from the user request. The LLM receives the original query together with the retrieved relevant texts as additional context. Based on this extended context, the LLM generates a response that addresses the original query while integrating the retrieved relevant information. This results in a more precise and comprehensive response that takes into account both the query and the additional context.</p><h3>RAG in Tasking AI through assistants</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7AaaEbHbbbr65fUB" /></figure><p>To create an LLM assistant with a ‘memory’, an embedding model must be selected. This embedding model can also be Mistral, Llama 3.1 or GPT-4o, for example. An embedding model is used to convert text data into numerical vectors. These vectors represent the semantic meaning of the text in a multidimensional space. An embedding model therefore ensures that all texts are consistently projected into the same vector space and also converts the text of the user request into a vector so that the request can be compared with the stored vectors in the database. This is crucial for an effective similarity search.</p><h3>Embedding Modell</h3><p>Once an embedding model has been selected, a collection must be created in Tasking AI. A collection is responsible for the structured storage of data within the RAG process. However, it is not a vector database in the conventional sense. A collection is a comprehensive organisational unit for various data sources, whereas a vector database is specifically designed for managing and searching vectors. A collection in TaskingAI can contain metadata, raw texts and their vectorisations.</p><h3>Memory</h3><p>In TaskingAI, “memory” refers to an assistant’s ability to store and use the context of conversations to provide coherent and relevant responses. There are three types of memory:</p><p>1. zero memory: each exchange is handled independently, without context storage. Suitable for isolated queries.</p><p>2. naive memory: Saves all messages of a session in order to retain the complete context. Ideal for short, precise interactions.</p><p>3. message window memory: Focusses on recent, relevant parts of the conversation. Suitable for longer dialogues with a detailed history.</p><h3>Tools</h3><p>Tools are a way of integrating third-party APIs into the assistant. For example, the assistant could receive a text description from the user and use the Stability AI API or DALL-E to generate an image and display the image to the user. A real-time web search would also be possible by creating a ‘programmatic search engine’ at Google — 100 queries per day free of charge — and searching the Internet for suitable sources for each user query, which an open source model such as Llama or Mistral does not natively support.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*02RR_DMKbqiFjcTP" /></figure><p>I hope I was able to give you a good first impression of how Tasking AI can significantly simplify your own local LLM infrastructure. If you now link Tasking AI with customised billing software such as <a href="https://www.getlago.com/">Lago</a>, you could not only supply LLM models to your own apps, but also offer local LLMs from Germany — with extra data protection 😉 — as a service with usage-based billing per token.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ac0070f1c7f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>