<?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 Berkay Ersoy on Medium]]></title>
        <description><![CDATA[Stories by Berkay Ersoy on Medium]]></description>
        <link>https://medium.com/@bersoy12?source=rss-64bb91e6f86f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*YnyvvRBWopnTk7y0w-dX8g.jpeg</url>
            <title>Stories by Berkay Ersoy on Medium</title>
            <link>https://medium.com/@bersoy12?source=rss-64bb91e6f86f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 20:25:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bersoy12/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[Simplify News Content for n8n with Readability and Docker]]></title>
            <link>https://medium.com/@bersoy12/simplify-news-content-for-n8n-with-readability-and-docker-203aab76b500?source=rss-64bb91e6f86f------2</link>
            <guid isPermaLink="false">https://medium.com/p/203aab76b500</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[n8n]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[readability]]></category>
            <dc:creator><![CDATA[Berkay Ersoy]]></dc:creator>
            <pubDate>Sat, 06 Sep 2025 15:49:27 GMT</pubDate>
            <atom:updated>2025-09-06T15:49:27.448Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s fast-moving world, new updates appear every minute, and we all try to keep up. But following news articles from websites or scrolling through social media is a little old-school. Ads, pop-ups, and unrelated contents makes even more distracting.</p><p>Using language models like ChatGPT, Gemini, or Claude to summarize long articles is a clever solution.</p><p>One of the easiest ways is building a workflow with <strong>n8n</strong>. Scraping a website is straightforward. However, the real challenge is cleaning up all the noise — ads, menus, headers, footers, and unrelated text.</p><p>That’s where <strong>Readability</strong> comes in. In this article, we’ll show see how to create a simple Readability microservice and connect it to n8n through an HTTP Request node. This way, you can automate the process of turning messy web pages into clean, structured content ready to be summarized by your favorite AI model.</p><h3>Why Readability?</h3><p>The <a href="https://github.com/buriy/python-readability">Readability library</a> works like the <strong>“Reader mode”</strong> you might use in your browser. It clears ads, menus, footage, headers, and unrelated content by leaving only the clean article text and title.</p><p>By passing the simplified content to your LLM, you:</p><ul><li>Reduce the number of tokens (and cost)</li><li>Improve the quality of summaries</li><li>Focus only on the relevant text</li></ul><h3>Building the Readability Service with Docker</h3><p>First, let’s prepare a simple Flask API that wraps the Readability library. Create a folder and open your code editor.</p><p><em>Dockerfile</em></p><pre>FROM python:3.11-slim<br><br>WORKDIR /app<br><br>COPY . .<br><br>RUN pip install flask readability-lxml requests<br><br>EXPOSE 5000<br><br>CMD [&quot;python&quot;, &quot;readability_server.py&quot;]</pre><p><em>readability_server.py</em></p><pre>from flask import Flask, request, jsonify<br>from readability import Document<br>import requests<br><br>app = Flask(__name__)<br><br>@app.route(&#39;/readability&#39;, methods=[&#39;GET&#39;, &#39;POST&#39;])<br>def readability():<br>    data = request.json<br>    url = data.get(&#39;url&#39;)<br>    if not url:<br>        return jsonify({&#39;error&#39;: &#39;No URL provided&#39;}), 400<br><br>    res = requests.get(url)<br>    doc = Document(res.text)<br>    content = doc.summary()<br>    title = doc.title()<br><br>    return jsonify({<br>        &#39;title&#39;: title,<br>        &#39;content&#39;: content<br>    })<br><br>if __name__ == &#39;__main__&#39;:<br>    app.run(host=&#39;0.0.0.0&#39;, port=5000)</pre><h3>Running the Service</h3><p>Once you have Docker Desktop running, open your terminal in the project folder and run:</p><pre>docker build -t readability-server .</pre><p>This builds the service and installs the necessary libraries.</p><pre>docker run -p 5000:5000 readability-server</pre><p>Now your API is available at <a href="http://localhost:5000/">http://localhost:5000</a>.</p><p>In n8n, add an <strong>HTTP Request node</strong> with the following settings:</p><ul><li><strong>URL</strong>: <a href="http://localhost:5000/readability">http://localhost:5000/readability</a></li><li><strong>Method</strong>: POST</li><li><strong>Headers</strong>: Content-Type: application/json</li><li><strong>Body</strong>: {“url”: “<a href="https://www.atlanticcouncil.org/content-series/fastthinking/twenty-six-european-countries-have-committed-to-help-defend-ukraine-after-the-war-whats-next/">https://www.atlanticcouncil.org/content-series/fastthinking/twenty-six-european-countries-have-committed-to-help-defend-ukraine-after-the-war-whats-next/</a>&quot;}</li></ul><p>This will return a JSON response containing the title and content fields. You can then pass this clean text to the LLM of your choice.</p><h3>Alternative: Pass URL as Argument</h3><p>If you prefer sending the URL as a query parameter, update <em>readability_server.py </em>script:</p><pre>@app.route(&#39;/readability&#39;, methods=[&#39;GET&#39;])<br>def readability():<br>    url = request.args.get(&#39;url&#39;)<br>    if not url:<br>        return jsonify({&#39;error&#39;: &#39;No URL provided&#39;}), 400<br><br>    res = requests.get(url)<br>    res.encoding = &#39;utf-8&#39;<br>    doc = Document(res.text)<br>    content = doc.summary()<br>    title = doc.title()<br><br>    return f&quot;&lt;html&gt;&lt;head&gt;&lt;meta charset=&#39;utf-8&#39;&gt;&lt;title&gt;{title}&lt;/title&gt;&lt;/head&gt;&lt;body&gt;{content}&lt;/body&gt;&lt;/html&gt;&quot;, 200, {&#39;Content-Type&#39;: &#39;text/html; charset=utf-8&#39;}</pre><p>Now you can open the service directly in your browser:</p><pre>http://localhost:5000/readability?url=https://www.atlanticcouncil.org/content-series/fastthinking/twenty-six-european-countries-have-committed-to-help-defend-ukraine-after-the-war-whats-next/</pre><p>Full repository: <a href="https://github.com/bersoy12/readability">https://github.com/bersoy12/readability</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=203aab76b500" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Integrate Language Learning with LLMs]]></title>
            <link>https://medium.com/@bersoy12/how-to-integrate-language-learning-with-llms-276e9415226b?source=rss-64bb91e6f86f------2</link>
            <guid isPermaLink="false">https://medium.com/p/276e9415226b</guid>
            <category><![CDATA[llm-applications]]></category>
            <category><![CDATA[hugging-face]]></category>
            <category><![CDATA[mistral]]></category>
            <category><![CDATA[ai-database]]></category>
            <category><![CDATA[llm-function-calling]]></category>
            <dc:creator><![CDATA[Berkay Ersoy]]></dc:creator>
            <pubDate>Mon, 04 Nov 2024 23:40:45 GMT</pubDate>
            <atom:updated>2024-11-11T09:43:39.752Z</atom:updated>
            <content:encoded><![CDATA[<p>Ever struggled to remember a foreign word you learned recently? You’re not alone — many language learners face this issue.</p><p>In this article, I’ll show how I tackled this issue using an LLM to store and retrieve Spanish vocabulary effectively. I used the <em>mistral-large-latest</em> model and combined several techniques: structured data with Pydantic, function calls, vector embeddings, and database storage in MongoDB.</p><h4>What if I want to engage with a Language Model only?</h4><p>I employed four distinct techniques to address this issue:</p><ol><li>Utilizing Pydantic for structured data format.</li><li>Implementing function calls to extract information such as meaning, example sentences, synonyms, antonyms and etc.</li><li>Using embeddings to enable searching from the meaning even if I cannot remember the exact word or phrase.</li><li>Storing each of Spanish phrases in a database.</li></ol><p><a href="https://colab.research.google.com/drive/1khWppSjQYizIAuwvQVGZ0ZOsFlb9-N_d#scrollTo=_I6Ayt2FVFLs"><em>Reach my full notebook</em></a> on Google Colab, which contains the complete code for this approach.</p><h3>Structured Data with Pydantic</h3><p>Here are two classes that help me extract many SpanishWords.</p><pre>class SpanishWord(BaseModel):<br>    &quot;&quot;&quot;Information about a Spanish word or phrase for language learners.&quot;&quot;&quot;<br>    word: Optional[str] = Field(default=None, description=&quot;The Spanish word or phrase&quot;)<br>    meaning: Optional[str] = Field(default=None, description=&quot;The meaning or translation of the word in English&quot;)<br>    part_of_speech: Optional[str] = Field(default=None, description=&quot;The part of speech (e.g., noun, verb, adjective)&quot;)<br>    example_sentence: Optional[str] = Field(default=None, description=&quot;An example sentence in Spanish using the word&quot;)<br>    example_translation: Optional[str] = Field(default=None, description=&quot;The English translation of the example sentence&quot;)<br>    synonyms: Optional[List[str]] = Field(default=None, description=&quot;A list of synonyms in Spanish, if any&quot;)<br>    antonyms: Optional[List[str]] = Field(default=None, description=&quot;A list of antonyms in Spanish, if any&quot;)<br>    notes: Optional[str] = Field(default=None, description=&quot;Any additional notes on usage or context&quot;)<br><br>class SpanishWordList(BaseModel):<br>    words: List[SpanishWord]</pre><p>A basic reference to extract information from the text.</p><p><a href="https://python.langchain.com/docs/tutorials/extraction/">https://python.langchain.com/docs/tutorials/extraction/</a></p><h3>Tool Calls for Extracting Information</h3><pre>tools = [{<br>            &quot;type&quot;: &quot;function&quot;,<br>            &quot;function&quot;: {<br>                &quot;name&quot;: &quot;structure_spanish_content&quot;,<br>                &quot;description&quot;: &quot;Structure Spanish language content from free text into a formatted data structure&quot;,<br>                &quot;parameters&quot;: SpanishWordList.model_json_schema()<br>            }<br>        }]</pre><h4>Querying</h4><p>Here’s how I query the model to recall and explain various Spanish phrases I’ve learned.</p><pre>user_input = &quot;Levantarse, cepillarse, luego, abrir, hasta el mediodía, \<br>    despejado, soleado, volví a casa, \<br>    fui al parque, tomé un café, comencé s trabajar. \<br>    Explain these phrases and memorise them.&quot;</pre><pre>messages = [<br>    {<br>            &quot;role&quot;: &quot;system&quot;,<br>            &quot;content&quot;: &quot;You are a helpful assistant. \<br>                        Unfortunately, you always add bad jokes at the end of your answers.&quot;<br>        },<br>    {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: user_input}]</pre><p>I want to ensure that the model’s response is not solely focused on the SpanishWord class. Therefore, I’ve included a creative prompt for an additional joke at the end.</p><p>After call and pushes to messages list, here is the final response i get.</p><pre>Here are the explanations and memorization tips for the phrases you provided:<br><br>1. **Levantarse** - &quot;To get up&quot;<br>   - Example: Me levanté temprano esta mañana. (I got up early this morning.)<br>   - Memorization Tip: Imagine a lever lifting you out of bed.<br><br>2. **Cepillarse** - &quot;To brush&quot;<br>   - Example: Me cepillé los dientes después de desayunar. (I brushed my teeth after breakfast.)<br>   - Memorization Tip: Picture a toothbrush with a cape, brushing teeth heroically.<br><br>3. **Luego** - &quot;Then&quot;<br>   - Example: Primero hice la cama, luego me duché. (First I made the bed, then I showered.)<br>   - Memorization Tip: Think of &quot;luego&quot; as the sequel (&quot;luego-quel&quot;) to the first action.<br><br>4. **Abrir** - &quot;To open&quot;<br>   - Example: Abrí la ventana para dejar entrar el aire fresco. (I opened the window to let in the fresh air.)<br>   - Memorization Tip: Imagine opening a door with a giant &quot;Abrir&quot; sign on it.<br><br>5. **Hasta el mediodía** - &quot;Until noon&quot;<br>   - Example: Trabajé hasta el mediodía. (I worked until noon.)<br>   - Memorization Tip: Picture a clock with hands pointing to 12, with &quot;hasta&quot; written above it.<br><br>6. **Despejado** - &quot;Clear&quot;<br>   - Example: El cielo está despejado hoy. (The sky is clear today.)<br>   - Memorization Tip: Imagine a clear desk (&quot;despejado&quot; desk) reflecting a clear sky.<br><br>7. **Soleado** - &quot;Sunny&quot;<br>   - Example: Hace un día soleado. (It&#39;s a sunny day.)<br>   - Memorization Tip: Picture a sun with sunglasses saying &quot;soleado.&quot;<br><br>8. **Volví a casa** - &quot;I returned home&quot;<br>   - Example: Después del trabajo, volví a casa. (After work, I returned home.)<br>   - Memorization Tip: Imagine a volleyball (&quot;volví&quot;) bouncing back home.<br><br>9. **Fui al parque** - &quot;I went to the park&quot;<br>   - Example: Ayer, fui al parque con mis amigos. (Yesterday, I went to the park with my friends.)<br>   - Memorization Tip: Picture a park with a big &quot;Fui&quot; sign at the entrance.<br><br>10. **Tomé un café** - &quot;I had a coffee&quot;<br>    - Example: Por la mañana, tomé un café. (In the morning, I had a coffee.)<br>    - Memorization Tip: Imagine a cup of coffee with a &quot;Tomé&quot; label on it.<br><br>11. **Comencé a trabajar** - &quot;I started working&quot;<br>    - Example: Después del almuerzo, comencé a trabajar. (After lunch, I started working.)<br>    - Memorization Tip: Picture a commencement (graduation) cap with a &quot;trabajar&quot; diploma.<br><br>And now, for the bad joke: Why don&#39;t scientists trust atoms? Because they make up everything! 🤭🧪</pre><p>The model didn’t perform memorization as intended because I hadn’t defined a specific function for that purpose.</p><h3>Creating vector embeddings for the Spanish words using sentence-transformers</h3><p>I simply employed a sentence transformer API from Hugging Face</p><pre>from sentence_transformers import SentenceTransformer<br><br>model = SentenceTransformer(&quot;sentence-transformers/all-MiniLM-L12-v2&quot;)<br><br>spanishDict = [word_list for word_list in listOfWords]<br><br>embeddings = model.encode(spanishDict)</pre><h3>Connect to MongoDB and Store the Data</h3><p>Firstly, you should crate a MongoDB account and setup a machine for your database. After you log in, create a project &gt; create a cluster (choose free learning environment), name your cluster, choose your provider &gt; create a database user (choose the exisitng one) &gt; choose MongoDB for VScode &gt; copy your connection string once your database initialized &gt; finally provide your string to MONGO_URI.</p><pre>try:<br>    uri = MONGO_URI<br>    mongo = pymongo.MongoClient(uri<br>                         , server_api=pymongo.server_api.ServerApi(version=&quot;1&quot;<br>                                                                   , strict=True<br>                                                                   , deprecation_errors=True)<br>                        , tlsAllowInvalidCertificates=False)<br><br>    mongo.admin.command(&quot;ping&quot;)<br>    print(&quot;Connected successfully&quot;)<br><br>except Exception as e:<br>    raise Exception(<br>        &quot;The following error occurred: &quot;, e)</pre><p>Least simple way to push your data to the collection in your database, here is the code.</p><pre>db = mongo[&quot;spanish_words&quot;]<br><br>collection_words = db[&quot;words&quot;]<br><br>embeddings_list = embeddings.tolist()<br><br>for i in range(0, len(spanishDict)):<br>    spanishDict[i][&quot;embedding&quot;] = embeddings_list[i]<br><br>collection_words.insert_many(spanishDict)</pre><p>References</p><ul><li><a href="https://docs.mistral.ai/capabilities/function_calling/">Function calling | Mistral AI Large Language Models</a></li><li><a href="https://python.langchain.com/docs/tutorials/extraction/">Build an Extraction Chain | 🦜️🔗 LangChain</a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FJEBDfGqrAUA%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DJEBDfGqrAUA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FJEBDfGqrAUA%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6f5804cafb9d5b715966c6f8c68aa498/href">https://medium.com/media/6f5804cafb9d5b715966c6f8c68aa498/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=276e9415226b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spell Checker for Turkish Texts]]></title>
            <link>https://medium.com/@bersoy12/spell-checker-for-turkish-texts-b828627e328a?source=rss-64bb91e6f86f------2</link>
            <guid isPermaLink="false">https://medium.com/p/b828627e328a</guid>
            <category><![CDATA[machine-translation]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Berkay Ersoy]]></dc:creator>
            <pubDate>Fri, 13 Sep 2024 09:10:11 GMT</pubDate>
            <atom:updated>2024-09-13T09:13:08.904Z</atom:updated>
            <content:encoded><![CDATA[<p>We humans can understand spelling mistakes, however machines are not good at this and need to be trained. A clear example of this can be seen in intent classification in chatbots.</p><p>In this study, I will show how to train a character-level spelling correction model for Turkish. Since Turkish is an agglutinative language,<strong> character-level tokenization</strong> makes more sense compared to English because the number of possible Turkish word variations is potentially unlimited. For example, consider the word <em>“çekoslavakyalılaştıramadıklarımızdan”</em> which is a grammatically correct word in Turkish, even though we probably haven’t encountered such a word in our daily conversations.</p><p>For the whole code: <a href="https://github.com/bersoy12/spell-checker">https://github.com/bersoy12/spell-checker</a></p><h3>Attention-Based Seq2Seq Models</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*YSIpAN5ulkV3z4ahxFxDnw.jpeg" /></figure><p>I built my model based on a <a href="https://arxiv.org/abs/2102.03218">spelling correction paper for Azerbaijani</a>. The model is a seq2seq model including an Bahdanau attention mechanism which makes the model context-dependent. In oppose to <a href="https://arxiv.org/abs/2102.03218">the study</a>, using fewer LSTM layers and one-hot encoding for embedding resulted better in my experiments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*aw9QNMKxH7tLioy-XCAOVA.png" /><figcaption>My Model</figcaption></figure><h3>Dataset Preparation</h3><p>For the dataset, I found<a href="https://github.com/tdd-ai/spell-checking-and-correction/blob/main/evaluation/data/true_words.txt"> true words dataset</a> that contains Turkish words and their some derived forms by Turkish Data Depository (TDD). I didn’t include special characters like periods, commas, or percentage signs etc. With the help of <a href="https://norvig.com/spell-correct.html">Norvig’s spell checker</a>, I generated spelling errors. I added replace, transpose, delete, and insert errors but excluded splits. Additionally, I manually added some common spelling mistakes such as <em>“kesicek”-&gt;“kesecek”</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*2CKKUX3--J07oRwQkdrm1g.png" /><figcaption>Caption from Training Set</figcaption></figure><p>As you see, some of my training data pairs had no spelling mistakes. I realized that including non-corrupted form of some words is important to prevent the model to alter the correct characters of the input word.</p><h3>Training Process</h3><p>I tried to find out optimal hyperparameters to reach the maximum accuracy. The reference paper trained the model with 12,000 data samples. I didn’t go too far beyond this number but found that 12,000 samples were not enough for me. However, increasing the dataset to 40,000–50,000 didn’t make a significant improvement either.</p><pre>INPUT_LENGTH = 50000<br>LATENT_DIM = 1024<br>LEARNING_RATE = 0.001<br>EPOCH = 50<br>BATCH_SIZE = 16</pre><p>Also, I see that val_loss should not be at the lowest point during training. Val_loss will be slightly increasing right after the lowest level. At this point, we can conclude that the training is sufficient when the validation loss stabilizes.</p><h3>Requirements</h3><p>I used a GPU-powered machine on Colab to train the model. When the number of LSTM layers increased or the dataset grew larger, I used machines with higher RAM. However, since these didn’t result in significant accuracy improvements, I decided to stop using high-RAM machines.</p><h3>Tests</h3><p>I tested my model on <a href="https://github.com/tdd-ai/spell-checking-and-correction/blob/main/evaluation/data/official_test.csv"><em>official_test.csv</em></a> dataset. I reached the correct spelling with a success rate of 53%. I believe that training dataset may be improved by data reduction method.</p><h3>Future Improvements</h3><p>The model has word-level context, thanks to the attention mechanism, but it doesn’t have sentence-level context. For example, the word “rman” could be corrected to “orman” or “roman.” To handle this, the model could be enhanced with sentence context.</p><p>Additionally, the spelling error examples in the dataset could be improved. The dataset can be split in different ways to analyze which samples have the most impact on the model. By performing an n-gram study on the dataset, we can find common and uncommon n-grams and examine their effect on accuracy.</p><p>References</p><ul><li><a href="https://www.tensorflow.org/text/tutorials/nmt_with_attention?hl=en">Neural machine translation with attention | Text | TensorFlow</a></li><li><a href="https://keras.io/examples/nlp/lstm_seq2seq/">Keras documentation: Character-level recurrent sequence-to-sequence model</a></li><li><a href="https://arxiv.org/abs/2102.03218">Spell Correction for Azerbaijani Language using Deep Neural Networks</a></li><li><a href="https://norvig.com/spell-correct.html">How to Write a Spelling Corrector</a></li><li><a href="https://github.com/tdd-ai/spell-checking-and-correction/tree/main">GitHub - tdd-ai/spell-checking-and-correction</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b828627e328a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>