<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>2.1.2: Embeddings | GenAI Learning</title>
    <link>https://genai.gitpull.in/2-intro-genai/2.1-key-concept/2-embeddings/index.html</link>
    <description>Embeddings Embeddings are numerical representations of tokens in a high-dimensional space. They capture the semantic meaning of tokens, allowing models to understand relationships between words.&#xA;Why are Embeddings Important?&#xA;Words with similar meanings have similar embeddings. Embeddings enable models to generalize and understand context. Example:&#xA;The embeddings for &#34;king&#34;, &#34;queen&#34;, &#34;man&#34;, and &#34;woman&#34; might satisfy the relationship: king - man + woman ≈ queen Hands-On: Embeddings from transformers import AutoTokenizer, AutoModel import torch # Load the tokenizer and model tokenizer = AutoTokenizer.from_pretrained(&#34;gpt2&#34;) model = AutoModel.from_pretrained(&#34;gpt2&#34;) # Tokenize input text text = &#34;Hello, how are you?&#34; inputs = tokenizer(text, return_tensors=&#34;pt&#34;) # Generate embeddings with torch.no_grad(): outputs = model(**inputs) # Extract embeddings for the first token embeddings = outputs.last_hidden_state print(&#34;Embeddings shape:&#34;, embeddings.shape) print(&#34;Embeddings for &#39;Hello&#39;:&#34;, embeddings[0, 0, :5]) # First 5 dimensions Output:</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <atom:link href="https://genai.gitpull.in/2-intro-genai/2.1-key-concept/2-embeddings/index.xml" rel="self" type="application/rss+xml" />
  </channel>
</rss>