llama.cpp/examples/high_level_api_basic_inference.py

20 lines
420 B
Python
Raw Normal View History

2023-03-23 09:33:06 +00:00
import json
2023-03-23 18:57:31 +00:00
import argparse
2023-03-23 09:33:06 +00:00
from llama_cpp import Llama
2023-03-23 18:57:31 +00:00
parser = argparse.ArgumentParser()
2023-03-24 03:12:42 +00:00
parser.add_argument("-m", "--model", type=str, default=".//models/...")
2023-03-23 18:57:31 +00:00
args = parser.parse_args()
llm = Llama(model_path=args.model)
2023-03-23 09:33:06 +00:00
2023-03-24 18:35:41 +00:00
output = llm(
"Question: What are the names of the planets in the solar system? Answer: ",
max_tokens=48,
stop=["Q:", "\n"],
echo=True,
)
2023-03-23 09:33:06 +00:00
2023-03-24 18:35:41 +00:00
print(json.dumps(output, indent=2))