Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b6bb7ac

Browse filesBrowse files
committed
docs: Add Llama class example
1 parent c5173b0 commit b6bb7ac
Copy full SHA for b6bb7ac

File tree

Expand file treeCollapse file tree

1 file changed

+24
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+24
-0
lines changed

‎llama_cpp/llama.py

Copy file name to clipboardExpand all lines: llama_cpp/llama.py
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,30 @@ def __init__(
765765
**kwargs, # type: ignore
766766
):
767767
"""Load a llama.cpp model from `model_path`.
768+
769+
Examples:
770+
Basic usage
771+
772+
>>> import llama_cpp
773+
>>> model = llama_cpp.Llama(
774+
... model_path="path/to/model",
775+
... )
776+
>>> print(model("The quick brown fox jumps ", stop=["."])["choices"][0]["text"])
777+
the lazy dog
778+
779+
Loading a chat model
780+
781+
>>> import llama_cpp
782+
>>> model = llama_cpp.Llama(
783+
... model_path="path/to/model",
784+
... chat_format="llama-2",
785+
... )
786+
>>> print(model.create_chat_completion(
787+
... messages=[{
788+
... "role": "user",
789+
... "content": "what is the meaning of life?"
790+
... }]
791+
... ))
768792
769793
Args:
770794
model_path: Path to the model.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.