Skip to content

Commit

Permalink
Add instruct prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandresablayrolles committed Dec 13, 2023
1 parent eb3d6c2 commit 922e4e0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,14 @@ def generate(prompts: List[str], model: Transformer, tokenizer: Tokenizer, *, ma
return generated_words, logprobs


def interactive(model_path: str, max_tokens: int = 35, temperature: float = 0.7):
def interactive(model_path: str, max_tokens: int = 35, temperature: float = 0.7, instruct: bool = False):
tokenizer = Tokenizer(str(Path(model_path) / "tokenizer.model"))
transformer = Transformer.from_folder(Path(model_path), max_batch_size=3)

while True:
prompt = input("Prompt: ")
if instruct:
prompt = f"[INST] {prompt} [/INST]"
res, _logprobs = generate(
[prompt],
transformer,
Expand Down

0 comments on commit 922e4e0

Please sign in to comment.