Skip to content

Commit c2a234a

Browse files
committed
docs: Add embeddings section
1 parent f736827 commit c2a234a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,22 @@ llama = Llama(
398398
)
399399
```
400400

401+
### Embeddings
402+
403+
`llama-cpp-python` supports generating embeddings from the text.
404+
405+
```python
406+
import llama_cpp
407+
408+
llm = llama_cpp.Llama(model_path="path/to/model.gguf", embeddings=True)
409+
410+
embeddings = llm.create_embedding("Hello, world!")
411+
412+
# or batched
413+
414+
embeddings = llm.create_embedding(["Hello, world!", "Goodbye, world!"])
415+
```
416+
401417
### Adjusting the Context Window
402418

403419
The context window of the Llama models determines the maximum number of tokens that can be processed at once. By default, this is set to 512 tokens, but can be adjusted based on your requirements.

0 commit comments

Comments
 (0)