<?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>DEV Community: Arti Kondziela</title>
    <description>The latest articles on DEV Community by Arti Kondziela (@arti_kondziela_16634e239e).</description>
    <link>https://dev.to/arti_kondziela_16634e239e</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%2F1495043%2Ff966e81b-97e0-4a49-a887-d8c06aa09920.png</url>
      <title>DEV Community: Arti Kondziela</title>
      <link>https://dev.to/arti_kondziela_16634e239e</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arti_kondziela_16634e239e"/>
    <language>en</language>
    <item>
      <title>RAG Search with AWS Lambda and Bedrock</title>
      <dc:creator>Arti Kondziela</dc:creator>
      <pubDate>Thu, 03 Apr 2025 18:26:04 +0000</pubDate>
      <link>https://dev.to/arti_kondziela_16634e239e/rag-search-with-aws-lambda-and-bedrock-4nf1</link>
      <guid>https://dev.to/arti_kondziela_16634e239e/rag-search-with-aws-lambda-and-bedrock-4nf1</guid>
      <description>&lt;p&gt;Today I would like to show you how I solved with &lt;strong&gt;Retrieval-Augmented Generation (RAG)&lt;/strong&gt; Search my problem of poor &lt;strong&gt;Large Language Model (LLM)&lt;/strong&gt; response results.&lt;/p&gt;

&lt;p&gt;I was creating a system, one of the elements of which was the cooperation of the &lt;strong&gt;LLM model&lt;/strong&gt; with the &lt;strong&gt;Google search engine.&lt;/strong&gt; The model specified what queries it wanted to perform under a given case, and the search engine provided it with the text of the retrieved pages.&lt;/p&gt;

&lt;p&gt;The resulting data, however, was not always ideal. The page could be very large, and the interesting information was only a fraction of the entire page content.&lt;/p&gt;

&lt;p&gt;This caused problems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;large attached files caused a significant &lt;strong&gt;increase in waiting&lt;/strong&gt; for a response from the model,&lt;/li&gt;
&lt;li&gt;larger input &lt;strong&gt;increased the cost&lt;/strong&gt; of the query,&lt;/li&gt;
&lt;li&gt;large text not always related to the topic caused &lt;strong&gt;hallucinations of the model&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After a brief research, I decided to use the RAG search method. However, I could not use the classic vector database approach because my data was not on my server. In addition, I cared about speed; my solution is serverless, so I didn’t want to lose the speed I had for the time being.&lt;/p&gt;

&lt;p&gt;The choice was to create &lt;strong&gt;AWS Lambda&lt;/strong&gt;, using &lt;strong&gt;AWS Bedrock&lt;/strong&gt; model &lt;strong&gt;Titan&lt;/strong&gt; for embedding and &lt;strong&gt;Numpy&lt;/strong&gt; libraries for calculations.&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%2Fb2avg2dra9bgwi55bbn6.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%2Fb2avg2dra9bgwi55bbn6.png" alt="Principle of AWS Lambda" width="800" height="299"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is RAG Search?
&lt;/h2&gt;

&lt;p&gt;RAG Search is a method for finding interesting passages in a text using computation on vectors. In the simplest terms, it is a search for the answer to a question in an article that contains a lot of unnecessary information.&lt;/p&gt;

&lt;p&gt;Below, you can find an example of what RAG looks like in practice together with its definition.&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%2Fr31kck71ykqmwfad5k70.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%2Fr31kck71ykqmwfad5k70.png" alt="Example of RAG Search" width="800" height="637"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementation
&lt;/h2&gt;

