File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -122,7 +122,11 @@ const __dirname = path.dirname(
122122
123123const llama = await getLlama();
124124const 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});
127131const context = await model.createEmbeddingContext();
128132
Original file line number Diff line number Diff line change @@ -117,7 +117,6 @@ const session = new LlamaChatSession({
117117 contextSequence: context .getSequence ()
118118});
119119
120-
121120const q1 = " Hi there, how are you?" ;
122121console .log (" User: " + q1 );
123122
@@ -139,18 +138,17 @@ const __dirname = path.dirname(
139138
140139const llama = await getLlama ();
141140const 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
150146const text = " Hello world" ;
147+
151148console .log (" Text:" , text );
152149
153150const embedding = await context .getEmbeddingFor (text );
151+
154152console .log (" Embedding vector:" , embedding .vector );
155153```
156154
You can’t perform that action at this time.
0 commit comments