Text Embedding

A text embedding is a numerical vector a trained model assigns to a word or passage so similar meanings lie close, used to search and screen HTA evidence.

Status
Published, version 1.0.1
Last reviewed
2 Nov 2026, by Dr Darrin Baines
Report a problem
Tell us if something is wrong or out of date

Concept Architecture

Text Embedding for Evidence Search and Screening

A text embedding is a point in a space of a few hundred dimensions, placed there by a trained model for a word, sentence or paragraph, and the distance between two points stands in for how alike their meanings are. Health economists meet the idea when software ranks records for a systematic review, finds NICE recommendations that overlap with a guideline under review, or retrieves passages for a language model. The method finds related text even when no words are shared, yet the score measures resemblance only, so a close match says nothing about whether a statement is correct or still in force. The term is unrelated to the embedding effect in contingent valuation, where stated willingness to pay fails to rise with the scope of the good being valued.

Words as learned vectors rather than codes

Mikolov and colleagues observed that many language systems treated words as atomic units, indices in a vocabulary with no notion of similarity between them. Distributed representations replace each index with a dense vector learned from unlabelled text. Their two architectures, continuous bag-of-words and skip-gram, learned high-quality vectors from 1.6 billion words in less than a day.

The skip-gram model learns by predicting the words that surround each word. Zhang and colleagues write its objective as follows.

J=1T∑t=1T∑c∈Ctlog⁡p(wc∣wt),p(wc∣wt)=exp⁡(uwt⊤vwc)∑j=1Wexp⁡(uwt⊤vwj)J = \frac{1}{T} \sum_{t=1}^{T} \sum_{c \in C_t} \log p(w_c \mid w_t), \qquad p(w_c \mid w_t) = \frac{\exp(u_{w_t}^{\top} v_{w_c})}{\sum_{j=1}^{W} \exp(u_{w_t}^{\top} v_{w_j})}

where wtw_t is the word at position tt of a training text of TT words, CtC_t is the set of words around wtw_t, wcw_c is one of them, uwtu_{w_t} and vwcv_{w_c} are the learned vectors of the two words, WW is the vocabulary size, p(wc∣wt)p(w_c \mid w_t) is the probability of seeing wcw_c near wtw_t and JJ is the objective that training maximises. Words that appear in similar company end up with similar vectors, so "hazard" and "risk" can sit close together without any rule saying they are related.

The authors measured closeness by cosine distance and suggested that such vectors could improve information retrieval and question answering, the uses that matter most for evidence work.

Biomedical vectors trained on PubMed and MeSH

Vectors learned from news text carry the usage of news, so biomedical work needs biomedical training text. Zhang and colleagues built BioWordVec from the titles and abstracts of 27,599,238 PubMed articles together with the Medical Subject Headings (MeSH). The fastText subword model they used builds each word vector from vectors for its character n-grams, so a rare compound such as "deltaproteobacteria" inherits meaning from "proteo" and "bacteria". Each released vector has 200 dimensions.

The MeSH part brings a knowledge graph into the training data. The authors ran SPARQL queries on the MeSH RDF data to build a graph of 28,436 main headings and 52,013 relations, then turned random walks along the graph into word sequences for training. They treated every edge as undirected and did not distinguish the types and direction of the relations, so a broader-narrower link counts the same as any other once the graph is folded into vectors. That typing is what an ontology keeps.

With the same word2vec model, vectors trained on PubMed and PubMed Central clearly outperformed vectors trained on Google News, and the cosine similarity between "mycosis" and "histoplasmosis" was 0.353 with the Google News vectors and 0.706 with BioWordVec. The authors add that it is difficult to say how high an absolute cosine score should be, so they judged the vectors by their correlation with expert similarity ratings.

Sentence and passage embeddings

A recommendation or an abstract needs one vector for the whole text. The simplest method averages the word vectors, which Zhang and colleagues describe as a common baseline for sentence similarity. BERT reads sentences in context but compares two sentences by passing both through the network together, and Reimers and Gurevych calculate that finding the most similar pair among 10,000 sentences this way takes about 50 million inference computations, roughly 65 hours.

Their Sentence-BERT model trains two copies of BERT with shared weights so that each sentence gets its own fixed-size vector, stored once and compared by cosine similarity. The same task then took about 5 seconds of embedding and about 0.01 seconds of comparison. Averaging the outputs of an untuned BERT gave poor sentence vectors, worse on semantic similarity tasks than averaged GloVe word vectors, so the encoder has to be trained for the purpose.

The same design sits inside retrieval-augmented generation, covered on its own page in this set. Lewis and colleagues encoded documents and questions with two BERT encoders, embedded each passage once and ranked passages by the inner product of the two vectors.

Measuring closeness with cosine similarity

Cosine similarity compares the direction of two vectors and ignores their length. Reimers and Gurevych found that negative Manhattan and Euclidean distances gave roughly the same results.

