<?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 Nahuel Alejandro Nucera on Medium]]></title>
        <description><![CDATA[Stories by Nahuel Alejandro Nucera on Medium]]></description>
        <link>https://medium.com/@alejandro_14707?source=rss-fb4e6d5ebc5e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Kqyi9BYhPc1wdIB5</url>
            <title>Stories by Nahuel Alejandro Nucera on Medium</title>
            <link>https://medium.com/@alejandro_14707?source=rss-fb4e6d5ebc5e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 18:24:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alejandro_14707/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[Why we stopped mocking AWS and started emulating it]]></title>
            <link>https://medium.com/@alejandro_14707/why-we-stopped-mocking-aws-and-started-emulating-it-78ecb1821c6c?source=rss-fb4e6d5ebc5e------2</link>
            <guid isPermaLink="false">https://medium.com/p/78ecb1821c6c</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Nahuel Alejandro Nucera]]></dc:creator>
            <pubDate>Tue, 07 Apr 2026 18:48:27 GMT</pubDate>
            <atom:updated>2026-04-07T18:48:27.007Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*-q4ESHEB4qokNbyyddFVMw.jpeg" /><figcaption>Ministack, the best AWS emulator</figcaption></figure><p>Every team that tests against AWS hits the same wall: mocks drift from reality, real AWS costs money, and LocalStack went paid.</p><p>MiniStack is a free, open-source AWS emulator that runs 38 services on a single Docker container. Not mocks — actual API implementations that accept the same requests and return the same responses as AWS.</p><h3>What “not mocking” means</h3><p>When you mock S3, you replace put_object with a function that returns {&quot;ETag&quot;: &quot;fake&quot;}. When you emulate S3, you accept the same HTTP request AWS does, store the object in memory, and return the same XML response with the same headers. Your code doesn&#39;t know the difference.</p><p>This matters because:</p><ul><li><strong>Terraform works.</strong> Your terraform apply creates real VPCs, subnets, security groups, and route tables — the same API calls, the same responses.</li><li><strong>CDK works.</strong> cdk bootstrap and cdk deploy run against the same endpoints.</li><li><strong>Step Functions execute.</strong> Your state machines run through the ASL interpreter with Retry, Catch, parallel branches, and now aws-sdk:* integrations that call any of the 38 emulated services.</li><li><strong>Real databases.</strong> RDS creates actual Postgres containers. ElastiCache runs real Redis. ECS starts real Docker containers.</li></ul><h3>The numbers</h3><p>AWS services 38<br>Integration tests 1,047<br>CloudFormation resource types 48<br>Docker image~250MB<br>Startup&lt;1 second<br>Memory at idle~40MB</p><h3>One command</h3><pre>docker run -p 4566:4566 nahuelnucera/ministack</pre><p>Point your AWS SDK at http://localhost:4566. Everything works — S3, DynamoDB, Lambda, EC2, SQS, SNS, Step Functions, KMS, CloudFormation, and more.</p><p>MIT licensed. No account. No telemetry. Free forever.</p><p><strong>GitHub:</strong> <a href="https://github.com/Nahuel990/ministack">github.com/Nahuel990/ministack</a> <strong>Website:</strong> <a href="https://ministack.org/">ministack.org</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78ecb1821c6c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LocalStack Is Dead. MiniStack Runs Real Databases for Free.]]></title>
            <link>https://medium.com/@alejandro_14707/localstack-is-dead-ministack-runs-real-databases-for-free-ba55500fd8dc?source=rss-fb4e6d5ebc5e------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba55500fd8dc</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Nahuel Alejandro Nucera]]></dc:creator>
            <pubDate>Sat, 28 Mar 2026 12:36:33 GMT</pubDate>
            <atom:updated>2026-03-28T12:36:33.262Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hDYaQXmm5EsTKX9itmSaiw.png" /></figure><h3>LocalStack archived its repo on March 23. Pipelines are breaking everywhere. Here’s a drop-in replacement that actually spins up real Postgres, Redis, and Docker containers — no account, no API key, MIT licensed.</h3><p>If you woke up last week to broken pipelines, you’re not alone.</p><p>LocalStack archived its public GitHub repository and moved every image behind mandatory authentication. No warning in your docker-compose.yml. No deprecation period for CI. Just — gone.</p><p>New players have surged: Moto, Floci, individual service emulators. But one project stands out for a reason nobody else is doing — it runs <strong>real infrastructure</strong> instead of faking it.</p><h3>MiniStack: The One That Doesn’t Fake It</h3><pre>docker run -p 4566:4566 nahuelnucera/ministack</pre><p>No account. No API key. No telemetry. No BSL license. MIT, forever.</p><p>Existing --endpoint-url configs, boto3 clients, Terraform providers, and CDK stacks work without code changes.</p><pre>aws --endpoint-url=http://localhost:4566 s3 mb s3://my-bucket<br>aws --endpoint-url=http://localhost:4566 sqs create-queue --queue-name my-queue<br>aws --endpoint-url=http://localhost:4566 dynamodb list-tables</pre><h3>The Killer Feature: Real Infrastructure</h3><p>Most AWS emulators fake everything in memory. MiniStack doesn’t — not where it matters.</p><p><strong>RDS creates actual database containers:</strong></p><pre>import boto3<br>import psycopg2</pre><pre>rds = boto3.client(&quot;rds&quot;,<br>    endpoint_url=&quot;http://localhost:4566&quot;,<br>    aws_access_key_id=&quot;test&quot;,<br>    aws_secret_access_key=&quot;test&quot;,<br>    region_name=&quot;us-east-1&quot;<br>)</pre><pre>resp = rds.create_db_instance(<br>    DBInstanceIdentifier=&quot;mydb&quot;,<br>    DBInstanceClass=&quot;db.t3.micro&quot;,<br>    Engine=&quot;postgres&quot;,<br>    MasterUsername=&quot;admin&quot;,<br>    MasterUserPassword=&quot;password&quot;,<br>    DBName=&quot;appdb&quot;,<br>    AllocatedStorage=20,<br>)</pre><pre>endpoint = resp[&quot;DBInstance&quot;][&quot;Endpoint&quot;]</pre><pre># This is a REAL Postgres instance<br>conn = psycopg2.connect(<br>    host=endpoint[&quot;Address&quot;],<br>    port=endpoint[&quot;Port&quot;],<br>    user=&quot;admin&quot;,<br>    password=&quot;password&quot;,<br>    dbname=&quot;appdb&quot;,<br>)</pre><p>That conn is talking to a real Postgres process. Not a mock. Not an in-memory fake. A real database you can inspect with psql.</p><p>Same story for:</p><ul><li><strong>ElastiCache</strong> → spins up a real Redis container</li><li><strong>ECS</strong> → runs real Docker containers</li><li><strong>Athena</strong> → executes real SQL via DuckDB</li><li><strong>Lambda</strong> → real Python execution with warm starts between invocations</li></ul><h3>Why This Matters</h3><p>If a test says “insert a row into RDS and read it back,” the question is: is it testing application code or testing someone’s mock of Postgres?</p><p>Moto is excellent for unit tests. But when integration confidence is what matters — when SQL migrations need to actually run, connection pooling needs to actually work, Redis TTLs need to actually expire — real infrastructure beats mocks. Locally.</p><p>That’s the gap MiniStack fills.</p><h3>21 Services, One Port</h3><p><strong>Real infrastructure services:</strong></p><p>✅ <strong>Lambda</strong> — Real Python execution with warm starts between invocations</p><p>✅ <strong>RDS</strong> — Actual Postgres/MySQL Docker containers (supports aurora-postgresql, aurora-mysql, mariadb)</p><p>✅ <strong>ElastiCache</strong> — Real Redis containers with IAM auth support</p><p>✅ <strong>ECS</strong> — Actual Docker container execution</p><p>✅ <strong>Athena</strong> — Real SQL via DuckDB (optional)</p><p><strong>In-memory emulated services:</strong></p><p><strong>S3</strong> — Full API including presigned URLs, with optional persistence</p><p><strong>SQS</strong> — FIFO queues, dead-letter queues, visibility timeout</p><p><strong>SNS</strong> — Subscriptions and filtering</p><p><strong>DynamoDB</strong> — Streams, GSI, LSI</p><p><strong>IAM / STS</strong> — Policies, roles, assume-role</p><p><strong>Secrets Manager</strong> — Full CRUD and rotation</p><p><strong>SSM Parameter Store</strong> — String, SecureString, StringList</p><p><strong>EventBridge</strong> — Rules, targets, event patterns</p><p><strong>Kinesis</strong> — Shards and iterators</p><p><strong>CloudWatch Logs</strong> — Log groups, streams, events</p><p><strong>CloudWatch Metrics</strong> — Put/Get metric data</p><p><strong>SES</strong> — Send email (logged, not delivered)</p><p><strong>Step Functions</strong> — State machine execution</p><p><strong>Glue</strong> — Catalog and crawlers</p><h3>How It Compares</h3><p><strong>MiniStack</strong> — MIT licensed. No account required. Real databases, real containers for ECS. ~150 MB image, ~30 MB RAM at idle. Best for integration tests where real infrastructure matters.</p><p><strong>Floci</strong> — MIT licensed. No account required. In-memory emulation only, no real databases or containers. ~90 MB image, ~13 MB RAM at idle. Best for fast, lightweight CI emulation.</p><p><strong>Moto</strong> — Apache 2.0. No account required. In-process Python mock, no Docker needed. Best for Python unit tests where speed matters and real endpoints aren’t needed.</p><p><strong>LocalStack (was)</strong> — BSL license (was Apache). Account now required. Real databases and containers were Pro-only. ~1 GB image, ~500 MB RAM at idle. No longer a viable free option.</p><p>The key differentiator: MiniStack is the only free tool that spins up actual Postgres containers for RDS, actual Redis for ElastiCache, and actual Docker containers for ECS. Every other free option fakes it in memory.</p><h3>5-Minute Migration from LocalStack</h3><p><strong>Step 1: Swap the image.</strong></p><pre># docker-compose.yml<br>services:<br>  # OLD<br>  # localstack:<br>  #   image: localstack/localstack</pre><pre>  # NEW<br>  ministack:<br>    image: nahuelnucera/ministack<br>    ports:<br>      - &quot;4566:4566&quot;<br>    volumes:<br>      - /var/run/docker.sock:/var/run/docker.sock<br>    environment:<br>      - REDIS_HOST=redis</pre><pre>  redis:<br>    image: redis:7-alpine<br>    ports:<br>      - &quot;6379:6379&quot;</pre><p><strong>Step 2: There is no step 2.</strong></p><p>Same port. Same endpoint format. Same AWS API. boto3 clients, Terraform configs, and CDK stacks don’t change.</p><h3>GitHub Actions</h3><pre>- name: Start MiniStack<br>  run: |<br>    docker run -d -p 4566:4566 nahuelnucera/ministack<br>    sleep 2<br>    curl http://localhost:4566/_localstack/health</pre><pre>- name: Run tests<br>  env:<br>    AWS_ENDPOINT_URL: <a href="http://localhost:4566/">http://localhost:4566</a><br>    AWS_ACCESS_KEY_ID: test<br>    AWS_SECRET_ACCESS_KEY: test<br>    AWS_DEFAULT_REGION: us-east-1<br>  run: pytest</pre><h3>The Footprint Difference</h3><p>LocalStack’s image was over 1 GB and consumed ~500 MB at idle. That’s a real cost in CI — especially on GitHub Actions free tier or when running parallel jobs.</p><p>MiniStack is ~150 MB and idles at ~30 MB. CI spins up faster, laptop fans stay quiet, and there’s headroom for actual test workloads.</p><h3>FAQ</h3><p><strong>Is this production-ready?</strong> It’s a local dev and CI tool. Don’t expose it to the internet — it has no authentication by design. That’s the whole point.</p><p><strong>What about Moto?</strong> Moto is the right choice for Python unit tests where in-process speed matters and Docker isn’t wanted. MiniStack is the right choice when real infrastructure is needed — actual database connections, real Redis commands, real container execution.</p><p><strong>What about Floci?</strong> Floci is a solid project with faster startup and smaller footprint. MiniStack’s differentiator is real infrastructure — actual Postgres/Redis containers out of the box, not in-memory fakes.</p><p><strong>Will this stay free?</strong> MIT is MIT. Fork it, embed it, sell it. No “community vs pro” split. No feature gates. No bait-and-switch.</p><p>🐙 <strong>GitHub:</strong> <a href="https://github.com/Nahuel990/ministack">github.com/Nahuel990/ministack</a></p><p>🌐 <strong>Website:</strong> <a href="https://ministack.org/">ministack.org</a></p><p>🐳 <strong>Docker Hub:</strong> <a href="https://hub.docker.com/r/nahuelnucera/ministack">nahuelnucera/ministack</a></p><p><em>Star the repo if this saved your pipeline. PRs welcome.</em></p><p><em>No account. No API key. No telemetry. Just AWS APIs, locally.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba55500fd8dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why News250 Stands Out in the World of News Aggregators]]></title>
            <link>https://medium.com/@alejandro_14707/why-news250-stands-out-in-the-world-of-news-aggregators-2bf9ecfc6300?source=rss-fb4e6d5ebc5e------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bf9ecfc6300</guid>
            <dc:creator><![CDATA[Nahuel Alejandro Nucera]]></dc:creator>
            <pubDate>Fri, 05 Sep 2025 07:44:02 GMT</pubDate>
            <atom:updated>2025-09-05T07:44:02.451Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g00zlWWLlk86VBzcRWuP0Q.jpeg" /></figure><p>In a digital world overflowing with headlines, clickbait, and endless scrolling, news aggregators have become the filters through which we consume information. Platforms like <strong>Google News</strong>, <strong>Feedly</strong>, <strong>Flipboard</strong>, <strong>SmartNews</strong>, and <strong>Ground News</strong> each offer their own approach to curation and personalization.</p><p>But a new player — <strong>News250</strong> — is rethinking the formula by prioritizing <strong>conciseness, multilingual access, and transparency</strong>.</p><h3>Comparative Snapshot</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wzxz2uTek3axpzJsWZIGfg.png" /></figure><h3>Why This Matters</h3><ul><li>For <strong>casual readers</strong>: News250 is the fastest way to get the gist without drowning in text.</li><li>For <strong>researchers &amp; journalists</strong>: The ability to see multiple sources at once avoids single-source bias.</li><li>For <strong>global users</strong>: Multilingual support means access across cultures and regions.</li></ul><p>It’s not about replacing in-depth journalism — it’s about <strong>removing friction</strong> between you and the news.</p><h3>Curious? Try it yourself at <a href="https://news250.com/">http://n<strong>ews250.com</strong></a></h3><p>The world doesn’t need another personalized news bubble. It needs clarity.</p><p><strong>News250 is carving out a unique space</strong>: short, transparent, multilingual news summaries that keep readers informed without the noise.</p><p>In a crowded market of aggregators, that makes it worth watching.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bf9ecfc6300" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fine-tuning DistilBERT for Multilingual News Classification: A Real-World Journey with 13k Articles]]></title>
            <link>https://medium.com/@alejandro_14707/fine-tuning-distilbert-for-multilingual-news-classification-a-real-world-journey-with-13k-articles-cbd89c81e48c?source=rss-fb4e6d5ebc5e------2</link>
            <guid isPermaLink="false">https://medium.com/p/cbd89c81e48c</guid>
            <dc:creator><![CDATA[Nahuel Alejandro Nucera]]></dc:creator>
            <pubDate>Wed, 13 Aug 2025 06:53:05 GMT</pubDate>
            <atom:updated>2025-08-13T06:53:05.604Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uaz5rfhLbImrN4eIeybi1w.png" /><figcaption>https://news250.com</figcaption></figure><p><em>How we built a production-ready news classifier, overcame data quality challenges, and achieved 85% accuracy across 7 categories and multiple languages</em></p><h3>Introduction</h3><p>When you’re sitting on 2 million not-very-well-categorized news articles and have a $5 OpenAI budget, you need to be strategic. This is the story of how we built a production-ready multilingual news classifier for <a href="https://news250.com/">https://news250.com/</a> by carefully selecting and labeling just 13,000 articles from our massive dataset, to keep delivering news in around 250 characters.</p><p><strong>What we learned:</strong></p><ul><li>How to strategically sample from massive datasets with limited labeling budget</li><li>Why smart sampling beats random sampling for news classification</li><li>How to maximize GPT-4’s labeling efficiency under budget constraints</li><li>Production-ready code for building your own news classifier</li></ul><h3>The Challenge: 2 Million Articles, $5 Budget</h3><p>We started with nearly 2 million scraped news articles across multiple languages and countries, but they were unlabeled. With only $5 to spend on OpenAI tokens for labeling, we needed a surgical approach to create our training dataset.</p><p><strong>Our target categories:</strong></p><ul><li><strong>health</strong>: Medicine, diseases, healthcare systems</li><li><strong>tech</strong>: Technology, software, AI, cybersecurity</li><li><strong>business</strong>: Economy, markets, corporate news</li><li><strong>politics</strong>: Government, elections, legislation</li><li><strong>sports</strong>: Competitive sports, athletes, teams</li><li><strong>entertainment</strong>: Movies, music, celebrities, arts</li><li><strong>society</strong>: Social issues, education, crime, lifestyle</li></ul><h3>Phase 1: Strategic Sampling from 2 Million Articles</h3><h3>The Sampling Strategy</h3><p>Rather than randomly sampling 13k articles, we designed a strategic approach to maximize diversity and representation:</p><pre>def strategic_sample_for_labeling(total_articles: int = 2_000_000, target_sample: int = 13_000):<br>    &quot;&quot;&quot;<br>    Strategic sampling from 2M articles to maximize diversity within budget constraints<br>    &quot;&quot;&quot;<br>    <br>    # Sample distribution strategy<br>    sampling_criteria = {<br>        &#39;languages&#39;: {<br>            &#39;en&#39;: 0.4,    # 40% English (largest source)<br>            &#39;es&#39;: 0.25,   # 25% Spanish  <br>            &#39;fr&#39;: 0.15,   # 15% French<br>            &#39;it&#39;: 0.10,   # 10% Italian<br>            &#39;de&#39;: 0.05,   # 5% German<br>            &#39;other&#39;: 0.05 # 5% Other languages<br>        },<br>        &#39;countries&#39;: {<br>            &#39;US&#39;: 0.3, &#39;GB&#39;: 0.1, &#39;ES&#39;: 0.15, &#39;FR&#39;: 0.15, <br>            &#39;IT&#39;: 0.1, &#39;DE&#39;: 0.05, &#39;other&#39;: 0.15<br>        },<br>        &#39;time_periods&#39;: {<br>            &#39;recent&#39;: 0.6,      # 60% from last 3 months<br>            &#39;medium&#39;: 0.3,      # 30% from 3-12 months  <br>            &#39;older&#39;: 0.1        # 10% older articles<br>        },<br>        &#39;content_length&#39;: {<br>            &#39;short&#39;: 0.2,       # 20% short articles (50-200 words)<br>            &#39;medium&#39;: 0.6,      # 60% medium articles (200-800 words)<br>            &#39;long&#39;: 0.2         # 20% long articles (800+ words)<br>        }<br>    }<br>    <br>    print(f&quot;🎯 STRATEGIC SAMPLING FROM {total_articles:,} ARTICLES&quot;)<br>    print(f&quot;📊 Target sample: {target_sample:,} articles&quot;)<br>    print(f&quot;💰 Budget constraint: $5 OpenAI tokens&quot;)<br>    <br>    return sampling_criteria<br><br>def execute_sampling_query():<br>    &quot;&quot;&quot;<br>    Execute the strategic sampling - database details hidden for production security<br>    &quot;&quot;&quot;<br>    # In production, this would be your actual database sampling logic<br>    # We keep the sampling strategy public but hide infrastructure details<br>    <br>    sample_articles = []<br>    <br>    # Pseudo-code for the sampling approach:<br>    # 1. Stratified sampling by language/country<br>    # 2. Temporal distribution to avoid bias  <br>    # 3. Content length diversity<br>    # 4. Source diversity (avoid single-source bias)<br>    <br>    print(&quot;✅ Strategic sampling completed&quot;)<br>    print(f&quot;📦 Selected {len(sample_articles)} articles for labeling&quot;)<br>    <br>    return sample_articles</pre><h3>Why This Sampling Approach Worked</h3><ol><li><strong>Language diversity</strong>: Ensured multilingual capability</li><li><strong>Geographic spread</strong>: Avoided country-specific bias</li><li><strong>Temporal balance</strong>: Included both recent and historical content</li><li><strong>Content variety</strong>: Mixed short breaking news with long-form articles</li><li><strong>Source diversity</strong>: Prevented single-publisher bias</li></ol><h3>Phase 2: Maximizing GPT-4 Efficiency Under Budget</h3><h3>The $5 Token Budget Challenge</h3><p>With approximately 13k articles to label and a $5 budget, we had roughly a few tokens per article. This forced us to optimize aggressively:</p><pre>class BudgetOptimizedCategorizer:<br>    &quot;&quot;&quot;<br>    GPT-4 categorizer optimized for maximum efficiency under strict budget constraints<br>    &quot;&quot;&quot;<br>    <br>    # Streamlined prompt - every token counts!<br>    EFFICIENT_PROMPT = &quot;&quot;&quot;Classify this news article:<br><br>Headline: &quot;{headline}&quot;<br>Summary: &quot;{ai_summary}&quot;<br>Country: &quot;{country}&quot;<br><br>Categories: health, tech, business, politics, sports, entertainment, society<br>Scope: national, international<br><br>Output JSON only:<br>{{&quot;content_category&quot;: &quot;category&quot;, &quot;scope&quot;: &quot;scope&quot;}}&quot;&quot;&quot;<br><br>    def __init__(self, budget_limit_tokens: int = 33000):<br>        self.budget_limit = budget_limit_tokens<br>        self.tokens_used = 0<br>        self.client = OpenAI()<br>        <br>    def categorize_with_budget_control(self, article: Dict) -&gt; Dict:<br>        &quot;&quot;&quot;Categorize article with strict budget monitoring&quot;&quot;&quot;<br>        <br>        if self.tokens_used &gt;= self.budget_limit:<br>            print(f&quot;💰 Budget limit reached: {self.tokens_used}/{self.budget_limit} tokens&quot;)<br>            return self._default_classification(&quot;Budget exceeded&quot;)<br>        <br>        # Use the most efficient model<br>        prompt = self.EFFICIENT_PROMPT.format(<br>            headline=article[&#39;headline&#39;][:100],  # Truncate to save tokens<br>            ai_summary=article.get(&#39;ai_summary&#39;, &#39;&#39;)[:200],  # Limit summary length<br>            country=article.get(&#39;country&#39;, &#39;UNKNOWN&#39;)<br>        )<br>        <br>        try:<br>            response = self.client.chat.completions.create(<br>                model=&quot;gpt-4o-mini&quot;,  # Most cost-effective option<br>                messages=[{&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: prompt}],<br>                max_tokens=50,  # Strict output limit<br>                temperature=0    # Deterministic for consistency<br>            )<br>            <br>            tokens_used = response.usage.total_tokens<br>            self.tokens_used += tokens_used<br>            <br>            # Progress monitoring<br>            if self.tokens_used % 5000 == 0:<br>                remaining_budget = self.budget_limit - self.tokens_used<br>                articles_remaining = remaining_budget // 2.5  # Estimated tokens per article<br>                print(f&quot;💰 Budget status: {self.tokens_used}/{self.budget_limit} tokens used&quot;)<br>                print(f&quot;📊 Estimated articles remaining: {articles_remaining:.0f}&quot;)<br>            <br>            content = response.choices[0].message.content.strip()<br>            return json.loads(content)<br>            <br>        except Exception as e:<br>            return self._default_classification(f&quot;Error: {str(e)}&quot;)<br>    <br>    def _default_classification(self, reason: str) -&gt; Dict:<br>        &quot;&quot;&quot;Fallback classification to avoid losing articles&quot;&quot;&quot;<br>        return {<br>            &#39;content_category&#39;: &#39;general&#39;,<br>            &#39;scope&#39;: &#39;national&#39;,<br>            &#39;reasoning&#39;: f&quot;Default due to: {reason}&quot;<br>        }</pre><h3>Budget Optimization Techniques</h3><ol><li><strong>Minimal prompt</strong>: Stripped to essential information only</li><li><strong>Token limits</strong>: Hard caps on input and output length</li><li><strong>Progress monitoring</strong>: Real-time budget tracking</li><li><strong>Graceful degradation</strong>: Fallback for budget overruns</li><li><strong>Batch processing</strong>: Efficient API usage patterns</li></ol><h3>Phase 3: The Labeling Process</h3><h3>Two-Phase Labeling Approach</h3><pre>def execute_budget_constrained_labeling():<br>    &quot;&quot;&quot;<br>    Execute the labeling process with budget constraints<br>    &quot;&quot;&quot;<br>    <br>    categorizer = BudgetOptimizedCategorizer(budget_limit_tokens=33000)<br>    <br>    # Phase 1: Console preview (minimal tokens)<br>    print(&quot;🔍 PHASE 1: Budget-conscious preview&quot;)<br>    sample_articles = get_sample_for_preview(100)  # Small sample first<br>    <br>    preview_cost = 0<br>    for article in sample_articles:<br>        classification = categorizer.categorize_with_budget_control(article)<br>        preview_cost += 2.5  # Estimated tokens per article<br>        <br>        if preview_cost &gt; 1000:  # Stop preview if approaching 1/5 of budget<br>            break<br>    <br>    print(f&quot;💰 Preview cost: ~{preview_cost} tokens&quot;)<br>    print(f&quot;📊 Projected full cost: ~{preview_cost * 130} tokens&quot;)  # Scale to 13k<br>    <br>    # Phase 2: Full labeling if preview looks good<br>    if input(&quot;Continue with full labeling? (y/n): &quot;).lower() == &#39;y&#39;:<br>        return execute_full_labeling(categorizer)<br>    <br>def execute_full_labeling(categorizer):<br>    &quot;&quot;&quot;Execute full 13k article labeling&quot;&quot;&quot;<br>    <br>    articles = load_strategic_sample()  # Our 13k strategic sample<br>    labeled_dataset = []<br>    <br>    print(f&quot;🏭 PHASE 2: Full labeling of {len(articles)} articles&quot;)<br>    <br>    for i, article in enumerate(articles, 1):<br>        if categorizer.tokens_used &gt;= categorizer.budget_limit:<br>            print(f&quot;⚠️ Budget exhausted at article {i}&quot;)<br>            break<br>            <br>        classification = categorizer.categorize_with_budget_control(article)<br>        <br>        labeled_article = {<br>            &#39;id&#39;: article[&#39;id&#39;],<br>            &#39;headline&#39;: article[&#39;headline&#39;],<br>            &#39;content&#39;: article[&#39;content&#39;],<br>            &#39;ai_summary&#39;: article.get(&#39;ai_summary&#39;, &#39;&#39;),<br>            &#39;country&#39;: article[&#39;country&#39;],<br>            &#39;language&#39;: article[&#39;language&#39;],<br>            &#39;content_category&#39;: classification[&#39;content_category&#39;],<br>            &#39;scope&#39;: classification[&#39;scope&#39;],<br>            &#39;source_dataset&#39;: &#39;2M_strategic_sample&#39;  # Track provenance<br>        }<br>        <br>        labeled_dataset.append(labeled_article)<br>        <br>        # Progress updates<br>        if i % 1000 == 0:<br>            cost_so_far = categorizer.tokens_used * 0.00015  # GPT-4o-mini pricing<br>            print(f&quot;📊 Progress: {i}/{len(articles)} articles labeled&quot;)<br>            print(f&quot;💰 Cost so far: ${cost_so_far:.2f}&quot;)<br>    <br>    # Save the labeled dataset<br>    timestamp = datetime.now().strftime(&quot;%Y%m%d_%H%M%S&quot;)<br>    output_file = f&quot;labeled_news_dataset_{timestamp}.json&quot;<br>    <br>    with open(output_file, &#39;w&#39;, encoding=&#39;utf-8&#39;) as f:<br>        json.dump(labeled_dataset, f, indent=2, ensure_ascii=False)<br>    <br>    final_cost = categorizer.tokens_used * 0.00015<br>    print(f&quot;✅ Labeling completed!&quot;)<br>    print(f&quot;📊 Articles labeled: {len(labeled_dataset)}&quot;)<br>    print(f&quot;💰 Total cost: ${final_cost:.2f}&quot;)<br>    print(f&quot;📁 Dataset saved: {output_file}&quot;)<br>    <br>    return labeled_dataset</pre><h3>Phase 4: From Labels to Training Data</h3><h3>Discovering the Reality of Our Sample</h3><p>After labeling our strategic 13k sample, we discovered the natural distribution:</p><pre>📊 LABELED DATASET ANALYSIS:<br>============================================================<br>Total articles: 13,196<br>Categories: 7<br>Languages: 6 different languages  <br>Countries: 12 different countries<br><br>📋 Category Distribution:<br>  politics    : 4,905 ( 37.2%) ✅ OK<br>  society     : 4,527 ( 34.3%) ✅ OK  <br>  business    : 1,036 (  7.9%) ✅ OK<br>  entertainment: 1,044 (  7.9%) ✅ OK<br>  health      :   830 (  6.3%) ✅ OK<br>  sports      :   537 (  4.1%) ✅ OK<br>  tech        :   317 (  2.4%) ⚠️ SEVERELY UNDER<br><br>⚖️ Imbalance Analysis:<br>  Ratio (max/min): 15.5<br>  🚨 CRITICAL: Extreme imbalance detected!</pre><p>This revealed a fundamental truth about news distribution: <strong>politics and society naturally dominate real-world news</strong>. Our strategic sampling reflected reality, not academic balance.</p><h3>Phase 5: Handling Extreme Imbalance</h3><h3>The Three-Pronged Approach</h3><p>We couldn’t collect more data due to budget constraints, so we had to work with what we had:</p><pre>def handle_extreme_imbalance(df):<br>    &quot;&quot;&quot;<br>    Handle 15:1 class imbalance with multiple strategies<br>    &quot;&quot;&quot;<br>    <br>    print(&quot;⚖️ HANDLING EXTREME CLASS IMBALANCE&quot;)<br>    print(&quot;=&quot; * 50)<br>    <br>    # Strategy 1: Dataset balancing<br>    def balance_dataset(df, max_samples=800):<br>        balanced_data = []<br>        <br>        for category in df[&#39;category&#39;].unique():<br>            cat_data = df[df[&#39;category&#39;] == category]<br>            if len(cat_data) &gt; max_samples:<br>                # Cap overrepresented categories<br>                cat_data = cat_data.sample(n=max_samples, random_state=42)<br>                print(f&quot;📉 {category}: {len(df[df[&#39;category&#39;] == category])} → {max_samples}&quot;)<br>            else:<br>                print(f&quot;✅ {category}: {len(cat_data)} (keeping all)&quot;)<br>            balanced_data.append(cat_data)<br>        <br>        return pd.concat(balanced_data, ignore_index=True)<br>    <br>    # Strategy 2: Enhanced class weights  <br>    def calculate_boosted_weights(y_train, label_encoder):<br>        base_weights = compute_class_weight(&#39;balanced&#39;, classes=np.unique(y_train), y=y_train)<br>        <br>        boosted_weights = {}<br>        for i, weight in enumerate(base_weights):<br>            category = label_encoder.inverse_transform([i])[0]<br>            <br>            # Extreme boost for severely underrepresented categories<br>            if category == &#39;tech&#39;:<br>                boost_factor = 6.0  # 6x boost for tech<br>            elif category == &#39;sports&#39;:<br>                boost_factor = 3.0  # 3x boost for sports  <br>            else:<br>                boost_factor = 1.0  # Normal weight<br>                <br>            boosted_weights[i] = weight * boost_factor<br>            print(f&quot;  {category}: {weight:.3f} → {boosted_weights[i]:.3f} (boost: {boost_factor}x)&quot;)<br>        <br>        return boosted_weights<br>    <br>    # Strategy 3: Custom loss function<br>    class ExtremeImbalanceTrainer(Trainer):<br>        def __init__(self, class_weights, *args, **kwargs):<br>            super().__init__(*args, **kwargs)<br>            self.class_weights = torch.tensor(<br>                list(class_weights.values()), <br>                dtype=torch.float<br>            ).to(device)<br>        <br>        def compute_loss(self, model, inputs, return_outputs=False, num_items_in_batch=None):<br>            labels = inputs.get(&quot;labels&quot;)<br>            outputs = model(**inputs)<br>            logits = outputs.get(&quot;logits&quot;)<br>            <br>            # Weighted cross entropy with extreme imbalance handling<br>            loss_fct = CrossEntropyLoss(weight=self.class_weights)<br>            loss = loss_fct(<br>                logits.view(-1, self.model.config.num_labels), <br>                labels.view(-1)<br>            )<br>            <br>            return (loss, outputs) if return_outputs else loss<br>    <br>    return balance_dataset, calculate_boosted_weights, ExtremeImbalanceTrainer</pre><h3>Phase 6: Training and Results</h3><h3>Final Training Configuration</h3><pre># Model configuration optimized for our constraints<br>MODEL_NAME = &quot;distilbert-base-multilingual-cased&quot;<br>MAX_LENGTH = 512<br>BATCH_SIZE = 16<br>LEARNING_RATE = 2e-5<br>NUM_EPOCHS = 4<br><br>training_args = TrainingArguments(<br>    output_dir=&#39;./results&#39;,<br>    num_train_epochs=NUM_EPOCHS,<br>    per_device_train_batch_size=BATCH_SIZE,<br>    per_device_eval_batch_size=32,<br>    gradient_accumulation_steps=2,  # Effective batch size = 32<br>    warmup_steps=500,<br>    weight_decay=0.01,<br>    learning_rate=LEARNING_RATE,<br>    lr_scheduler_type=&quot;cosine&quot;,<br>    fp16=True,  # Mixed precision for efficiency<br>    evaluation_strategy=&quot;steps&quot;,<br>    eval_steps=200,<br>    save_strategy=&quot;steps&quot;, <br>    save_steps=200,<br>    load_best_model_at_end=True,<br>    metric_for_best_model=&quot;f1&quot;,<br>    greater_is_better=True,<br>    report_to=None,  # No external logging<br>)</pre><h3>Production Results</h3><p>After all optimizations on our strategically sampled 13k dataset:</p><pre>📊 FINAL PRODUCTION RESULTS:<br>============================================================<br>✅ Test Accuracy: 85.8%<br>📈 Weighted F1-Score: 0.85<br>💰 Total labeling cost: $4.73 (under budget!)<br>📦 Training data: 13,196 articles from 2M original<br><br>🎯 Per-Category Performance:<br>  politics     : F1=0.894 (excellent for dominant class)<br>  sports       : F1=0.844 (good despite small sample)  <br>  entertainment: F1=0.888 (strong performance)<br>  business     : F1=0.775 (acceptable)<br>  health       : F1=0.787 (acceptable)<br>  tech         : F1=0.831 (impressive given only 317 examples!)<br>  society      : F1=0.688 (needs improvement but usable)<br><br>🌍 Multilingual Performance:<br>  English: 87.2% accuracy<br>  Spanish: 84.1% accuracy  <br>  French: 83.8% accuracy<br>  Italian: 82.5% accuracy<br>  German: 81.9% accuracy</pre><h3>Conclusion</h3><p>Starting with 2 million articles and a $5 budget taught us that constraints breed creativity. Our strategic approach to sampling, labeling, and training produced a robust multilingual news classifier that handles real-world news distribution effectively.</p><p><strong>Key takeaways:</strong></p><ol><li><strong>Strategic sampling</strong> from massive datasets beats random sampling</li><li><strong>Budget constraints</strong> force efficient prompt engineering and model selection</li><li><strong>Natural imbalance</strong> in news data requires specialized handling techniques</li><li><strong>Production systems</strong> need to hide infrastructure while sharing methodology</li></ol><p>The classifier now processes a few thousand of daily articles across multiple languages with 85.8% accuracy. While the extreme class imbalance means some categories perform better than others, the system is robust enough for production deployment on <a href="https://news250.com/">https://news250.com/</a> with appropriate confidence thresholding.</p><p><strong>Tags:</strong> #MachineLearning #NLP #DataSampling #BudgetOptimization #NewsClassification #DistilBERT #ProductionML #StrategicSampling</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cbd89c81e48c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[News250.com: Born from Frustration, Fueled by Purpose]]></title>
            <link>https://medium.com/@alejandro_14707/news250-com-born-from-frustration-fueled-by-purpose-3c5e8dc37da6?source=rss-fb4e6d5ebc5e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c5e8dc37da6</guid>
            <dc:creator><![CDATA[Nahuel Alejandro Nucera]]></dc:creator>
            <pubDate>Sun, 03 Aug 2025 13:54:18 GMT</pubDate>
            <atom:updated>2025-08-03T13:54:49.204Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YRYe28dWeeruSBH_OdcS5w.jpeg" /></figure><p><strong>News250 didn’t start in a boardroom or a startup incubator (sadly it didnt started in the basement of a fancy house in California). It was born out of pure frustration. Out of sitting in Rome, on December 30th, 2024, drinking a birra, watching fireworks near the Colosseum — and thinking: <em>“This can’t be it.”</em></strong></p><p>I was working at a so-called AI company. Big budget. Great branding. Absolutely useless engineering.<br> They said they were doing artificial intelligence, but nothing scaled. Nothing worked. The only thing that grew was the amount of internal meetings and polished LinkedIn posts.</p><p>At the same time, I was trying to find a simple piece of information:<br> <strong>Which streets in Rome were closed for the Jubilee?</strong><br> And after scrolling through bloated news articles full of pop-ups, ads, and misleading headlines — I realized how broken the information landscape truly is.</p><h3>The spark</h3><p>That night, as fireworks lit up the sky, I made a New Year’s resolution:</p><blockquote><strong><em>Build the most efficient, transparent, no-bullshit news platform in the world.</em></strong></blockquote><p>Something radically simple.<br>Something that uses real AI for good.<br>Something that gives you <strong>what happened</strong>, without the noise.</p><h3>7 months later: News250.com goes public</h3><p>Fast forward to today — <strong>News250.com</strong> is live in public beta. It’s raw. It’s early. It’s far from done.<br> But the foundation is there. The mission is unshakable. The values are crystal clear:</p><ul><li><strong>Zero clickbait.</strong></li><li><strong>250 characters per story.</strong></li><li><strong>AI-powered, human-curated clarity.</strong></li><li><strong>No ads, no fluff, no tricks.</strong></li></ul><p>We built <strong>News250</strong> to answer a very simple question:</p><blockquote><em>“Can I trust what I’m reading?”<br> If the answer isn’t a firm “yes,” then we’ve failed.</em></blockquote><h3>What is News250?</h3><p><strong>News250.com </strong>is a tech-first, AI-powered news startup founded with one goal:</p><blockquote><strong><em>To bring you the news in the most direct, honest, and concise way possible.</em></strong></blockquote><p>Every day, <strong>News250</strong> scans hundreds of sources, removes duplicates, filters noise, and uses state-of-the-art AI to summarize real news in under 250 characters.<br> We make it dead simple to stay informed — without wasting your time.</p><h3>Built by engineers. Not marketers.</h3><p>News250 wasn’t born on a deck. It was built with code, caffeine, and conviction.<br> The platform is constantly evolving, and yes — it still has a long way to go. But we’re not faking it till we make it. We’re <strong>building it as it should be.</strong></p><p><strong>Follow the journey. Share the vision. Clean the news.</strong><br>Welcome to <strong>News250</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c5e8dc37da6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>