&lt;p&gt;The principle of the search is generally very simple and is contained in 3 steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;divide the text into parts, here called chunks,&lt;/li&gt;
&lt;li&gt;determine for each part a vector,&lt;/li&gt;
&lt;li&gt;compare the query vector with the vectors of chunks and select, for example, the best 3.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I decided to split the text after the characters. I borrowed the function from the &lt;a href="https://medium.com/@usmansiddiqui316/rag-on-the-fly-9ebc17555b88" rel="noopener noreferrer"&gt;article&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;def split_full_text(text, chunk_size=500, overlap=50):
    text = text.replace("\n", " ")
    chunks = []
    start = 0
    while start &amp;lt; len(text):
        end = min(start + chunk_size, len(text))
        chunk = text[start:end]
        chunks.append({"text": chunk})
        start += chunk_size - overlap
    return chunks
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Having already had text fragments, it was now necessary to change them into vectors. Since the solution is on AWS the choice was AWS Bedrock.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MODEL_ID = "amazon.titan-embed-text-v2:0"
bedrock_client = boto3.client("bedrock-runtime")
def transform_text_to_vector(text: str):
    request = json.dumps({"inputText": text})
    response = bedrock_client.invoke_model(modelId=MODEL_ID, body=request)
    model_response = json.loads(response["body"].read())
    embedding = model_response["embedding"]
    input_text_token_count = model_response["inputTextTokenCount"]
    print(f"Input token counts: {input_text_token_count}")
    return embedding
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All that's left is a function comparing 2 vectors, but for that we'll need Numpy. It is best to add it to the Layer that we will attach to our Lambda. The following command will create the file you need to upload like a Layer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir python
pip install numpy -t python --platform manylinux2014_x86_64 --implementation cp --python-version 3.11 --upgrade --only-binary=:all:
zip layer.zip -r python
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will use the cosine similarity for comparison. I borrowed the function from the article &lt;a href="https://dev.to/vivekalhat/building-a-tiny-vector-store-from-scratch-59ep"&gt;Building a tiny vector store from scratch&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;def cosine_similarity(store_embeddings, query_embedding, top_k):
    dot_product = np.dot(store_embeddings, query_embedding)
    magnitude_a = np.linalg.norm(store_embeddings, axis=1)
    magnitude_b = np.linalg.norm(query_embedding)
    similarity = dot_product / (magnitude_a * magnitude_b)
    sim = np.argsort(similarity)
    top_k_indices = sim[::-1][:top_k]
    return top_k_indices
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, we can put everything together and prepare our Lambda. It takes 2 input parameters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;query - the query we are looking for&lt;/li&gt;
&lt;li&gt;content - the source page
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import json
import boto3
import numpy as np
TOP_K = 3
def lambda_handler(event, context):
    content = event["content"]
    query = event["query"]
    content_chunks = split_full_text(content)
    query_vector = transform_text_to_vector(query)
    content_vectors = []
    for chunk in content_chunks:
        content_vector = transform_text_to_vector(chunk["text"])
        content_vectors.append(content_vector)
    print(f"Content vector: {len(content_vectors)}")
    top_k_indices = cosine_similarity(content_vectors, query_vector, TOP_K)
    result = []
    for top_k_index in top_k_indices:
        print(content_chunks[top_k_index])
        result.append(content_chunks[top_k_index]["text"])
    return result
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result is a list with the TOP_K most matched fragments to the query.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;My solution is very quick and simple. It uses simple components that fit easily into AWS Lambda. The use of serverless allows unlimited scaling of the solution, the Numpy library computes vectors in an instant, and Bedrock works great as an embedded.&lt;/p&gt;

&lt;p&gt;Search has significantly &lt;strong&gt;speed up&lt;/strong&gt; my model, &lt;strong&gt;improved the quality of responses&lt;/strong&gt; and &lt;strong&gt;reduced costs&lt;/strong&gt;. The difference in execution time is visible to the naked eye. Throwing an entire page into the model often resulted in a timeout despite setting it for 5 minutes. Currently, it rarely exceeds 10 seconds.&lt;/p&gt;

&lt;p&gt;I hope you will find them useful as well.&lt;/p&gt;

</description>
      <category>llm</category>
      <category>rag</category>
      <category>lambda</category>
      <category>bedrock</category>
    </item>
    <item>
      <title>How to Validate Business Ideas in Just 5 Minutes</title>
      <dc:creator>Arti Kondziela</dc:creator>
      <pubDate>Tue, 18 Feb 2025 19:03:32 +0000</pubDate>
      <link>https://dev.to/arti_kondziela_16634e239e/how-to-validate-business-ideas-in-just-5-minutes-1bi7</link>
      <guid>https://dev.to/arti_kondziela_16634e239e/how-to-validate-business-ideas-in-just-5-minutes-1bi7</guid>
      <description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;If you have ever wondered what it would be like to create something that was &lt;strong&gt;invented in your head&lt;/strong&gt;, then you have come to the right place. The prospect of creating something of your own is very appealing and exciting.&lt;/p&gt;

&lt;p&gt;I myself decided a few years ago to try my hand at creating something of my own from scratch. Looking back, I wonder why everyone doesn't try to turn their ideas into projects that work and make money. It seems to me that the main factor is the time we have to invest in an idea without the certainty of success, time which we always have too little of and which is the most precious of our resources.&lt;/p&gt;

&lt;p&gt;And it was time that was the main motivation to create &lt;a href="https://www.cresh.me?utm_source=dev.to&amp;amp;utm_medium=artykul&amp;amp;utm_campaign=devto_dandus"&gt;&lt;strong&gt;Cresh&lt;/strong&gt;&lt;/a&gt;, which allows us to &lt;strong&gt;quickly validate an idea&lt;/strong&gt; and research in literally minutes.&lt;/p&gt;

&lt;p&gt;The best way to understand how this app works is to use a &lt;strong&gt;real-life example&lt;/strong&gt;. This will show you how easy and fast it is to assess your startup concepts.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Business Idea: Dog Tinder
&lt;/h2&gt;

