Spaces:
Running
Running
Sébastien De Greef
commited on
Commit
•
6ed5f5f
1
Parent(s):
e3bf489
feat: Add "Embeddings" section to website navigation
Browse files- src/_quarto.yml +12 -0
- src/index.qmd +7 -80
- src/llms/embeddings.qmd +53 -0
src/_quarto.yml
CHANGED
@@ -31,6 +31,8 @@ website:
|
|
31 |
text: "Prompting"
|
32 |
- href: theory/chainoftoughts.qmd
|
33 |
text: "Chain of toughts"
|
|
|
|
|
34 |
- href: llms/index.qmd
|
35 |
text: "LLM'xs"
|
36 |
|
@@ -44,6 +46,7 @@ website:
|
|
44 |
text: "Advanced RAG"
|
45 |
- href: notebooks/rag_evaluation.qmd
|
46 |
text: "RAG Evaluation"
|
|
|
47 |
- section: "Additional Techniques"
|
48 |
contents:
|
49 |
- href: notebooks/automatic_embedding.ipynb
|
@@ -53,6 +56,15 @@ website:
|
|
53 |
- href: notebooks/single_gpu.ipynb
|
54 |
text: "Single GPU Optimization"
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
format:
|
57 |
html:
|
58 |
theme: cosmo
|
|
|
31 |
text: "Prompting"
|
32 |
- href: theory/chainoftoughts.qmd
|
33 |
text: "Chain of toughts"
|
34 |
+
- href: llms/embeddings.qmd
|
35 |
+
text: "Embeddings"
|
36 |
- href: llms/index.qmd
|
37 |
text: "LLM'xs"
|
38 |
|
|
|
46 |
text: "Advanced RAG"
|
47 |
- href: notebooks/rag_evaluation.qmd
|
48 |
text: "RAG Evaluation"
|
49 |
+
|
50 |
- section: "Additional Techniques"
|
51 |
contents:
|
52 |
- href: notebooks/automatic_embedding.ipynb
|
|
|
56 |
- href: notebooks/single_gpu.ipynb
|
57 |
text: "Single GPU Optimization"
|
58 |
|
59 |
+
- section: "Computer Vision"
|
60 |
+
contents:
|
61 |
+
- href: notebooks/automatic_embedding.ipynb
|
62 |
+
text: "Automatic Embedding"
|
63 |
+
- href: notebooks/faiss.ipynb
|
64 |
+
text: "FAISS for Efficient Search"
|
65 |
+
- href: notebooks/single_gpu.ipynb
|
66 |
+
text: "Single GPU Optimization"
|
67 |
+
|
68 |
format:
|
69 |
html:
|
70 |
theme: cosmo
|
src/index.qmd
CHANGED
@@ -1,84 +1,11 @@
|
|
1 |
-
|
2 |
-
title: "About
|
3 |
---
|
4 |
|
5 |
-
|
6 |
-
You can also use Quarto to write [books](https://quarto.org/docs/books/), create [dashboards](https://quarto.org/docs/dashboards/), and embed web applications with [Observable](https://quarto.org/docs/interactive/ojs/) and [Shinylive](https://quarto.org/docs/blog/posts/2022-10-25-shinylive-extension/).
|
7 |
-
```{mermaid}
|
8 |
-
flowchart LR
|
9 |
-
A[Hard edge] --> B(Round edge)
|
10 |
-
B --> C{Decision}
|
11 |
-
C --> D[Result one]
|
12 |
-
C --> E[Result two]
|
13 |
-
```
|
14 |
-
## Getting started with Quarto
|
15 |
-
|
16 |
-
Once you've created the space, click on the `Files` tab in the top right to take a look at the files which make up this Space.
|
17 |
-
There are a couple of important files which you should pay attention to:
|
18 |
-
|
19 |
-
- `Dockerfile`: This contains the system setup to build and serve the Quarto site on Hugging Face. You probably won't need to change this file that
|
20 |
-
often unless you need to add additional system dependencies or modify the Quarto version.
|
21 |
-
- `requirements.txt`: This is where you should include any Python dependencies which you need for your website.
|
22 |
-
These are installed when the Dockerfile builds.
|
23 |
-
- The `src` directory contains the source files for the Quarto website. You can include Jupyter notebooks or markdown (`.qmd` or `.md`) files.
|
24 |
-
- `src/_quarto.yml` defines the navigation for your website. If you want to add new pages or reorganize the existing ones, you'll need to change this file.
|
25 |
-
|
26 |
-
|
27 |
-
## Recommended Workflow
|
28 |
-
|
29 |
-
1. **Clone the space locally**
|
30 |
-
2. **Install Quarto**: In order to render your Quarto site without Docker, we recommend installing Quarto by following the instructions on the [official Quarto website](https://quarto.org/docs/get-started/).
|
31 |
-
3. **Install Quarto VS Code extension**: The [Quarto VS Code Extension](https://quarto.org/docs/tools/vscode.html) includes a number of productivity tools including YAML Autocomplete, a preview button, and a visual editor. Quarto works great with VS Code, but the extension does make it easier to get the most out of Quarto.
|
32 |
-
4. **Edit the site**: The website files are contained in the `src` directory, and the site navigation is defined in `src/_quarto.yml`. Try editing these files and either clicking the "Preview" button in VS Code, or calling `quarto preview src` from the command line.
|
33 |
-
5. **Learn more about Quarto**: You can do a lot of things with Quarto, and they are all documented on the [Quarto Website](https://quarto.org/guide/). In particular, you may be interested in:
|
34 |
-
|
35 |
-
- All about building [websites](https://quarto.org/docs/websites/)
|
36 |
-
- Building Static [Dashboards](https://quarto.org/docs/dashboards/)
|
37 |
-
- How to write [books](https://quarto.org/docs/books/index.html) and [manuscripts](https://quarto.org/docs/manuscripts/)
|
38 |
-
- Reproducible [presentations](https://quarto.org/docs/presentations/)
|
39 |
-
- Including [Observable](https://quarto.org/docs/interactive/ojs/) or [Shiny](https://quarto.org/docs/interactive/shiny/) applications in your Quarto site
|
40 |
-
|
41 |
-
::: {.callout-warning}
|
42 |
-
It can take a couple of minutes for the Space to deploy to Hugging Face after the Docker build process completes. Two see your changes you will need to do two things:
|
43 |
-
|
44 |
-
1) Wait for your space's status to go from 'Building' to 'Running'(this is visible in the status bar above the Space)
|
45 |
-
2) Force-reload the web page by holding Shift and hitting the reload button in your browser.
|
46 |
-
:::
|
47 |
-
|
48 |
-
## Code Execution
|
49 |
-
|
50 |
-
One of the main virtues of Quarto is that it lets you combine code and text in a single document.
|
51 |
-
By default, if you include a code chunk in your document, Quarto will execute that code and include the output in the rendered document.
|
52 |
-
This is great for reproducibility and for creating documents that are always up-to-date.
|
53 |
-
For example you can include code which generates a plot like this:
|
54 |
-
|
55 |
-
```{python}
|
56 |
-
import seaborn as sns
|
57 |
-
import matplotlib.pyplot as plt
|
58 |
-
|
59 |
-
# Sample data
|
60 |
-
tips = sns.load_dataset("tips")
|
61 |
-
# Create a seaborn plot
|
62 |
-
sns.set_style("whitegrid")
|
63 |
-
g = sns.lmplot(x="total_bill", y="tip", data=tips, aspect=2)
|
64 |
-
g = g.set_axis_labels("Total bill (USD)", "Tip").set(xlim=(0, 60), ylim=(0, 12))
|
65 |
-
|
66 |
-
plt.title("Tip by Total Bill")
|
67 |
-
plt.show()
|
68 |
-
```
|
69 |
-
|
70 |
-
When the website is built the Python code will run and the output will be included in the document.
|
71 |
-
|
72 |
-
You can also include [inline code](https://quarto.org/docs/computations/inline-code.html) to insert computed values into text.
|
73 |
-
For example we can include the maximum tip value in the `tips` data frame like this: ``{python} tips['tip'].max()``.
|
74 |
-
You can control [code execution](https://quarto.org/docs/computations/execution-options.html), or [freeze code output](https://quarto.org/docs/projects/code-execution.html#freeze) to capture the output of long running computations.
|
75 |
-
|
76 |
-
|
77 |
-
## About the Open Source AI Cookbook
|
78 |
-
|
79 |
-
To provide a realistic example of how Quarto can help you organize long-form documentation,
|
80 |
-
we've implemented the Hugging Face [Open-Source AI Cookbook](https://github.com/huggingface/cookbook) in Quarto.
|
81 |
-
The Open-Source AI Cookbook is a collection of notebooks illustrating practical aspects of building AI applications and solving various machine learning tasks using open-source tools and models.
|
82 |
-
You can read more about it, or contribute your own Notebook on the [Github Repo](https://github.com/huggingface/cookbook)
|
83 |
|
|
|
|
|
84 |
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: "About My AI Cookbook"
|
3 |
---
|
4 |
|
5 |
+
This repository is my personal collection of recipes and notebooks, documenting my journey of learning and exploring various aspects of Artificial Intelligence (AI). As a self-taught AI enthusiast, I created this cookbook to serve as a knowledge base, a "how-to" guide, and a reference point for my own projects and experiments.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
::: {.callout-tip}
|
8 |
+
## Tip with Title
|
9 |
|
10 |
+
This is an example of a callout with a title.
|
11 |
+
:::
|
src/llms/embeddings.qmd
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Understanding Embeddings in Large Language Models (LLMs)
|
2 |
+
Embeddings in Large Language Models (LLMs) like GPT, BERT, and others, are a foundational component in the field of natural language processing (NLP). These embeddings transform words, phrases, or even longer texts into a vector space, capturing the semantic meaning that enables LLMs to perform a variety of language-based tasks with remarkable proficiency. This article focuses on the role of embeddings in LLMs, how they are generated, and their impact on the performance of these models.
|
3 |
+
|
4 |
+
## What are Embeddings in LLMs?
|
5 |
+
In the context of LLMs, embeddings are dense vector representations of text. Each vector aims to encapsulate aspects of linguistic meaning such as syntax, semantics, and context. Unlike simpler models that might use one-hot encoding, LLM embeddings map words or tokens to vectors in a way that reflects their semantic and contextual relationships.
|
6 |
+
|
7 |
+
## Role of Embeddings in LLMs
|
8 |
+
Embeddings are the input layer of LLMs, where each word or token from the input text is converted into vectors. These vectors are then processed by the model’s deeper layers to perform tasks such as text classification, question answering, translation, and more. Here’s how embeddings contribute to the functionality of LLMs:
|
9 |
+
|
10 |
+
## Pre-trained Word Embeddings
|
11 |
+
Many LLMs start with a layer of pre-trained word embeddings obtained from vast amounts of text data. These pre-trained embeddings encapsulate general language features before being fine-tuned on specific tasks.
|
12 |
+
|
13 |
+
## Contextual Embeddings
|
14 |
+
Advanced models like BERT and GPT use embeddings that adjust according to the context of a word in a sentence, differing from static word embeddings used in earlier models. This means the embedding for the word "bank" would differ when used in the context of a river compared to a financial institution.
|
15 |
+
|
16 |
+
## Generating Embeddings in LLMs
|
17 |
+
LLMs typically generate embeddings using one of two architectures:
|
18 |
+
|
19 |
+
### Transformer-Based Models
|
20 |
+
These models, including BERT and GPT, utilize the transformer architecture that processes all words or tokens in parallel. This architecture allows for the generation of contextual embeddings where the meaning of a word can dynamically change based on the surrounding words.
|
21 |
+
|
22 |
+
### Autoencoder Models
|
23 |
+
Some LLMs employ autoencoders to generate embeddings that are then used to reconstruct the input data. This process helps in learning efficient representations of the data.
|
24 |
+
|
25 |
+
## Applications of Embeddings in LLMs
|
26 |
+
Embeddings in LLMs enable a wide range of applications:
|
27 |
+
|
28 |
+
**Machine Translation**: Understanding and translating languages by capturing contextual nuances.
|
29 |
+
|
30 |
+
**Sentiment Analysis**: Determining the sentiment of text by understanding the contextual meaning of words.
|
31 |
+
|
32 |
+
**Content Recommendation**: Suggesting relevant articles or products by understanding textual descriptions.
|
33 |
+
|
34 |
+
**Automated Question Answering**: Providing answers to questions based on understanding the context of the content.
|
35 |
+
|
36 |
+
## Benefits of Embeddings in LLMs
|
37 |
+
|
38 |
+
**Efficiency**: Embeddings significantly reduce the dimensionality of text data, making it manageable for neural networks.
|
39 |
+
|
40 |
+
**Effectiveness**: By capturing deep semantic properties, embeddings allow models to perform complex language tasks.
|
41 |
+
|
42 |
+
**Flexibility**: Once trained, the same embeddings can be used across different tasks and domains, enhancing the model's utility.
|
43 |
+
|
44 |
+
## Challenges with Embeddings in LLMs
|
45 |
+
|
46 |
+
**Resource Intensive**: Training LLMs to generate useful embeddings requires substantial computational resources and data.
|
47 |
+
|
48 |
+
**Bias and Fairness**: Embeddings can perpetuate or amplify biases present in the training data, leading to fairness issues in model outputs.
|
49 |
+
|
50 |
+
**Interpretability**: It can be difficult to interpret what specific dimensions of an embedding represent, complicating model debugging and transparency.
|
51 |
+
|
52 |
+
## Conclusion
|
53 |
+
Embeddings are a crucial part of the infrastructure that powers LLMs, enabling these models to process language with a depth and nuance that was previously unachievable. As NLP continues to evolve, the techniques for generating and refining embeddings will remain key to unlocking even more sophisticated language understanding and generation capabilities.
|