Those templates are prepared based on the offical Phi-2 documentation.


Check llama.cpp to see how to use those templates with llama.cpp server.

QA Format

It is crucial to add the Question: and Answer: strings to the prompt, without them Phi-2 tends to stray off the question a lot.

This format is great for one-off questions.

Question: How to make a cat happy?
<?php namespace App; use Distantmagic\Resonance\LlmPromptTemplate\Phi2Question; $template = new Phi2Question('How to make a cat happy?');

Code Format

Phi-2 can generate some basic Python code. Since it doesn't require additional prompting, you can use the Plain prompt template, which forwards your prompt to the LLM as is.

For example, Phi-2 is able to infill code based on comments:

<?php namespace App; use Distantmagic\Resonance\LlmPromptTemplate\Plain; $template = new Plain(<<<'PYTHON' def print_prime(n): """ Print all primes between 1 and n """ 'PYTHON');
Edit on GitHub