cos⁡(a,b)=∑k=1dakbk∑k=1dak2 ∑k=1dbk2\cos(\mathbf{a}, \mathbf{b}) = \frac{\sum_{k=1}^{d} a_k b_k}{\sqrt{\sum_{k=1}^{d} a_k^2} \, \sqrt{\sum_{k=1}^{d} b_k^2}}

where a\mathbf{a} and b\mathbf{b} are two embedding vectors, aka_k and bkb_k are their values in dimension kk, dd is the number of dimensions and cos⁡(a,b)\cos(\mathbf{a}, \mathbf{b}) is the cosine similarity. The score is 1 when the vectors point the same way and 0 when they are at right angles. When every vector is scaled to length 1 on storage, the cosine equals the plain sum of products.

How NICE uses embeddings to find related recommendations

The UK algorithmic transparency record for NORMA, published on 17 December 2024, describes an internal NICE tool built with the Office for National Statistics Data Science Campus. Rule-based pattern matching extracts the recommendations from each clinical guideline, and a pre-trained biomedical model called Bio-embedding-intrinsic, which the record links to the BioWordVec paper, turns each one into the average vector of its nouns. A query is embedded the same way and compared with every stored vector by cosine similarity.

The Data Science Campus report explains the choices. Averaging the nouns gave consistently better results than averaging every word, and BERT sentence models were set aside because they needed a graphics processor to run at a reasonable pace and did not suit searches of one or two keywords.

The report adds that the scores of true and false matches overlapped so widely that recovering most known matches would have meant including thousands of non-matches.

Screening records for a systematic review

Machine learning tools for title and abstract screening in evidence synthesis first turn each record into numbers, often an embedding. Ali and colleagues tested TF-IDF, Doc2Vec and Sentence-BERT features with several classifiers on real systematic review datasets from education. Work saved at 95% recall ranged from 1.2% to 75.6% across datasets, so the same tool could save most of the effort on one review and almost none on another.

The separability of relevant and irrelevant records in embedding space, measured by the Davies-Bouldin score, strongly predicted the work saved (overall R = 0.81). The score is a ratio of within-cluster to between-cluster distance, so smaller values mean the relevant records stand further apart, an idea close to cluster analysis. The authors note that education may lack the standardised vocabularies of medicine, so health reviews may behave differently, and that their datasets were few.

Worked example ranking recommendations by similarity

The vectors in this example are illustrative, with three dimensions in place of the 200 used by BioWordVec. A surveillance query about lipid-lowering treatment is embedded as q=(0.6,0.8,0.0)\mathbf{q} = (0.6, 0.8, 0.0), and three stored recommendations are r1=(0.8,0.6,0.0)\mathbf{r}_1 = (0.8, 0.6, 0.0) on statin dose, r2=(0.48,0.6,0.64)\mathbf{r}_2 = (0.48, 0.6, 0.64) on lipid monitoring and r3=(0.0,0.28,0.96)\mathbf{r}_3 = (0.0, 0.28, 0.96) on smoking cessation.

Step 1. Each vector has length 1. For the lipid monitoring vector the squares are 0.2304 + 0.36 + 0.4096 = 1.0, and the other three also sum to 1, so each cosine is the sum of products.

Step 2. The scores are 0.6 × 0.8 + 0.8 × 0.6 = 0.96 for statin dose, 0.6 × 0.48 + 0.8 × 0.6 = 0.768 for lipid monitoring and 0.8 × 0.28 = 0.224 for smoking cessation, which gives the ranking.

Step 3. A fourth recommendation is embedded NORMA-style as the mean of two noun vectors, "statin" (0.8, 0.6, 0.0) and "intolerance" (0.6, 0.0, 0.8), giving m=(0.7,0.3,0.4)\mathbf{m} = (0.7, 0.3, 0.4) with length 0.74=0.8602\sqrt{0.74} = 0.8602.

cos⁡(q,m)=0.6×0.7+0.8×0.3+0.0×0.41×0.8602=0.660.8602=0.767\cos(\mathbf{q}, \mathbf{m}) = \frac{0.6 \times 0.7 + 0.8 \times 0.3 + 0.0 \times 0.4}{1 \times 0.8602} = \frac{0.66}{0.8602} = 0.767

where q\mathbf{q} is the query vector, m\mathbf{m} is the averaged vector and 0.8602 is its length. Without dividing by the length the score would be 0.66, so averaged vectors must be normalised before their scores are compared.

Step 4. For screening, suppose a search returns 2,000 records of which 40 are relevant, and ranking by similarity to known includes finds 38 of them in the first 500 records read. Recall is 38 out of 40, or 95%, the share screened is 500 out of 2,000, or 25%, and work saved at 95% recall, as Ali and colleagues define it, is 95% minus 25%, or 70%.

None of these scores shows that the statin recommendation is current or correct. Similarity ranks text for a human to read, and the reading decides.

Choices that change the result

Several settings sit between a document and its score. Each belongs in the methods of an analysis that relies on embeddings.

  • Training corpus. Biomedical vectors outperformed news vectors on medical term pairs in the BioWordVec validation.
  • What text is embedded. Very short recommendations relied on neighbouring text, and the Data Science Campus found that adding the guideline title and headings as context improved results.
  • Model version. NORMA's model has stayed fixed, and the Data Science Campus suggested a refresh every two to three years, so a reported search needs the model name and version.