&lt;p&gt;A friend of mine decided to learn programming, so we decided not to teach him with dry examples, but to &lt;strong&gt;s&lt;/strong&gt;tart a project that would have a &lt;strong&gt;chance of being realised.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The idea is simple:
&lt;/h3&gt;

&lt;p&gt;✅ The app allows users to &lt;strong&gt;browse dogs&lt;/strong&gt; available for adoption.&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Shelters&lt;/strong&gt; (or anyone) can upload dogs in need of a home.&lt;/p&gt;

&lt;p&gt;✅ If you like a dog, you &lt;strong&gt;swipe right&lt;/strong&gt;. If it's a &lt;strong&gt;match&lt;/strong&gt;, you get the shelter's contact details.&lt;/p&gt;

&lt;p&gt;✅ The goal? &lt;strong&gt;To make adopting a dog&lt;/strong&gt; as fun and easy as possible.&lt;/p&gt;

&lt;p&gt;However, I began to wonder if the idea had a chance of success, what its strengths were, what the situation was with competition, functionality, etc.&lt;/p&gt;

&lt;p&gt;I would now like to show you how I carried out the analysis with &lt;strong&gt;Cresh&lt;/strong&gt; and what conclusions I drew from the results.&lt;br&gt;
You can find the analysis here: &lt;a href="https://cresh.me/examples/dog-tinder?utm_source=dev.to&amp;amp;utm_medium=artykul&amp;amp;utm_campaign=devto_dandus"&gt;Cresh Analysis&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Cresh and how does it work?
&lt;/h2&gt;

&lt;p&gt;Cresh is an AI-based tool that, based on a project description, generates &lt;strong&gt;33 metrics&lt;/strong&gt; with a score from 1 to 5. Each is accompanied by an &lt;strong&gt;explanation&lt;/strong&gt; and &lt;strong&gt;suggestions&lt;/strong&gt;. The metrics are grouped into &lt;strong&gt;5 categories&lt;/strong&gt; that allow you to look at different aspects of the project.&lt;/p&gt;

&lt;p&gt;In my quick analysis, I focused on the numerical values to identify weaknesses for which I checked the explanation. This allowed me to quickly understand the context and market of the project, as well as potential threats and opportunities.&lt;/p&gt;

&lt;h2&gt;
  
  
  5 minute conclusions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;1. Market Viability Group&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;📊 &lt;strong&gt;Is there a demand?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Yes, there is! People love dogs, and shelters are full of them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Adoption is a long-term trend—there will &lt;em&gt;always&lt;/em&gt; be dogs needing homes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;People already use online platforms to find pets. This just makes it more appealing.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;2. Market Strategy Group&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;🚀 &lt;strong&gt;Are we reaching the right audience?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Finding shelters to partner with should be easy. Every neighbourhood has one.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The challenge? &lt;strong&gt;The competition&lt;/strong&gt;. It's not a hard idea to copy. A bigger company could start the same thing overnight.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;3. Product Viability Group&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;💡 &lt;strong&gt;Can we make a great product?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Absolutely! A simple, user-friendly design can make it fun.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The product itself isn't the problem - scaling &lt;em&gt;is&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;4. Technical Viability Group&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;🛠 &lt;strong&gt;Is it easy to build?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Basic version? Yes, quite simple.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;But if we want to stand out, we'll need a &lt;strong&gt;lot of integrations&lt;/strong&gt; (shelters, adoption agencies, vet services, etc). That's where it gets tricky.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;5. Risk &amp;amp; Finance Viability Group&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;⚠️ &lt;strong&gt;Is there any risk?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The biggest risk: Another company comes up with the same idea, but better.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scaling requires &lt;strong&gt;a lot&lt;/strong&gt; of effort (new markets, partnerships, automation).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;High investment required to make it big.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Verdict: A Cool Idea, But Hard to Scale
&lt;/h2&gt;

&lt;p&gt;So, what did I learn?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Dog Tinder&lt;/em&gt; is a &lt;strong&gt;fun, marketable idea&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It’s &lt;strong&gt;technically possible&lt;/strong&gt;, but real success would require serious partnerships.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Competition is a huge risk&lt;/strong&gt;—big platforms could quickly take over.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Scaling is the hardest part&lt;/strong&gt;—lots of integrations, moving into new markets, and gaining user trust.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Early adopters&lt;/strong&gt; - go to nearby shelters and ask if they would be interested in cooperating. Try to find contact with local authorities for support.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Would I build it? Maybe. But I’d need a clear strategy to &lt;strong&gt;differentiate it from the competiton&lt;/strong&gt; and &lt;strong&gt;secure partnerships early on&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>startup</category>
      <category>validation</category>
      <category>ai</category>
      <category>dog</category>
    </item>
  </channel>
</rss>
