Token LabBuscar

← Todos los experimentos
Geometría de embeddings / 1 OF 5

Vecinos por coseno

A large document norm should not dominate cosine ranking.

Cálculo / simulación local

Experimento educativo local, sin API externa. Los datos sintéticos no son mediciones de producción.

Study guide & lesson outlineLEARNING CONTRACT

Understand → implement → investigate

Goal: explain the mechanism in this lesson, reproduce one example and test a failure case. Reading alone does not mark mastery.

02 · Predice y configura

Las notas técnicas, los parámetros y las respuestas están actualmente en inglés.

03 · Analiza la evidencia

Ejecuta para ver resultados.

Métodos y referencias

Five manually chosen 2D vectors, not embeddings generated by a language model. Zero-vector cosine is defined as 0 in this lab. Ties preserve fixture order.

Text / 原始公式
cos(q,d)=q·d/(||q|| ||d||); dot(q,d)=Σqᵢdᵢ

Geometry alone cannot establish semantic relevance; these vectors are hand-authored.

Introduction to Information Retrieval · vector space scoring ↗

Preguntas de práctica

embedding-1 / 01What does “Cosine nearest neighbors” test?

A large document norm should not dominate cosine ranking.

Original teaching answer / local derivation. Method reference: Introduction to Information Retrieval · vector space scoring ↗

Abrir laboratorio →
embedding-1 / 02Which computation produces the result in “Cosine nearest neighbors”?

·d/(||q|| ||d||);

Original teaching answer / local derivation. Method reference: Introduction to Information Retrieval · vector space scoring ↗

Abrir laboratorio →
embedding-1 / 03What is the baseline configuration for “Cosine nearest neighbors”?

{"x":1,"y":0.2,"metric":0}

Original teaching answer / local derivation. Method reference: Introduction to Information Retrieval · vector space scoring ↗

Abrir laboratorio →
embedding-1 / 04What numerical result should you check for “Cosine nearest neighbors”?

{"Top score":0.9999999999999998,"Query norm":1.019803902718557}

Original teaching answer / local derivation. Method reference: Introduction to Information Retrieval · vector space scoring ↗

Abrir laboratorio →
embedding-1 / 05How would you run a controlled comparison for “Cosine nearest neighbors”?

Keep the supplied fixture and other settings fixed; change x. Compare ranking order, vector norms and scores on identical documents.

Original teaching answer / local derivation. Method reference: Introduction to Information Retrieval · vector space scoring ↗

Abrir laboratorio →
embedding-1 / 06What failure could invalidate a conclusion from “Cosine nearest neighbors”?

Geometry alone cannot establish semantic relevance; these vectors are hand-authored.

Original teaching answer / local derivation. Method reference: Introduction to Information Retrieval · vector space scoring ↗

Abrir laboratorio →
embedding-1 / 07Is “Cosine nearest neighbors” a benchmark of a deployed language model?

No. Five manually chosen 2D vectors, not embeddings generated by a language model. Zero-vector cosine is defined as 0 in this lab. Ties preserve fixture order.

Original teaching answer / local derivation. Method reference: Introduction to Information Retrieval · vector space scoring ↗

Abrir laboratorio →
embedding-1 / 08Which evidence should you report for “Cosine nearest neighbors”?

Compare ranking order, vector norms and scores on identical documents. Export inputs, engine, result and method; distinguish synthetic fixtures from observed production data.

Original teaching answer / local derivation. Method reference: Introduction to Information Retrieval · vector space scoring ↗

Abrir laboratorio →
embedding-1 / 09How can another researcher reproduce “Cosine nearest neighbors”?

Open embedding-1, reset the preset, retain the exact inputs and run. The calculation is deterministic for identical inputs.

Original teaching answer / local derivation. Method reference: Introduction to Information Retrieval · vector space scoring ↗

Abrir laboratorio →
embedding-1 / 10What is the next validation step after “Cosine nearest neighbors”?

Geometry alone cannot establish semantic relevance; these vectors are hand-authored. Test the hypothesis on a representative held-out workload and document a baseline, success metric and stopping rule before claiming deployment readiness.

Original teaching answer / local derivation. Method reference: Introduction to Information Retrieval · vector space scoring ↗

Abrir laboratorio →
MATHEMATICAL REVIEW · 2026-10-26

Assumptions, implementation & acceptance

Mathematical cosine is undefined for a zero vector. This software returns zero as a sentinel, which must not be interpreted as orthogonality. Dot product and cosine have different scale sensitivity.

Engine formulas, scenario presets and numerical safeguards reviewed. Seeded synthetic inputs are not a production benchmark.

Query and document vectors → Dot product or normalized cosine → Sort scores · inspect zero-vector case → Change norm · compare ranking
Mechanism map: follow the transformations from top to bottom.

Before running: predict a boundary case

A large document norm should not dominate cosine ranking.

Hint: isolate the assumption

Keep the baseline input fixed, change one parameter or boundary, and compare both the numerical result and the claimed units. A passing example verifies this fixture only.

Minimal executable example

Save the example and linked modules in one folder. Use Node.js 22 or newer, then run node embedding-1.mjs. No third-party runtime dependencies.

import {calculate,network} from './academy-core.mjs';
const params={
  "x": 1,
  "y": 0.2,
  "metric": 0
};
const result=calculate('embedding',params);
console.log(result.metrics);

Test and transfer

A large document norm should not dominate cosine ranking.

Record input, code version, expected result and observed result in the notebook below. Then construct a counterexample that violates the assumption above and explain why the original conclusion no longer follows.

Download complete kit (.tar.gz) · Complete reference kit and regression checks

Predict, test and keep evidence

Before revealing an answer, predict one result. After the exercise, record the discrepancy and a transfer test. Saved locally across language editions.

Open notebook / export / clear →

The mathematical review scope is recorded per lesson. It does not establish empirical paper reproduction; report suspected errors in your notes. Review scope