Skip to content

Commit 8542ef5

Browse files
author
eugenio.segala
committed
fix: improve embedding doc to use encoders
1 parent 28c7984 commit 8542ef5

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

docs/guide/embedding.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,11 @@ const __dirname = path.dirname(
122122
123123
const llama = await getLlama();
124124
const model = await llama.loadModel({
125-
modelPath: path.join(__dirname, "my-model.gguf")
125+
/*
126+
You can also load quantized models such as "Meta-Llama-3.1-8B-Instruct.Q4_K_M.gguf", which generate embeddings
127+
using their intermediate layers. However, specialized encoders models are generally more accurate for search.
128+
*/
129+
modelPath: path.join(__dirname, "nomic-embed-text-v1.5.f16.gguf")
126130
});
127131
const context = await model.createEmbeddingContext();
128132

docs/index.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ const session = new LlamaChatSession({
117117
contextSequence: context.getSequence()
118118
});
119119

120-
121120
const q1 = "Hi there, how are you?";
122121
console.log("User: " + q1);
123122

@@ -139,18 +138,17 @@ const __dirname = path.dirname(
139138

140139
const llama = await getLlama();
141140
const model = await llama.loadModel({
142-
modelPath: path.join(__dirname, "my-model.gguf")
141+
modelPath: path.join(__dirname, "my-emb-model.gguf")
143142
});
144-
const context = await model.createEmbeddingContext();
145-
146-
147-
148143

144+
const context = await model.createEmbeddingContext();
149145

150146
const text = "Hello world";
147+
151148
console.log("Text:", text);
152149

153150
const embedding = await context.getEmbeddingFor(text);
151+
154152
console.log("Embedding vector:", embedding.vector);
155153
```
156154

0 commit comments

Comments
 (0)