home.social

Search

1000 results for “re_do”

  1. Ukraine hits Russian refinery as Zelenskyy says ‘we’re done’ with Trump’s energy truce

    Russia and Ukraine had agreed to halt attacks on energy sites but in the days that followed, Russia rained down missile and drone strikes, including on energy targets such as power stations, knocking out power to hundreds of thousands of people

    justpaste.in/news/russia-ukrai

    #donaldtrump #Russia #RussiaUkrainecrisis #ukraine #VolodymyrZelenskyy

  2. RE: social.vivaldi.net/@AntiFascis

    It's as if Republicans know they're doomed if they don't demonize the real competition.

    It is yet another reminder that the Latino vote could prove decisive in determining whether Republicans retain control of both chambers of Congress or Democrats reclaim them.

    The Latino electorate is diverse, but one characteristic stands out: its youth. The median age of eligible Hispanic voters is 39, compared with 45 among Black voters, 47 among Asian Americans and 52 among white voters.

  3. Can't You See What You're Doing to Me
    Albert King

    youtu.be/A7NZim5OPl0

    Hey baby, can't you see what you're doin' to me
    Hey baby, baby, baby, can't you see what you're doin' to me
    Well you say you're gonna leave me, darlin'
    You're goin' back to your old time, used to be

    #mastobada #pouetradio

  4. if you're not using power tools, you're doing it wrong

  5. The first pots were pressed with cord to look like baskets. The first cars were horseless carriages. We meet the new in the clothes of the old. With AI we’re doing it with words: “think,” “understand.” Those words weren’t built for this. #philosophy #ai dougsmithphd.substack.com/p/no

  6. There's another PHP vulnerability out. They're saying it's only a thing if you have a web app that's configured "weirdly."

    If you're on linux and you don't think you have PHP installed, you should check.

    That's not meant to be fear mongering about PHP. I don't have an issue with PHP generally. However, you shouldn't have server software running on your computer unless you're doing it on purpose. If you are doing it on purpose, you have to keep track of vulnerabilities.

    #PHP #Linux

  7. Steelers canceled practice today due to a wind storm in Paris. They’re doing their media obligations now. #Steelers #NFL

  8. #SixYearsAgoToday #AreWeGreatYet

    October 24, 2020 – Speaking about the coronavirus at a campaign rally in North Carolina, Trump declared, “We’re doing great, we’re rounding the turn, our numbers are incredible.”

    The day before, more than 85,000 new cases of the coronavirus were reported in the United States — the highest number on any single day since the pandemic began.

    #TrumpMustGo #SaddamInsane #RepublicansOwnThis #NoRepublicansEverAgain #USPol

  9. "No judgement, but are you back with that twat?"

    "No. We're done. God, I love that you care though. I'll kiss you on the mouth if I can reach those lips."

    — ted lasso (2020)

  10. Even though I'm not actively looking for a job, the "I don't join companies with no women in leadership positions" recruiter response is still scary to send.

    Like, on the one hand, I want them to receive this feedback (I see what you're doing over there, with your page of faces that look suspiciously like mine). On the other hand, it's still scary to close off potential work, even though I'm employed.

  11. Dear CFO:

    If the department is chugging along, and consistently breaking PY records month after month ... d ... don't fuck with it. Just don't. We know what we're doing, and we're clearly proving it. Our department doesn't need you to pick it up and shake it over your head like an Etch-a-Sketch so you can put your own ignorant, overconfident stamp on it.

    Just go back in your big office and check your stonks. We got this.

  12. This week's pick comes with minimal backstory, maximum riffage, and a band who clearly know exactly what they're doing. #Eallic, you've got our attention!

    Check it out and see what we had to say, and follow us for weekly picks and musings from across the world of #rock and #metal!

    #musicblog #nowplaying #melodeath #songoftheweek

    rocksongoftheweek.com/song/eal

  13. In 2016, Microsoft released a chatbot called Tay on Twitter. Within 16 hours, it had been shut down for posting racist, sexist, and antisemitic content. The postmortem blamed “coordinated attacks” by trolls. That framing was technically accurate and completely wrong. Tay didn’t break. Tay did exactly what it was designed to do: learn from the conversation it was placed in. The conversation it was placed in was a cesspool. Tay was a mirror, and the mirror worked perfectly.

    Nearly a decade later, we’re still having the wrong conversation about what models reveal. The discourse treats AI as an entity with properties: is it aligned? Is it safe? Is it biased? These are questions about the mirror, not the reflection. The more interesting questions are about what the reflection shows us: about our data, our preferences, our blind spots, and the things we didn’t know we were collectively doing until a model did them back to us at scale.

    Here’s the claim I want to test: AI models are not windows into machine intelligence. They are windows into human behavior, aggregated, compressed, and served back to us with a confidence that makes us mistake the reflection for an external truth. The most important thing AI reveals is not what machines can do. It’s what we already do, at a scale we’ve never been able to see before.

    The Mirror Was Always There. AI Just Made It Legible.

    Humans have always been reflected back to themselves by their tools, but the reflection was always slow and partial. A novel reflected its author. A newspaper reflected its readership. A city reflected its inhabitants. But the reflection took years to develop, and it was filtered through gatekeepers who decided what was worth showing.

    AI compresses the reflection cycle. A model trained on a year of internet text reflects that year back to us in hours. A model fine-tuned on user feedback reflects user preferences back to us in a single deployment. The mirror is faster, wider, and less filtered, and it shows us patterns we couldn’t see before because we never had a technology that could aggregate human behavior at that scale and serve it back in a coherent form.

    What does the mirror actually show? Let me give you specific examples, because the abstract version is useless.

    1. The distribution of human patience.

    When you train a model on human conversations, you see how quickly humans give up on unclear interactions. You see the average number of turns before a user rephrases, the average number of messages before a user abandons, the average tolerance for a response that doesn’t directly answer the question. These distributions are not what most designers assume. Users are more patient than designers think in some contexts and less patient in others, and the patterns are consistent across languages and cultures in ways that surprised everyone who measured them.

    1. The shape of human curiosity.

    When you train a model on search queries, you see the actual topology of human curiosity. Not what people say they’re curious about, but what they type at 2 AM. The distribution is flatter, stranger, and more repetitive than any survey would suggest. A small number of questions account for a huge fraction of queries, and the long tail is enormous. This is the mirror showing us that curiosity is much more concentrated than our cultural narratives about it suggest.

    1. The limits of human consistency.

    When you train a model on human judgments, you discover how inconsistent humans actually are. The same person, asked the same question in a slightly different framing, gives a different answer at rates that would be alarming if we hadn’t built a whole society on the assumption that we’re consistent. The mirror shows us that human judgment is heavily context-dependent, and that most of what we call “preferences” are actually “situational responses” that we mistake for stable traits.

    1. The distribution of human writing.

    When you train a model on human text, you discover that a small fraction of the corpus accounts for a large fraction of the unique content. Most writing is derivative of a smaller set of writing. The mirror shows us that the diversity we imagine in human expression is partially an illusion, sustained by the fact that we never had to measure it before.

    These aren’t facts about models. They’re facts about us, revealed by models.

    The Sacred Cow: “AI Has Biases That We Should Remove”

    Here’s the belief I want to dismantle, and it’s the load-bearing assumption of nearly every AI safety and fairness conversation.

    The claim goes like this: AI models have biases, biases are bad, and the solution is to remove them.

    This framing is wrong, and it’s wrong in a way that produces bad engineering and worse policy.

    Here’s the problem. AI models don’t have biases. They reflect biases. The biases are in the training data, and the training data is a sample of human behavior. Removing the bias from the model doesn’t remove the bias from the data. It just hides it.

    What actually happens when you try to “remove bias” from a model:

    You filter the training data to exclude certain patterns.

    You fine-tune the model to refuse certain outputs.

    You add safety layers that override the model’s default behavior.

    Each of these moves makes the model appear less biased on the specific metrics you’re measuring, while leaving the underlying distribution intact. The model still learned the biased pattern. It just learned to hide it. And the hiding is now invisible, which makes it harder to study, not easier.

    The contrarian take: the mirror is more useful when it shows us the ugliness, not when it hides it. A model that reflects the full distribution of human behavior, including the parts we don’t like, is a tool for understanding what we’re actually doing. A model that’s been scrubbed of everything uncomfortable is a tool for pretending we’re not doing it.

    This doesn’t mean we should deploy unfiltered models. It means we should distinguish between two different goals: building a model that behaves well (which requires filtering) and building a model that tells us the truth about human behavior (which requires not filtering). These are different products for different purposes, and conflating them gives us the worst of both.

    If you want to understand human behavior, study the unfiltered mirror. If you want to build a product that behaves responsibly, filter the outputs. Just don’t pretend the filtered outputs tell you what humans are actually like.

    What the Mirror Reveals About Builders

    The mirror doesn’t just show users. It shows builders.

    Here’s the part that gets less attention and matters more over time. The models we build reflect not just the data but the choices we make about the data. Every decision about what to include, what to exclude, what to weight, and what to ignore is a decision that shapes the reflection.

    Consider what a model reflects about the team that built it:

    The choice of training data reflects the team’s assumptions about what “counts” as legitimate text. Mostly English? Mostly Western? Mostly published? Each of these is a choice that encodes a worldview.

    The choice of fine-tuning data reflects the team’s assumptions about what good behavior looks like. Helpful? Refuse? Deferential? Each of these is a choice.

    The choice of evaluation reflects the team’s assumptions about what success looks like. Accuracy? Safety? Engagement? Each of these is a choice, and most teams never state them explicitly.

    The choice of deployment reflects the team’s assumptions about who gets to use the model and how. Free? Paid? API? Consumer? Each of these shapes who is reflected in the next round of data.

    The mirror, in other words, is not just reflecting human behavior. It’s reflecting the specific humans who built the model, through the specific choices they made about what to reflect.

    If you want to know what a model will do, don’t read the model card. Read the training data provenance, the fine-tuning guidelines, the evaluation criteria, and the deployment terms. These are the mirrors of the team’s priorities, and they’re more informative than any technical spec.

    What the Mirror Reveals About Users

    The mirror also shows what users are actually doing, which is often different from what they say they’re doing, and very different from what product teams assume.

    Concrete examples:

    Users are more repetitive than they think. In many AI products, a small fraction of users ask a small fraction of questions, over and over. The “long tail” of use cases is often thinner than the design team imagines.

    Users are more forgiving than product teams assume. When a model makes a mistake, users often correct it and keep going. The assumption that mistakes will cause churn is often wrong, especially for high-value use cases where the model is genuinely useful.

    Users are less interested in features than product teams hope. The features that get talked about in product reviews are often not the features that drive usage. Usage is dominated by a small number of core workflows, and the rest is noise.

    Users are more sophisticated about the model’s limits than product teams assume. Users develop intuitions about where the model is reliable and where it isn’t, and they route their usage accordingly. The “trust” problem is often a UI problem: the model doesn’t signal uncertainty, so users don’t know when to trust it.

    The mirror is useful for product teams because it shows them what users are actually doing, not what the team imagines users are doing. The gap between those two is where most product mistakes live.

    What To Actually Do

    Three moves, concrete enough to start on Monday.

    1. Study the failures, not just the successes.

    When you evaluate a model, look at the cases where it failed, and ask what the failure reveals about the data. A model that hallucinates on certain topics is telling you that the training data on those topics is thin. A model that refuses certain requests is telling you that the safety tuning has a specific shape. The failures are the mirror at its most useful.

    A simple starting point:

    def failure_analysis(model, eval_set):
    failures =
    [] for example in eval_set:
    output = model.generate(example.prompt)
    if not evaluate(output, example.expected):
    failures.append({
    “prompt”: example.prompt,
    “output”: output,
    “expected”: example.expected,
    “failure_type”: classify_failure(output, example.expected),
    })
    return summarize_by_type(failures)

    The summary is more informative than the pass rate. The pass rate tells you how good the model is. The failure summary tells you what the model has learned and what it hasn’t, which is what you need to know to improve it.

    1. Audit the training data, not the output.

    If you want to understand a model’s behavior, read a random sample of 500 training examples. Not the cleaned, curated examples that appear in the data card, but the raw examples. You’ll learn more about the model’s behavior in an afternoon than you’ll learn from a month of prompt engineering.

    1. Distinguish between the model you want and the mirror you need.

    If you’re building an AI product, decide explicitly whether you’re building a product that behaves well or a product that tells the truth about human behavior. These are different goals. A product that tells the truth might be more useful for research and less useful for consumers. A product that behaves well might be more useful for consumers and less useful for research. Pick one, and be honest about which one you’re building.

    The Mental Model

    Here’s the lens I want you to keep.

    AI models are mirrors, not minds. They reflect what we put into them, which is a sample of human behavior, shaped by the choices of the people who selected the sample. The reflection is more accurate than any survey and less accurate than any single conversation, and it reveals patterns we couldn’t see without it.

    The interesting question is not whether the mirror is biased. It is. The question is what we want to do with the reflection. We can hide the uncomfortable parts, which makes us feel better and teaches us nothing. Or we can study them, which makes us uncomfortable and teaches us a lot. The choice is ours, and it’s available every time we build a model, curate a dataset, or evaluate an output.

    The mirror is not a threat. It’s a discovery. The question is whether we’re brave enough to look at what it shows us.

    What’s your read? If you’ve studied model behavior, what’s the most surprising thing the mirror has shown you? And if you’ve built models, what’s the choice you’ve made about what to hide and what to reflect? Drop it in the comments. I’m genuinely curious what patterns others are seeing.#ai #promptengineering #chatgpt #software #coding #development #engineering #inclusive #community
    The AI Mirror: What Models Reveal About Us, Not About Themselves

  14. "Aiming to harness the opportunities of AI to raise living standards, back UK businesses and support economic growth, the chancellor said he wanted to seize the opportunities of the technology as a central plank of Labour’s plan for growth"

    Oh FFS.
    We're doomed...

    #Budget2026 #UKPolitics #AI
    theguardian.com/uk-news/2026/o

  15. I wonder if one reason we've seen so much growth in the in the last decade is that pretty much everyone who actually fought in or even just lived through WWII has now passed on.

    The philosopher George Santayana famously wrote: "Those who cannot remember the past are condemned to repeat it."

    Not only that, but I think a lot of these raise-the-flags, stop-the-boats folk genuinely believe that their ancestors from that time would support what they're doing — when probably the opposite is true.

  16. What IS that?

    You know curiosity isn't good for cats, Zaz, but at least this onion won't hurt you, though you won't like it.

    Have a good #caturday all, and keep warm if it's cold outside! If you're down under you can ignore that last bit.

    #EllieKPosts #Zaz #ZazTheCat #CornishRex #CatsOfMastondon #FediCats

  17. CW: Muh both sides

    I didn't like Biden's cabinet, either, but this is absurd. Eg: Biden chose a somewhat corrupt zionist lady to head DNI, while Trump chose a man who worked for an Epstein-affiliated billionaire Trump placed on the board in charge of redeveloping Gaza (aka building his new resort) after we're done paying to bomb it flat until he was placed in charge of sdny to stop investigating Eric Adams' before being given control of America's intelligence apparatus. Or, compare the small-time "classy" influence peddling by Hunter & James Biden with the egregious & over-the-top corruption of the Trump clan i mentioned just a few examples of. It's like the difference between picking your pocket and stealing your car.

    Politicians should have incredibly stringent regulations on their finances/investments, as well as those of associates with relevant financial flows. I fear that the open & apparently legalized corruption has grown to be more than the system can bear.

  18. When I started out, I thought being a good developer meant knowing everything. Every framework, every algorithm, every command. I pictured the senior engineers as walking encyclopedias.

    Then I watched one of them Google “how to undo a git commit” in front of the whole team. Nobody blinked.

    That moment changed how I saw this job. Here’s what I’ve learned since.

    1. Nobody remembers everything


    Googling isn’t cheating. It’s the job. The skill isn’t memorizing syntax, it’s knowing what to search for and recognizing a good answer when you see one.

    I used to feel guilty every time I opened Stack Overflow. Now I keep a notes file of the things I look up more than twice. Future me says thanks.

    2. Your first solution doesn’t have to be elegant


    I once spent three days designing the “perfect” architecture for a feature that, it turned out, five people used. A messy version that worked would have shipped in an afternoon.

    Make it work first, then make it clean, and only if it matters. Shipped and imperfect beats perfect and imaginary every time.

    3. Reading code is a bigger skill than writing it


    Most of your day won’t be spent writing brand-new code. It’ll be spent understanding code someone else wrote, sometimes years ago, sometimes you.

    Get comfortable being lost in a codebase. Follow one request from start to finish. Add a few console.log or print statements. Break things on purpose to see what happens. It feels slow, but it’s the fastest way to level up.

    4. Ask questions, but do it well


    I was terrified of looking dumb, so I stayed stuck for hours rather than ask. That was a mistake.

    What works better is a quick message with three parts: what I’m trying to do, what I’ve already tried, and where I’m stuck. Teammates respond faster, and half the time writing it out helps you spot the answer yourself.

    5. Burnout doesn’t announce itself


    It sneaks in. You skip lunch to fix one more bug, you code late “just to catch up,” and one day the thing you loved feels like a chore.

    Log off. Take the weekend. The bug will still be there on Monday, and you’ll fix it in ten minutes with a rested brain.

    6. Soft skills move your career more than you’d expect


    Clear writing, honest updates, and saying “I don’t know, but I’ll find out” make people want to work with you. I’ve seen average coders with great communication get trusted with big projects over brilliant ones nobody could talk to.

    7. Build small things, often


    Tutorials make you feel productive, but building teaches you. Make a tiny tool that fixes an annoyance in your own life. Break it, fix it, put it on GitHub.

    Small projects add up, and they give you real stories to tell in interviews.

    In Conclusion

    You don’t need to know everything. You need to be curious, stay kind to yourself, keep shipping, and keep learning in public. The people you look up to are still figuring it out too. They’ve just gotten comfortable not having all the answers.

    If you’re early in your journey, you’re doing better than you think.

    What’s one thing you wish you’d known when you started? Drop it in the comments. I read every one.#webdev #programming #beginners #career #software #coding #development #engineering #inclusive #community
    What I Wish Someone Had Told Me Before My First Dev Job

  19. Picture this: you're skiing down a Swiss mountain as the clock strikes midnight at the legendary Ski In Party Out on Trübsee—complete with fondue and a chalet celebration that'll have you toasting 2027 in style 🎉 Engelberg's scene goes beyond typical parties, with options ranging from the upscale Kempinski Palace to cozy village bars where locals and travelers mix. Whether you're after alpine adventure or après-ski vib...

    events.europa.tips/silvester-e

  20. So what do you do when your company’s security posture is being held ransom by SVPs that refuse to provide company owned phones because “costs to much” (we’re a double digits billion $ company), BYOD users who refuse to install Authenticator on their personal phones because “privacy!”, and lawyers who won’t decide if making them to it is winnable in court?

  21. "In the end, we're not doing the festival just for tourists. It's for us — for our town." Organizers of rural festivals in aging Japan are facing a conundrum: Attract more tourists or die out. japantimes.co.jp/life/2026/10/ #life #lifestyle #festivals #depopulation #rurallife #travel #tourism

  22. A good Doors live show recording from the archives. The band is definitely in a jam band mode as it opens with “Break On Through” So far, Jim Morrison has remained zipped. Crowd is loving it.

    They’re playing Doors standards at the off but lots of improv. Fresh take on old friends.

    #Doors #LiveShow #Recording #music #now_listening

  23. Understanding cosine similarity, Euclidean distance, and how machines find relevant text and images.

    1. Why do we need semantic search?


    Imagine you're building a search feature for your application.

    A user searches:

    How do I make my application faster?


    Your database contains these articles:

    1. How to optimize database queries
    2. Improving API performance with caching
    3. A beginner's guide to JavaScript arrays
    4. How to bake a chocolate cake

    Which articles should appear first?

    Traditional keyword search looks for matching words. Since the first two articles don't contain the exact phrase "make my application faster," a basic keyword search might rank them poorly.

    Semantic search takes a different approach: it searches for meaning, not just matching words.

    It can recognize that "make my application faster," "optimize database queries," and "improve API performance" may describe related ideas.

    To understand how semantic search works, we need three concepts:

    • Embeddings: Representing text or images as numbers.
    • Vectors: Working with those numbers mathematically.
    • Similarity and distance: Comparing vectors to rank relevant results.

    Let's build these concepts from scratch using simple mathematics and JavaScript.

    2. What is a vector?


    A vector is an ordered list of numbers.

    For example:

    const vector = [3, 4];

    We can imagine this vector as a point on a two-dimensional graph:

    • 3 represents the horizontal coordinate.
    • 4 represents the vertical coordinate.

    The point is therefore located at (3, 4).

    A vector can have two dimensions, three dimensions, or thousands of dimensions.

    For learning purposes, we'll use two-dimensional vectors because they're easy to visualize and calculate by hand.

    Important: These examples use illustrative numbers. Real embedding dimensions generally don't have simple, individually interpretable meanings.

    3. What is an embedding?


    An embedding is a numerical representation of content generated by a machine-learning model.

    Imagine an embedding model converts three sentences into vectors:

    SentenceIllustrative embedding"Make my app faster"[0.9, 0.1]"Improve application performance"[0.8, 0.2]"Chocolate cake recipe"[0.1, 0.9]


    The first two vectors point in similar directions. The third points in a different direction.

    This gives us a way to compare content mathematically.

    The embedding model learns useful representations during training. Our search system uses those representations to find and rank related content.

    A simplified semantic-search pipeline looks like this:

    User query
    |
    v
    Embedding model
    |
    v
    Query vector
    |
    v
    Compare with document vectors
    |
    v
    Rank relevant documents

    Now let's explore the mathematics behind those comparisons.

    4. Vector magnitude: how long is a vector?


    Before comparing vectors, let's understand their length, also called their magnitude or L2 norm.

    Suppose we have:

    a = [3, 4]

    The magnitude is calculated using the Pythagorean theorem.

    Step 1: Square both coordinates.

    ‖a‖₂ = √(3² + 4²)

    Step 2: Simplify the squares.

    ‖a‖₂ = √(9 + 16)

    Step 3: Add the values and calculate the square root.

    ‖a‖₂ = √25 = 5

    Therefore, the magnitude of vector [3, 4] is 5.

    In simple terms, the magnitude tells us how far the point is from the origin, (0, 0).

    Implementing magnitude in JavaScript


    function magnitude(vector) {
    const sumOfSquares = vector.reduce(
    (sum, value) => sum + value * value,
    0
    );

    return Math.sqrt(sumOfSquares);
    }

    console.log(magnitude([3, 4])); // 5

    Here's what the code does:

    1. Squares every value.
    2. Adds the squared values together.
    3. Takes the square root of the sum.

    We'll reuse this function when calculating cosine similarity.

    5. Euclidean distance: how far apart are two vectors?


    Magnitude measures the distance from the origin. Euclidean distance measures the distance between two points.

    Suppose we have two points.

    Point A

    a = [1, 2]

    Point B

    b = [4, 6]

    How far apart are they?

    First, calculate the difference between their coordinates:

    • Horizontal difference: 4 − 1 = 3
    • Vertical difference: 6 − 2 = 4

    Using the Pythagorean theorem:

    d = √(3² + 4²)

    d = √(9 + 16)

    d = √25 = 5

    The Euclidean distance is 5 units.

    The general L2 distance formula


    For two vectors with the same number of dimensions:

    dL2(a, b) = √[Σᵢ₌₁ⁿ (aᵢ − bᵢ)²]

    You don't need to memorize the notation immediately. Remember the process:

    1. Subtract corresponding coordinates.
    2. Square each difference.
    3. Add the squared differences.
    4. Take the square root.


    Implementing L2 distance in JavaScript


    function l2Distance(a, b) {
    if (a.length !== b.length) {
    throw new Error("Vectors must have equal dimensions");
    }

    const sumOfSquares = a.reduce((sum, value, i) => {
    const difference = value - b[i];
    return sum + difference * difference;
    }, 0);

    return Math.sqrt(sumOfSquares);
    }

    const a = [1, 2];
    const b = [4, 6];

    console.log(l2Distance(a, b)); // 5

    How does this help with semantic search?


    Imagine our query has already been converted into a vector:

    const query = [2, 3];

    We also have two document embeddings:

    const documentA = [4, 4];
    const documentB = [2, 5];

    Let's calculate the distance from the query to each document.

    Document A

    Distance = √((2 − 4)² + (3 − 4)²)

    Distance = √(4 + 1)

    Distance ≈ 2.236

    Document B

    Distance = √((2 − 2)² + (3 − 5)²)

    Distance = √(0 + 4)

    Distance = 2

    Document B is closer to the query because 2 is smaller than 2.236.

    When ranking by L2 distance, a smaller distance means the vectors are closer together.

    However, Euclidean distance isn't the only way to compare vectors. Another popular metric is cosine similarity.

    6. Dot product: multiplying corresponding values


    The dot product is an operation used in vector mathematics. It also plays an important role in calculating cosine similarity.

    Suppose we have two vectors:

    a = [2, 3]

    b = [4, 5]

    Multiply their corresponding values and add the results:

    a · b = (2 × 4) + (3 × 5)

    a · b = 8 + 15 = 23

    The dot product is 23.

    Implementing dot product in JavaScript


    function dotProduct(a, b) {
    if (a.length !== b.length) {
    throw new Error("Vectors must have equal dimensions");
    }

    return a.reduce(
    (sum, value, i) => sum + value * b[i],
    0
    );
    }

    console.log(dotProduct([2, 3], [4, 5])); // 23

    The dot product combines information from corresponding dimensions. When divided by the magnitudes of both vectors, it gives us the cosine of the angle between them.

    That is the foundation of cosine similarity.

    7. Cosine similarity: are the vectors pointing in the same direction?


    Euclidean distance asks:

    How far apart are two points?

    Cosine similarity asks:

    How closely do two vectors point in the same direction?

    Its formula is:

    cosineSimilarity(a, b) = (a · b) / (‖a‖₂ × ‖b‖₂)

    Let's work through an example.

    Suppose:

    a = [1, 2]

    b = [2, 4]

    Notice that vector B is twice vector A. Both point in exactly the same direction.

    Step 1: Calculate the dot product


    a · b = (1 × 2) + (2 × 4) = 10

    Step 2: Calculate both magnitudes


    For vector A:

    ‖a‖₂ = √(1² + 2²) = √5

    For vector B:

    ‖b‖₂ = √(2² + 4²) = √20

    Step 3: Calculate cosine similarity


    cosineSimilarity = 10 / (√5 × √20)

    Since √5 × √20 = 10:

    cosineSimilarity = 10 / 10 = 1

    The cosine similarity is 1, meaning the vectors point in exactly the same direction.

    Interpreting cosine similarity

    ScoreGeometric interpretation1Same direction0.8Strong positive directional alignment0Perpendicular directions-1Opposite directions


    These are geometric interpretations, not universal thresholds for semantic relevance. Whether a score indicates similar meaning depends on the embedding model and the data.

    Implementing cosine similarity in JavaScript


    function magnitude(vector) {
    return Math.sqrt(
    vector.reduce((sum, value) => sum + value * value, 0)
    );
    }

    function dotProduct(a, b) {
    if (a.length !== b.length) {
    throw new Error("Vectors must have equal dimensions");
    }

    return a.reduce(
    (sum, value, i) => sum + value * b[i],
    0
    );
    }

    function cosineSimilarity(a, b) {
    const magnitudeA = magnitude(a);
    const magnitudeB = magnitude(b);

    if (magnitudeA === 0 || magnitudeB === 0) {
    throw new Error(
    "Cosine similarity is undefined for zero vectors"
    );
    }

    return dotProduct(a, b) / (magnitudeA * magnitudeB);
    }

    console.log(cosineSimilarity([1, 2], [2, 4])); // 1
    console.log(cosineSimilarity([1, 0], [0, 1])); // 0
    console.log(cosineSimilarity([1, 0], [-1, 0])); // -1

    Cosine similarity is useful because multiplying a nonzero vector by a positive number doesn't change its direction. Consequently, cosine similarity is unaffected by positive scaling of either vector.

    This can be helpful when comparing embeddings whose lengths differ.

    8. Cosine distance: turning similarity into distance


    Sometimes we want a distance metric where lower values indicate a closer match.

    A common definition is:

    cosineDistance = 1 − cosineSimilarity

    Suppose Document A has a cosine similarity score of 0.9.

    Distance A = 1 − 0.9 = 0.1

    Document B has a cosine similarity score of 0.6.

    Distance B = 1 − 0.6 = 0.4

    Document A is the closer match under this metric because its cosine distance is smaller.

    Implementing cosine distance


    function cosineDistance(a, b) {
    return 1 - cosineSimilarity(a, b);
    }

    console.log(cosineDistance([1, 2], [2, 4])); // 0
    console.log(cosineDistance([1, 0], [0, 1])); // 1

    Remember the distinction:

    • Cosine similarity: Higher is better for directional alignment.
    • Cosine distance: Lower is better.
    • L2 distance: Lower means the points are closer.

    Implementations and vector databases may define or report metrics differently, so check the documentation for the system you're using.

    9. L2 distance vs. cosine similarity


    Let's compare two vectors:

    a = [1, 1]

    b = [10, 10]

    These vectors point in exactly the same direction, but their magnitudes differ.

    Their cosine similarity is:

    cosineSimilarity(a, b) = 1

    Their cosine distance is:

    cosineDistance = 1 − 1 = 0

    Now calculate their Euclidean distance:

    dL2 = √((1 − 10)² + (1 − 10)²)

    dL2 = √(81 + 81)

    dL2 = √162 ≈ 12.728

    The vectors have perfect directional alignment, yet their Euclidean distance is greater than 12.

    This illustrates the key difference:

    PropertyL2 distanceCosine similarityMeasuresDistance between coordinatesAlignment of directionsAffected by vector magnitude?YesNot by positive scalingBetter scoreSmallerLargerUseful whenCoordinate distance mattersDirectional alignment matters


    Neither metric is always better. The right choice depends on how the embedding model was trained and how its vectors should be compared.

    10. Build a simple semantic-ranking example


    Now let's combine our functions to build a small vector-ranking demonstration in JavaScript.

    Imagine an embedding model has already converted a search query and three documents into two-dimensional vectors.

    const query = [0.8, 0.6];

    const documents = [
    {
    title: "API performance optimization",
    embedding: [0.9, 0.4]
    },
    {
    title: "Database query optimization",
    embedding: [0.7, 0.7]
    },
    {
    title: "Chocolate cake recipe",
    embedding: [-0.5, 0.8]
    }
    ];

    These vectors are invented for demonstration. In a real application, an embedding model would generate them.

    Let's rank the documents by cosine similarity.

    function magnitude(vector) {
    return Math.sqrt(
    vector.reduce((sum, value) => sum + value * value, 0)
    );
    }

    function cosineSimilarity(a, b) {
    if (a.length !== b.length) {
    throw new Error("Vectors must have equal dimensions");
    }

    const dot = a.reduce(
    (sum, value, i) => sum + value * b[i],
    0
    );

    const normA = magnitude(a);
    const normB = magnitude(b);

    if (normA === 0 || normB === 0) {
    throw new Error("Zero vectors are not supported");
    }

    return dot / (normA * normB);
    }

    const rankedDocuments = documents
    .map(document => ({
    title: document.title,
    score: cosineSimilarity(query, document.embedding)
    }))
    .sort((a, b) => b.score - a.score);

    console.log(rankedDocuments);

    The results are approximately:

    [
    {
    title: "Database query optimization",
    score: 0.990
    },
    {
    title: "API performance optimization",
    score: 0.975
    },
    {
    title: "Chocolate cake recipe",
    score: 0.085
    }
    ]

    We sort the results in descending order because higher cosine similarity means stronger directional alignment.

    Notice something important: our JavaScript code doesn't understand language. It only compares vectors.

    The embedding model is responsible for learning useful representations of language. The ranking code uses those representations to order the results.

    Our example demonstrates the mechanics of vector search, not a complete semantic search system.

    11. Where do real embeddings come from?


    So far, we've manually supplied vectors such as [0.8, 0.6].

    Real applications use an embedding model to generate vectors from text or images.

    A typical workflow looks like this:

    1. Choose an embedding model.
    2. Convert each document into a vector.
    3. Store the vectors alongside document IDs and content.
    4. Convert the user's query into a vector using a compatible model.
    5. Find the nearest document vectors.
    6. Return the corresponding documents in ranked order.

    A JavaScript application might call an embedding API like this:

    // Illustrative pseudocode.
    // Replace this with your embedding provider's SDK.

    const queryEmbedding = await embeddingModel.embed(
    "How do I make my application faster?"
    );

    const documentEmbedding = await embeddingModel.embed(
    "Improve API performance with caching."
    );

    const score = cosineSimilarity(
    queryEmbedding,
    documentEmbedding
    );

    console.log(score);

    The exact API depends on your embedding provider. The key requirement is that both vectors must come from compatible embedding representations.

    For thousands or millions of documents, calculating every distance in application code can become expensive. A vector database or search engine can index embeddings and retrieve nearby candidates more efficiently.

    12. Does the same mathematics work for image search?


    Yes. The comparison mathematics is the same, but the process that generates the vectors differs.

    Imagine you're building an image-search application. A user enters:

    A dog playing on a beach.


    A compatible text-image model converts the query into an embedding. It also converts the available images into embeddings in a shared vector space.

    The application compares the query vector against the image vectors and ranks the images by similarity.

    The process looks like this:

    Text query
    |
    v
    Text encoder
    |
    v
    Query embedding
    |
    v
    Compare against image embeddings
    |
    v
    Rank matching images

    This works directly only when the model is designed to produce comparable text and image embeddings.

    Why not simply compare raw pixels?

    Two photographs of the same dog might have different lighting, camera angles, cropping, or backgrounds. Raw pixel differences may be large even when the images depict similar content.

    Learned image embeddings can capture useful visual patterns that raw pixel distance misses.

    However, the model can still make mistakes. A high similarity score is a ranking signal, not proof that an image contains every detail in the query.

    13. Why normalized vectors matter


    Some embedding models produce vectors with a magnitude of 1. These are called L2-normalized vectors.

    For unit-normalized vectors, Euclidean distance and cosine similarity are mathematically related:

    L2 distance² = 2 × (1 − cosine similarity)

    Equivalently:

    L2 distance = √[2 × (1 − cosine similarity)]

    This means that ranking the same unit-normalized vectors by L2 distance or cosine similarity produces the same ordering:

    • Higher cosine similarity means lower L2 distance.
    • Lower cosine similarity means higher L2 distance.

    This relationship can be useful when choosing a metric for a vector index.

    Don't assume every embedding model automatically normalizes its output. Check the model documentation before relying on this property.

    14. What would I use in a real JavaScript application?


    For a practical semantic-search feature, I'd separate the system into four responsibilities.

    1. Embedding model

    Converts text or images into vectors that represent useful features of the content.

    2. Vector database

    Stores the vectors and retrieves nearby candidates efficiently.

    3. Similarity metric

    Determines how the system compares vectors, using cosine similarity, Euclidean distance, or another supported metric.

    4. Application code

    Handles queries, metadata, filtering, ranking, and displaying results to users.

    Start with the metric recommended by your embedding model, then test it against real queries and expected results.

    For example, if you're building documentation search, create a test set of queries such as "make API faster" and identify which articles should appear first. Measure whether those articles show up in the top five results.

    That gives you a practical way to evaluate your search quality rather than choosing a metric based only on intuition.

    You may also want hybrid search, which combines vector similarity with keyword search. This can be especially useful when users search for exact identifiers, error messages, version numbers, or technical terms that must match precisely.

    Conclusion


    Semantic search becomes much easier to understand when we break it into smaller mathematical concepts.

    A vector is an ordered list of numbers. An embedding model converts text or images into vectors. Euclidean distance measures how far apart two vectors are, while cosine similarity measures how closely their directions align. Cosine distance converts similarity into a distance-style score.

    With a few JavaScript functions, we can implement these calculations and build a simple vector-ranking demonstration.

    The most important distinction is this:

    Vector mathematics gives us a way to compare representations. The embedding model learns representations that can capture useful relationships in meaning.

    Both parts matter when building a useful semantic-search system.#ai #machinelearning #search #software #coding #development #engineering #inclusive #community
    How Machines Find Meaning: The Math Behind Semantic Search

  24. 14. Spread Me by .

    You’d think this would be just my thing: horny science horror. But Gailey’s work is largely uneven for me and this is another miss. It made me think of queers getting handsy in justice spaces, their belief that if you won’t have sex with them, you’re not down. And maybe consent is among the ideas Gailey’s exploring, but I couldn’t get past feeling squicked out.

    Their prior novels, The Echo Wife and Just Like Home use discomfort more successfully, which is part of why I keep coming back to Gailey: they write about the ugly parts of us with interest and courage.

    @bookstodon

  25. RE: nexxtpress.de/mediathekperlen/

    Unbedingt ansehen!
    Eine echte Perle in der Welt der Dokumentationen.
    Poetisch, kunstvoll, verblüffend. Ohne Interviews, ohne gesprochenen Kommentar. Eine Art Collage aus Bildern, Musik, Sound, die lange nachwirkt.

    Die kurzen Making-offs sind auch toll, liefern spannenden Hintergrund und Gedanken der Macher. Vlady von der NDR Bigband ist so eine coole Socke😄 . Da sind soviel positive Vibes in der Kooperation, macht richtig Spaß.

Share on Mastodon

Enter the server where you have an account.