llama.cpp/examples/basic.py

14 lines
401 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()
parser.add_argument("-m", "--model", type=str, default="../models/...")
args = parser.parse_args()
llm = Llama(model_path=args.model)
2023-03-23 09:33:06 +00:00
2023-03-23 18:57:31 +00:00
output = llm("Question: What are the names of the planets in the solar system? Answer: ", max_tokens=48, stop=["Q:", "\n"], echo=False)
2023-03-23 09:33:06 +00:00
print(json.dumps(output, indent=2))