Text embeddings beside related ideas

An embedding is a building block of artificial intelligence in health. The transformer behind most large language models, the subject of another page in this set, uses learned embeddings to turn input tokens into vectors, a link to deep learning in health. Semantic search ranks documents by embedding similarity, and a vector database stores the vectors and finds near neighbours quickly.

An ontology such as HealthEconomics.wiki's HEO records that one concept is a type of another, while an embedding of the two definitions yields only a distance between them.

Misreadings that lead to wrong conclusions

Most errors come from treating a similarity score as a judgement about the evidence.

  1. Reading closeness as truth. A score shows that two texts use language in similar ways. Nothing in the vector records whether a recommendation is still in force, and the Data Science Campus proposed a separate flag for whether each recommendation is live.
  2. Reading the score as a probability. Cosine values have no fixed scale across models, and Zhang and colleagues note that the right absolute level is hard to judge, so a threshold tuned on one model does not transfer to another.
  3. Assuming nothing is missed. NORMA misses a small share of recommendations, and work saved in screening varies widely between reviews, so recall needs checking on each project.
  4. Using general vectors for specialist text. News-trained vectors gave weaker similarity on medical terms, and whole-word models such as word2vec learn rare or unseen terms poorly.

Sources

Frequently Asked Questions (6)

  • What is a text embedding?

    A text embedding is a numerical vector a trained model assigns to a word or passage so similar meanings lie close, used to search and screen HTA evidence.

    Source: Reimers & Gurevych 2019

  • How does the skip-gram model learn a text embedding for each word?

    Mikolov and colleagues replaced the practice of treating words as atomic vocabulary indices with dense vectors learned from unlabelled text. The skip-gram architecture trains on the task of predicting the words that surround each word in a large corpus, and the vectors are what remains once training ends. Words that appear in similar company therefore end up with similar vectors, so "hazard" and "risk" can sit close together without any rule linking them. The authors learned high-quality vectors from 1.6 billion words in less than a day and measured closeness between vectors by cosine distance.

    Source: Mikolov et al. 2013

  • How is a text embedding produced for a whole sentence or abstract?

    The simplest approach averages the vectors of the words in the text. BERT reads words in context but compares two sentences by passing both through the network together, and Reimers and Gurevych calculate that finding the most similar pair among 10,000 sentences this way takes about 65 hours. Their Sentence-BERT model trains two copies of BERT with shared weights so that each sentence receives its own fixed-size vector, stored once and compared by cosine similarity, and the same task then took about 5 seconds. Averaging the outputs of an untuned BERT gave vectors worse on semantic similarity tasks than averaged GloVe word vectors, so the encoder has to be trained for the purpose.

    Source: Reimers & Gurevych 2019

  • How does NICE use a text embedding model to find overlapping guideline recommendations?

    NICE's NORMA tool, developed with the Office for National Statistics Data Science Campus, turns each guideline recommendation into the average vector of its nouns using a pre-trained biomedical model linked to BioWordVec. A search is embedded the same way and compared with the stored vectors by cosine similarity. The Data Science Campus found that averaging the nouns gave consistently better results than averaging every word, and it set aside BERT sentence models because they needed a graphics processor to run at a reasonable pace and did not suit searches of one or two keywords. Scores for true and false matches overlapped so widely that recovering most known matches would have meant including thousands of non-matches.

    Source: ONS 2022

  • How much screening work can a text embedding save in a systematic review?

    Ali and colleagues turned title and abstract records into features with TF-IDF, Doc2Vec and Sentence-BERT and tested several classifiers on real systematic review datasets. Work saved at 95% recall ranged from 1.2% to 75.6% across datasets, so the same approach saved most of the effort on one review and almost none on another. The separability of relevant and irrelevant records in embedding space, measured by the Davies-Bouldin score, strongly predicted the work saved (overall R = 0.81). The datasets came from education, which may lack the standardised vocabularies of medicine, so recall needs checking on each health review.

    Source: Ali et al. 2025

  • What mistakes are common when reading a text embedding similarity score?

    A high score shows that two texts use language in similar ways, yet nothing in the vector records whether a statement is correct or still in force. Cosine values also have no fixed scale across models. Zhang and colleagues found that the cosine similarity between "mycosis" and "histoplasmosis" was 0.353 with vectors trained on Google News and 0.706 with BioWordVec, and they noted that the right absolute level for a score is hard to judge, so they assessed vectors by their correlation with expert similarity ratings. A threshold tuned on one model therefore does not transfer to another, and general vectors can understate the similarity of specialist terms.

    Source: Zhang et al. 2019

Trust Record

Verified by Dr Darrin Baines

British health economist

Professional identity: darrinbaines.org

Verification date: 2 Nov 2026

Content version: 1.0.1

Canonical Identity

Term code
HS-HP-DH-061

Stable URI · Machine-readable · Resolvable · CC BY 4.0