description: Learn how to write a language generation application with ONNX Runtime GenAI in Python using the phi-2 model
has_children: false
parent: Tutorials
grand_parent: Generative AI (Preview)
nav_order: 1
---
# Language generation in Python with phi-2
## Setup and installation
Install the ONNX Runtime GenAI Python package using the [installation instructions](../howto/install.md).
## Build phi-2 ONNX model
The onnxruntime-genai package contains a model builder that generates the phi-2 ONNX model using the weights and config on Huggingface. The tools also allows you to download the weights from Hugging Face, load locally stored weights, or convert from GGUF format. For more details, see [how to build models](../howto/build-model.md)
If using the `-m` option shown here, you will need to login into Hugging Face.
You can replace the name of the output folder specified with the `-o` option with a folder of your choice.
After you run the script, you will see a series of files generated in this folder. They include the HuggingFace configs for your reference, as well as the following generated files used by ONNX Runtime GenAI.
-`model.onnx`: the phi-2 ONNX model
-`model.onnx.data`: the phi-2 ONNX model weights
-`genai_config.json`: the configuration used by ONNX Runtime GenAI
You can view and change the values in the `genai_config.json` file. The model section should not be updated unless you have brought your own model and it has different parameters.
The search parameters can be changed. For example, you might want to generate with a different temperature value. These values can also be set via the `set_search_options` method shown below.
## Run the model with a sample prompt
Run the model with the following Python script. You can change the prompt and other parameters as needed.